diff --git a/xbps-src/libexec/xbps-src-doinst-helper.sh.in b/xbps-src/libexec/xbps-src-doinst-helper.sh.in index 1ad86ad2ede..33faeec34f9 100644 --- a/xbps-src/libexec/xbps-src-doinst-helper.sh.in +++ b/xbps-src/libexec/xbps-src-doinst-helper.sh.in @@ -209,8 +209,7 @@ install_src_phase() # Remove $wrksrc if -C not specified. # if [ -d "$saved_wrksrc" -a "$dontrm_builddir" = "no" ]; then - rm -rf $saved_wrksrc && \ - msg_normal "Package '$sourcepkg ($lver)': removed build directory." + remove_tmpl_wrksrc $saved_wrksrc fi } diff --git a/xbps-src/shutils/tmpl_funcs.sh.in b/xbps-src/shutils/tmpl_funcs.sh.in index f98f2687df1..4978da437c7 100644 --- a/xbps-src/shutils/tmpl_funcs.sh.in +++ b/xbps-src/shutils/tmpl_funcs.sh.in @@ -252,6 +252,19 @@ prepare_tmpl() fi } +remove_tmpl_wrksrc() +{ + local lwrksrc="$1" + + if [ -z "$lwrksrc" -o ! -d "$lwrksrc" ]; then + return 1 + fi + + msg_normal "Cleaning '$pkgname' build directory... " + rm -rf $lwrksrc + return $? +} + set_tmpl_common_vars() { [ -z "$pkgname" ] && return 1 diff --git a/xbps-src/xbps-src.sh.in b/xbps-src/xbps-src.sh.in index c038834597d..5f4b88df200 100644 --- a/xbps-src/xbps-src.sh.in +++ b/xbps-src/xbps-src.sh.in @@ -77,6 +77,7 @@ Targets: checkvers Checks installed package versions against srcpkgs for new available versions. chroot Enter to the chroot in . + clean Remove build directory. configure Configure a package (fetch + extract + configure). extract Extract distribution file(s) into build directory. Build directory is always available in @@ -312,6 +313,12 @@ chroot) . $XBPS_SHUTILSDIR/chroot.sh xbps_chroot_handler chroot dummy ;; +clean) + . $XBPS_SHUTILSDIR/tmpl_funcs.sh + [ ! -r ./template ] && msg_error "missing build template in $(pwd)." + setup_tmpl $(basename_cwd) + remove_tmpl_wrksrc $wrksrc + ;; extract|fetch|info) . $XBPS_SHUTILSDIR/tmpl_funcs.sh [ ! -r ./template ] && msg_error "missing build template in $(pwd)."