ferdium: fix and simplify update script

This commit is contained in:
Jörg Thalheim 2023-12-26 17:55:37 +01:00
parent fc7331203e
commit 11cd7aa7d6

View file

@ -1,40 +1,12 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused nix-prefetch jq
#!nix-shell -i bash -p git bash curl jq nix-update
set -e
set -xe
dirname="$(dirname "$0")"
updateHash()
{
version=$1
arch=$2
hashKey="${arch}-linux_hash"
url="https://github.com/ferdium/ferdium-app/releases/download/v$version/Ferdium-linux-$version-$arch.deb"
hash=$(nix-prefetch-url --type sha256 $url)
sriHash="$(nix hash to-sri --type sha256 $hash)"
sed -i "s|$hashKey = \"[a-zA-Z0-9\/+-=]*\";|$hashKey = \"$sriHash\";|g" "$dirname/default.nix"
}
updateVersion()
{
sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix"
}
currentVersion=$(cd $dirname && nix eval --raw -f ../../../../.. ferdium.version)
latestTag=$(curl https://api.github.com/repos/ferdium/ferdium-app/releases/latest | jq -r ".tag_name")
latestVersion="$(expr $latestTag : 'v\(.*\)')"
if [[ "$currentVersion" == "$latestVersion" ]]; then
echo "Ferdium is up-to-date: ${currentVersion}"
exit 0
fi
updateVersion $latestVersion
updateHash $latestVersion amd64
updateHash $latestVersion arm64
nix-update --version "$latestVersion" --system aarch64-linux --override-filename "$dirname/default.nix" ferdium
nix-update --version skip --system x86_64-linux --override-filename "$dirname/default.nix" ferdium