nixpkgs/pkgs/development/web/iojs/update-iojs
2015-04-15 21:01:48 -07:00

51 lines
979 B
Bash
Executable File

#!/bin/sh
#
# Fetch the latest io.js release (stable/nightly) and update
# `default.nix` in this directory.
#
# Call this from the root of your nixpkgs directory.
#
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 -> $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 "hash -> $value" >&2
echo "$value"
}
stableVersion=$(latest_log stable 'https://iojs.org/dist/')
stableHash=$(hash_log "$(url iojs.src)")
sed -i \
"/version = /s/\"[^\"]*\"/\"$stableVersion\"/" \
"$HERE/default.nix"
sed -i \
"/sha256 = /s/\"[^\"]*\"/\"$stableHash\"/" \
"$HERE/default.nix"