Skip to content

Instantly share code, notes, and snippets.

@MilhouseVH
Created August 11, 2017 00:56
Show Gist options
  • Save MilhouseVH/2746e75d822dc4899d5c5a21b0ac4e47 to your computer and use it in GitHub Desktop.
Save MilhouseVH/2746e75d822dc4899d5c5a21b0ac4e47 to your computer and use it in GitHub Desktop.
diff --git a/config/functions b/config/functions
index 4ed2351..33b88d6 100644
--- a/config/functions
+++ b/config/functions
@@ -525,6 +525,38 @@ debug_strip() {
fi
}
+get_color() {
+ local clr_var="$1"
+ local clr_actual="${!clr_var}"
+
+ [ "$DISABLE_COLOURS" == "yes" ] && return 0
+
+ if [ -z "${clr_actual}" -o -z "${!clr_actual}" ]; then
+ case "$clr_var" in
+ CLR_ERROR) clr_actual="boldred";;
+ CLR_WARNING) clr_actual="boldred";;
+ CLR_WARNING_DIM) clr_actual="red";;
+
+
+ CLR_CLEAN) clr_actual="boldred";;
+ CLR_INSTALL) clr_actual="boldgreen";;
+ CLR_AUTORECONF) clr_actual="boldmagenta";;
+ CLR_BUILD) clr_actual="boldyellow";;
+ CLR_GET) clr_actual="boldcyan";;
+ CLR_INFO) clr_actual="boldgreen";;
+ CLR_UNPACK) clr_actual="boldcyan";;
+ CLR_APPLY_PATCH) clr_actual="boldgreen";;
+ CLR_FIXCONFIG) clr_actual="boldyellow";;
+ CLR_PATCH_DESC) clr_actual="boldwhite";;
+ CLR_TARGET) clr_actual="boldwhite";;
+
+ CLR_ENDCOLOR) clr_actual="endcolor";;
+ esac
+ fi
+
+ echo -en "${!clr_actual}"
+}
+
# Use distribution functions if any
if [ -f "distributions/$DISTRO/config/functions" ]; then
. distributions/$DISTRO/config/functions
diff --git a/scripts/autoreconf b/scripts/autoreconf
index 8af2bd2..c6d60cb 100755
--- a/scripts/autoreconf
+++ b/scripts/autoreconf
@@ -30,7 +30,7 @@ if [ ! -f $PKG_BUILD/.autoreconf-done ] ; then
touch $PKG_BUILD/NEWS $PKG_BUILD/AUTHORS $PKG_BUILD/ChangeLog
mkdir -p $PKG_BUILD/m4
- printf "%${BUILD_INDENT}c ${boldmagenta}AUTORECONF${endcolor} $1\n" ' '>&$SILENT_OUT
+ printf "%${BUILD_INDENT}c $(get_color CLR_AUTORECONF)AUTORECONF$(get_color CLR_ENDCOLOR) $1\n" ' '>&$SILENT_OUT
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
do_autoreconf $PKG_BUILD
diff --git a/scripts/build b/scripts/build
index ae818a6..52ab8f1 100755
--- a/scripts/build
+++ b/scripts/build
@@ -26,7 +26,7 @@ if [ -z "$1" ]; then
fi
if [ ! -f $PKG_DIR/package.mk ]; then
- printf "${boldred}$1: no package.mk file found${endcolor}\n"
+ printf "$(get_color CLR_ERROR)$1: no package.mk file found$(get_color CLR_ENDCOLOR)\n"
exit 1
fi
@@ -182,7 +182,7 @@ if [ ! -f $STAMP ]; then
done
fi
- printf "%${BUILD_INDENT}c ${boldyellow}BUILD${endcolor} $PACKAGE_NAME ${boldwhite}($TARGET)${endcolor}\n" ' '>&$SILENT_OUT
+ printf "%${BUILD_INDENT}c $(get_color CLR_BUILD)BUILD$(get_color CLR_ENDCOLOR) $PACKAGE_NAME $(get_color CLR_TARGET)($TARGET)$(get_color CLR_ENDCOLOR)\n" ' '>&$SILENT_OUT
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
if [ "$PKG_AUTORECONF" = yes ]; then
diff --git a/scripts/clean b/scripts/clean
index 2673b0b..4b2d296 100755
--- a/scripts/clean
+++ b/scripts/clean
@@ -21,7 +21,7 @@
. config/options $1
clean_package() {
- printf "%${BUILD_INDENT}c ${boldred}CLEAN${endcolor} $1\n" ' '>&$SILENT_OUT
+ printf "%${BUILD_INDENT}c $(get_color CLR_CLEAN)CLEAN$(get_color CLR_ENDCOLOR) $1\n" ' '>&$SILENT_OUT
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
if [ "$CLEAN_SOURCES" = true ]; then
@@ -34,7 +34,7 @@ clean_package() {
if [ -d $i -a -f "$i/.libreelec-unpack" ] ; then
. "$i/.libreelec-unpack"
if [ "$STAMP_PKG_NAME" = "$1" ]; then
- printf "%${BUILD_INDENT}c ${boldred}*${endcolor} ${red}Removing $i ...${endcolor}\n" ' '>&$SILENT_OUT
+ printf "%${BUILD_INDENT}c $(get_color CLR_WARNING)*$(get_color CLR_ENDCOLOR) $(get_color CLR_WARNING_DIM)Removing $i ...$(get_color CLR_ENDCOLOR)\n" ' '>&$SILENT_OUT
rm -rf $i
fi
else
diff --git a/scripts/get b/scripts/get
index 0367f1f..80d9f3b 100755
--- a/scripts/get
+++ b/scripts/get
@@ -63,7 +63,7 @@ done
_get_file_already_downloaded $1 && exit 0
# At this point, we need to download something...
-printf "%${BUILD_INDENT}c ${boldcyan}GET${endcolor} $1\n" ' '>&$SILENT_OUT
+printf "%${BUILD_INDENT}c $(get_color CLR_GET)GET$(get_color CLR_ENDCOLOR) $1\n" ' '>&$SILENT_OUT
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
# unset LD_LIBRARY_PATH to stop wget from using toolchain/lib and loading libssl.so/libcrypto.so instead of host libraries
@@ -80,7 +80,7 @@ while [ $NBWGET -gt 0 ]; do
[ -z "${PKG_SHA256}" -o "${PKG_SHA256}" == "${CALC_SHA256}" ] && break
- printf "%${BUILD_INDENT}c ${boldred}WARNING${endcolor} Incorrect checksum calculated on downloaded file: got ${CALC_SHA256}, wanted ${PKG_SHA256}\n\n" ' '>&$SILENT_OUT
+ printf "%${BUILD_INDENT}c $(get_color CLR_WARNING)WARNING$(get_color CLR_ENDCOLOR) Incorrect checksum calculated on downloaded file: got ${CALC_SHA256}, wanted ${PKG_SHA256}\n\n" ' '>&$SILENT_OUT
fi
NBWGET=$((NBWGET - 1))
done
@@ -89,7 +89,7 @@ if [ $NBWGET -eq 0 ]; then
echo -e "\nCant't get $1 sources : $PKG_URL\n Try later !!"
exit 1
else
- printf "%${BUILD_INDENT}c ${boldgreen}INFO${endcolor} Calculated checksum: ${CALC_SHA256}\n\n" ' '>&$SILENT_OUT
+ printf "%${BUILD_INDENT}c $(get_color CLR_INFO)INFO$(get_color CLR_ENDCOLOR) Calculated checksum: ${CALC_SHA256}\n\n" ' '>&$SILENT_OUT
echo "${PKG_URL}" > $STAMP_URL
echo "${CALC_SHA256}" > $STAMP_SHA
fi
diff --git a/scripts/install b/scripts/install
index 4ef8eb1..f2a2b5e 100755
--- a/scripts/install
+++ b/scripts/install
@@ -49,13 +49,13 @@ if [ -n "$PKG_ARCH" -a ! "$PKG_ARCH" = "any" ]; then
fi
if [ ! -f $PKG_DIR/package.mk ]; then
- printf "${boldred}${PACKAGE_NAME}: no package.mk file found${endcolor}\n"
+ printf "$(get_color CLR_ERROR)${PACKAGE_NAME}: no package.mk file found$(get_color CLR_ENDCOLOR)\n"
exit 1
fi
$SCRIPTS/build $@
-printf "%${BUILD_INDENT}c ${boldgreen}INSTALL${endcolor} $PACKAGE_NAME ${boldwhite}($TARGET)${endcolor}\n" ' '>&$SILENT_OUT
+printf "%${BUILD_INDENT}c $(get_color CLR_INSTALL)INSTALL$(get_color CLR_ENDCOLOR) $PACKAGE_NAME $(get_color CLR_TARGET)($TARGET)$(get_color CLR_ENDCOLOR)\n" ' '>&$SILENT_OUT
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
if [ "$TARGET" = target ] ; then
diff --git a/scripts/unpack b/scripts/unpack
index a1fae1e..570a28e 100755
--- a/scripts/unpack
+++ b/scripts/unpack
@@ -26,7 +26,7 @@ if [ -z "$1" ]; then
fi
if [ ! -f $PKG_DIR/package.mk ]; then
- printf "${boldred}$1: no package.mk file found${endcolor}\n"
+ printf "$(get_color CLR_ERROR)$1: no package.mk file found$(get_color CLR_ENDCOLOR)\n"
exit 1
fi
@@ -61,7 +61,7 @@ fi
[ -f "$STAMP" ] && exit 0
if [ -d "$SOURCES/$1" -o -d "$PKG_DIR/sources" ]; then
- printf "%${BUILD_INDENT}c ${boldcyan}UNPACK${endcolor} $1\n" ' '>&$SILENT_OUT
+ printf "%${BUILD_INDENT}c $(get_color CLR_UNPACK)UNPACK$(get_color CLR_ENDCOLOR) $1\n" ' '>&$SILENT_OUT
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
# unset functions
@@ -172,7 +172,7 @@ if [ -d "$SOURCES/$1" -o -d "$PKG_DIR/sources" ]; then
fi
if [ -f "$i" ]; then
- printf "%${BUILD_INDENT}c ${boldgreen}APPLY PATCH${endcolor} ${boldwhite}${PATCH_DESC}${endcolor} ${i#$ROOT/}\n" ' '>&$SILENT_OUT
+ printf "%${BUILD_INDENT}c $(get_color CLR_APPLY_PATCH)APPLY PATCH$(get_color CLR_ENDCOLOR) $(get_color CLR_PATCH_DESC)${PATCH_DESC}$(get_color CLR_ENDCOLOR) ${i#$ROOT/}\n" ' '>&$SILENT_OUT
if [ -n "$(grep -E '^GIT binary patch$' $i)" ]; then
cat $i | git apply --directory=`echo "$PKG_BUILD" | cut -f1 -d\ ` -p1 --verbose --whitespace=nowarn --unsafe-paths >&$VERBOSE_OUT
else
@@ -187,7 +187,7 @@ if [ -d "$SOURCES/$1" -o -d "$PKG_DIR/sources" ]; then
if [ ! "$PKG_NAME" == "configtools" ] ; then
for config in `find $PKG_BUILD -name config.guess | sed 's/config.guess//'`; do
- printf "%${BUILD_INDENT}c ${boldyellow}FIXCONFIG${endcolor} $config\n" ' '
+ printf "%${BUILD_INDENT}c $(get_color CLR_FIXCONFIG)FIXCONFIG$(get_color CLR_ENDCOLOR) $config\n" ' '
[ -f "$config/config.guess" -a -f $TOOLCHAIN/configtools/config.guess ] && \
cp -f $TOOLCHAIN/configtools/config.guess $config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment