mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
sourcehut: fix update.sh
This commit is contained in:
parent
9066c52e5a
commit
b6f26842c2
1 changed files with 34 additions and 18 deletions
|
@ -1,8 +1,11 @@
|
||||||
#! /usr/bin/env nix-shell
|
#! /usr/bin/env nix-shell
|
||||||
#! nix-shell -i bash -p git mercurial common-updater-scripts
|
#! nix-shell -i bash -p git mercurial common-updater-scripts
|
||||||
|
set -x
|
||||||
|
|
||||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
|
||||||
root=../../../..
|
root=../../../..
|
||||||
|
tmp=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
|
|
||||||
default() {
|
default() {
|
||||||
(cd "$root" && nix-instantiate --eval --strict -A "sourcehut.python.pkgs.$1.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
|
(cd "$root" && nix-instantiate --eval --strict -A "sourcehut.python.pkgs.$1.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
|
||||||
|
@ -13,19 +16,18 @@ version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
src_url() {
|
src_url() {
|
||||||
(cd "$root" && nix-instantiate --eval --strict -A "sourcehut.python.pkgs.$1.src.drvAttrs.url" | tr -d '"')
|
nix-instantiate --eval --strict --expr " with import $root {}; let src = sourcehut.python.pkgs.$1.drvAttrs.src; in src.url or src.meta.homepage" | tr -d '"'
|
||||||
}
|
}
|
||||||
|
|
||||||
get_latest_version() {
|
get_latest_version() {
|
||||||
src="$(src_url "$1")"
|
src="$(src_url "$1")"
|
||||||
tmp=$(mktemp -d)
|
rm -rf "$tmp"
|
||||||
|
|
||||||
if [ "$1" = "hgsrht" ]; then
|
if [ "$1" = "hgsrht" ]; then
|
||||||
hg clone "$src" "$tmp" &> /dev/null
|
hg clone "$src" "$tmp" >/dev/null
|
||||||
printf "%s" "$(cd "$tmp" && hg log --limit 1 --template '{latesttag}')"
|
printf "%s" "$(cd "$tmp" && hg log --limit 1 --template '{latesttag}')"
|
||||||
else
|
else
|
||||||
git clone "$src" "$tmp"
|
git clone "$src" "$tmp" >/dev/null
|
||||||
printf "%s" "$(cd "$tmp" && git describe $(git rev-list --tags --max-count=1))"
|
printf "%s" "$(cd "$tmp" && git describe "$(git rev-list --tags --max-count=1)")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,19 +38,33 @@ update_version() {
|
||||||
|
|
||||||
(cd "$root" && update-source-version "sourcehut.python.pkgs.$1" "$version")
|
(cd "$root" && update-source-version "sourcehut.python.pkgs.$1" "$version")
|
||||||
|
|
||||||
|
# Update vendorSha256 of Go modules
|
||||||
|
nixFile="${1%srht}".nix
|
||||||
|
nixFile="${nixFile/build/builds}"
|
||||||
|
retry=true
|
||||||
|
while "$retry"; do
|
||||||
|
retry=false;
|
||||||
|
exec < <(exec nix -L build -f "$root" sourcehut.python.pkgs."$1" 2>&1)
|
||||||
|
while IFS=' :' read -r origin hash; do
|
||||||
|
case "$origin" in
|
||||||
|
(expected|specified) oldHash="$hash";;
|
||||||
|
(got) sed -i "s|$oldHash|$(nix hash to-sri --type sha256 "$hash")|" "$nixFile"; retry=true; break;;
|
||||||
|
(*) printf >&2 "%s\n" "$origin${hash:+:$hash}"
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
git add "$default_nix"
|
git add "$default_nix"
|
||||||
git commit -m "$1: $version_old -> $version"
|
git commit -m "sourcehut.$1: $version_old -> $version"
|
||||||
}
|
}
|
||||||
|
|
||||||
services=( "srht" "buildsrht" "dispatchsrht" "gitsrht" "hgsrht" "hubsrht" "listssrht" "mansrht"
|
if [ $# -gt 0 ]; then
|
||||||
"metasrht" "pastesrht" "todosrht" "scmsrht" )
|
services=("$@")
|
||||||
|
|
||||||
# Whether or not a specific service is requested
|
|
||||||
if [ -n "$1" ]; then
|
|
||||||
version="$(get_latest_version "$1")"
|
|
||||||
(cd "$root" && update-source-version "sourcehut.python.pkgs.$1" "$version")
|
|
||||||
else
|
else
|
||||||
for service in "${services[@]}"; do
|
services=( "srht" "buildsrht" "dispatchsrht" "gitsrht" "hgsrht" "hubsrht" "listssrht" "mansrht"
|
||||||
update_version "$service"
|
"metasrht" "pastesrht" "todosrht" "scmsrht" )
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for service in "${services[@]}"; do
|
||||||
|
update_version "$service"
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in a new issue