Skip to content

Commit

Permalink
electrum: implement crude updater
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joachifm committed May 17, 2019
1 parent c295ffa commit fc1129c
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
30 changes: 29 additions & 1 deletion pkgs/applications/misc/electrum/default.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 = ''
Expand Down
59 changes: 59 additions & 0 deletions pkgs/applications/misc/electrum/update.nix
Original file line number Diff line number Diff line change
@@ -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"
''

0 comments on commit fc1129c

Please sign in to comment.