2021-09-29 16:41:19 +02:00
|
|
|
|
#!/usr/bin/env bash
|
2020-04-13 22:57:30 +02:00
|
|
|
|
|
|
|
|
|
# lists all available versions listed for a package in a site (http)
|
|
|
|
|
|
2022-02-21 16:10:33 +01:00
|
|
|
|
pname="" # package name
|
2022-09-27 22:49:23 +02:00
|
|
|
|
attr_path="" # package attribute path
|
2022-09-30 14:59:29 +02:00
|
|
|
|
url="" # directory listing url
|
2022-02-21 16:10:33 +01:00
|
|
|
|
file="" # file for writing debugging information
|
2020-04-13 22:57:30 +02:00
|
|
|
|
|
2022-02-21 02:11:49 +01:00
|
|
|
|
while (( $# > 0 )); do
|
|
|
|
|
flag="$1"
|
|
|
|
|
shift 1
|
|
|
|
|
case "$flag" in
|
|
|
|
|
--pname=*)
|
|
|
|
|
pname="${flag#*=}"
|
|
|
|
|
;;
|
2022-09-27 22:49:23 +02:00
|
|
|
|
--attr-path=*)
|
|
|
|
|
attr_path="${flag#*=}"
|
|
|
|
|
;;
|
|
|
|
|
--url=*)
|
|
|
|
|
url="${flag#*=}"
|
|
|
|
|
;;
|
2022-02-21 02:11:49 +01:00
|
|
|
|
--file=*)
|
2022-02-21 16:10:33 +01:00
|
|
|
|
file="${flag#*=}"
|
2022-02-21 02:11:49 +01:00
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "$0: unknown option ‘${flag}’"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2022-09-27 22:49:23 +02:00
|
|
|
|
if [[ -z "$pname" ]]; then
|
2022-09-30 14:59:29 +02:00
|
|
|
|
pname="$UPDATE_NIX_PNAME"
|
2022-02-21 16:10:33 +01:00
|
|
|
|
fi
|
|
|
|
|
|
2022-09-27 22:49:23 +02:00
|
|
|
|
if [[ -z "$attr_path" ]]; then
|
|
|
|
|
attr_path="$UPDATE_NIX_ATTR_PATH"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# by default set url to the base dir of the first url in src.urls
|
|
|
|
|
if [[ -z "$url" ]]; then
|
|
|
|
|
url="$(nix-instantiate $systemArg --eval -E \
|
|
|
|
|
"with import ./. {}; dirOf (dirOf (lib.head $attr_path.src.urls))" \
|
|
|
|
|
| tr -d '"')"
|
2020-04-13 22:57:30 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# print a debugging message
|
2022-02-21 16:10:33 +01:00
|
|
|
|
if [[ -n "$file" ]]; then
|
2022-09-27 22:49:23 +02:00
|
|
|
|
echo "# Listing versions for '$pname' at $url" >> $file
|
2020-04-13 22:57:30 +02:00
|
|
|
|
fi
|
|
|
|
|
|
2022-09-27 22:49:23 +02:00
|
|
|
|
# list all major-minor versions from url
|
|
|
|
|
tags1=$(curl -sS "$url/")
|
2020-04-13 22:57:30 +02:00
|
|
|
|
tags1=$(echo "$tags1" | sed -rne 's,^<a href="([0-9]+\.[0-9]+)/">.*,\1,p')
|
|
|
|
|
|
|
|
|
|
# print available versions
|
|
|
|
|
for tag in $tags1; do
|
2022-09-27 22:49:23 +02:00
|
|
|
|
tags2=$(curl -sS "$url/$tag/")
|
2020-04-13 22:57:30 +02:00
|
|
|
|
tags2=$(echo "$tags2" | sed -rne "s,^<a href=\"$pname-([0-9.]+)\\.[^0-9].*\">.*,\\1,p")
|
|
|
|
|
echo "$tags2"
|
|
|
|
|
done
|