nixpkgs/pkgs/development/web/iojs/update-iojs

55 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/sh
2015-02-22 13:39:31 +00:00
#
# Fetch the latest io.js release (stable/nightly) and update
# `default.nix` in this directory.
#
# Call this from the root of your nixpkgs directory.
#
2015-02-22 13:39:31 +00:00
set -e
HERE="$(dirname "$0")"
latest() {
curl -s "$1" | grep 'href="v' \
| tail -1 | sed 's/.*href="v//;s/\/".*//'
}
latest_log() {
echo "Getting latest $1 version from $2" >&2
version=$(latest "$2")
echo " -> $version" >&2
echo "$version"
}
url() {
nix-instantiate -A "$1" \
| xargs cat \
| sed 's/.*"urls","//;s/".*//'
}
hash() {
nix-prefetch-url "$1"
}
hash_log() {
echo "Finding hash for $1" >&2
value=$(hash "$1")
echo " -> $value" >&2
echo "$value"
}
stable=$(latest_log stable 'https://iojs.org/dist/')
nightly=$(latest_log nightly 'https://iojs.org/download/nightly/')
sed -i \
"/version = if nightly/s/then.*/then \"$nightly\" else \"$stable\";/" \
"$HERE/default.nix"
stableHash=$(hash_log "$(url iojs.src)")
nightlyHash=$(hash_log "$(url iojs-nightly.src)")
sed -i \
"/sha256 = if nightly/{N;s/\"[^\"]*\"/\"$nightlyHash\"/;N;s/\"[^\"]*\";/\"$stableHash\";/}" \
"$HERE/default.nix"