compat: avoid color crap on log for good
authorLuis R. Rodriguez <mcgrof@frijolero.org>
Tue, 28 Feb 2012 23:32:34 +0000 (15:32 -0800)
committerLuis R. Rodriguez <mcgrof@frijolero.org>
Tue, 28 Feb 2012 23:32:34 +0000 (15:32 -0800)
This skips color output on the log file for all
output as we go.

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
bin/ckmake

index ccb291b1dd11cce7021529319f87720bab46881a..2d9a5ebe6c9ea1adbce87218917911938e8b3a1c 100755 (executable)
@@ -41,6 +41,21 @@ esac
 
 nice make clean 2>&1 > $LOG
 
+function tee_color_split()
+{
+       while read; do
+               echo -e $REPLY | ./scripts/skip-colors >> $LOG
+               echo -e $REPLY
+       done
+}
+
+function log_try_kernel()
+{
+       echo -en "Trying kernel ${BLUE}"
+       printf "%40s\t" "${1}"
+       echo -en "${NORMAL}"
+}
+
 for i in $KLIBS; do
        KERNEL=$(basename $i)
        DIR=${i}/build/
@@ -50,19 +65,18 @@ for i in $KLIBS; do
                continue
        fi
 
-       echo -en "Trying kernel ${BLUE}" | tee -a $LOG
-       printf "%40s\t" "${KERNEL}" | tee -a $LOG
-       echo -en "${NORMAL}" | tee -a $LOG
+       # We cannot use tee_color_split() as bash read only spits
+       # out output when a newline comes in. We can modif IFS but
+       # I am still not sure how to do this properly.
+       log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG
+       log_try_kernel $KERNEL
 
        ionice -c 3 nice -n 20 make KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG
        if [[ $? -eq 0 ]]; then
-               echo -e "${GREEN}[OK]${NORMAL}" | tee -a $LOG
+               echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split
        else
-               echo -e "${RED}[FAILED]${NORMAL}" | tee -a $LOG
+               echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split
        fi
 
        nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG
 done
-
-cat $LOG | ./scripts/skip-colors > $LOG.tmp
-mv $LOG.tmp $LOG