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")
|
2015-04-09 18:57:37 +01:00
|
|
|
echo "version -> $version" >&2
|
2015-02-22 13:28:10 +00:00
|
|
|
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")
|
2015-04-09 18:57:37 +01:00
|
|
|
echo "hash -> $value" >&2
|
2015-02-22 13:28:10 +00:00
|
|
|
echo "$value"
|
|
|
|
}
|
|
|
|
|
2015-04-09 18:57:37 +01:00
|
|
|
stableVersion=$(latest_log stable 'https://iojs.org/dist/')
|
|
|
|
stableHash=$(hash_log "$(url iojs.src)")
|
2015-02-22 13:28:10 +00:00
|
|
|
|
|
|
|
sed -i \
|
2015-04-09 18:57:37 +01:00
|
|
|
"/version = /s/\"[^\"]*\"/\"$stableVersion\"/" \
|
2015-03-17 22:00:16 +00:00
|
|
|
"$HERE/default.nix"
|
2015-02-22 13:28:10 +00:00
|
|
|
sed -i \
|
2015-04-09 18:57:37 +01:00
|
|
|
"/sha256 = /s/\"[^\"]*\"/\"$stableHash\"/" \
|
2015-03-17 22:00:16 +00:00
|
|
|
"$HERE/default.nix"
|