[pacman-dev] [PATCH] updpkgsums: use a throwaway build dir

Dave Reisner dreisner at archlinux.org
Sun Sep 7 12:37:34 EDT 2014

This prevents updpkgsums from potentially dirtying an otherwise pristine
directory (likely $PWD) when makepkg creates the srclinks.
 contrib/updpkgsums.sh.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/contrib/updpkgsums.sh.in b/contrib/updpkgsums.sh.in
index 7e680b8..d41e362 100644
--- a/contrib/updpkgsums.sh.in
+++ b/contrib/updpkgsums.sh.in
@@ -79,6 +79,8 @@ fi
 	# Generate the new sums and try to unlink the file before writing stdin back
 	# into it. This final precaution shouldn't fail based on the previous checks,
 	# but it's better to be extra careful before unlinking files.
+	export BUILDDIR=$(mktemp -d --tmpdir updpkgsums.XXXXXX)
+	trap "rm -rf '$BUILDDIR'" EXIT
 	newsums=$(makepkg -g -p "$buildfile") && rm -f "$buildfile" &&
 	exec awk -v newsums="$newsums" '
 	/^[[:blank:]]*(md|sha)[[:digit:]]+sums=/,/\)[[:blank:]]*(#.*)?$/ {

More information about the pacman-dev mailing list