summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-06-02 12:28:14 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-06-02 12:28:14 -0400
commit209a8c565f61c9491b151201c5ac0917d6ff26b7 (patch)
treebcd5e8c2ece43d625be37c1c56ce981b331fac9d
parentc54ef152ed0a55e7739c06bcaaa41edf7aa37a7c (diff)
librechroot: Properly clean up temporary pacman.conf file
-rwxr-xr-xsrc/chroot-tools/librechroot3
-rw-r--r--test/librechroot-test.sh13
2 files changed, 16 insertions, 0 deletions
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 6ae4b12..d763830 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -449,6 +449,9 @@ main() {
# - set 'CacheDir' in \`/etc/pacman.conf'"
# - apply -C or -M flags
arch-nspawn "$copydir" true
+ if [[ -n ${tmppacmanconf:-} ]]; then
+ rm -f -- "$tmppacmanconf"
+ fi
trap EXIT # clear the trap to remove the tmp pacman.conf from -A
arch_nspawn_flags=() # XXX dirty hack, don't apply -C or -M again
fi
diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh
index 42d4803..edf7a4f 100644
--- a/test/librechroot-test.sh
+++ b/test/librechroot-test.sh
@@ -145,3 +145,16 @@ it_deletes_subvolumes_recursively() {
testsudo librechroot -l "$roundup_test_name" delete
not test -e "$chrootdir/default/$roundup_test_name"
}
+
+it_cleans_up_TMPDIR() {
+ require network sudo || return 0
+
+ local dir="$tmpdir/tmp"
+ mkdir -- "$dir"
+
+ libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
+ TMPDIR=$dir testsudo librechroot -l "$roundup_test_name" -A x86_64 make
+
+ # Make sure $dir is now empty
+ rmdir -- "$dir"
+}