Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2014-12-31 14:33:31 -0500
committerAllan McRae <allan@archlinux.org>2015-01-02 21:43:28 +1000
commitca5a2771aeb0babca8270b83b0cb0172db4cebe5 (patch)
tree86d763975a43c2fc4487e4a726639b30827785fb /contrib
parent39fe2d0e39956961bdcb9c4bd78ca11247f044bd (diff)
updpkgsums: retain permissions on rewritten PKGBUILD
This could have been easy with something like chown's --reference flag, but this is GNU specific. Instead, just truncate and rewrite the file. Our exit trap cleans up after us. Fixes: https://bugs.archlinux.org/task/43272 Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/updpkgsums.sh.in8
1 files changed, 3 insertions, 5 deletions
diff --git a/contrib/updpkgsums.sh.in b/contrib/updpkgsums.sh.in
index b0d2d69e..7b92efe3 100644
--- a/contrib/updpkgsums.sh.in
+++ b/contrib/updpkgsums.sh.in
@@ -82,9 +82,6 @@ fi
export BUILDDIR=$(mktemp -d --tmpdir updpkgsums.XXXXXX)
newbuildfile=$(mktemp --tmpdir updpkgsums.XXXXXX)
-# In case the eventual replacement fails, we don't want to leave behind
-# $newbuildfile as garbage in $TMPDIR. This fails silently if the replacement
-# succeeds.
trap "rm -rf '$BUILDDIR' '$newbuildfile'" EXIT
newsums=$(makepkg -g -p "$buildfile") || die 'Failed to generate new checksums'
awk -v newsums="$newsums" '
@@ -100,8 +97,9 @@ awk -v newsums="$newsums" '
END { if (!w) print newsums }
' "$buildfile" > "$newbuildfile" || die 'Failed to write new PKGBUILD'
-# Replace the original buildfile.
-if ! mv -- "$newbuildfile" "$buildfile"; then
+# Rewrite the original buildfile. Use cat instead of mv/cp to preserve
+# permissions implicitly.
+if ! cat -- "$newbuildfile" >"$buildfile"; then
die "Failed to update %s. The file has not been modified." "$buildfile"
fi