3 # lists all available versions listed for a package in a site (http)
5 pname
="" # package name
6 attr_path
="" # package attribute path
7 url
="" # directory listing url
8 file="" # file for writing debugging information
10 while (( $# > 0 )); do
18 attr_path
="${flag#*=}"
27 echo "$0: unknown option ‘${flag}’"
33 if [[ -z "$pname" ]]; then
34 pname
="$UPDATE_NIX_PNAME"
37 if [[ -z "$attr_path" ]]; then
38 attr_path
="$UPDATE_NIX_ATTR_PATH"
41 # by default set url to the base dir of the first url in src.urls
42 if [[ -z "$url" ]]; then
43 url
="$(nix-instantiate $systemArg --eval -E \
44 "with import .
/.
{}; dirOf
(dirOf
(lib.
head $attr_path.src.urls
))" \
48 # print a debugging message
49 if [[ -n "$file" ]]; then
50 echo "# Listing versions for '$pname' at $url" >> $file
53 # list all major-minor versions from url
54 tags1=$(curl -sS "$url/")
55 tags1=$(echo "$tags1" | sed -rne 's
,^
<a href
="([0-9]+\.[0-9]+)/">.
*,\
1,p
')
57 # print available versions
59 tags2=$(curl -sS "$url/$tag/")
60 tags2=$(echo "$tags2" | sed -rne "s,^<a href=\"$pname-([0-9.]+)\\.[^0-9].*\">.*,\\1,p")