mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 22:43:01 +00:00
common-updater-scripts: Fix replacement failure detections
Previously, we only made `sed` back up the version replacement. This meant that `cmp` would already recognize the files as changed before replacing hash and the other values, and the error would not be printed. Let’s always make the `sed` create a backup so that we can detect success of each situation. This will no longer allow us to revert to the original version on failure but the updated file should be tracked in git anyway.
This commit is contained in:
parent
f31881a619
commit
17bc96df08
@ -206,30 +206,28 @@ oldHashEscaped=$(echo "$oldHash" | sed -re 's|[+]|\\&|g')
|
||||
tempHashEscaped=$(echo "$tempHash" | sed -re 's|[+]|\\&|g')
|
||||
|
||||
# Replace new version
|
||||
sed -i.bak "$nixFile" -re "$pattern"
|
||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
||||
sed -i.cmp "$nixFile" -re "$pattern"
|
||||
if cmp -s "$nixFile" "$nixFile.cmp"; 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
|
||||
sed -i.cmp "$nixFile" -re "s|\"$oldUrlEscaped\"|\"$newUrl\"|"
|
||||
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||
die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"
|
||||
fi
|
||||
fi
|
||||
|
||||
sed -i "$nixFile" -re "s|\"$oldHashEscaped\"|\"$tempHash\"|"
|
||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
||||
sed -i.cmp "$nixFile" -re "s|\"$oldHashEscaped\"|\"$tempHash\"|"
|
||||
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||
die "Failed to replace source hash of '$attr' to a temporary hash!"
|
||||
fi
|
||||
|
||||
# Replace new revision, if given
|
||||
if [[ -n "$newRevision" ]]; then
|
||||
sed -i "$nixFile" -re "s|\"$oldRevision\"|\"$newRevision\"|"
|
||||
|
||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
||||
sed -i.cmp "$nixFile" -re "s|\"$oldRevision\"|\"$newRevision\"|"
|
||||
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||
die "Failed to replace source revision '$oldRevision' to '$newRevision' in '$attr'!"
|
||||
fi
|
||||
fi
|
||||
@ -254,16 +252,15 @@ if [[ -z "$newHash" ]]; then
|
||||
fi
|
||||
|
||||
if [[ -z "${ignoreSameHash}" && "$oldVersion" != "$newVersion" && "$oldHash" = "$newHash" ]]; then
|
||||
mv "$nixFile.bak" "$nixFile"
|
||||
die "Both the old and new source hashes of '$attr.$sourceKey' were equivalent. Please fix the package's source URL to be dependent on '\${version}'!"
|
||||
fi
|
||||
|
||||
sed -i "$nixFile" -re "s|\"$tempHashEscaped\"|\"$newHash\"|"
|
||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
||||
sed -i.cmp "$nixFile" -re "s|\"$tempHashEscaped\"|\"$newHash\"|"
|
||||
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||
die "Failed to replace temporary source hash of '$attr' to the final source hash!"
|
||||
fi
|
||||
|
||||
rm -f "$nixFile.bak"
|
||||
rm -f "$nixFile.cmp"
|
||||
rm -f "$attr.fetchlog"
|
||||
|
||||
if [ -n "$printChanges" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user