makepkg: define escape sequences globally
In doing so, it is possible to get rid of all the tests for colored messages except for one global one. Signed-off-by: Cedric Staniewski <cedric@gmx.ca> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
1000c0bd2e
commit
013fc9a795
1 changed files with 13 additions and 27 deletions
|
@ -72,7 +72,6 @@ IGNOREARCH=0
|
||||||
HOLDVER=0
|
HOLDVER=0
|
||||||
PKGFUNC=0
|
PKGFUNC=0
|
||||||
SPLITPKG=0
|
SPLITPKG=0
|
||||||
COLORMSG=0
|
|
||||||
|
|
||||||
# Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
|
# Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
|
||||||
# when dealing with svn/cvs/etc PKGBUILDs.
|
# when dealing with svn/cvs/etc PKGBUILDs.
|
||||||
|
@ -84,47 +83,27 @@ PACMAN_OPTS=
|
||||||
|
|
||||||
plain() {
|
plain() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ $COLORMSG -eq 1 ]; then
|
printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
||||||
printf "\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
|
||||||
else
|
|
||||||
printf " ${mesg}\n" "$@" >&2
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg() {
|
msg() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ $COLORMSG -eq 1 ]; then
|
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
||||||
printf "\033[1;32m==>\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
|
||||||
else
|
|
||||||
printf "==> ${mesg}\n" "$@" >&2
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg2() {
|
msg2() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ $COLORMSG -eq 1 ]; then
|
printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
||||||
printf "\033[1;34m ->\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
|
||||||
else
|
|
||||||
printf " -> ${mesg}\n" "$@" >&2
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
warning() {
|
warning() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ $COLORMSG -eq 1 ]; then
|
printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
||||||
printf "\033[1;33m==> $(gettext "WARNING:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
|
||||||
else
|
|
||||||
printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ $COLORMSG -eq 1 ]; then
|
printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
||||||
printf "\033[1;31m==> $(gettext "ERROR:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
|
||||||
else
|
|
||||||
printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1580,9 +1559,16 @@ if [ -r ~/.makepkg.conf ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if messages are to be printed using color
|
# check if messages are to be printed using color
|
||||||
|
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
|
||||||
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
||||||
COLORMSG=1
|
ALL_OFF="\033[1;0m"
|
||||||
|
BOLD="\033[1;1m"
|
||||||
|
BLUE="${BOLD}\033[1;34m"
|
||||||
|
GREEN="${BOLD}\033[1;32m"
|
||||||
|
RED="${BOLD}\033[1;31m"
|
||||||
|
YELLOW="${BOLD}\033[1;33m"
|
||||||
fi
|
fi
|
||||||
|
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
|
||||||
|
|
||||||
# override settings with an environment variable for batch processing
|
# override settings with an environment variable for batch processing
|
||||||
PKGDEST=${_PKGDEST:-$PKGDEST}
|
PKGDEST=${_PKGDEST:-$PKGDEST}
|
||||||
|
|
Loading…
Add table
Reference in a new issue