#!/usr/bin/env bash
set -euE

hook_pre_build+=("clean_chroot")

clean_chroot() (
	set +x
	local copydir=$1
	if $INCHROOT; then
		cd /startdir
		sudo -u nobody "$(librelib chroot/chcleanup)"
	else
		librechroot "${librechroot_flags[@]}" clean-pkgs
	fi
)