diff options
author | Erik Arvstedt <erik.arvstedt@gmail.com> | 2021-10-19 01:38:46 +0200 |
---|---|---|
committer | Erik Arvstedt <erik.arvstedt@gmail.com> | 2021-10-19 01:52:44 +0200 |
commit | 890ca19818c9a6b6409f70465b4964b0126799a5 (patch) | |
tree | b2018c999206cffe921de426ae9e3e6d0868530a /pkgs/applications/blockchains/electrs | |
parent | aeaf4453be3151fb4fd6a73eeac708940bed5d5f (diff) |
electrs: add update script
Diffstat (limited to 'pkgs/applications/blockchains/electrs')
-rwxr-xr-x | pkgs/applications/blockchains/electrs/update.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/pkgs/applications/blockchains/electrs/update.sh b/pkgs/applications/blockchains/electrs/update.sh new file mode 100755 index 0000000000000..3e4d90db59de1 --- /dev/null +++ b/pkgs/applications/blockchains/electrs/update.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p coreutils curl jq git gnupg common-updater-scripts +set -euo pipefail + +# Fetch latest release, GPG-verify the tag, update derivation + +scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd) +nixpkgs=$(realpath "$scriptDir"/../../../..) + +oldVersion=$(nix-instantiate --eval -E "(import \"$nixpkgs\" { config = {}; overlays = []; }).electrs.version" | tr -d '"') +version=$(curl -s --show-error "https://api.github.com/repos/romanz/electrs/releases/latest" | jq -r '.tag_name' | tail -c +2) + +if [[ $version == $oldVersion ]]; then + echo "Already at latest version $version" + exit 0 +fi +echo "New version: $version" + +tmpdir=$(mktemp -d /tmp/electrs-verify-gpg.XXX) +repo=$tmpdir/repo +trap "rm -rf $tmpdir" EXIT + +git clone --depth 1 --branch v${version} -c advice.detachedHead=false https://github.com/romanz/electrs $repo + +export GNUPGHOME=$tmpdir +echo +echo "Fetching romanz's key" +gpg --keyserver hkps://keys.openpgp.org --recv-keys 15c8c3574ae4f1e25f3f35c587cae5fa46917cbb 2> /dev/null +echo +echo "Verifying commit" +git -C $repo verify-tag v${version} + +rm -rf $repo/.git +hash=$(nix hash path $repo) + +(cd "$nixpkgs" && update-source-version electrs "$version" "$hash") +sed -i 's|cargoHash = .*|cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";|' "$scriptDir/default.nix" +echo +echo "electrs: $oldVersion -> $version" |