From 186de9ca9ef5650180f2f0cf0a9efdc7dfb16e2e Mon Sep 17 00:00:00 2001 From: taku0 Date: Wed, 14 Mar 2018 23:24:34 +0900 Subject: common-updater: support updating source URL --- .../networking/browsers/firefox/update.nix | 4 +++- pkgs/common-updater/scripts/update-source-version | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/update.nix b/pkgs/applications/networking/browsers/firefox/update.nix index 6c264a94673..997bccbe9a9 100644 --- a/pkgs/applications/networking/browsers/firefox/update.nix +++ b/pkgs/applications/networking/browsers/firefox/update.nix @@ -28,7 +28,9 @@ writeScript "update-${attrPath}" '' sort --version-sort | \ tail -n 1` + source_url=`curl --silent $url$version/SOURCE | grep -o 'https://.*\.tar\.bz2'` + shasum=`curl --silent $url$version/SHA512SUMS | grep 'source\.tar\.xz' | cut -d ' ' -f 1` - update-source-version ${attrPath} "$version" "$shasum" + update-source-version ${attrPath} "$version" "$shasum" "$source_url" '' diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version index 4c32ae046f3..3e507660a65 100755 --- a/pkgs/common-updater/scripts/update-source-version +++ b/pkgs/common-updater/scripts/update-source-version @@ -6,10 +6,11 @@ die() { exit 1 } -# Usage: update-source-hash [] +# Usage: update-source-hash [] [] attr=$1 newVersion=$2 newHash=$3 +newUrl=$4 nixFile=$(nix-instantiate --eval --strict -A "$attr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/') if [ ! -f "$nixFile" ]; then @@ -27,6 +28,12 @@ if [ $(grep -c "$oldHash" "$nixFile") != 1 ]; then die "Couldn't locate old source hash '$oldHash' (or it appeared more than once) in '$nixFile'!" fi +oldUrl=$(nix-instantiate --eval -E "with import ./. {}; builtins.elemAt $attr.src.drvAttrs.urls 0" | tr -d '"') + +if [ -z "$oldUrl" ]; then + die "Couldn't evaluate source url from '$attr.name'!" +fi + drvName=$(nix-instantiate --eval -E "with import ./. {}; (builtins.parseDrvName $attr.name).name" | tr -d '"') oldVersion=$(nix-instantiate --eval -E "with import ./. {}; $attr.version or (builtins.parseDrvName $attr.name).version" | tr -d '"') @@ -41,6 +48,7 @@ fi # Escape regex metacharacter that are allowed in store path names oldVersion=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g') +oldUrl=$(echo "$oldUrl" | sed -re 's|[${}.+]|\\&|g') if [ $(grep -c -E "^\s*(let\b)?\s*version\s*=\s*\"$oldVersion\"" "$nixFile") = 1 ]; then pattern="/\bversion\b\s*=/ s|\"$oldVersion\"|\"$newVersion\"|" @@ -56,6 +64,15 @@ if cmp -s "$nixFile" "$nixFile.bak"; then die "Failed to replace version '$oldVersion' to '$newVersion' in '$attr'!" fi +# Replace new URL +if [ -n "$newUrl" ]; then + sed -i "$nixFile" -re "s|\"$oldUrl\"|\"$newUrl\"|" + + if cmp -s "$nixFile" "$nixFile.bak"; then + die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!" + fi +fi + case "$oldHashAlgo" in sha256) hashLength=64 ;; sha512) hashLength=128 ;; @@ -74,7 +91,7 @@ fi if [ -z "$newHash" ]; then nix-build --no-out-link -A "$attr.src" 2>"$attr.fetchlog" >/dev/null || true # FIXME: use nix-build --hash here once https://github.com/NixOS/nix/issues/1172 is fixed - newHash=$(egrep -v "killing process|dependencies couldn't be built" "$attr.fetchlog" | tail -n2 | sed "s~output path .* has .* hash \(.*\) when .* was expected\|fixed-output derivation produced path '.*' with .* hash '\(.*\)' instead of the expected hash '.*'~\1\2~" | head -n1) + newHash=$(egrep -v "killing process|dependencies couldn't be built" "$attr.fetchlog" | tail -n2 | sed "s~output path .* has .* hash ‘\(.*\)’ when .* was expected\|fixed-output derivation produced path '.*' with .* hash '\(.*\)' instead of the expected hash '.*'~\1\2~" | head -n1) fi if [ -z "$newHash" ]; then -- cgit 1.4.1