mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +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')
|
tempHashEscaped=$(echo "$tempHash" | sed -re 's|[+]|\\&|g')
|
||||||
|
|
||||||
# Replace new version
|
# Replace new version
|
||||||
sed -i.bak "$nixFile" -re "$pattern"
|
sed -i.cmp "$nixFile" -re "$pattern"
|
||||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||||
die "Failed to replace version '$oldVersion' to '$newVersion' in '$attr'!"
|
die "Failed to replace version '$oldVersion' to '$newVersion' in '$attr'!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Replace new URL
|
# Replace new URL
|
||||||
if [[ -n "$newUrl" ]]; then
|
if [[ -n "$newUrl" ]]; then
|
||||||
sed -i "$nixFile" -re "s|\"$oldUrlEscaped\"|\"$newUrl\"|"
|
sed -i.cmp "$nixFile" -re "s|\"$oldUrlEscaped\"|\"$newUrl\"|"
|
||||||
|
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
|
||||||
die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"
|
die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i "$nixFile" -re "s|\"$oldHashEscaped\"|\"$tempHash\"|"
|
sed -i.cmp "$nixFile" -re "s|\"$oldHashEscaped\"|\"$tempHash\"|"
|
||||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||||
die "Failed to replace source hash of '$attr' to a temporary hash!"
|
die "Failed to replace source hash of '$attr' to a temporary hash!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Replace new revision, if given
|
# Replace new revision, if given
|
||||||
if [[ -n "$newRevision" ]]; then
|
if [[ -n "$newRevision" ]]; then
|
||||||
sed -i "$nixFile" -re "s|\"$oldRevision\"|\"$newRevision\"|"
|
sed -i.cmp "$nixFile" -re "s|\"$oldRevision\"|\"$newRevision\"|"
|
||||||
|
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
|
||||||
die "Failed to replace source revision '$oldRevision' to '$newRevision' in '$attr'!"
|
die "Failed to replace source revision '$oldRevision' to '$newRevision' in '$attr'!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -254,16 +252,15 @@ if [[ -z "$newHash" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${ignoreSameHash}" && "$oldVersion" != "$newVersion" && "$oldHash" = "$newHash" ]]; then
|
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}'!"
|
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
|
fi
|
||||||
|
|
||||||
sed -i "$nixFile" -re "s|\"$tempHashEscaped\"|\"$newHash\"|"
|
sed -i.cmp "$nixFile" -re "s|\"$tempHashEscaped\"|\"$newHash\"|"
|
||||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||||
die "Failed to replace temporary source hash of '$attr' to the final source hash!"
|
die "Failed to replace temporary source hash of '$attr' to the final source hash!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "$nixFile.bak"
|
rm -f "$nixFile.cmp"
|
||||||
rm -f "$attr.fetchlog"
|
rm -f "$attr.fetchlog"
|
||||||
|
|
||||||
if [ -n "$printChanges" ]; then
|
if [ -n "$printChanges" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user