summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Fyfe <andrew@neptune-one.net>2007-05-28 20:21:58 +0100
committerAndrew Fyfe <andrew@neptune-one.net>2007-05-28 20:27:18 +0100
commit124693af37f175703328be0b34a68ed3e50a6c64 (patch)
tree78a4768d9cf575842a240e14ed30c97e647f4f98
parent7e98eac309f323f2e9cb9b2cffc2f6d04b35fa54 (diff)
downloadpacman-124693af37f175703328be0b34a68ed3e50a6c64.tar.xz
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>
-rw-r--r--scripts/makepkg.in86
1 files changed, 45 insertions, 41 deletions
diff --git a/scripts/makepkg.in b/scripts/makepkg.in
index 5c0bc591..0d147041 100644
--- a/scripts/makepkg.in
+++ b/scripts/makepkg.in
@@ -70,42 +70,47 @@ PACMAN_OPTS=
### SUBROUTINES ###
plain() {
+ local mesg=$1; shift
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
- echo " $1" >&2
+ printf " ${mesg}\n" "$@" >&2
fi
}
msg() {
+ local mesg=$1; shift
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
- echo "==> $1" >&2
+ printf "==> ${mesg}\n" "$@" >&2
fi
}
msg2() {
+ local mesg=$1; shift
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
- echo " -> $1" >&2
+ printf " -> ${mesg}\n" "$@" >&2
fi
}
warning() {
+ local mesg=$1; shift
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
- echo "==> WARNING: $1" >&2
+ printf "==> WARNING: ${mesg}\n" "$@" >&2
fi
}
error() {
+ local mesg=$1; shift
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
- echo "==> ERROR: $1" >&2
+ printf "==> ERROR: ${mesg}\n" "$@" >&2
fi
}
@@ -131,7 +136,7 @@ check_option() {
# TODO This code should be removed in the next release of makepkg
elif [ "$lc" = "no$needle" ]; then
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"
return
elif [ "$lc" = "keepdocs" -a "$needle" = "docs" ]; then
@@ -208,7 +213,7 @@ getdownloadclient() {
local program="$(echo $agent | awk '{print $1 }')"
if [ ! -x "$program" ]; then
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...")"
exit 1 # $E_MISSING_PROGRAM # TODO: error code
fi
@@ -224,7 +229,7 @@ checkdeps() {
if [ $ret -eq 1 ]; then #unresolved deps
echo "$pmout"
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
fi
}
@@ -273,7 +278,7 @@ handledeps() {
for dep in $striplist; do
candidates=$(find $SRCROOT -type d -name "$dep")
if [ "$candidates" = "" ]; then
- error "$(eval_gettext "Could not find \"\$dep\" under \$SRCROOT")"
+ error "$(gettext "Could not find \"%s\" under %s")" "$dep" "$SRCROOT"
exit 1
fi
success=0
@@ -292,7 +297,7 @@ handledeps() {
fi
done
if [ "$success" = "0" ]; then
- error "$(eval_gettext "Failed to build \"\$dep\"")"
+ error "$(gettext "Failed to build \"%s\"")" "$dep"
exit 1
fi
done
@@ -549,8 +554,8 @@ create_package() {
# TODO maybe remove this at some point
# warn if license array is not present or empty
if [ "$license" = "" ]; then
- warning "$(eval_gettext "Please add a license line to your \$BUILDSCRIPT!")"
- plain "$(gettext "example for GPL\'ed software: license=(\'GPL\').")"
+ warning "$(gettext "Please add a license line to your %s!")" "$BUILDSCRIPT"
+ plain "$(gettext "example for GPL'ed software: license=('GPL').")"
fi
local comp_files
@@ -595,10 +600,9 @@ installpackage() {
}
usage() {
- echo "$(eval_gettext "makepkg version \$myver")"
+ printf "$(gettext "makepkg version %s")\n" "$myver"
echo
- makepkg=$0
- echo "$(eval_gettext "Usage: \$makepkg [options]")"
+ printf "$(gettext "Usage: %s [options]")\n" "$0"
echo
echo "$(gettext "Options:")"
echo "$(gettext " -b, --builddeps Build missing dependencies from source")"
@@ -613,7 +617,7 @@ usage() {
echo "$(gettext " -L, --log Log package build process")"
echo "$(gettext " -m, --nocolor Disable colorized output messages")"
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")"
# fix flyspray feature request #2978
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 " --noprogressbar Do not show a progress bar when downloading files")"
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
}
@@ -735,14 +739,14 @@ fi
if [ "$CLEANCACHE" = "1" ]; then
#fix flyspray feature request #5223
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] ")"
read answer
answer=$(echo $answer | tr [:upper:] [:lower:])
if [ "$answer" = "yes" -o "$answer" = "y" ]; then
rm "$SRCDEST"/*
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
else
# removal worked
@@ -801,7 +805,7 @@ unset replaces depends conflicts backup source install build makedepends
unset options noextract
if [ ! -f $BUILDSCRIPT ]; then
- error "$(eval_gettext "\$BUILDSCRIPT does not exist.")"
+ error "$(gettext "%s does not exist.")" "$BUILDSCRIPT"
exit 1
#TODO this is an attempt at a generic way to unset all package specific
#variables in a PKGBUILD
@@ -832,14 +836,14 @@ if [ $(echo "$pkgrel" | grep '-') ]; then
exit 1
fi
if ! in_array $CARCH ${arch[@]}; then
- error "$(eval_gettext "\$pkgname is not available for the \'\$CARCH\' architecture.")"
- plain "$(eval_gettext "Note that many packages may need a line added to their \$BUILDSCRIPT")"
- plain "$(eval_gettext "such as arch=(\'\$CARCH\').")"
+ error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgname" "$CARCH"
+ plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
+ plain "$(gettext "such as arch=('%s').")" "$CARCH"
exit 1
fi
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
fi
@@ -872,7 +876,7 @@ if [ "$INFAKEROOT" = "1" ]; then
fi
date=$(date)
-msg "$(eval_gettext "Making package: \$pkgname \$pkgver-\$pkgrel (\$date)")"
+msg "$(gettext "Making package: %s")" "$pkgname $pkgver-$pkgrel ($date)"
# fix flyspray bug #5973
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
file=$(strip_url "$netfile")
if [ -f "../$file" ]; then
- msg2 "$(eval_gettext "Found \$file in build dir")"
+ msg2 "$(gettext "Found %s in build dir")" "$file"
cp "../$file" .
continue
elif [ -f "$SRCDEST/$file" ]; then
- msg2 "$(eval_gettext "Using cached copy of \$file")"
+ msg2 "$(gettext "Using cached copy of %s")" "$file"
cp "$SRCDEST/$file" .
continue
fi
@@ -932,12 +936,12 @@ for netfile in ${source[@]}; do
# find the client we should use for this URL
dlclient=$(getdownloadclient $netfile) || exit $?
- msg2 "$(eval_gettext "Downloading \$file")"
+ msg2 "$(gettext "Downloading %s")" "$file"
# fix flyspray bug #3289
ret=0
$dlclient "$netfile" || ret=$?
if [ $ret -gt 0 ]; then
- error "$(gettext "Failure while downloading $file")"
+ error "$(gettext "Failure while downloading %s")" "$file"
msg "$(gettext "Aborting...")"
exit 1
fi
@@ -945,7 +949,7 @@ for netfile in ${source[@]}; do
if [ -n "$SRCDEST" ]; then
mkdir -p "$SRCDEST" && cp "$file" "$SRCDEST" || ret=$?
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" ..
fi
else
@@ -971,10 +975,10 @@ else
sha256) integrity_name="sha256sum" ;;
sha384) integrity_name="sha384sum" ;;
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
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
fi
@@ -1007,7 +1011,7 @@ else
integrity_sums=($(eval echo \${${integrity_name}s[@]}))
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
idx=0
for netfile in "${source[@]}"; do
@@ -1027,7 +1031,7 @@ else
exit 1
fi
else
- warning "$(eval_gettext "Integrity checks (\$integ) are missing or incomplete.")"
+ warning "$(gettext "Integrity checks (%s) are missing or incomplete.")" "$integ"
fi
fi
done
@@ -1075,7 +1079,7 @@ else
if [ $? -ne 0 ]; then
# unzip will return a 1 as a warning, it is not an error
if [ "$unziphack" != "1" -o $? -ne 1 ]; then
- error "$(eval_gettext "Failed to extract \$file")"
+ error "$(gettext "Failed to extract %s")" "$file"
msg "$(gettext "Aborting...")"
exit 1
fi
@@ -1131,7 +1135,7 @@ fi
removedeps
date=$(date)
-msg "$(eval_gettext "Finished making: \$pkgname (\$date)")"
+msg "$(gettext "Finished making: %s")" "$pkgname ($date)"
installpackage