2021-09-29 15:41:19 +01:00
|
|
|
|
#!/usr/bin/env bash
|
2020-04-13 21:57:30 +01:00
|
|
|
|
|
|
|
|
|
# lists all available versions listed for a package in a site (http)
|
|
|
|
|
|
2022-02-21 15:10:33 +00:00
|
|
|
|
archive="" # archive url
|
|
|
|
|
pname="" # package name
|
|
|
|
|
file="" # file for writing debugging information
|
2020-04-13 21:57:30 +01:00
|
|
|
|
|
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=*)
|
2022-02-21 15:10:33 +00:00
|
|
|
|
file="${flag#*=}"
|
2022-02-21 01:11:49 +00:00
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "$0: unknown option ‘${flag}’"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2022-02-21 15:10:33 +00:00
|
|
|
|
# by default set url to the base dir of the first url in src.urls
|
|
|
|
|
if [[ -z "$archive" ]]; then
|
|
|
|
|
archive="$(nix-instantiate $systemArg --eval -E \
|
|
|
|
|
"with import ./. {}; dirOf (dirOf (lib.head $UPDATE_NIX_ATTR_PATH.src.urls))" \
|
|
|
|
|
| tr -d '"')"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ -z "$pname" ]]; then
|
|
|
|
|
pname="$UPDATE_NIX_ATTR_PATH"
|
2020-04-13 21:57:30 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# print a debugging message
|
2022-02-21 15:10:33 +00:00
|
|
|
|
if [[ -n "$file" ]]; then
|
2022-02-21 01:11:49 +00:00
|
|
|
|
echo "# Listing versions for '$pname' at $archive" >> $file
|
2020-04-13 21:57:30 +01: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
|