Switch to printf for output messages.

Using printf we can avoid haveing to use eval_gettext and the ugly escape sequances required to use it.

Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
This commit is contained in:
Andrew Fyfe 2007-05-28 20:21:58 +01:00
parent 7e98eac309
commit 124693af37

View file

@ -70,42 +70,47 @@ PACMAN_OPTS=
### SUBROUTINES ### ### SUBROUTINES ###
plain() { plain() {
local mesg=$1; shift
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e " \033[1;1m$1\033[1;0m" >&2 printf "\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else else
echo " $1" >&2 printf " ${mesg}\n" "$@" >&2
fi fi
} }
msg() { msg() {
local mesg=$1; shift
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2 printf "\033[1;32m==>\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else else
echo "==> $1" >&2 printf "==> ${mesg}\n" "$@" >&2
fi fi
} }
msg2() { msg2() {
local mesg=$1; shift
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e " \033[1;34m->\033[1;0m \033[1;1m$1\033[1;0m" >&2 printf "\033[1;34m ->\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else else
echo " -> $1" >&2 printf " -> ${mesg}\n" "$@" >&2
fi fi
} }
warning() { warning() {
local mesg=$1; shift
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e "\033[1;33m==> WARNING:\033[1;0m \033[1;1m$1\033[1;0m" >&2 printf "\033[1;33m==> WARNING:\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else else
echo "==> WARNING: $1" >&2 printf "==> WARNING: ${mesg}\n" "$@" >&2
fi fi
} }
error() { error() {
local mesg=$1; shift
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2 printf "\033[1;31m==> ERROR:\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else else
echo "==> ERROR: $1" >&2 printf "==> ERROR: ${mesg}\n" "$@" >&2
fi fi
} }
@ -131,7 +136,7 @@ check_option() {
# TODO This code should be removed in the next release of makepkg # TODO This code should be removed in the next release of makepkg
elif [ "$lc" = "no$needle" ]; then elif [ "$lc" = "no$needle" ]; then
warning "$(gettext "Options beginning with 'no' will be deprecated in the next version of makepkg!")" warning "$(gettext "Options beginning with 'no' will be deprecated in the next version of makepkg!")"
plain "$(eval_gettext "Please replace 'no' with '!': no\$needle -> !\$needle.")" plain "$(gettext "Please replace 'no' with '!': no%s -> !%s.")" "$needle" "$needle"
echo "n" echo "n"
return return
elif [ "$lc" = "keepdocs" -a "$needle" = "docs" ]; then elif [ "$lc" = "keepdocs" -a "$needle" = "docs" ]; then
@ -208,7 +213,7 @@ getdownloadclient() {
local program="$(echo $agent | awk '{print $1 }')" local program="$(echo $agent | awk '{print $1 }')"
if [ ! -x "$program" ]; then if [ ! -x "$program" ]; then
local baseprog=$(basename $program) local baseprog=$(basename $program)
error "$(eval_gettext "The download program \$baseprog is not installed.")" error "$(gettext "The download program %s is not installed.")" "$baseprog"
error "$(gettext "Aborting...")" error "$(gettext "Aborting...")"
exit 1 # $E_MISSING_PROGRAM # TODO: error code exit 1 # $E_MISSING_PROGRAM # TODO: error code
fi fi
@ -224,7 +229,7 @@ checkdeps() {
if [ $ret -eq 1 ]; then #unresolved deps if [ $ret -eq 1 ]; then #unresolved deps
echo "$pmout" echo "$pmout"
elif [ $ret -ne 0 ]; then elif [ $ret -ne 0 ]; then
error "$(eval_gettext "pacman returned a fatal error (\$ret): \$pmout")" error "$(gettext "pacman returned a fatal error (%i): %s")" "$ret" "$pmout"
exit 1 exit 1
fi fi
} }
@ -273,7 +278,7 @@ handledeps() {
for dep in $striplist; do for dep in $striplist; do
candidates=$(find $SRCROOT -type d -name "$dep") candidates=$(find $SRCROOT -type d -name "$dep")
if [ "$candidates" = "" ]; then if [ "$candidates" = "" ]; then
error "$(eval_gettext "Could not find \"\$dep\" under \$SRCROOT")" error "$(gettext "Could not find \"%s\" under %s")" "$dep" "$SRCROOT"
exit 1 exit 1
fi fi
success=0 success=0
@ -292,7 +297,7 @@ handledeps() {
fi fi
done done
if [ "$success" = "0" ]; then if [ "$success" = "0" ]; then
error "$(eval_gettext "Failed to build \"\$dep\"")" error "$(gettext "Failed to build \"%s\"")" "$dep"
exit 1 exit 1
fi fi
done done
@ -549,8 +554,8 @@ create_package() {
# TODO maybe remove this at some point # TODO maybe remove this at some point
# warn if license array is not present or empty # warn if license array is not present or empty
if [ "$license" = "" ]; then if [ "$license" = "" ]; then
warning "$(eval_gettext "Please add a license line to your \$BUILDSCRIPT!")" warning "$(gettext "Please add a license line to your %s!")" "$BUILDSCRIPT"
plain "$(gettext "example for GPL\'ed software: license=(\'GPL\').")" plain "$(gettext "example for GPL'ed software: license=('GPL').")"
fi fi
local comp_files local comp_files
@ -595,10 +600,9 @@ installpackage() {
} }
usage() { usage() {
echo "$(eval_gettext "makepkg version \$myver")" printf "$(gettext "makepkg version %s")\n" "$myver"
echo echo
makepkg=$0 printf "$(gettext "Usage: %s [options]")\n" "$0"
echo "$(eval_gettext "Usage: \$makepkg [options]")"
echo echo
echo "$(gettext "Options:")" echo "$(gettext "Options:")"
echo "$(gettext " -b, --builddeps Build missing dependencies from source")" echo "$(gettext " -b, --builddeps Build missing dependencies from source")"
@ -613,7 +617,7 @@ usage() {
echo "$(gettext " -L, --log Log package build process")" echo "$(gettext " -L, --log Log package build process")"
echo "$(gettext " -m, --nocolor Disable colorized output messages")" echo "$(gettext " -m, --nocolor Disable colorized output messages")"
echo "$(gettext " -o, --nobuild Download and extract files only")" echo "$(gettext " -o, --nobuild Download and extract files only")"
echo "$(eval_gettext " -p <buildscript> Use an alternate build script (instead of '\$BUILDSCRIPT')")" printf "$(gettext " -p <buildscript> Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT"
echo "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build")" echo "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build")"
# fix flyspray feature request #2978 # fix flyspray feature request #2978
echo "$(gettext " -R, --repackage Repackage contents of pkg/ without building")" echo "$(gettext " -R, --repackage Repackage contents of pkg/ without building")"
@ -625,7 +629,7 @@ usage() {
echo "$(gettext " --noconfirm Do not ask for confirmation when resolving dependencies")" echo "$(gettext " --noconfirm Do not ask for confirmation when resolving dependencies")"
echo "$(gettext " --noprogressbar Do not show a progress bar when downloading files")" echo "$(gettext " --noprogressbar Do not show a progress bar when downloading files")"
echo echo
echo "$(eval_gettext "If -p is not specified, makepkg will look for '\$BUILDSCRIPT'")" printf "$(gettext "If -p is not specified, makepkg will look for '%s'")\n" "$BUILDSCRIPT"
echo echo
} }
@ -735,14 +739,14 @@ fi
if [ "$CLEANCACHE" = "1" ]; then if [ "$CLEANCACHE" = "1" ]; then
#fix flyspray feature request #5223 #fix flyspray feature request #5223
if [ -n "$SRCDEST" -a "$SRCDEST" != "$startdir" ]; then if [ -n "$SRCDEST" -a "$SRCDEST" != "$startdir" ]; then
msg "$(eval_gettext "Cleaning up ALL files from \$SRCDEST.")" msg "$(gettext "Cleaning up ALL files from %s.")" "$SRCDEST"
echo -n "$(gettext " Are you sure you wish to do this? [Y/n] ")" echo -n "$(gettext " Are you sure you wish to do this? [Y/n] ")"
read answer read answer
answer=$(echo $answer | tr [:upper:] [:lower:]) answer=$(echo $answer | tr [:upper:] [:lower:])
if [ "$answer" = "yes" -o "$answer" = "y" ]; then if [ "$answer" = "yes" -o "$answer" = "y" ]; then
rm "$SRCDEST"/* rm "$SRCDEST"/*
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
error "$(eval_gettext "Problem removing files; you may not have correct permissions in \$SRCDEST")" error "$(gettext "Problem removing files; you may not have correct permissions in %s")" "$SRCDEST"
exit 1 exit 1
else else
# removal worked # removal worked
@ -801,7 +805,7 @@ unset replaces depends conflicts backup source install build makedepends
unset options noextract unset options noextract
if [ ! -f $BUILDSCRIPT ]; then if [ ! -f $BUILDSCRIPT ]; then
error "$(eval_gettext "\$BUILDSCRIPT does not exist.")" error "$(gettext "%s does not exist.")" "$BUILDSCRIPT"
exit 1 exit 1
#TODO this is an attempt at a generic way to unset all package specific #TODO this is an attempt at a generic way to unset all package specific
#variables in a PKGBUILD #variables in a PKGBUILD
@ -832,14 +836,14 @@ if [ $(echo "$pkgrel" | grep '-') ]; then
exit 1 exit 1
fi fi
if ! in_array $CARCH ${arch[@]}; then if ! in_array $CARCH ${arch[@]}; then
error "$(eval_gettext "\$pkgname is not available for the \'\$CARCH\' architecture.")" error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgname" "$CARCH"
plain "$(eval_gettext "Note that many packages may need a line added to their \$BUILDSCRIPT")" plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
plain "$(eval_gettext "such as arch=(\'\$CARCH\').")" plain "$(gettext "such as arch=('%s').")" "$CARCH"
exit 1 exit 1
fi fi
if [ "$install" -a ! -f "$install" ]; then if [ "$install" -a ! -f "$install" ]; then
error "$(eval_gettext "install scriptlet (\$install) does not exist.")" error "$(gettext "install scriptlet (%s) does not exist.")" "$install"
exit 1 exit 1
fi fi
@ -872,7 +876,7 @@ if [ "$INFAKEROOT" = "1" ]; then
fi fi
date=$(date) date=$(date)
msg "$(eval_gettext "Making package: \$pkgname \$pkgver-\$pkgrel (\$date)")" msg "$(gettext "Making package: %s")" "$pkgname $pkgver-$pkgrel ($date)"
# fix flyspray bug #5973 # fix flyspray bug #5973
if [ "$NODEPS" = "1" -o "$GENINTEG" = "1" -o "$NOBUILD" = "1" -o "$REPKG" = "1" ]; then if [ "$NODEPS" = "1" -o "$GENINTEG" = "1" -o "$NOBUILD" = "1" -o "$REPKG" = "1" ]; then
@ -920,11 +924,11 @@ msg "$(gettext "Retrieving Sources...")"
for netfile in ${source[@]}; do for netfile in ${source[@]}; do
file=$(strip_url "$netfile") file=$(strip_url "$netfile")
if [ -f "../$file" ]; then if [ -f "../$file" ]; then
msg2 "$(eval_gettext "Found \$file in build dir")" msg2 "$(gettext "Found %s in build dir")" "$file"
cp "../$file" . cp "../$file" .
continue continue
elif [ -f "$SRCDEST/$file" ]; then elif [ -f "$SRCDEST/$file" ]; then
msg2 "$(eval_gettext "Using cached copy of \$file")" msg2 "$(gettext "Using cached copy of %s")" "$file"
cp "$SRCDEST/$file" . cp "$SRCDEST/$file" .
continue continue
fi fi
@ -932,12 +936,12 @@ for netfile in ${source[@]}; do
# find the client we should use for this URL # find the client we should use for this URL
dlclient=$(getdownloadclient $netfile) || exit $? dlclient=$(getdownloadclient $netfile) || exit $?
msg2 "$(eval_gettext "Downloading \$file")" msg2 "$(gettext "Downloading %s")" "$file"
# fix flyspray bug #3289 # fix flyspray bug #3289
ret=0 ret=0
$dlclient "$netfile" || ret=$? $dlclient "$netfile" || ret=$?
if [ $ret -gt 0 ]; then if [ $ret -gt 0 ]; then
error "$(gettext "Failure while downloading $file")" error "$(gettext "Failure while downloading %s")" "$file"
msg "$(gettext "Aborting...")" msg "$(gettext "Aborting...")"
exit 1 exit 1
fi fi
@ -945,7 +949,7 @@ for netfile in ${source[@]}; do
if [ -n "$SRCDEST" ]; then if [ -n "$SRCDEST" ]; then
mkdir -p "$SRCDEST" && cp "$file" "$SRCDEST" || ret=$? mkdir -p "$SRCDEST" && cp "$file" "$SRCDEST" || ret=$?
if [ $ret -gt 0 ]; then if [ $ret -gt 0 ]; then
warning "$(eval_gettext "You do not have correct permissions to cache source in \$SRCDEST")" warning "$(gettext "You do not have correct permissions to cache source in %s")" "$SRCDEST"
cp "$file" .. cp "$file" ..
fi fi
else else
@ -971,10 +975,10 @@ else
sha256) integrity_name="sha256sum" ;; sha256) integrity_name="sha256sum" ;;
sha384) integrity_name="sha384sum" ;; sha384) integrity_name="sha384sum" ;;
sha512) integrity_name="sha512sum" ;; sha512) integrity_name="sha512sum" ;;
*) error "$(eval_gettext "Invalid integrity algorithm \'\$integ\' specified")"; exit 1;; *) error "$(gettext "Invalid integrity algorithm '%s' specified")" "$integ"; exit 1;;
esac esac
if [ ! $(type -p $integrity_name) ]; then if [ ! $(type -p $integrity_name) ]; then
error "$(eval_gettext "Cannot find the \$integrity_name program.")" error "$(gettext "Cannot find the %s program.")" "$integrity_name"
exit 1 exit 1
fi fi
@ -1007,7 +1011,7 @@ else
integrity_sums=($(eval echo \${${integrity_name}s[@]})) integrity_sums=($(eval echo \${${integrity_name}s[@]}))
if [ ${#integrity_sums[@]} -eq ${#source[@]} ]; then if [ ${#integrity_sums[@]} -eq ${#source[@]} ]; then
msg "$(eval_gettext "Validating source files with \${integrity_name}s")" msg "$(gettext "Validating source files with %s")" "${integrity_name}s"
errors=0 errors=0
idx=0 idx=0
for netfile in "${source[@]}"; do for netfile in "${source[@]}"; do
@ -1027,7 +1031,7 @@ else
exit 1 exit 1
fi fi
else else
warning "$(eval_gettext "Integrity checks (\$integ) are missing or incomplete.")" warning "$(gettext "Integrity checks (%s) are missing or incomplete.")" "$integ"
fi fi
fi fi
done done
@ -1075,7 +1079,7 @@ else
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# unzip will return a 1 as a warning, it is not an error # unzip will return a 1 as a warning, it is not an error
if [ "$unziphack" != "1" -o $? -ne 1 ]; then if [ "$unziphack" != "1" -o $? -ne 1 ]; then
error "$(eval_gettext "Failed to extract \$file")" error "$(gettext "Failed to extract %s")" "$file"
msg "$(gettext "Aborting...")" msg "$(gettext "Aborting...")"
exit 1 exit 1
fi fi
@ -1131,7 +1135,7 @@ fi
removedeps removedeps
date=$(date) date=$(date)
msg "$(eval_gettext "Finished making: \$pkgname (\$date)")" msg "$(gettext "Finished making: %s")" "$pkgname ($date)"
installpackage installpackage