changeset 1061:52b36e54f1b7

vanilla: add some colors in scripts
author David Demelier <markand@malikania.fr>
date Mon, 02 Sep 2019 21:20:00 +0200
parents 89ba3e75ca96
children 5aaa48712c23
files Scripts/bulk.sh Scripts/lint-deps.sh Scripts/lint-options.sh Scripts/lint-pkg.sh Scripts/lint-src.sh Scripts/scripts.subr
diffstat 6 files changed, 30 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Scripts/bulk.sh	Mon Sep 02 21:10:00 2019 +0200
+++ b/Scripts/bulk.sh	Mon Sep 02 21:20:00 2019 +0200
@@ -59,6 +59,7 @@
 		if vpk build > $TMPDIR/fail.$name 2>&1; then
 			echo "ok"
 			vpk add -qr /tmp/vpk/$name*pkg.txz
+			rm -f $TMPDIR/fail.$name
 		else
 			echo "failed"
 			return 1
--- a/Scripts/lint-deps.sh	Mon Sep 02 21:10:00 2019 +0200
+++ b/Scripts/lint-deps.sh	Mon Sep 02 21:20:00 2019 +0200
@@ -40,7 +40,7 @@
 		exit 1
 	fi
 
-	echo "=> checking dependencies for $PKGNAME"
+	printf "${BOLD}=> checking dependencies for $PKGNAME${RESET}\n"
 
 	for d in $PKGDEPENDS; do
 		local dep=${d%:*}
--- a/Scripts/lint-options.sh	Mon Sep 02 21:10:00 2019 +0200
+++ b/Scripts/lint-options.sh	Mon Sep 02 21:20:00 2019 +0200
@@ -27,7 +27,7 @@
 		exit 1
 	fi
 
-	echo "=> checking common options for $PKGNAME"
+	printf "${BOLD}=> checking common options for $PKGNAME${RESET}\n"
 
 	for o in $PKGOPTIONS; do
 		if ! grep -q "^- $o:" $TOP/Docs/options.md; then
--- a/Scripts/lint-pkg.sh	Mon Sep 02 21:10:00 2019 +0200
+++ b/Scripts/lint-pkg.sh	Mon Sep 02 21:20:00 2019 +0200
@@ -21,7 +21,7 @@
 
 check_fhs()
 {
-	echo "==> checking directory hierarchy"
+	printf "${BOLD}==> checking directory hierarchy${RESET}\n"
 
 	if tar tf $1 | grep -Ev '^(bin|etc|include|lib|libexec|local|share|tmp|var)' 1>&2; then
 		echo "warning: the above files are not part of Vanilla Linux FHS" 1>&2
@@ -30,7 +30,7 @@
 
 check_libtool()
 {
-	echo "==> checking presence of libtool files:"
+	printf "${BOLD}==> checking presence of libtool files:${RESET}\n"
 
 	if tar tf $1 | grep -E '\.la$' 1>&2; then
 		echo "warning: the following libtool files must be removed" 1>&2
@@ -39,7 +39,7 @@
 
 check_manpages()
 {
-	echo "==> checking manual pages in uncompressed form:"
+	printf "${BOLD}==> checking manual pages in uncompressed form:${RESET}\n"
 
 	if tar tf $1 | grep -E 'share/man/man./.*\.(gz|bz2)$'; then
 		echo "warning: the above files must not be compressed" 1>&2
@@ -57,7 +57,7 @@
 	# NOTREACHED
 fi
 
-echo "=> checking binary package content for $1"
+printf "${BOLD}=> checking binary package content for $1${RESET}\n"
 
 check_fhs $1
 check_libtool $1
--- a/Scripts/lint-src.sh	Mon Sep 02 21:10:00 2019 +0200
+++ b/Scripts/lint-src.sh	Mon Sep 02 21:20:00 2019 +0200
@@ -21,7 +21,7 @@
 
 check_structure()
 {
-	echo "==> checking structure"
+	printf "${BOLD}==> checking structure${RESET}\n"
 
 	local pkgname=$(basename ${1%#*})
 
@@ -49,6 +49,6 @@
 	# NOTREACHED
 fi
 
-echo "=> checking binary package content for $1"
+printf "${BOLD}=> checking binary package content for $1${RESET}\n"
 
 check_structure $1
--- a/Scripts/scripts.subr	Mon Sep 02 21:10:00 2019 +0200
+++ b/Scripts/scripts.subr	Mon Sep 02 21:20:00 2019 +0200
@@ -1,3 +1,4 @@
+#!/bin/busybox sh
 #
 # script.subr -- subroutines for Vanilla scripts
 #
@@ -16,12 +17,32 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #
 
+: ${COLORS:=auto}
+
 for applet in $(busybox --list); do
 	alias applet="busybox $applet"
 done
 
 TOP=$(realpath $(dirname $0)/../)
 
+case $COLORS in
+"auto")
+	if [ ! -t 1 ]; then
+		COLORS=""
+	else
+		COLORS="yes"
+	fi
+	;;
+"no")
+	COLORS=""
+	;;
+esac
+
+if [ -n "$COLORS" ]; then
+	RESET="\033[0m"
+	BOLD="\033[1m"
+fi
+
 vnl_warn()
 {
 	echo "abort: $1" 1>&2