git.iko.soy/typeable/nixpkgs
on master help sign in
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

commitfc1129c8af5705039d197d133e15a090052ebb24 authorJoachim Fasting <joachifm@fastmail.fm> dateFri 17 May 2019, 12:29 (8 years ago) parentc295ffa
2 files changed+88−1
pkgs/applications/misc/electrum/default.nix+29−1 pkgs/applications/misc/electrum/update.nix+59
pkgs/applications/misc/electrum/default.nix+29−1
@@ -1,4 +1,17 @@
1−{ stdenv, fetchurl, fetchFromGitHub, python3, python3Packages, zbar, secp256k1 }:
1+{ stdenv, fetchurl, fetchFromGitHub, python3, python3Packages, zbar, secp256k1
2+
3+
4+# for updater.nix
5+, writeScript
6+, common-updater-scripts
7+, bash
8+, coreutils
9+, curl
10+, gnugrep
11+, gnupg
12+, gnused
13+, nix
14+}:
215
316let
417 version = "3.3.6";
@@ -85,6 +98,21 @@ python3Packages.buildPythonApplication rec {
8598 $out/bin/electrum help >/dev/null
8699 '';
87100
101+ passthru.updateScript = import ./update.nix {
102+ inherit (stdenv) lib;
103+ inherit
104+ writeScript
105+ common-updater-scripts
106+ bash
107+ coreutils
108+ curl
109+ gnupg
110+ gnugrep
111+ gnused
112+ nix
113+ ;
114+ };
115+
88116 meta = with stdenv.lib; {
89117 description = "A lightweight Bitcoin wallet";
90118 longDescription = ''
pkgs/applications/misc/electrum/update.nixnew file+59
@@ -0,0 +1,59 @@
1+{ lib
2+, writeScript
3+, common-updater-scripts
4+, bash
5+, coreutils
6+, curl
7+, gnugrep
8+, gnupg
9+, gnused
10+, nix
11+}:
12+
13+with lib;
14+
15+let
16+ downloadPageUrl = "https://download.electrum.org";
17+
18+ signingKeys = ["6694 D8DE 7BE8 EE56 31BE D950 2BD5 824B 7F94 70E6"];
19+in
20+
21+writeScript "update-electrum" ''
22+#! ${bash}/bin/bash
23+
24+set -eu -o pipefail
25+
26+export PATH=${makeBinPath [
27+ common-updater-scripts
28+ coreutils
29+ curl
30+ gnugrep
31+ gnupg
32+ gnused
33+ nix
34+]}
35+
36+version=$(curl -L --list-only -- '${downloadPageUrl}' \
37+ | grep -Po '<a href="\K([[:digit:]]+\.?)+' \
38+ | sort -Vu \
39+ | tail -n1)
40+
41+srcName=Electrum-$version
42+srcFile=$srcName.tar.gz
43+srcUrl="${downloadPageUrl}/$version/$srcFile"
44+sigUrl=$srcUrl.asc
45+sigFile=$srcFile.asc
46+
47+[[ -e "$srcFile" ]] || curl -L -o "$srcFile" -- "$srcUrl"
48+[[ -e "$sigFile" ]] || curl -L -o "$sigFile" -- "$sigUrl"
49+
50+export GNUPGHOME=$PWD/gnupg
51+mkdir -m 700 -p "$GNUPGHOME"
52+
53+gpg --batch --recv-keys ${concatStringsSep " " (map (x: "'${x}'") signingKeys)}
54+gpg --batch --verify "$sigFile" "$srcFile"
55+
56+sha256=$(nix-prefetch-url --type sha256 "file://$PWD/$srcFile")
57+
58+update-source-version electrum "$version" "$sha256"
59+''