nodejs: Add updater script

This commit is contained in:
adisbladis 2018-02-18 22:19:01 +08:00
parent e1bd5b33b6
commit 43cf893d44
No known key found for this signature in database
GPG Key ID: ED58F95069B004F5
2 changed files with 36 additions and 0 deletions

View File

@ -1,5 +1,8 @@
{ stdenv, fetchurl, openssl, python2, zlib, libuv, utillinux, http-parser { stdenv, fetchurl, openssl, python2, zlib, libuv, utillinux, http-parser
, pkgconfig, which , pkgconfig, which
# Updater dependencies
, writeScript, coreutils, gnugrep, jq, curl, common-updater-scripts, nix
, gnupg
, darwin ? null , darwin ? null
}: }:
@ -78,6 +81,12 @@ in
''} ''}
''; '';
passthru.updateScript = import ./update.nix {
inherit writeScript coreutils gnugrep jq curl common-updater-scripts gnupg nix;
inherit (stdenv) lib;
majorVersion = with stdenv.lib; elemAt (splitString "." version) 0;
};
meta = { meta = {
description = "Event-driven I/O framework for the V8 JavaScript engine"; description = "Event-driven I/O framework for the V8 JavaScript engine";
homepage = https://nodejs.org; homepage = https://nodejs.org;

View File

@ -0,0 +1,27 @@
{ lib
, writeScript
, coreutils
, curl
, gnugrep
, jq
, gnupg
, common-updater-scripts
, majorVersion
, nix
}:
writeScript "update-nodejs" ''
PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep jq gnupg nix ]}
HOME=`mktemp -d`
cat ${./nodejs-release-keys.asc} | gpg --import
tags=`curl --silent https://api.github.com/repos/nodejs/node/git/refs/tags`
version=`echo $tags | jq -r '.[] | select(.ref | startswith("refs/tags/v${majorVersion}")) | .ref' | sort --version-sort | tail -1 | grep -oP "^refs/tags/v\K.*"`
curl --silent -o $HOME/SHASUMS256.txt.asc https://nodejs.org/dist/v''${version}/SHASUMS256.txt.asc
hash_hex=`gpgv --keyring=$HOME/.gnupg/pubring.kbx --output - $HOME/SHASUMS256.txt.asc | grep -oP "^([0-9a-f]{64})(?=\s+node-v''${version}.tar.xz$)"`
hash=`nix-hash --type sha256 --to-base32 ''${hash_hex}`
update-source-version nodejs-${majorVersion}_x "''${version}" "''${hash}"
''