Merge pull request #216850 from lilyinstarlight/misc/touchosc-updatescript
touchosc: make updateScript more readable and robust, 1.1.6.150 → 1.1.9.163
This commit is contained in:
commit
2cc866fb41
@ -45,7 +45,7 @@ in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "touchosc";
|
||||
version = "1.1.6.150";
|
||||
version = "1.1.9.163";
|
||||
|
||||
suffix = {
|
||||
aarch64-linux = "linux-arm64";
|
||||
@ -56,9 +56,9 @@ stdenv.mkDerivation rec {
|
||||
src = fetchurl {
|
||||
url = "https://hexler.net/pub/${pname}/${pname}-${version}-${suffix}.deb";
|
||||
hash = {
|
||||
aarch64-linux = "sha256-sYkAFyXnmzgSzo68OF0oiv8tUvY+g1WCcY783OZO+RM=";
|
||||
armv7l-linux = "sha256-GWpYW1262plxIzPVzBEh4Z3fQIhSmy0N9xAgwnjXrQE=";
|
||||
x86_64-linux = "sha256-LUWlLEsTUqVoWAkjXC/zOziPqO85H8iIlwJU7eqLRcY=";
|
||||
aarch64-linux = "sha256-LhF0pgMRbEXeLt5g56VBNuCssaTjsczx/+C76ckmGZo=";
|
||||
armv7l-linux = "sha256-T4AzXIbhO6fNN8xDFwz6M2lSH6hLgNjVyDsSt8m+Mr4=";
|
||||
x86_64-linux = "sha256-LJ36kHx8PPzfLpJMx1ANSmifS84saCQ8pF0quhgzdt0=";
|
||||
}.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p nix curl libxml2 jq common-updater-scripts
|
||||
#!nix-shell -i bash -p nix curl libxml2 jq
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
@ -8,6 +8,20 @@ nixpkgs="$(git rev-parse --show-toplevel || (printf 'Could not find root of nixp
|
||||
attr="${UPDATE_NIX_ATTR_PATH:-touchosc}"
|
||||
version="$(curl -sSL https://hexler.net/touchosc/appcast/linux | xmllint --xpath '/rss/channel/item/enclosure/@*[local-name()="version"]' - | cut -d= -f2- | tr -d '"' | head -n1)"
|
||||
|
||||
narhash() {
|
||||
nix --extra-experimental-features nix-command store prefetch-file --json "$url" | jq -r .hash
|
||||
}
|
||||
|
||||
nixeval() {
|
||||
if [ "$#" -ge 2 ]; then
|
||||
systemargs=(--argstr system "$2")
|
||||
else
|
||||
systemargs=()
|
||||
fi
|
||||
|
||||
nix --extra-experimental-features nix-command eval --json --impure "${systemargs[@]}" -f "$nixpkgs" "$1" | jq -r .
|
||||
}
|
||||
|
||||
findpath() {
|
||||
path="$(nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1.meta.position" | jq -r . | cut -d: -f1)"
|
||||
outpath="$(nix --extra-experimental-features nix-command eval --json --impure --expr "builtins.fetchGit \"$nixpkgs\"")"
|
||||
@ -19,15 +33,22 @@ findpath() {
|
||||
echo "$path"
|
||||
}
|
||||
|
||||
oldversion="${UPDATE_NIX_OLD_VERSION:-$(nixeval "$attr".version)}"
|
||||
|
||||
pkgpath="$(findpath "$attr")"
|
||||
|
||||
sed -i -e "/version\s*=/ s|\"$UPDATE_NIX_OLD_VERSION\"|\"$version\"|" "$pkgpath"
|
||||
if [ "$version" = "$oldversion" ]; then
|
||||
echo 'update.sh: New version same as old version, nothing to do.'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sed -i -e "/version\s*=/ s|\"$oldversion\"|\"$version\"|" "$pkgpath"
|
||||
|
||||
for system in aarch64-linux armv7l-linux x86_64-linux; do
|
||||
url="$(nix --extra-experimental-features nix-command eval --json --impure --argstr system "$system" -f "$nixpkgs" "$attr".src.url | jq -r .)"
|
||||
url="$(nixeval "$attr".src.url "$system")"
|
||||
|
||||
curhash="$(nix --extra-experimental-features nix-command eval --json --impure --argstr system "$system" -f "$nixpkgs" "$attr".src.outputHash | jq -r .)"
|
||||
newhash="$(nix --extra-experimental-features nix-command store prefetch-file --json "$url" | jq -r .hash)"
|
||||
curhash="$(nixeval "$attr".src.outputHash "$system")"
|
||||
newhash="$(narhash "$url")"
|
||||
|
||||
sed -i -e "s|\"$curhash\"|\"$newhash\"|" "$pkgpath"
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user