summary refs log tree commit diff
path: root/pkgs/common-updater
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2020-01-30 21:58:48 +0100
committerJan Tojnar <jtojnar@gmail.com>2020-02-04 06:25:38 +0100
commite4a0953ac70143f12ce192cda31711455d010743 (patch)
tree39620b71a2cf50ea0686ae531cdea3b07baf8da7 /pkgs/common-updater
parent65543d103193c46abdb190808b671fa2c66dde42 (diff)
downloadnixpkgs-e4a0953ac70143f12ce192cda31711455d010743.tar
nixpkgs-e4a0953ac70143f12ce192cda31711455d010743.tar.gz
nixpkgs-e4a0953ac70143f12ce192cda31711455d010743.tar.bz2
nixpkgs-e4a0953ac70143f12ce192cda31711455d010743.tar.lz
nixpkgs-e4a0953ac70143f12ce192cda31711455d010743.tar.xz
nixpkgs-e4a0953ac70143f12ce192cda31711455d010743.tar.zst
nixpkgs-e4a0953ac70143f12ce192cda31711455d010743.zip
common-updater-scripts: move destructive changes further in the script
We can check some things before the modifications take place.
Diffstat (limited to 'pkgs/common-updater')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version30
1 files changed, 15 insertions, 15 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index f152877e098..7fb5e413a26 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -117,21 +117,6 @@ else
     die "Couldn't figure out where out where to patch in new version in '$attr'!"
 fi
 
-# Replace new version
-sed -i.bak "$nixFile" -re "$pattern"
-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|\"$oldUrlEscaped\"|\"$newUrl\"|"
-
-    if cmp -s "$nixFile" "$nixFile.bak"; then
-        die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"
-    fi
-fi
-
 if [[ "$oldHash" =~ ^(sha256|sha512)[:-] ]]; then
     # Handle the possible SRI-style hash attribute (in the form ${type}${separator}${hash})
     # True SRI uses dash as a separator and only supports base64, whereas Nix’s SRI-style format uses a colon and supports all the same encodings like regular hashes (16/32/64).
@@ -159,6 +144,21 @@ if [[ -n "$sri" ]]; then
     tempHash="$(nix to-sri --type "$oldHashAlgo" "$tempHash")"
 fi
 
+# Replace new version
+sed -i.bak "$nixFile" -re "$pattern"
+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|\"$oldUrlEscaped\"|\"$newUrl\"|"
+
+    if cmp -s "$nixFile" "$nixFile.bak"; then
+        die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"
+    fi
+fi
+
 sed -i "$nixFile" -re "s|\"$oldHash\"|\"$tempHash\"|"
 if cmp -s "$nixFile" "$nixFile.bak"; then
     die "Failed to replace source hash of '$attr' to a temporary hash!"