summaryrefslogtreecommitdiff
path: root/src/chroot-tools/hooks-chcleanup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot-tools/hooks-chcleanup.sh')
-rw-r--r--src/chroot-tools/hooks-chcleanup.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/chroot-tools/hooks-chcleanup.sh b/src/chroot-tools/hooks-chcleanup.sh
new file mode 100644
index 0000000..09e6dd9
--- /dev/null
+++ b/src/chroot-tools/hooks-chcleanup.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+set -euE
+
+hooks_pre_build+=("clean_chroot")
+
+clean_chroot() (
+ set +x
+ local copydir=$1
+ if $INCHROOT; then
+ cd /build
+ sudo -u nobody "$(librelib chroot/chcleanup)"
+ else
+ librechroot -l "$copydir" clean-pkgs
+ fi
+ r=$?; echo clean_chroot returning $r; return $r
+)