From: Fabian Castelli <fabian.castelli@kit.edu>
Date: Wed, 26 May 2021 16:47:52 +0000 (+0200)
Subject: Add instant clean up option
X-Git-Tag: v9.3.0-r3~18^2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F182%2Fhead;p=candi.git

Add instant clean up option
---

diff --git a/candi.cfg b/candi.cfg
index 449b080..dc520d2 100644
--- a/candi.cfg
+++ b/candi.cfg
@@ -116,3 +116,13 @@ MKL=OFF
 #       this mode!
 DEVELOPER_MODE=OFF
 
+################################################################################
+
+# OPTION {ON|OFF}: Remove build directory after successful installation
+INSTANT_CLEAN_BUILD_AFTER_INSTALL=OFF
+
+# OPTION {ON|OFF}: Remove downloaded packed src after successful installation
+INSTANT_CLEAN_SRC_AFTER_INSTALL=OFF
+
+# OPTION {ON|OFF}: Remove unpack directory after successful installation
+INSTANT_CLEAN_UNPACK_AFTER_INSTALL=OFF
diff --git a/candi.sh b/candi.sh
index d008646..817db39 100755
--- a/candi.sh
+++ b/candi.sh
@@ -1130,6 +1130,23 @@ for PACKAGE in ${PACKAGES[@]}; do
             package_unpack
         fi
         package_build
+
+        # Clean build directory after install
+        if [ ${INSTANT_CLEAN_BUILD_AFTER_INSTALL} = ON ]; then
+            rm -rf ${BUILDDIR}
+        fi
+
+        # Clean src after install
+        if [ ${INSTANT_CLEAN_SRC_AFTER_INSTALL} = ON ]; then
+            if [ -f ${DOWNLOAD_PATH}/${NAME}${PACKING} ]; then
+                rm -f ${DOWNLOAD_PATH}/${NAME}${PACKING}
+            fi
+        fi
+
+        # Clean unpack directory after install
+        if [ ${INSTANT_CLEAN_UNPACK_AFTER_INSTALL} = ON ]; then
+            rm -rf ${UNPACK_PATH}/${EXTRACTSTO}
+        fi
     else
         if [ ! -z "${LOAD}" ]; then
             # Let the user know we're loading the current package