Improve debugcleanup code master
authorRobin H. Johnson <robbat2@gentoo.org>
Wed, 16 Apr 2014 08:32:11 +0000 (01:32 -0700)
committerRobin H. Johnson <robbat2@gentoo.org>
Wed, 16 Apr 2014 08:32:20 +0000 (01:32 -0700)
- Improve the debug-cleanup code to use isTrue and match other code
  style.
- add explicit return 0 after debug-cleanup to avoid passing a false
  negative failure code up to a higher level function.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
gen_compile.sh
genkernel

index 9b5df01..0fb33d5 100755 (executable)
@@ -430,7 +430,7 @@ compile_busybox() {
                yes '' 2>/dev/null | compile_generic oldconfig utils
 
                print_info 1 'busybox: >> Compiling...'
-               compile_generic all utils
+               compile_generic all utils V=1
                print_info 1 'busybox: >> Copying to cache...'
                [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
                        gen_die 'Busybox executable does not exist!'
@@ -440,7 +440,8 @@ compile_busybox() {
                        gen_die 'Could not create the busybox bincache!'
 
                cd "${TEMP}"
-               rm -rf "${BUSYBOX_DIR}" > /dev/null
+               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${BUSYBOX_DIR}" > /dev/null
+               return 0
        fi
 }
 
@@ -485,8 +486,9 @@ compile_lvm() {
                        gen_die 'Could not create binary cache'
 
                cd "${TEMP}"
-               rm -rf "${TEMP}/lvm" > /dev/null
-               rm -rf "${LVM_DIR}" lvm
+               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${TEMP}/lvm" > /dev/null
+               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${LVM_DIR}" lvm
+               return 0
        fi
 }
 
@@ -525,7 +527,8 @@ compile_mdadm() {
                        gen_die 'Could not create binary cache'
 
                cd "${TEMP}"
-               rm -rf "${MDADM_DIR}" mdadm
+               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${MDADM_DIR}" mdadm
+               return 0
        fi
 }
 
@@ -574,8 +577,9 @@ compile_dmraid() {
                        gen_die 'Could not create binary cache'
 
                cd "${TEMP}"
-               rm -rf "${TEMP}/lvm" > /dev/null
-               rm -rf "${DMRAID_DIR}" dmraid
+               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${TEMP}/lvm" > /dev/null
+               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${DMRAID_DIR}" dmraid
+               return 0
        fi
 }
 
@@ -612,7 +616,8 @@ compile_fuse() {
 #                      gen_die 'Could not create fuse bincache!'
 
                cd "${TEMP}"
-#              rm -rf "${FUSE_DIR}" > /dev/null
+#              isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${FUSE_DIR}" > /dev/null
+               return 0
        fi
 }
 
@@ -647,7 +652,8 @@ compile_unionfs_fuse() {
                        gen_die 'Could not copy the unionfs binary to the package directory, does the directory exist?'
 
                cd "${TEMP}"
-               rm -rf "${UNIONFS_FUSE_DIR}" > /dev/null
+               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${UNIONFS_FUSE_DIR}" > /dev/null
+               return 0
        fi
 }
 
@@ -697,7 +703,8 @@ compile_iscsi() {
                        gen_die 'Could not copy the iscsistart binary to the package directory, does the directory exist?'
 
                cd "${TEMP}"
-               rm -rf "${ISCSI_DIR}" > /dev/null
+               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${ISCSI_DIR}" > /dev/null
+               return 0
        fi
 }
 
@@ -742,6 +749,7 @@ compile_gpg() {
                        gen_die 'Could not copy the gpg binary to the package directory, does the directory exist?'
 
                cd "${TEMP}"
-               rm -rf "${GPG_DIR}" > /dev/null
+               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${GPG_DIR}" > /dev/null
+               return 0
        fi
 }
index ed7f3ad..1d2a372 100755 (executable)
--- a/genkernel
+++ b/genkernel
@@ -61,12 +61,7 @@ trap_cleanup(){
 }
 
 cleanup(){
-       if [ "${CMD_DEBUGCLEANUP}" == "no" ]; then
-               print_info 1 "Not running any cleanup per DEBUGCLEANUP"
-               print_info 1 "TEMP: ${TEMP}"
-               print_info 1 "CACHE_DIR: ${CACHE_DIR}"
-               print_info 1 "TMPDIR: ${TMPDIR}"
-       else
+       if isTrue "${CMD_DEBUGCLEANUP}"; then
                if [ -n "$TEMP" -a -d "$TEMP" ]; then
                        rm -rf "$TEMP"
                fi
@@ -82,6 +77,11 @@ cleanup(){
                        print_info 1 "TMPDIR: ${TMPDIR}"
                        clear_tmpdir
                fi
+       else
+               print_info 1 "Not running any cleanup per DEBUGCLEANUP"
+               print_info 1 "TEMP: ${TEMP}"
+               print_info 1 "CACHE_DIR: ${CACHE_DIR}"
+               print_info 1 "TMPDIR: ${TMPDIR}"
        fi
 }