abuild: support for -c and -m options to enable/disable colors

and make sure those options are passed over when building recursively

Based on patch from Andrew Manison. Thanks!
This commit is contained in:
Natanael Copa 2010-05-18 09:42:04 +00:00
parent 072e93458d
commit e9509e5ffe
1 changed files with 24 additions and 6 deletions

View File

@ -26,15 +26,27 @@ APK=${APK:-apk}
ABUILD_CONF=${ABUILD_CONF:-"$sysconfdir/abuild.conf"} ABUILD_CONF=${ABUILD_CONF:-"$sysconfdir/abuild.conf"}
[ -f "$ABUILD_CONF" ] && . "$ABUILD_CONF" [ -f "$ABUILD_CONF" ] && . "$ABUILD_CONF"
default_colors() {
#colors
if [ -n "$USE_COLORS" ]; then
NORMAL="\033[1;0m" NORMAL="\033[1;0m"
STRONG="\033[1;1m" STRONG="\033[1;1m"
RED="\033[1;31m" RED="\033[1;31m"
GREEN="\033[1;32m" GREEN="\033[1;32m"
YELLOW="\033[1;33m" YELLOW="\033[1;33m"
BLUE="\033[1;34m" BLUE="\033[1;34m"
}
monochrome() {
NORMAL=""
STRONG=""
RED=""
GREEN=""
YELLOW=""
BLUE=""
}
#colors
if [ -n "$USE_COLORS" ]; then
default_colors
fi fi
@ -663,7 +675,7 @@ rootpkg() {
fi fi
cd "$startdir" cd "$startdir"
[ -n "$FAKEROOT" ] && msg "Entering fakeroot..." [ -n "$FAKEROOT" ] && msg "Entering fakeroot..."
$FAKEROOT "$abuild_path" $do_build \ $FAKEROOT -- "$abuild_path" $color_opt $do_build \
prepare_subpackages \ prepare_subpackages \
prepare_package \ prepare_package \
create_apks create_apks
@ -873,7 +885,7 @@ builddeps() {
msg "Entering $dir" msg "Entering $dir"
cd "$dir" && $0 $forceroot $keep $quiet $install_deps \ cd "$dir" && $0 $forceroot $keep $quiet $install_deps \
$recursive $upgrade abuildindex || return 1 $recursive $upgrade $color_opt abuildindex || return 1
done done
$SUDO $APK add -u --repository "$abuildrepo" \ $SUDO $APK add -u --repository "$abuildrepo" \
--wait 30 \ --wait 30 \
@ -1016,12 +1028,14 @@ usage() {
echo " [-s SRCDEST] [cmd] ..." echo " [-s SRCDEST] [cmd] ..."
echo " $program [-c] -n PKGNAME[-PKGVER]" echo " $program [-c] -n PKGNAME[-PKGVER]"
echo "Options:" echo "Options:"
echo " -c Enable colored output"
echo " -d Disable dependency checking" echo " -d Disable dependency checking"
echo " -f Force specified cmd, even if they are already done" echo " -f Force specified cmd, even if they are already done"
echo " -F Force run as root" echo " -F Force run as root"
echo " -h Show this help" echo " -h Show this help"
echo " -i Install PKG after successul build" echo " -i Install PKG after successul build"
echo " -k Keep built packages, even if APKBUILD or sources are newer" echo " -k Keep built packages, even if APKBUILD or sources are newer"
echo " -m Disable colors (monochrome)"
echo " -p Set package destination directory" echo " -p Set package destination directory"
echo " -P Set PKGDEST to REPODEST/<repo>, where repo is the parents dir name" echo " -P Set PKGDEST to REPODEST/<repo>, where repo is the parents dir name"
echo " -q Quiet" echo " -q Quiet"
@ -1055,14 +1069,18 @@ usage() {
APKBUILD="${APKBUILD:-./APKBUILD}" APKBUILD="${APKBUILD:-./APKBUILD}"
unset force unset force
unset recursive unset recursive
while getopts "dfFhi:kinp:P:qrRs:u" opt; do while getopts "cdfFhi:kimnp:P:qrRs:u" opt; do
case $opt in case $opt in
'c') default_colors
color_opt="-c";;
'd') nodeps=1;; 'd') nodeps=1;;
'f') force="-f";; 'f') force="-f";;
'F') forceroot="-F";; 'F') forceroot="-F";;
'h') usage;; 'h') usage;;
'i') install_after="$install_after $OPTARG";; 'i') install_after="$install_after $OPTARG";;
'k') keep="-k";; 'k') keep="-k";;
'm') monochrome
color_opt="-m";;
'n') die "Use newapkbuild to create new aports";; 'n') die "Use newapkbuild to create new aports";;
'p') PKGDEST=$OPTARG;; 'p') PKGDEST=$OPTARG;;
'P') REPODEST=$OPTARG;; 'P') REPODEST=$OPTARG;;