summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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`)