use colors on messages

This commit is contained in:
Linux User 2008-11-08 11:05:45 +00:00
parent e4a3c05d83
commit d9f5462b34
2 changed files with 30 additions and 6 deletions

33
abuild
View File

@ -25,20 +25,41 @@ PKGDEST=${PKGDEST:-$startdir}
default_cmds="sanitycheck builddeps clean fetch md5check unpack rootpkg"
#colors
if [ -n "$USE_COLORS" ]; then
NORMAL="\033[1;0m"
STRONG="\033[1;1m"
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
fi
# functions
msg() {
local fake="${FAKEROOTKEY:+(fakeroot) }"
local name="${subpkgname:-$pkgname}"
[ -z "$quiet" ] && echo ">>> ${fake}${name}:" "$@" >&2
local prompt="$GREEN>>>${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
[ -z "$quiet" ] && printf "${prompt} ${fake}${name}: $@\n" >&2
}
warning() {
echo ">>> Warning:" "$@" >&2
local prompt="${YELLOW}>>> WARNING: ${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${fake}${name}: $@\n" >&2
}
error() {
local prompt="${RED}>>> ERROR: ${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${fake}${name}: $@\n" >&2
}
die() {
quiet=
msg "$@" >&2
error "$@"
exit 1
}

View File

@ -4,3 +4,6 @@ export CXXFLAGS="$CFLAGS"
export PATH=:/usr/i386-gentoo-linux-uclibc/binutils-bin/2.18:$PATH
export MAKEFLAGS=-j2
# remove line below to disable colors
USE_COLORS=1