Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / servers / prowlarr / update.sh
blob883f299d9aa00ac1d63179b14830578be2f0bbe2
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnused nix-prefetch jq
4 set -eou pipefail
6 dirname="$(dirname "$0")"
8 updateHash()
10 # nixos
11 version=$1
12 system=$2
14 # prowlarr
15 arch=$3
16 os=$4
18 url="https://github.com/Prowlarr/Prowlarr/releases/download/v$version/Prowlarr.master.$version.$os-core-$arch.tar.gz"
19 hash=$(nix-prefetch-url --type sha256 $url)
20 sriHash="$(nix hash to-sri --type sha256 $hash)"
22 sed -i "s|$system = \"sha256-[a-zA-Z0-9\/+-=]*\";|$system = \"$sriHash\";|g" "$dirname/default.nix"
25 updateVersion()
27 sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix"
30 currentVersion=$(cd $dirname && nix eval --raw -f ../../.. prowlarr.version)
32 latestTag=$(curl https://api.github.com/repos/Prowlarr/Prowlarr/releases/latest | jq -r ".tag_name")
33 latestVersion="$(expr $latestTag : 'v\(.*\)')"
35 if [[ "$currentVersion" == "$latestVersion" ]]; then
36 echo "Prowlarr is up-to-date: ${currentVersion}"
37 exit 0
40 updateVersion $latestVersion
42 updateHash $latestVersion aarch64-darwin arm64 osx
43 updateHash $latestVersion aarch64-linux arm64 linux
44 updateHash $latestVersion x86_64-darwin x64 osx
45 updateHash $latestVersion x86_64-linux x64 linux