3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/web/iojs/update-iojs

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