2021-09-29 14:41:19 +00:00
|
|
|
|
#!/usr/bin/env bash
|
2020-04-13 20:57:30 +00:00
|
|
|
|
|
|
|
|
|
# lists all available versions listed for a package in a site (http)
|
|
|
|
|
|
|
|
|
|
archive="$1" # archive url
|
|
|
|
|
pname="$2" # package name
|
|
|
|
|
file="$3" # file for writing debugging information
|
|
|
|
|
|
2022-02-21 01:11:49 +00:00
|
|
|
|
while (( $# > 0 )); do
|
|
|
|
|
flag="$1"
|
|
|
|
|
shift 1
|
|
|
|
|
case "$flag" in
|
|
|
|
|
--url=*)
|
|
|
|
|
archive="${flag#*=}"
|
|
|
|
|
;;
|
|
|
|
|
--pname=*)
|
|
|
|
|
pname="${flag#*=}"
|
|
|
|
|
;;
|
|
|
|
|
--file=*)
|
|
|
|
|
version="${flag#*=}"
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "$0: unknown option ‘${flag}’"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2020-04-13 20:57:30 +00:00
|
|
|
|
if [ -z "$archive" ]; then
|
|
|
|
|
echo "$scriptName: Missing archive url"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# print a debugging message
|
|
|
|
|
if [ -n "$file" ]; then
|
2022-02-21 01:11:49 +00:00
|
|
|
|
echo "# Listing versions for '$pname' at $archive" >> $file
|
2020-04-13 20:57:30 +00:00
|
|
|
|
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
|