1 #! /usr/bin/env nix-shell
2 #! nix-shell -i bash -p gnused git mercurial common-updater-scripts
5 cd "$(dirname "${BASH_SOURCE[0]}")" ||
exit 1
8 trap 'rm -rf "$tmp"' EXIT
12 pagessrht
) printf "sourcehut.$1";;
13 *) printf "sourcehut.python.pkgs.$1";;
18 local p
="$(attr_path "$1")"
19 (cd "$root" && nix-instantiate
--eval --strict -A $p.meta.position |
sed -re 's/^"(.*):[0-9]+"$/\1/')
23 local p
="$(attr_path "$1")"
24 (cd "$root" && nix-instantiate
--eval --strict -A $p.version |
tr -d '"')
28 local p
="$(attr_path "$1")"
29 nix-instantiate
--eval --strict --expr " with import $root {}; let src = $p.drvAttrs.src; in src.meta.homepage" |
tr -d '"'
32 get_latest_version
() {
35 if [ "$1" = "hgsrht" ]; then
36 hg clone
"$src" "$tmp" >/dev
/null
38 "$(cd "$tmp" && hg log --limit 1 --template '{latesttag}')" \
39 "$(cd "$tmp" && sed -ne 's/^\s*github\.com\/99designs\/gqlgen v\(.*\)$/\1/p' go.mod)"
41 git clone
"$src" "$tmp" >/dev
/null
43 "$(cd "$tmp" && git describe "$
(git rev-list
--tags --max-count=1)")" \
44 "$(cd "$tmp" && sed -ne 's/^\s*github\.com\/99designs\/gqlgen v\(.*\)$/\1/p' go.mod)"
49 default_nix
="$(default "$1")"
50 oldVersion
="$(version "$1")"
51 read -r version gqlgen_ver
< <(get_latest_version
"$1")
52 local p
="$(attr_path "$1")"
54 (cd "$root" && update-source-version
"$p" "$version")
56 # update `gqlgenVersion` if necessary
57 old_gqlgen_ver
="$(sed -ne 's/^.*gqlgenVersion = "\
(.
*\
)".*$/\1/p' "$default_nix")"
58 sed -ri "s|gqlgenVersion = \"$old_gqlgen_ver\";|gqlgenVersion = \"$gqlgen_ver\";|w /dev/stdout" "$default_nix"
60 # Update vendorHash of Go modules
64 exec < <(exec nix
-L build
-f "$root" sourcehut.python.pkgs.
"$1" 2>&1)
65 while IFS
=' :' read -r origin
hash; do
67 (expected|specified
) oldHash
="$hash";;
68 (got
) sed -i "s|$oldHash|$hash|" "$default_nix"; retry
=true
; break;;
69 (*) printf >&2 "%s\n" "$origin${hash:+:$hash}"
74 if [ "$oldVersion" != "$version" ] ||
[ "$old_gqlgen_ver" != "$gqlgen_ver" ]; then
75 git add
"$default_nix"
76 git commit
-m "sourcehut.$1: $oldVersion -> $version"
83 # Beware that some packages must be updated before others,
84 # eg. buildsrht must be updated before gitsrht,
85 # otherwise this script would enter an infinite loop
86 # because the reported $oldHash to be changed
87 # may not actually be in $default_nix
88 # but in the file of one of its dependencies.
89 services
=( "srht" "scmsrht" "buildsrht" "gitsrht" "hgsrht" "hubsrht" "listssrht" "mansrht"
90 "metasrht" "pagessrht" "pastesrht" "todosrht" )
93 for service
in "${services[@]}"; do
94 update_version
"$service"