summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-06-09 21:10:19 -0600
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-06-09 21:10:19 -0600
commitc03660fd04e8c6496a83e44c9f51b81db0d4be06 (patch)
tree6422585f62a5352041a587e752daa4d7ab05b723
parent2df0b1eaa9e78756d8e847e73ba59518c7bf4032 (diff)
libremakepkg: fix up clean up routines
-rwxr-xr-xsrc/chroot-tools/libremakepkg12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index baf8015..d2ce222 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -46,12 +46,14 @@ trap_exit() {
#
# Environment
# - $INCHROOT is set
-run() {
+run() (
local HASNET=true
[[ $1 == -N ]] && { HASNET=false; shift; }
local copydir=$1; shift
local cmd="$*"
+ trap "rm -f -- '$copydir/chrootexec'" EXIT
+
cat >"$copydir/chrootexec" <<EOF
#!/bin/bash
. /etc/profile
@@ -70,7 +72,7 @@ EOF
$HASNET || flags='-N'
librechroot $flags -l "$copydir" run /chrootexec
fi
-}
+)
# Usage: add_to_local_repo $copydir $pkgfiles...
add_to_local_repo() (
@@ -148,7 +150,7 @@ EOF
# - $INCHROOT is set
# - $copydir is set
# - $LIBREUSER is set
-extract() {
+extract() (
local user=$LIBREUSER
$INCHROOT || user=nobody
@@ -156,13 +158,13 @@ extract() {
if $INCHROOT; then
clean=chcleanup
else
+ trap "rm -f '$copydir/clean'" EXIT
cp -a "$(which chcleanup)" "${copydir}/clean"
clean=/clean
fi
run "$copydir" "${clean} && sudo -u ${user} -- makepkg ${makepkg_args} -o"
- rm -f "$copydir"/clean
-}
+)
# Usage: build
# Builds the package (`makepkg -e`)