# found. This relies on distribution specific kernels, but can handle
# your own custom list of target kernels. Log is setnt to LOG variable.
-# Pretty colors
-GREEN="\033[01;32m"
-YELLOW="\033[01;33m"
-NORMAL="\033[00m"
-BLUE="\033[34m"
-RED="\033[31m"
-PURPLE="\033[35m"
-CYAN="\033[36m"
-UNDERLINE="\033[02m"
#export KCFLAGS="-Wno-unused-but-set-variable"
KERNEL_DIR="/lib/modules"
LOG_TMP="ckmake-tmp.log"
REPORT="ckmake-report.log"
TIME="0"
-QUIET=""
-DEBUG=""
+DEBUG="0"
+NOCOLOR="0"
ARGS=""
+QUIET=""
RET_FILE="ret-tmp.txt"
# First and last kernels to use
KSRC_PREFIX="$HOME/compat-ksrc"
fi
+# Colorify output if NOCOLOR != 1 or -n is not given
+function prettify()
+{
+ if [[ $NOCOLOR == "1" ]]; then
+ echo -n "$2"
+ else
+ ANSI_CODE=
+ NORMAL="\033[00m"
+ case $1 in
+ "green")
+ ANSI_CODE="\033[01;32m"
+ ;;
+ "yellow")
+ ANSI_CODE="\033[01;33m"
+ ;;
+ "blue")
+ ANSI_CODE="\033[34m"
+ ;;
+ "red")
+ ANSI_CODE="\033[31m"
+ ;;
+ "purple")
+ ANSI_CODE="\033[35m"
+ ;;
+ "cyan")
+ ANSI_CODE="\033[36m"
+ ;;
+ "underline")
+ ANSI_CODE="\033[02m"
+ ;;
+ esac
+
+ echo -e -n "${ANSI_CODE}$2${NORMAL}"
+ fi
+}
+
function tee_color_split()
{
while read; do
function log_try_kernel()
{
- echo -en "Trying kernel ${BLUE}"
- printf "%40s\t" "${1}"
- echo -en "${NORMAL}"
+ printf "Trying kernel %40s\t" "$(prettify blue $1)"
}
function usage()
echo -e "-t will run: 'time ckmake; time ckmake' account for"
echo -e " benchmark how long it takes to compile without ccache"
echo -e " and a run after cache kicks in"
+ echo -e "-n Do not use colors in the output"
echo -e "-q will ask ckmake to run make with -s to only output errors"
echo
echo -e "<optional-target> is the arguments you want to pass to the"
TIME="1"
shift
;;
+ "-n")
+ NOCOLOR="1"
+ shift
+ ;;
"-s")
QUIET="-s"
shift
FIRST=$(echo $i | sed 's|\.\.|-|' | awk -F"-" '{print $1}')
LAST=$(echo $i | sed 's|\.\.|-|' | awk -F"-" '{print $2}')
RANGE="${FIRST}..${LAST}"
- echo -e "Going to use kernel ranges: ${BLUE}${FIRST}${NORMAL}..${BLUE}${LAST}${NORMAL}"
+ echo -e "Going to use kernel ranges: $(prettify blue $FIRST)..$(prettify blue $LAST)"
shift
fi
continue
fi
- # 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 | perl -pe 's|(\e)\[(\d+)(;*)(\d*)(\w)||g' >> $LOG
+ NOCOLOR="1" log_try_kernel $KERNEL >> $LOG
log_try_kernel $KERNEL
#ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable $ARGS &>> $LOG
fi
if [[ $CUR_RET -eq 0 ]]; then
- echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split $LOG
+ echo -e "$(prettify green [OK])" | tee_color_split $LOG
else
- echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split $LOG
+ echo -e "$(prettify red [FAILED])" | tee_color_split $LOG
RET=$CUR_RET
fi
fi
if [[ ! -z $DEBUG ]]; then
- echo -e "${CYAN}${FIRST}${NORMAL} $(kernel_version $FIRST) <= ${GREEN}${KERNEL}${NORMAL} $(kernel_version $KERNEL) <= ${CYAN}${LAST}${NORMAL} $(kernel_version $LAST)"
+ echo -e "$(prettify cyan $FIRST) $(kernel_version $FIRST) <= $(prettify green $KERNEL) $(kernel_version $KERNEL) <= $(prettify cyan $LAST) $(kernel_version $LAST)"
fi
fi