about summary refs log tree commit diff
path: root/pkgs/common-updater/scripts/list-archive-two-level-versions
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/common-updater/scripts/list-archive-two-level-versions')
-rwxr-xr-xpkgs/common-updater/scripts/list-archive-two-level-versions35
1 files changed, 35 insertions, 0 deletions
diff --git a/pkgs/common-updater/scripts/list-archive-two-level-versions b/pkgs/common-updater/scripts/list-archive-two-level-versions
new file mode 100755
index 0000000000000..e46652820ad2b
--- /dev/null
+++ b/pkgs/common-updater/scripts/list-archive-two-level-versions
@@ -0,0 +1,35 @@
+#! /bin/sh
+
+# lists all available versions listed for a package in a site (http)
+
+scriptName=list-archive-two-level-versions # do not use the .wrapped name
+
+usage() {
+    echo "Usage: $scriptName <archive url> [<package name> [<debug file path>]]"
+}
+
+archive="$1"  # archive url
+pname="$2"  # package name
+file="$3"  # file for writing debugging information
+
+if [ -z "$archive" ]; then
+    echo "$scriptName: Missing archive url"
+    usage
+    exit 1
+fi
+
+# print a debugging message
+if [ -n "$file" ]; then
+    echo "# Listing versions for $pname at $archive" >> $file
+fi
+
+# list all major-minor versions from archive
+tags1=$(curl -sS "$archive/")
+tags1=$(echo "$tags1" | sed -rne 's,^<a href="([0-9]+\.[0-9]+)/">.*,\1,p')
+
+# print available versions
+for tag in $tags1; do
+    tags2=$(curl -sS "$archive/$tag/")
+    tags2=$(echo "$tags2" | sed -rne "s,^<a href=\"$pname-([0-9.]+)\\.[^0-9].*\">.*,\\1,p")
+    echo "$tags2"
+done