[pacman-dev] [PATCH 3/3] scripts/*.sh.in: Honor TMPDIR environment variable

Lukas Fleischer archlinux at cryptocrack.de
Thu Oct 13 11:23:21 EDT 2011


Replace "/tmp" with "${TMPDIR:-/tmp}" to allow for overriding the
hardcoded path.

Since we only use "/tmp" in conjunction with mktemp(1), we could also
have used "--tmpdir", which is GNU-ish, however (and the BSD counterpart
"-t" has been deprecated in GNU mktemp).

Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
 scripts/pacman-optimize.sh.in |    2 +-
 scripts/repo-add.sh.in        |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in
index 5ff302e..154f982 100644
--- a/scripts/pacman-optimize.sh.in
+++ b/scripts/pacman-optimize.sh.in
@@ -113,7 +113,7 @@ fi
 # do not let pacman run while we do this
 touch "$lockfile"
 
-workdir=$(mktemp -d /tmp/pacman-optimize.XXXXXXXXXX) ||
+workdir=$(mktemp -d "${TMPDIR:-/tmp}/pacman-optimize.XXXXXXXXXX") ||
 	die_r "$(gettext "Can not create temp directory for database building.")\n" >&2
 
 # step 1: sum the old db
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 5e1d770..fc008fc 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -566,7 +566,7 @@ if [[ $cmd != "repo-add" && $cmd != "repo-remove" ]]; then
 	exit 1
 fi
 
-tmpdir=$(mktemp -d /tmp/repo-tools.XXXXXXXXXX) || (\
+tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/repo-tools.XXXXXXXXXX") || (\
 	error "$(gettext "Cannot create temp directory for database building.")"; \
 	exit 1)
 mkdir $tmpdir/tree
-- 
1.7.7



More information about the pacman-dev mailing list