2015-03-17 22:00:16 +00:00
|
|
|
#!/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.
|
|
|
|
#
|
2015-04-09 16:11:47 +01:00
|
|
|
# Call this from the root of your nixpkgs directory.
|
|
|
|
#
|
2015-02-22 13:39:31 +00:00
|
|
|
|
2015-03-17 22:00:16 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
HERE="$(dirname "$0")"
|
2015-02-22 13:28:10 +00:00
|
|
|
|
|
|
|
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() {
|
2015-04-09 16:11:47 +01:00
|
|
|
nix-instantiate -A "$1" \
|
|
|
|
| xargs cat \
|
2015-02-22 13:28:10 +00:00
|
|
|
| sed 's/.*"urls","//;s/".*//'
|
|
|
|
}
|
|
|
|
|
|
|
|
hash() {
|
2015-04-09 16:11:47 +01:00
|
|
|
nix-prefetch-url "$1"
|
2015-02-22 13:28:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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\";/" \
|
2015-03-17 22:00:16 +00:00
|
|
|
"$HERE/default.nix"
|
2015-02-22 13:28:10 +00:00
|
|
|
|
|
|
|
stableHash=$(hash_log "$(url iojs.src)")
|
|
|
|
nightlyHash=$(hash_log "$(url iojs-nightly.src)")
|
|
|
|
|
|
|
|
sed -i \
|
|
|
|
"/sha256 = if nightly/{N;s/\"[^\"]*\"/\"$nightlyHash\"/;N;s/\"[^\"]*\";/\"$stableHash\";/}" \
|
2015-03-17 22:00:16 +00:00
|
|
|
"$HERE/default.nix"
|