Gettext support in makepkg

Add gettext support to makepkg. Still to do- figure out for sure what
textdomain the translations should go in (perhaps share with pacman?), and
ensure this doesn't break anything.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Giovanni Scafora 2007-03-31 20:07:37 -04:00 committed by Dan McGee
parent 583b4b10a3
commit f044e23a60
3 changed files with 145 additions and 126 deletions

View File

@ -203,6 +203,11 @@ AC_DEFINE_UNQUOTED([PM_EXT_PKG], "$pkgext", [The file extension used by pacman p
dnl Set database file extension dnl Set database file extension
AC_DEFINE_UNQUOTED([PM_EXT_DB], "$dbext", [The file extension used by pacman databases]) AC_DEFINE_UNQUOTED([PM_EXT_DB], "$dbext", [The file extension used by pacman databases])
dnl Set up localedir substitution, double eval to get full path
localedir="$(eval echo ${localedir})"
LOCALEDIR="$(eval echo ${localedir})"
AC_SUBST(LOCALEDIR)
dnl ========================================================================== dnl ==========================================================================
AC_OUTPUT([ AC_OUTPUT([

1
scripts/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
makepkg

View File

@ -25,6 +25,14 @@
# USA. # USA.
# #
# gettext initialization
source gettext.sh
TEXTDOMAIN=makepkg
export TEXTDOMAIN
TEXTDOMAINDIR='@LOCALEDIR@'
export TEXTDOMAINDIR
myver='3.0.0' myver='3.0.0'
startdir=$(pwd) startdir=$(pwd)
@ -123,12 +131,12 @@ check_option() {
# START DEPRECATED # START DEPRECATED
# 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 "Options beginning with 'no' will be depricated in the next version of makepkg!" warning "$(gettext "Options beginning with 'no' will be depricated in the next version of makepkg!")"
plain "Please replace 'no' with '!': no$needle -> !$needle." plain "$(eval_gettext "Please replace 'no' with '!': no\$needle -> !\$needle.")"
echo "n" echo "n"
return return
elif [ "$lc" = "keepdocs" -a "$needle" = "docs" ]; then elif [ "$lc" = "keepdocs" -a "$needle" = "docs" ]; then
warning "Option 'keepdocs' may not work as intended. Please replace with 'docs'." warning "$(gettext "Option 'keepdocs' may not work as intended. Please replace with 'docs'.")"
# END DEPRECATED # END DEPRECATED
fi fi
done done
@ -143,7 +151,7 @@ check_option() {
return return
fi fi
done done
echo "unknown" echo "$(gettext "unknown")"
return return
} }
@ -162,7 +170,7 @@ check_buildenv() {
return return
fi fi
done done
echo "unknown" echo "$(gettext "unknown")"
return return
} }
@ -185,7 +193,7 @@ checkdeps() {
#strip out the pacman prefix from "requires: xyz" #strip out the pacman prefix from "requires: xyz"
echo $pmout | sed 's|requires:||g' echo $pmout | sed 's|requires:||g'
elif [ $ret -ne 0 ]; then elif [ $ret -ne 0 ]; then
error "pacman returned a fatal error ($ret): $pmout" error "$(eval_gettext "pacman returned a fatal error (\$ret): \$pmout")"
exit 1 exit 1
fi fi
} }
@ -208,7 +216,7 @@ handledeps() {
if [ "$deplist" != "" -a $haveperm -eq 1 ]; then if [ "$deplist" != "" -a $haveperm -eq 1 ]; then
if [ "$DEP_BIN" = "1" -a "$SUDO" = "1" ]; then if [ "$DEP_BIN" = "1" -a "$SUDO" = "1" ]; then
# install missing deps from binary packages (using pacman -S and sudo) # install missing deps from binary packages (using pacman -S and sudo)
msg "Installing missing dependencies..." msg "$(gettext "Installing missing dependencies...")"
if [ "$INFAKEROOT" = "1" ]; then if [ "$INFAKEROOT" = "1" ]; then
# kinda hacky, but we need to make pacman think that we're NOT # kinda hacky, but we need to make pacman think that we're NOT
# in fakeroot so it will go ahead and install the dependencies. # in fakeroot so it will go ahead and install the dependencies.
@ -217,7 +225,7 @@ handledeps() {
fi fi
sudo pacman $PACMAN_OPTS -S $striplist sudo pacman $PACMAN_OPTS -S $striplist
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
error "Pacman failed to install missing dependencies." error "$(gettext "Pacman failed to install missing dependencies.")"
exit 1 exit 1
fi fi
if [ "$INFAKEROOT" = "1" ]; then if [ "$INFAKEROOT" = "1" ]; then
@ -226,25 +234,25 @@ handledeps() {
fi fi
elif [ "$DEP_BIN" = "1" ]; then elif [ "$DEP_BIN" = "1" ]; then
# install missing deps from binary packages (using pacman -S) # install missing deps from binary packages (using pacman -S)
msg "Installing missing dependencies..." msg "$(gettext "Installing missing dependencies...")"
pacman $PACMAN_OPTS -S $striplist pacman $PACMAN_OPTS -S $striplist
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
error "Pacman failed to install missing dependencies." error "$(gettext "Pacman failed to install missing dependencies.")"
exit 1 exit 1
fi fi
elif [ "$DEP_SRC" = "1" ]; then elif [ "$DEP_SRC" = "1" ]; then
# install missing deps by building them from source. # install missing deps by building them from source.
# we look for each package name in $SRCROOT and build it. # we look for each package name in $SRCROOT and build it.
if [ "$SRCROOT" = "" ]; then if [ "$SRCROOT" = "" ]; then
error "Source root cannot be found - please make sure it is specified in /etc/makepkg.conf" error "$(gettext "Source root cannot be found - please make sure it is specified in /etc/makepkg.conf")"
exit 1 exit 1
fi fi
# TODO: handle version comparators (eg, glibc>=2.2.5) # TODO: handle version comparators (eg, glibc>=2.2.5)
msg "Building missing dependencies..." msg "$(gettext "Building missing dependencies...")"
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 "Could not find \"$dep\" under $SRCROOT" error "$(eval_gettext "Could not find \"\$dep\" under \$SRCROOT")"
exit 1 exit 1
fi fi
success=0 success=0
@ -263,7 +271,7 @@ handledeps() {
fi fi
done done
if [ "$success" = "0" ]; then if [ "$success" = "0" ]; then
error "Failed to build \"$dep\"" error "$(eval_gettext "Failed to build \"\$dep\"")"
exit 1 exit 1
fi fi
done done
@ -272,8 +280,8 @@ handledeps() {
fi fi
elif [ "$deplist" != "" -a $haveperm -eq 0 ]; then elif [ "$deplist" != "" -a $haveperm -eq 0 ]; then
if [ "$DEP_SRC" = "1" -o "$DEP_BIN" = "1" ]; then if [ "$DEP_SRC" = "1" -o "$DEP_BIN" = "1" ]; then
warning "Cannot auto-install missing dependencies as a normal user without sudo!" warning "$(gettext "Cannot auto-install missing dependencies as a normal user without sudo!")"
plain "Run makepkg as root or with -S to resolve dependencies automatically." plain "$(gettext "Run makepkg as root or with -S to resolve dependencies automatically.")"
fi fi
missingdeps=1 missingdeps=1
fi fi
@ -300,7 +308,7 @@ resolvedeps() {
# check deps again to make sure they were resolved # check deps again to make sure they were resolved
newdeplist=$(checkdeps $*) newdeplist=$(checkdeps $*)
if [ -n "${newdeplist}" ]; then if [ -n "${newdeplist}" ]; then
error "Failed to install all missing dependencies." error "$(gettext "Failed to install all missing dependencies.")"
fi fi
else else
newdeplist="$deplist" newdeplist="$deplist"
@ -309,7 +317,7 @@ resolvedeps() {
# if new dep list is not empty, print the list # if new dep list is not empty, print the list
if [ -n "${newdeplist}" ]; then if [ -n "${newdeplist}" ]; then
msg "Missing Dependencies:" msg "$(gettext "Missing Dependencies:")"
for dep in ${newdeplist}; do for dep in ${newdeplist}; do
msg2 "${dep}" msg2 "${dep}"
done done
@ -332,7 +340,7 @@ removedeps() {
done done
if [ "$RMDEPS" = "1" -a "$SUDO" = "1" -a -n "$deplist" ]; then if [ "$RMDEPS" = "1" -a "$SUDO" = "1" -a -n "$deplist" ]; then
msg "Removing installed dependencies..." msg "$(gettext "Removing installed dependencies...")"
if [ "$INFAKEROOT" = "1" ]; then if [ "$INFAKEROOT" = "1" ]; then
export FAKEROOTKEY2=$FAKEROOTKEY export FAKEROOTKEY2=$FAKEROOTKEY
unset FAKEROOTKEY unset FAKEROOTKEY
@ -343,14 +351,14 @@ removedeps() {
unset FAKEROOTKEY2 unset FAKEROOTKEY2
fi fi
elif [ "$RMDEPS" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" -a -n "$deplist" ]; then elif [ "$RMDEPS" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" -a -n "$deplist" ]; then
msg "Removing installed dependencies..." msg "$(gettext "Removing installed dependencies...")"
pacman $PACMAN_OPTS -Rs $striplist pacman $PACMAN_OPTS -Rs $striplist
fi fi
} }
installpackage() { installpackage() {
if [ "$INSTALL" = "1" -a "$SUDO" = "1" ]; then if [ "$INSTALL" = "1" -a "$SUDO" = "1" ]; then
msg "Installing package with pacman -U..." msg "$(gettext "Installing package with pacman -U...")"
if [ "$INFAKEROOT" = "1" ]; then if [ "$INFAKEROOT" = "1" ]; then
FAKEROOTKEY2=$FAKEROOTKEY FAKEROOTKEY2=$FAKEROOTKEY
unset FAKEROOTKEY unset FAKEROOTKEY
@ -363,43 +371,44 @@ installpackage() {
fi fi
exit $exitcode exit $exitcode
elif [ "$INSTALL" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then elif [ "$INSTALL" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
msg "Installing package with pacman -U..." msg "$(gettext "Installing package with pacman -U...")"
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT} pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
exit $? exit $?
fi fi
} }
usage() { usage() {
echo "makepkg version $myver" echo "$(eval_gettext "makepkg version \$myver")"
echo echo
echo "Usage: $0 [options]" makepkg=$0
echo "$(eval_gettext "Usage: \$makepkg [options]")"
echo echo
echo "Options:" echo "$(gettext "Options:")"
echo " -b, --builddeps Build missing dependencies from source" echo "$(gettext " -b, --builddeps Build missing dependencies from source")"
echo " -c, --clean Clean up work files after build" echo "$(gettext " -c, --clean Clean up work files after build")"
echo " -C, --cleancache Clean up source files from the cache" echo "$(gettext " -C, --cleancache Clean up source files from the cache")"
echo " -d, --nodeps Skip all dependency checks" echo "$(gettext " -d, --nodeps Skip all dependency checks")"
echo " -e, --noextract Do not extract source files (use existing src/ dir)" echo "$(gettext " -e, --noextract Do not extract source files (use existing src/ dir)")"
echo " -f, --force Overwrite existing package" echo "$(gettext " -f, --force Overwrite existing package")"
echo " -g, --geninteg Generate integrity checks for source files" echo "$(gettext " -g, --geninteg Generate integrity checks for source files")"
echo " -h, --help This help" echo "$(gettext " -h, --help This help")"
echo " -i, --install Install package after successful build" echo "$(gettext " -i, --install Install package after successful build")"
echo " -L, --log Log package build process" echo "$(gettext " -L, --log Log package build process")"
echo " -m, --nocolor Disable colorized output messages" echo "$(gettext " -m, --nocolor Disable colorized output messages")"
echo " -o, --nobuild Download and extract files only" echo "$(gettext " -o, --nobuild Download and extract files only")"
echo " -p <buildscript> Use an alternate build script (instead of '$BUILDSCRIPT')" echo "$(eval_gettext " -p <buildscript> Use an alternate build script (instead of \'\$BUILDSCRIPT\')")"
echo " -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 " -R, --repackage Repackage contents of pkg/ without building" echo "$(gettext " -R, --repackage Repackage contents of pkg/ without building")"
echo " -s, --syncdeps Install missing dependencies with pacman" echo "$(gettext " -s, --syncdeps Install missing dependencies with pacman")"
echo " -S, --usesudo When calling pacman, use sudo" echo "$(gettext " -S, --usesudo When calling pacman, use sudo")"
echo echo
echo "These options can be passed to pacman:" echo "$(gettext "These options can be passed to pacman:")"
echo echo
echo " --noconfirm Do not ask for confirmation when resolving dependencies" echo "$(gettext " --noconfirm Do not ask for confirmation when resolving dependencies")"
echo " --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 "If -p is not specified, makepkg will look for '$BUILDSCRIPT'" echo "$(eval_gettext "If -p is not specified, makepkg will look for \'\$BUILDSCRIPT\'")"
echo echo
} }
@ -413,7 +422,7 @@ _SRCDEST=${SRCDEST}
if [ -f /etc/makepkg.conf ]; then if [ -f /etc/makepkg.conf ]; then
source /etc/makepkg.conf source /etc/makepkg.conf
else else
error "/etc/makepkg.conf not found. cannot continue" error "$(gettext "/etc/makepkg.conf not found. cannot continue")"
exit 1 exit 1
fi fi
@ -500,36 +509,36 @@ done
# check for sudo # check for sudo
if [ "$SUDO" = "1" -a ! "$(type -p sudo)" ]; then if [ "$SUDO" = "1" -a ! "$(type -p sudo)" ]; then
error "Cannot find the sudo binary! Is sudo installed?" error "$(gettext "Cannot find the sudo binary! Is sudo installed?")"
exit 1 exit 1
fi 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 "Cleaning up ALL files from $SRCDEST." msg "$(eval_gettext "Cleaning up ALL files from \$SRCDEST.")"
echo -n " 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 "Problem removing files; you may not have correct permissions in $SRCDEST" error "$(eval_gettext "Problem removing files; you may not have correct permissions in \$SRCDEST")"
exit 1 exit 1
else else
# removal worked # removal worked
msg "Source cache cleaned." msg "$(gettext "Source cache cleaned.")"
exit 0 exit 0
fi fi
else else
# answer = no # answer = no
msg "No files have been removed." msg "$(gettext "No files have been removed.")"
exit 0 exit 0
fi fi
else else
# $SRCDEST is $startdir, two possibilities # $SRCDEST is $startdir, two possibilities
error "Source destination must be defined in makepkg.conf." error "$(gettext "Source destination must be defined in makepkg.conf.")"
plain "In addition, please run makepkg -C outside of your cache directory." plain "$(gettext "In addition, please run makepkg -C outside of your cache directory.")"
exit 1 exit 1
fi fi
fi fi
@ -539,7 +548,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 "$BUILDSCRIPT does not exist." error "$(eval_gettext "\$BUILDSCRIPT does not exist.")"
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
@ -554,41 +563,41 @@ source $BUILDSCRIPT
# check for no-no's in the build script # check for no-no's in the build script
if [ -z "$pkgver" ]; then if [ -z "$pkgver" ]; then
error "pkgver is not allowed to be empty." error "$(gettext "pkgver is not allowed to be empty.")"
exit 1 exit 1
fi fi
if [ -z "$pkgrel" ]; then if [ -z "$pkgrel" ]; then
error "pkgrel is not allowed to be empty." error "$(gettext "pkgrel is not allowed to be empty.")"
exit 1 exit 1
fi fi
if [ $(echo "$pkgver" | grep '-') ]; then if [ $(echo "$pkgver" | grep '-') ]; then
error "pkgver is not allowed to contain hyphens." error "$(gettext "pkgver is not allowed to contain hyphens.")"
exit 1 exit 1
fi fi
if [ $(echo "$pkgrel" | grep '-') ]; then if [ $(echo "$pkgrel" | grep '-') ]; then
error "pkgrel is not allowed to contain hyphens." error "$(gettext "pkgrel is not allowed to contain hyphens.")"
exit 1 exit 1
fi fi
if ! in_array $CARCH ${arch[@]}; then if ! in_array $CARCH ${arch[@]}; then
error "$pkgname is not available for the '$CARCH' architecture." error "$(eval_gettext "\$pkgname is not available for the \'\$CARCH\' architecture.")"
plain "Note that many packages may need a line added to their $BUILDSCRIPT" plain "$(eval_gettext "Note that many packages may need a line added to their \$BUILDSCRIPT")"
plain "such as arch=('$CARCH')." plain "$(eval_gettext "such as arch=(\'\$CARCH\').")"
exit 1 exit 1
fi fi
if [ "$install" -a ! -f "$install" ]; then if [ "$install" -a ! -f "$install" ]; then
error "install scriptlet ($install) does not exist." error "$(eval_gettext "install scriptlet (\$install) does not exist.")"
exit 1 exit 1
fi fi
if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}" \ if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}" \
-a "$FORCE" = "0" -a "$GENINTEG" = "0" ]; then -a "$FORCE" = "0" -a "$GENINTEG" = "0" ]; then
if [ "$INSTALL" = "1" ]; then if [ "$INSTALL" = "1" ]; then
warning "a package has already been built, installing existing package." warning "$(gettext "a package has already been built, installing existing package.")"
installpackage installpackage
exit $? exit $?
else else
error "a package has already been built. (use -f to overwrite)" error "$(gettext "a package has already been built. (use -f to overwrite)")"
exit 1 exit 1
fi fi
fi fi
@ -599,31 +608,32 @@ fi
if [ "$EUID" != "0" ]; then if [ "$EUID" != "0" ]; then
if [ "$(check_buildenv fakeroot)" = "y" ]; then if [ "$(check_buildenv fakeroot)" = "y" ]; then
if [ $(type -p fakeroot) ]; then if [ $(type -p fakeroot) ]; then
msg "Entering fakeroot environment" msg "$(gettext "Entering fakeroot environment")"
fakeroot -- $0 -F $ARGLIST fakeroot -- $0 -F $ARGLIST
exit $? exit $?
else else
warning "Fakeroot is not installed. Building as an unprivileged user" warning "$(gettext "Fakeroot is not installed. Building as an unprivileged user")"
plain "will result in non-root ownership of the packaged files. Install" plain "$(gettext "will result in non-root ownership of the packaged files. Install")"
plain "the fakeroot package to correctly build as a non-root user." plain "$(gettext "the fakeroot package to correctly build as a non-root user.")"
plain "" plain ""
sleep 1 sleep 1
fi fi
else else
warning "Running makepkg as an unprivileged user will result in non-root" warning "$(gettext "Running makepkg as an unprivileged user will result in non-root")"
plain "ownership of the packaged files. Try using the fakeroot environment" plain "$(gettext "ownership of the packaged files. Try using the fakeroot environment")"
plain "by placing 'fakeroot' in the BUILDENV array in makepkg.conf." plain "$(gettext "by placing 'fakeroot' in the BUILDENV array in makepkg.conf.")"
plain "" plain ""
sleep 1 sleep 1
fi fi
fi fi
msg "Making package: $pkgname $pkgver-$pkgrel ($(date))" date=$(date)
msg "$(eval_gettext "Making package: \$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
if [ "$NODEPS" = "1" ]; then if [ "$NODEPS" = "1" ]; then
warning "skipping dependency checks" warning "$(gettext "skipping dependency checks")"
fi fi
# skip printing a warning message for the others: geninteg, nobuild, repkg # skip printing a warning message for the others: geninteg, nobuild, repkg
elif [ $(type -p pacman) ]; then elif [ $(type -p pacman) ]; then
@ -631,7 +641,7 @@ elif [ $(type -p pacman) ]; then
# these two variables are needed later by removedeps # these two variables are needed later by removedeps
unset runtimedeps buildtimedeps unset runtimedeps buildtimedeps
msg "Checking Runtime Dependencies..." msg "$(gettext "Checking Runtime Dependencies...")"
resolvedeps ${depends[@]} resolvedeps ${depends[@]}
ret=$? ret=$?
# deplist is a global variable set by resolvedeps # deplist is a global variable set by resolvedeps
@ -640,7 +650,7 @@ elif [ $(type -p pacman) ]; then
deperr=1 deperr=1
fi fi
msg "Checking Buildtime Dependencies..." msg "$(gettext "Checking Buildtime Dependencies...")"
resolvedeps ${makedepends[@]} resolvedeps ${makedepends[@]}
ret=$? ret=$?
# deplist is a global variable set by resolvedeps # deplist is a global variable set by resolvedeps
@ -650,60 +660,61 @@ elif [ $(type -p pacman) ]; then
fi fi
if [ $deperr -eq 1 ]; then if [ $deperr -eq 1 ]; then
error "could not resolve all dependencies." error "$(gettext "could not resolve all dependencies.")"
exit 1 exit 1
fi fi
else else
warning "pacman was not found in PATH. skipping dependency checks." warning "$(gettext "pacman was not found in PATH. skipping dependency checks.")"
fi fi
cd "$startdir" cd "$startdir"
# retrieve sources # retrieve sources
msg "Retrieving Sources..." msg "$(gettext "Retrieving Sources...")"
mkdir -p src mkdir -p src
cd "$startdir/src" cd "$startdir/src"
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 "Found $file in build dir" msg2 "$(eval_gettext "Found \$file in build dir")"
cp "../$file" . cp "../$file" .
elif [ -f "$SRCDEST/$file" ]; then elif [ -f "$SRCDEST/$file" ]; then
msg2 "Using cached copy of $file" msg2 "$(eval_gettext "Using cached copy of \$file")"
cp "$SRCDEST/$file" . cp "$SRCDEST/$file" .
else else
# check for a download utility # check for a download utility
if [ -z "$FTPAGENT" ]; then if [ -z "$FTPAGENT" ]; then
error "FTPAGENT is not configured. Check the /etc/makepkg.conf file." error "$(gettext "FTPAGENT is not configured. Check the /etc/makepkg.conf file.")"
msg "Aborting..." msg "$(gettext "Aborting...")"
exit 1 exit 1
fi fi
ftpclient=$(echo $FTPAGENT | awk {'print $1'}) ftpclient=$(echo $FTPAGENT | awk {'print $1'})
if [ ! -x "$ftpclient" ]; then if [ ! -x "$ftpclient" ]; then
error "ftpclient $(basename $ftpclient) is not installed." local clientname=$(basename $ftpclient)
msg "Aborting..." error "$(eval_gettext "ftpclient \$clientname is not installed.")"
msg "$(gettext "Aborting...")"
exit 1 exit 1
fi fi
proto=$(echo "$netfile" | sed 's|://.*||') proto=$(echo "$netfile" | sed 's|://.*||')
if [ "$proto" != "ftp" -a "$proto" != "http" -a "$proto" != "https" ]; then if [ "$proto" != "ftp" -a "$proto" != "http" -a "$proto" != "https" ]; then
error "$netfile was not found in the build directory and is not a proper URL." error "$(eval_gettext "\$netfile was not found in the build directory and is not a proper URL.")"
msg "Aborting..." msg "$(gettext "Aborting...")"
exit 1 exit 1
fi fi
msg2 "Downloading $file" msg2 "$(eval_gettext "Downloading \$file")"
$FTPAGENT "$netfile" $FTPAGENT "$netfile"
# fix flyspray bug #3289 # fix flyspray bug #3289
ftpret=$? ftpret=$?
if [ $ftpret -gt 0 ]; then if [ $ftpret -gt 0 ]; then
error "Failure while downloading $file" error "$(eval_gettext "Failure while downloading \$file")"
msg "Aborting..." msg "$(gettext "Aborting...")"
#rm "$file" #rm "$file"
exit 1 exit 1
fi fi
if [ -n "$SRCDEST" ]; then if [ -n "$SRCDEST" ]; then
mkdir -p $SRCDEST && cp "$file" $SRCDEST mkdir -p $SRCDEST && cp "$file" $SRCDEST
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
warning "You do not have correct permissions to cache source in $SRCDEST" warning "$(eval_gettext "You do not have correct permissions to cache source in \$SRCDEST")"
cp "$file" .. cp "$file" ..
fi fi
else else
@ -713,11 +724,11 @@ for netfile in ${source[@]}; do
done done
if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
warning "Skipping source integrity checks -- using existing src/ tree" warning "$(gettext "Skipping source integrity checks -- using existing src/ tree")"
else else
# TODO we end up checking $GENINTEG 3 times, could probably be refactored # TODO we end up checking $GENINTEG 3 times, could probably be refactored
if [ "$GENINTEG" = "1" ]; then if [ "$GENINTEG" = "1" ]; then
msg "Generating checksums for source files" msg "$(gettext "Generating checksums for source files")"
plain "" plain ""
fi fi
@ -729,10 +740,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 "Invalid integrity algorithm '$integ' specified"; exit 1;; *) error "$(eval_gettext "Invalid integrity algorithm \'\$integ\' specified")"; exit 1;;
esac esac
if [ ! $(type -p $integrity_name) ]; then if [ ! $(type -p $integrity_name) ]; then
error "Cannot find the $integrity_name program." error "$(eval_gettext "Cannot find the \$integrity_name program.")"
exit 1 exit 1
fi fi
@ -761,7 +772,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 "Validating source files with ${integrity_name}s" msg "$(eval_gettext "Validating source files with \${integrity_name}s")"
errors=0 errors=0
idx=0 idx=0
for netfile in "${source[@]}"; do for netfile in "${source[@]}"; do
@ -769,19 +780,19 @@ else
echo -n " $file ... " >&2 echo -n " $file ... " >&2
echo "${integrity_sums[$idx]} $file" | $integrity_name -c - >/dev/null 2>&1 echo "${integrity_sums[$idx]} $file" | $integrity_name -c - >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FAILED" >&2 echo "$(gettext "FAILED")" >&2
errors=1 errors=1
else else
echo "Passed" >&2 echo "$(gettext "Passed")" >&2
fi fi
idx=$(($idx+1)) idx=$(($idx+1))
done done
if [ $errors -gt 0 ]; then if [ $errors -gt 0 ]; then
error "One or more files did not pass the validity check!" error "$(gettext "One or more files did not pass the validity check!")"
exit 1 exit 1
fi fi
else else
warning "Integrity checks ($integ) are missing or incomplete." warning "$(eval_gettext "Integrity checks (\$integ) are missing or incomplete.")"
fi fi
fi fi
done done
@ -794,9 +805,9 @@ fi
#Extract sources #Extract sources
if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
warning "Skipping source extraction -- using existing src/ tree" warning "$(gettext "Skipping source extraction -- using existing src/ tree")"
else else
msg "Extracting Sources..." msg "$(gettext "Extracting Sources...")"
for netfile in "${source[@]}"; do for netfile in "${source[@]}"; do
unziphack=0 unziphack=0
file=$(strip_url "$netfile") file=$(strip_url "$netfile")
@ -829,8 +840,8 @@ 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 "Failed to extract $file" error "$(eval_gettext "Failed to extract \$file")"
msg "Aborting..." msg "$(gettext "Aborting...")"
exit 1 exit 1
fi fi
fi fi
@ -844,14 +855,14 @@ else
fi fi
if [ "$NOBUILD" = "1" ]; then if [ "$NOBUILD" = "1" ]; then
msg "Sources are ready." msg "$(gettext "Sources are ready.")"
exit 0 exit 0
elif [ "$REPKG" = "1" ]; then elif [ "$REPKG" = "1" ]; then
warning "Skipping build" warning "$(gettext "Skipping build")"
else else
# check for existing pkg directory # check for existing pkg directory
if [ -d "$startdir/pkg" ]; then if [ -d "$startdir/pkg" ]; then
msg "Removing existing pkg/ directory..." msg "$(gettext "Removing existing pkg/ directory...")"
rm -rf "$startdir/pkg" rm -rf "$startdir/pkg"
fi fi
mkdir -p "$startdir/pkg" mkdir -p "$startdir/pkg"
@ -875,7 +886,7 @@ else
fi fi
# build # build
msg "Starting build()..." msg "$(gettext "Starting build()...")"
# some applications (eg, blackbox) will not build with some languages # some applications (eg, blackbox) will not build with some languages
unset LC_ALL LANG unset LC_ALL LANG
@ -911,7 +922,7 @@ else
[ $set_e -eq 1 ] && set +e [ $set_e -eq 1 ] && set +e
fi fi
if [ $ret -gt 0 ]; then if [ $ret -gt 0 ]; then
error "Build Failed. Aborting..." error "$(gettext "Build Failed. Aborting...")"
removedeps removedeps
exit 2 exit 2
fi fi
@ -919,7 +930,7 @@ fi
if [ "$(check_option docs)" = "n" ]; then if [ "$(check_option docs)" = "n" ]; then
# remove info/doc files # remove info/doc files
msg "Removing info/doc files..." msg "$(gettext "Removing info/doc files...")"
cd "$startdir/pkg" cd "$startdir/pkg"
#fix flyspray bug #5021 #fix flyspray bug #5021
rm -rf ${DOC_DIRS[@]} rm -rf ${DOC_DIRS[@]}
@ -934,7 +945,7 @@ if [ -d $startdir/pkg/usr/share/man ]; then
fi fi
# compress man pages # compress man pages
msg "Compressing man pages..." msg "$(gettext "Compressing man pages...")"
find "$startdir"/pkg/{usr{,/local},opt/*}/man -type f 2>/dev/null | while read i ; do find "$startdir"/pkg/{usr{,/local},opt/*}/man -type f 2>/dev/null | while read i ; do
ext="${i##*.}" ext="${i##*.}"
fn="${i##*/}" fn="${i##*/}"
@ -953,11 +964,11 @@ cd "$startdir"
# strip binaries # strip binaries
if [ "$(check_option strip)" = "y" ]; then if [ "$(check_option strip)" = "y" ]; then
msg "Stripping debugging symbols from libraries..." msg "$(gettext "Stripping debugging symbols from libraries...")"
find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \ find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \ -exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \
| grep -v "No such file" | grep -v "format not recognized" | grep -v "No such file" | grep -v "format not recognized"
msg "Stripping symbols from binaries..." msg "$(gettext "Stripping symbols from binaries...")"
find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -not -name "*.dll" -not -name "*.exe" \ find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip '{}' \; 2>&1 \ -exec /usr/bin/strip '{}' \; 2>&1 \
| grep -v "No such file" | grep -v "format not recognized" | grep -v "No such file" | grep -v "format not recognized"
@ -965,13 +976,13 @@ fi
# remove libtool (.la) files # remove libtool (.la) files
if [ "$(check_option libtool)" = "n" ]; then if [ "$(check_option libtool)" = "n" ]; then
msg "Removing libtool .la files..." msg "$(gettext "Removing libtool .la files...")"
find pkg -type f -name "*.la" -exec rm -f -- '{}' \; find pkg -type f -name "*.la" -exec rm -f -- '{}' \;
fi fi
# remove empty directories # remove empty directories
if [ "$(check_option emptydirs)" = "n" ]; then if [ "$(check_option emptydirs)" = "n" ]; then
msg "Removing empty directories..." msg "$(gettext "Removing empty directories...")"
cd "$startdir/pkg" cd "$startdir/pkg"
find -depth -type d -empty -delete; find -depth -type d -empty -delete;
fi fi
@ -986,12 +997,12 @@ fi
size=$(du -cb "$startdir/pkg" | tail -n 1 | awk '{print $1}') size=$(du -cb "$startdir/pkg" | tail -n 1 | awk '{print $1}')
# build a filelist - do this first to keep meta files out of the list # build a filelist - do this first to keep meta files out of the list
msg "Generating .FILELIST file..." msg "$(gettext "Generating .FILELIST file...")"
cd "$startdir/pkg" cd "$startdir/pkg"
tar cvf /dev/null * | sort >.FILELIST tar cvf /dev/null * | sort >.FILELIST
# write the .PKGINFO file # write the .PKGINFO file
msg "Generating .PKGINFO file..." msg "$(gettext "Generating .PKGINFO file...")"
cd "$startdir/pkg" cd "$startdir/pkg"
echo "# Generated by makepkg $myver" >.PKGINFO echo "# Generated by makepkg $myver" >.PKGINFO
echo -n "# " >>.PKGINFO echo -n "# " >>.PKGINFO
@ -1032,26 +1043,26 @@ done
# 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 "Please add a license line to your $BUILDSCRIPT!" warning "$(eval_gettext "Please add a license line to your \$BUILDSCRIPT!")"
plain "example for GPL'ed software: license=('GPL')." plain "$(gettext "example for GPL\'ed software: license=(\'GPL\').")"
fi fi
# check for an install script # check for an install script
if [ "$install" != "" ]; then if [ "$install" != "" ]; then
msg "Copying install script..." msg "$(gettext "Copying install script...")"
cp "$startdir/$install" "$startdir/pkg/.INSTALL" cp "$startdir/$install" "$startdir/pkg/.INSTALL"
fi fi
# do we have a changelog? # do we have a changelog?
have_changelog=0 have_changelog=0
if [ -f "$startdir/ChangeLog" ]; then if [ -f "$startdir/ChangeLog" ]; then
msg "Copying package changelog" msg "$(gettext "Copying package changelog")"
cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG" cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG"
have_changelog=1 have_changelog=1
fi fi
# tar it up # tar it up
msg "Compressing package..." msg "$(gettext "Compressing package...")"
cd "$startdir/pkg" cd "$startdir/pkg"
pkg_file="$PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT}" pkg_file="$PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT}"
@ -1059,23 +1070,25 @@ comp_files=".PKGINFO .FILELIST ${install:+.INSTALL}"
[ $have_changelog -eq 1 ] && comp_files=".CHANGELOG $comp_files" [ $have_changelog -eq 1 ] && comp_files=".CHANGELOG $comp_files"
if ! tar czf $pkg_file $comp_files *; then if ! tar czf $pkg_file $comp_files *; then
error "Failed to create package file." error "$(gettext "Failed to create package file.")"
exit 1 exit 1
fi fi
cd "$startdir" cd "$startdir"
if [ "$CLEANUP" = "1" ]; then if [ "$CLEANUP" = "1" ]; then
msg "Cleaning up..." msg "$(gettext "Cleaning up...")"
rm -rf src pkg rm -rf src pkg
rm -rf ${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log* rm -rf ${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*
fi fi
removedeps removedeps
msg "Finished making: $pkgname ($(date))" date=$(date)
msg "$(eval_gettext "Finished making: \$pkgname (\$date)")"
installpackage installpackage
exit 0 exit 0
# vim: set ts=2 sw=2 noet: # vim: set ts=2 sw=2 noet: