diff options
author | Joachim Fasting <joachifm@fastmail.fm> | 2019-05-17 12:29:44 +0200 |
---|---|---|
committer | Joachim Fasting <joachifm@fastmail.fm> | 2019-05-17 12:36:29 +0200 |
commit | fc1129c8af5705039d197d133e15a090052ebb24 (patch) | |
tree | 7d1703d56338739bd2c9aa5f0bca22bda13a3c6a /pkgs/applications/misc/electrum | |
parent | c295ffa2cda1527bf678632d94c60c579253cfdf (diff) | |
download | nixpkgs-fc1129c8af5705039d197d133e15a090052ebb24.tar nixpkgs-fc1129c8af5705039d197d133e15a090052ebb24.tar.gz nixpkgs-fc1129c8af5705039d197d133e15a090052ebb24.tar.bz2 nixpkgs-fc1129c8af5705039d197d133e15a090052ebb24.tar.lz nixpkgs-fc1129c8af5705039d197d133e15a090052ebb24.tar.xz nixpkgs-fc1129c8af5705039d197d133e15a090052ebb24.tar.zst nixpkgs-fc1129c8af5705039d197d133e15a090052ebb24.zip |
electrum: implement crude updater
Takes care of the tedium of checking signatures & whatnot. Does not update checksum for the tests yet ... Usage $ nix-shell maintainers/scripts/update.nix --argstr package electrum Warning: dumps cruft to $PWD
Diffstat (limited to 'pkgs/applications/misc/electrum')
-rw-r--r-- | pkgs/applications/misc/electrum/default.nix | 30 | ||||
-rw-r--r-- | pkgs/applications/misc/electrum/update.nix | 59 |
2 files changed, 88 insertions, 1 deletions
diff --git a/pkgs/applications/misc/electrum/default.nix b/pkgs/applications/misc/electrum/default.nix index 6e69665da2b..2f8b98f3a44 100644 --- a/pkgs/applications/misc/electrum/default.nix +++ b/pkgs/applications/misc/electrum/default.nix @@ -1,4 +1,17 @@ -{ stdenv, fetchurl, fetchFromGitHub, python3, python3Packages, zbar, secp256k1 }: +{ stdenv, fetchurl, fetchFromGitHub, python3, python3Packages, zbar, secp256k1 + + +# for updater.nix +, writeScript +, common-updater-scripts +, bash +, coreutils +, curl +, gnugrep +, gnupg +, gnused +, nix +}: let version = "3.3.6"; @@ -85,6 +98,21 @@ python3Packages.buildPythonApplication rec { $out/bin/electrum help >/dev/null ''; + passthru.updateScript = import ./update.nix { + inherit (stdenv) lib; + inherit + writeScript + common-updater-scripts + bash + coreutils + curl + gnupg + gnugrep + gnused + nix + ; + }; + meta = with stdenv.lib; { description = "A lightweight Bitcoin wallet"; longDescription = '' diff --git a/pkgs/applications/misc/electrum/update.nix b/pkgs/applications/misc/electrum/update.nix new file mode 100644 index 00000000000..247fabe3891 --- /dev/null +++ b/pkgs/applications/misc/electrum/update.nix @@ -0,0 +1,59 @@ +{ lib +, writeScript +, common-updater-scripts +, bash +, coreutils +, curl +, gnugrep +, gnupg +, gnused +, nix +}: + +with lib; + +let + downloadPageUrl = "https://download.electrum.org"; + + signingKeys = ["6694 D8DE 7BE8 EE56 31BE D950 2BD5 824B 7F94 70E6"]; +in + +writeScript "update-electrum" '' +#! ${bash}/bin/bash + +set -eu -o pipefail + +export PATH=${makeBinPath [ + common-updater-scripts + coreutils + curl + gnugrep + gnupg + gnused + nix +]} + +version=$(curl -L --list-only -- '${downloadPageUrl}' \ + | grep -Po '<a href="\K([[:digit:]]+\.?)+' \ + | sort -Vu \ + | tail -n1) + +srcName=Electrum-$version +srcFile=$srcName.tar.gz +srcUrl="${downloadPageUrl}/$version/$srcFile" +sigUrl=$srcUrl.asc +sigFile=$srcFile.asc + +[[ -e "$srcFile" ]] || curl -L -o "$srcFile" -- "$srcUrl" +[[ -e "$sigFile" ]] || curl -L -o "$sigFile" -- "$sigUrl" + +export GNUPGHOME=$PWD/gnupg +mkdir -m 700 -p "$GNUPGHOME" + +gpg --batch --recv-keys ${concatStringsSep " " (map (x: "'${x}'") signingKeys)} +gpg --batch --verify "$sigFile" "$srcFile" + +sha256=$(nix-prefetch-url --type sha256 "file://$PWD/$srcFile") + +update-source-version electrum "$version" "$sha256" +'' |