2012-01-26 10:28:31 -05:00
|
|
|
#!/bin/bash
|
2006-12-21 14:11:22 -05:00
|
|
|
#
|
2009-08-18 16:10:56 -04:00
|
|
|
# makepkg - make packages compatible for use with pacman
|
2007-05-30 11:04:49 -04:00
|
|
|
# @configure_input@
|
2006-12-21 14:11:22 -05:00
|
|
|
#
|
2014-01-01 05:24:48 -05:00
|
|
|
# Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
|
2009-07-01 03:08:33 -04:00
|
|
|
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
|
2006-11-14 02:58:42 -05:00
|
|
|
# Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
|
2006-10-19 11:15:20 -04:00
|
|
|
# Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
|
2006-11-14 02:58:42 -05:00
|
|
|
# Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
|
|
|
|
# Copyright (c) 2006 by Alex Smith <alex@alex-smith.me.uk>
|
|
|
|
# Copyright (c) 2006 by Andras Voroskoi <voroskoi@frugalware.org>
|
2006-12-21 14:11:22 -05:00
|
|
|
#
|
2005-03-14 20:51:43 -05:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
2006-12-21 14:11:22 -05:00
|
|
|
#
|
2005-03-14 20:51:43 -05:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2006-12-21 14:11:22 -05:00
|
|
|
#
|
2005-03-14 20:51:43 -05:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-12-10 23:55:22 -05:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-03-14 20:51:43 -05:00
|
|
|
#
|
|
|
|
|
2007-07-15 22:31:29 -04:00
|
|
|
# makepkg uses quite a few external programs during its execution. You
|
|
|
|
# need to have at least the following installed for makepkg to function:
|
2010-12-07 02:48:16 -05:00
|
|
|
# awk, bsdtar (libarchive), bzip2, coreutils, fakeroot, file, find (findutils),
|
2011-03-25 22:06:06 -04:00
|
|
|
# gettext, gpg, grep, gzip, openssl, sed, tput (ncurses), xz
|
2007-07-15 22:31:29 -04:00
|
|
|
|
2007-03-31 20:07:37 -04:00
|
|
|
# gettext initialization
|
2011-06-23 22:21:51 -04:00
|
|
|
export TEXTDOMAIN='pacman-scripts'
|
2007-06-01 10:28:52 -04:00
|
|
|
export TEXTDOMAINDIR='@localedir@'
|
2007-03-31 20:07:37 -04:00
|
|
|
|
2008-05-27 15:23:56 -04:00
|
|
|
# file -i does not work on Mac OSX unless legacy mode is set
|
|
|
|
export COMMAND_MODE='legacy'
|
2012-02-14 11:11:43 -05:00
|
|
|
# Ensure CDPATH doesn't screw with our cd calls
|
|
|
|
unset CDPATH
|
2013-03-29 21:52:55 -04:00
|
|
|
# Ensure GREP_OPTIONS doesn't screw with our grep calls
|
|
|
|
unset GREP_OPTIONS
|
2008-05-27 15:23:56 -04:00
|
|
|
|
2012-07-15 01:46:29 -04:00
|
|
|
declare -r makepkg_version='@PACKAGE_VERSION@'
|
2011-12-06 16:29:33 -05:00
|
|
|
declare -r confdir='@sysconfdir@'
|
|
|
|
declare -r BUILDSCRIPT='@BUILDSCRIPT@'
|
|
|
|
declare -r startdir="$PWD"
|
2009-01-16 07:22:04 -05:00
|
|
|
|
2013-09-22 06:25:30 -04:00
|
|
|
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
|
|
|
|
2013-03-04 20:03:43 -05:00
|
|
|
packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman' \
|
|
|
|
'purge' 'upx' 'debug')
|
2010-12-25 00:43:06 -05:00
|
|
|
other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
|
2012-06-02 09:36:16 -04:00
|
|
|
splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'url' 'license' \
|
2011-07-22 06:08:39 -04:00
|
|
|
'groups' 'depends' 'optdepends' 'provides' 'conflicts' \
|
|
|
|
'replaces' 'backup' 'options' 'install' 'changelog')
|
2009-01-16 07:22:04 -05:00
|
|
|
readonly -a packaging_options other_options splitpkg_overrides
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2013-09-02 16:02:34 -04:00
|
|
|
known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512')
|
2013-09-02 15:53:33 -04:00
|
|
|
|
2006-01-21 21:16:41 -05:00
|
|
|
# Options
|
2012-07-09 01:55:58 -04:00
|
|
|
ASDEPS=0
|
2013-10-08 23:28:23 -04:00
|
|
|
BUILDFUNC=0
|
|
|
|
CHECKFUNC=0
|
|
|
|
CLEANBUILD=0
|
2006-01-21 21:16:41 -05:00
|
|
|
CLEANUP=0
|
|
|
|
DEP_BIN=0
|
|
|
|
FORCE=0
|
2006-11-14 02:58:42 -05:00
|
|
|
GENINTEG=0
|
2012-07-15 10:16:25 -04:00
|
|
|
HOLDVER=0
|
2013-10-08 23:28:23 -04:00
|
|
|
IGNOREARCH=0
|
|
|
|
INFAKEROOT=0
|
2006-01-21 21:16:41 -05:00
|
|
|
INSTALL=0
|
2013-10-08 23:28:23 -04:00
|
|
|
LOGGING=0
|
|
|
|
NEEDED=0
|
2014-03-03 14:29:54 -05:00
|
|
|
NOARCHIVE=0
|
2006-01-21 21:16:41 -05:00
|
|
|
NOBUILD=0
|
|
|
|
NODEPS=0
|
|
|
|
NOEXTRACT=0
|
2009-01-17 01:41:01 -05:00
|
|
|
PKGFUNC=0
|
2010-07-24 17:13:01 -04:00
|
|
|
PKGLIST=()
|
2013-10-08 23:28:23 -04:00
|
|
|
PKGVERFUNC=0
|
|
|
|
PREPAREFUNC=0
|
|
|
|
REPKG=0
|
|
|
|
RMDEPS=0
|
|
|
|
SKIPCHECKSUMS=0
|
|
|
|
SKIPPGPCHECK=0
|
2011-03-25 22:06:06 -04:00
|
|
|
SIGNPKG=''
|
2013-10-08 23:28:23 -04:00
|
|
|
SPLITPKG=0
|
|
|
|
SOURCEONLY=0
|
|
|
|
VERIFYSOURCE=0
|
2006-01-21 21:16:41 -05:00
|
|
|
|
2007-10-26 22:32:09 -04:00
|
|
|
# Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
|
|
|
|
# when dealing with svn/cvs/etc PKGBUILDs.
|
|
|
|
FORCE_VER=""
|
|
|
|
|
2006-02-16 17:57:25 -05:00
|
|
|
PACMAN_OPTS=
|
|
|
|
|
2011-09-03 22:24:27 -04:00
|
|
|
shopt -s extglob
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
### SUBROUTINES ###
|
|
|
|
|
|
|
|
plain() {
|
2007-05-28 15:21:58 -04:00
|
|
|
local mesg=$1; shift
|
2009-10-23 11:11:38 -04:00
|
|
|
printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2006-12-21 12:42:58 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
msg() {
|
2007-05-28 15:21:58 -04:00
|
|
|
local mesg=$1; shift
|
2009-10-23 11:11:38 -04:00
|
|
|
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2006-11-14 02:58:42 -05:00
|
|
|
|
|
|
|
msg2() {
|
2007-05-28 15:21:58 -04:00
|
|
|
local mesg=$1; shift
|
2009-10-23 11:11:38 -04:00
|
|
|
printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
2006-11-14 02:58:42 -05:00
|
|
|
}
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
warning() {
|
2007-05-28 15:21:58 -04:00
|
|
|
local mesg=$1; shift
|
2009-10-23 11:11:38 -04:00
|
|
|
printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2006-12-21 12:42:58 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
error() {
|
2007-05-28 15:21:58 -04:00
|
|
|
local mesg=$1; shift
|
2009-10-23 11:11:38 -04:00
|
|
|
printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-06-02 20:59:54 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# Special exit call for traps, Don't print any error messages when inside,
|
|
|
|
# the fakeroot call, the error message will be printed by the main call.
|
|
|
|
##
|
|
|
|
trap_exit() {
|
2012-03-02 19:25:15 -05:00
|
|
|
local signal=$1; shift
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ! INFAKEROOT )); then
|
2007-06-02 20:59:54 -04:00
|
|
|
echo
|
|
|
|
error "$@"
|
|
|
|
fi
|
2009-12-02 13:05:39 -05:00
|
|
|
[[ -n $srclinks ]] && rm -rf "$srclinks"
|
2012-03-02 19:25:15 -05:00
|
|
|
|
|
|
|
# unset the trap for this signal, and then call the default handler
|
|
|
|
trap -- "$signal"
|
|
|
|
kill "-$signal" "$$"
|
2007-06-02 20:59:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Clean up function. Called automatically when the script exits.
|
|
|
|
##
|
|
|
|
clean_up() {
|
|
|
|
local EXIT_CODE=$?
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( INFAKEROOT )); then
|
2007-06-02 20:59:54 -04:00
|
|
|
# Don't clean up when leaving fakeroot, we're not done yet.
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ! EXIT_CODE && CLEANUP )); then
|
2010-06-25 19:16:36 -04:00
|
|
|
local pkg file
|
|
|
|
|
2007-06-02 20:59:54 -04:00
|
|
|
# If it's a clean exit and -c/--clean has been passed...
|
|
|
|
msg "$(gettext "Cleaning up...")"
|
2013-02-01 21:13:41 -05:00
|
|
|
rm -rf "$pkgdirbase" "$srcdir"
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -n $pkgbase ]]; then
|
2011-07-22 07:42:53 -04:00
|
|
|
local fullver=$(get_full_version)
|
2007-06-02 20:59:54 -04:00
|
|
|
# Can't do this unless the BUILDSCRIPT has been sourced.
|
2009-10-27 07:56:13 -04:00
|
|
|
if (( BUILDFUNC )); then
|
2011-01-20 19:16:06 -05:00
|
|
|
rm -f "${pkgbase}-${fullver}-${CARCH}-build.log"*
|
2009-10-27 07:56:13 -04:00
|
|
|
fi
|
2010-12-15 09:06:43 -05:00
|
|
|
if (( CHECKFUNC )); then
|
2011-01-20 19:16:06 -05:00
|
|
|
rm -f "${pkgbase}-${fullver}-${CARCH}-check.log"*
|
2010-12-15 09:06:43 -05:00
|
|
|
fi
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( PKGFUNC )); then
|
2011-01-20 19:16:06 -05:00
|
|
|
rm -f "${pkgbase}-${fullver}-${CARCH}-package.log"*
|
2009-11-12 15:07:34 -05:00
|
|
|
elif (( SPLITPKG )); then
|
2009-03-25 11:29:15 -04:00
|
|
|
for pkg in ${pkgname[@]}; do
|
2011-01-20 19:16:06 -05:00
|
|
|
rm -f "${pkgbase}-${fullver}-${CARCH}-package_${pkg}.log"*
|
2009-03-25 11:29:15 -04:00
|
|
|
done
|
|
|
|
fi
|
2009-11-02 23:31:15 -05:00
|
|
|
|
|
|
|
# clean up dangling symlinks to packages
|
|
|
|
for pkg in ${pkgname[@]}; do
|
2012-03-09 06:09:35 -05:00
|
|
|
for file in ${pkg}-*-*-*{${PKGEXT},${SRCEXT}}; do
|
2009-11-02 23:31:15 -05:00
|
|
|
if [[ -h $file && ! -e $file ]]; then
|
2012-03-09 02:32:11 -05:00
|
|
|
rm -f "$file"
|
2009-11-02 23:31:15 -05:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2007-06-02 20:59:54 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
remove_deps
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-15 02:02:22 -04:00
|
|
|
enter_fakeroot() {
|
2011-06-17 22:40:14 -04:00
|
|
|
msg "$(gettext "Entering %s environment...")" "fakeroot"
|
2012-06-03 05:33:34 -04:00
|
|
|
fakeroot -- $0 -F "${ARGLIST[@]}" || exit $?
|
2011-06-15 02:02:22 -04:00
|
|
|
}
|
|
|
|
|
2011-06-16 05:57:31 -04:00
|
|
|
|
|
|
|
# a source entry can have two forms :
|
|
|
|
# 1) "filename::http://path/to/file"
|
|
|
|
# 2) "http://path/to/file"
|
|
|
|
|
2010-06-03 11:32:50 -04:00
|
|
|
# Return the absolute filename of a source entry
|
|
|
|
get_filepath() {
|
|
|
|
local file="$(get_filename "$1")"
|
2012-06-03 22:02:36 -04:00
|
|
|
local proto="$(get_protocol "$1")"
|
2010-06-03 11:32:50 -04:00
|
|
|
|
2012-06-03 22:02:36 -04:00
|
|
|
case $proto in
|
2012-09-14 22:24:01 -04:00
|
|
|
bzr*|git*|hg*|svn*)
|
2012-06-03 22:02:36 -04:00
|
|
|
if [[ -d "$startdir/$file" ]]; then
|
|
|
|
file="$startdir/$file"
|
|
|
|
elif [[ -d "$SRCDEST/$file" ]]; then
|
|
|
|
file="$SRCDEST/$file"
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [[ -f "$startdir/$file" ]]; then
|
|
|
|
file="$startdir/$file"
|
|
|
|
elif [[ -f "$SRCDEST/$file" ]]; then
|
|
|
|
file="$SRCDEST/$file"
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2010-06-03 11:32:50 -04:00
|
|
|
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "$file"
|
2010-06-03 11:32:50 -04:00
|
|
|
}
|
|
|
|
|
2008-08-23 10:34:42 -04:00
|
|
|
# extract the filename from a source entry
|
|
|
|
get_filename() {
|
2012-06-03 21:39:15 -04:00
|
|
|
local netfile=$1
|
|
|
|
|
2008-08-23 10:34:42 -04:00
|
|
|
# if a filename is specified, use it
|
2012-06-03 21:39:15 -04:00
|
|
|
if [[ $netfile = *::* ]]; then
|
|
|
|
printf "%s\n" ${netfile%%::*}
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
local proto=$(get_protocol "$netfile")
|
|
|
|
|
|
|
|
case $proto in
|
2012-09-14 22:24:01 -04:00
|
|
|
bzr*|git*|hg*|svn*)
|
2012-08-16 05:30:34 -04:00
|
|
|
filename=${netfile%%#*}
|
|
|
|
filename=${filename%/}
|
|
|
|
filename=${filename##*/}
|
2013-04-10 12:54:02 -04:00
|
|
|
if [[ $proto = bzr* ]]; then
|
|
|
|
filename=${filename#*lp:}
|
|
|
|
fi
|
2012-08-16 05:30:34 -04:00
|
|
|
if [[ $proto = git* ]]; then
|
|
|
|
filename=${filename%%.git*}
|
|
|
|
fi
|
2012-06-03 21:39:15 -04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# if it is just an URL, we only keep the last component
|
|
|
|
filename="${netfile##*/}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
printf "%s\n" "${filename}"
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2009-08-18 16:10:56 -04:00
|
|
|
# extract the URL from a source entry
|
2008-08-23 10:34:42 -04:00
|
|
|
get_url() {
|
|
|
|
# strip an eventual filename
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "${1#*::}"
|
2008-08-23 10:34:42 -04:00
|
|
|
}
|
2007-06-02 13:04:41 -04:00
|
|
|
|
2012-06-03 19:02:03 -04:00
|
|
|
# extract the protocol from a source entry - return "local" for local sources
|
|
|
|
get_protocol() {
|
|
|
|
if [[ $1 = *://* ]]; then
|
|
|
|
# strip leading filename
|
|
|
|
local proto="${1##*::}"
|
|
|
|
printf "%s\n" "${proto%%://*}"
|
2013-04-10 12:54:02 -04:00
|
|
|
elif [[ $1 = *lp:* ]]; then
|
|
|
|
local proto="${1##*::}"
|
|
|
|
printf "%s\n" "${proto%%lp:*}"
|
2012-06-03 19:02:03 -04:00
|
|
|
else
|
|
|
|
printf "%s\n" local
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-06-03 08:08:25 -04:00
|
|
|
get_downloadclient() {
|
2012-06-03 08:57:35 -04:00
|
|
|
local proto=$1
|
2012-06-03 08:08:25 -04:00
|
|
|
|
|
|
|
# loop through DOWNLOAD_AGENTS variable looking for protocol
|
|
|
|
local i
|
|
|
|
for i in "${DLAGENTS[@]}"; do
|
|
|
|
local handler="${i%%::*}"
|
|
|
|
if [[ $proto = "$handler" ]]; then
|
|
|
|
local agent="${i##*::}"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# if we didn't find an agent, return an error
|
|
|
|
if [[ -z $agent ]]; then
|
2012-08-27 21:35:20 -04:00
|
|
|
error "$(gettext "Unknown download protocol: %s")" "$proto"
|
2012-06-03 08:08:25 -04:00
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_CONFIG_ERROR
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ensure specified program is installed
|
|
|
|
local program="${agent%% *}"
|
|
|
|
if [[ ! -x $program ]]; then
|
|
|
|
local baseprog="${program##*/}"
|
|
|
|
error "$(gettext "The download program %s is not installed.")" "$baseprog"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_MISSING_PROGRAM
|
|
|
|
fi
|
|
|
|
|
|
|
|
printf "%s\n" "$agent"
|
|
|
|
}
|
|
|
|
|
2012-06-03 08:57:35 -04:00
|
|
|
download_local() {
|
|
|
|
local netfile=$1
|
|
|
|
local filepath=$(get_filepath "$netfile")
|
|
|
|
|
|
|
|
if [[ -n "$filepath" ]]; then
|
|
|
|
msg2 "$(gettext "Found %s")" "${filepath##*/}"
|
|
|
|
else
|
|
|
|
local filename=$(get_filename "$netfile")
|
|
|
|
error "$(gettext "%s was not found in the build directory and is not a URL.")" "$filename"
|
|
|
|
exit 1 # $E_MISSING_FILE
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-06-03 08:08:25 -04:00
|
|
|
download_file() {
|
2012-06-03 08:57:35 -04:00
|
|
|
local netfile=$1
|
|
|
|
|
|
|
|
local filepath=$(get_filepath "$netfile")
|
|
|
|
if [[ -n "$filepath" ]]; then
|
|
|
|
msg2 "$(gettext "Found %s")" "${filepath##*/}"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
local proto=$(get_protocol "$netfile")
|
|
|
|
|
|
|
|
# find the client we should use for this URL
|
|
|
|
local dlcmd
|
|
|
|
dlcmd=$(get_downloadclient "$proto") || exit $?
|
|
|
|
|
|
|
|
local filename=$(get_filename "$netfile")
|
|
|
|
local url=$(get_url "$netfile")
|
|
|
|
|
|
|
|
if [[ $proto = "scp" ]]; then
|
|
|
|
# scp downloads should not pass the protocol in the url
|
|
|
|
url="${url##*://}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
msg2 "$(gettext "Downloading %s...")" "$filename"
|
|
|
|
|
2012-06-03 08:08:25 -04:00
|
|
|
# temporary download file, default to last component of the URL
|
|
|
|
local dlfile="${url##*/}"
|
|
|
|
|
|
|
|
# replace %o by the temporary dlfile if it exists
|
|
|
|
if [[ $dlcmd = *%o* ]]; then
|
2012-06-03 08:57:35 -04:00
|
|
|
dlcmd=${dlcmd//\%o/\"$filename.part\"}
|
|
|
|
dlfile="$filename.part"
|
2012-06-03 08:08:25 -04:00
|
|
|
fi
|
|
|
|
# add the URL, either in place of %u or at the end
|
|
|
|
if [[ $dlcmd = *%u* ]]; then
|
|
|
|
dlcmd=${dlcmd//\%u/\"$url\"}
|
|
|
|
else
|
|
|
|
dlcmd="$dlcmd \"$url\""
|
|
|
|
fi
|
|
|
|
|
|
|
|
local ret=0
|
2013-09-17 23:01:23 -04:00
|
|
|
eval "$dlcmd >&2 || ret=\$?"
|
2012-06-03 08:08:25 -04:00
|
|
|
if (( ret )); then
|
|
|
|
[[ ! -s $dlfile ]] && rm -f -- "$dlfile"
|
2012-06-03 08:57:35 -04:00
|
|
|
error "$(gettext "Failure while downloading %s")" "$filename"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
2012-06-03 08:08:25 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# rename the temporary download file to the final destination
|
2012-06-03 08:57:35 -04:00
|
|
|
if [[ $dlfile != "$filename" ]]; then
|
|
|
|
mv -f "$SRCDEST/$dlfile" "$SRCDEST/$filename"
|
2012-06-03 08:08:25 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-03-09 15:36:55 -05:00
|
|
|
extract_file() {
|
|
|
|
local file=$1
|
2013-10-09 22:29:07 -04:00
|
|
|
|
|
|
|
local filepath=$(get_filepath "$file")
|
|
|
|
rm -f "$srcdir/${file}"
|
|
|
|
ln -s "$filepath" "$srcdir/"
|
|
|
|
|
2013-07-15 00:14:46 -04:00
|
|
|
# do not rely on extension for file type
|
2013-03-09 15:36:55 -05:00
|
|
|
local file_type=$(file -bizL "$file")
|
|
|
|
local ext=${file##*.}
|
|
|
|
local cmd=''
|
|
|
|
case "$file_type" in
|
|
|
|
*application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*)
|
|
|
|
cmd="bsdtar" ;;
|
|
|
|
*application/x-gzip*)
|
|
|
|
case "$ext" in
|
|
|
|
gz|z|Z) cmd="gzip" ;;
|
2013-10-09 22:29:07 -04:00
|
|
|
*) return;;
|
2013-03-09 15:36:55 -05:00
|
|
|
esac ;;
|
|
|
|
*application/x-bzip*)
|
|
|
|
case "$ext" in
|
|
|
|
bz2|bz) cmd="bzip2" ;;
|
2013-10-09 22:29:07 -04:00
|
|
|
*) return;;
|
2013-03-09 15:36:55 -05:00
|
|
|
esac ;;
|
|
|
|
*application/x-xz*)
|
|
|
|
case "$ext" in
|
|
|
|
xz) cmd="xz" ;;
|
2013-10-09 22:29:07 -04:00
|
|
|
*) return;;
|
2013-03-09 15:36:55 -05:00
|
|
|
esac ;;
|
|
|
|
*)
|
|
|
|
# See if bsdtar can recognize the file
|
|
|
|
if bsdtar -tf "$file" -q '*' &>/dev/null; then
|
|
|
|
cmd="bsdtar"
|
|
|
|
else
|
2013-11-01 07:48:17 -04:00
|
|
|
return 0
|
2013-03-09 15:36:55 -05:00
|
|
|
fi ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
local ret=0
|
|
|
|
msg2 "$(gettext "Extracting %s with %s")" "$file" "$cmd"
|
|
|
|
if [[ $cmd = "bsdtar" ]]; then
|
|
|
|
$cmd -xf "$file" || ret=$?
|
|
|
|
else
|
|
|
|
rm -f -- "${file%.*}"
|
|
|
|
$cmd -dcf "$file" > "${file%.*}" || ret=$?
|
|
|
|
fi
|
|
|
|
if (( ret )); then
|
|
|
|
error "$(gettext "Failed to extract %s")" "$file"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( EUID == 0 )); then
|
|
|
|
# change perms of all source files to root user & root group
|
|
|
|
chown -R 0:0 "$srcdir"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-09-14 22:24:01 -04:00
|
|
|
download_bzr() {
|
|
|
|
local netfile=$1
|
|
|
|
|
|
|
|
local url=$(get_url "$netfile")
|
|
|
|
url=${url##*bzr+}
|
|
|
|
url=${url%%#*}
|
|
|
|
|
2013-03-09 11:50:58 -05:00
|
|
|
local repo=$(get_filename "$netfile")
|
2012-09-14 22:24:01 -04:00
|
|
|
local displaylocation="$url"
|
|
|
|
|
|
|
|
local dir=$(get_filepath "$netfile")
|
|
|
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
|
|
|
|
|
|
|
if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
|
|
|
|
msg2 "$(gettext "Branching %s ...")" "${displaylocation}"
|
2013-05-15 09:58:42 -04:00
|
|
|
if ! bzr branch "$url" "$dir" --no-tree --use-existing-dir; then
|
2012-09-14 22:24:01 -04:00
|
|
|
error "$(gettext "Failure while branching %s")" "${displaylocation}"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
elif (( ! HOLDVER )); then
|
|
|
|
# Make sure we are fetching the right repo
|
2013-04-10 12:54:02 -04:00
|
|
|
local distant_url="$(bzr info $url 2> /dev/null | sed -n '/branch root/{s/ branch root: //p;q;}')"
|
|
|
|
local local_url="$(bzr config parent_location -d $dir)"
|
|
|
|
if [[ -n $distant_url ]]; then
|
|
|
|
if [[ $distant_url != "$local_url" ]]; then
|
|
|
|
error "$(gettext "%s is not a branch of %s")" "$dir" "$url"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [[ $url != "$local_url" ]] ; then
|
|
|
|
error "$(gettext "%s is not a branch of %s")" "$dir" "$url"
|
|
|
|
error "$(gettext "The local URL is %s")" "$local_url"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-09-14 22:24:01 -04:00
|
|
|
fi
|
|
|
|
msg2 "$(gettext "Pulling %s ...")" "${displaylocation}"
|
|
|
|
cd_safe "$dir"
|
2013-05-15 09:58:42 -04:00
|
|
|
if ! bzr pull "$url" --overwrite; then
|
2012-09-14 22:24:01 -04:00
|
|
|
# only warn on failure to allow offline builds
|
|
|
|
warning "$(gettext "Failure while pulling %s")" "${displaylocation}"
|
|
|
|
fi
|
|
|
|
fi
|
2013-03-09 15:36:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_bzr() {
|
|
|
|
local netfile=$1
|
|
|
|
|
2013-05-15 09:58:42 -04:00
|
|
|
local repo=$(get_filename "$netfile")
|
2013-03-09 15:36:55 -05:00
|
|
|
local fragment=${netfile#*#}
|
|
|
|
if [[ $fragment = "$netfile" ]]; then
|
|
|
|
unset fragment
|
|
|
|
fi
|
|
|
|
|
2013-05-15 09:58:42 -04:00
|
|
|
if [[ -n $fragment ]]; then
|
|
|
|
case ${fragment%%=*} in
|
|
|
|
revision)
|
|
|
|
revision=("-r" "${fragment#*=}")
|
|
|
|
displaylocation="$url -r ${fragment#*=}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2013-03-09 15:36:55 -05:00
|
|
|
local dir=$(get_filepath "$netfile")
|
|
|
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
2012-09-14 22:24:01 -04:00
|
|
|
|
2013-03-09 11:50:58 -05:00
|
|
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "bzr"
|
2012-09-14 22:24:01 -04:00
|
|
|
pushd "$srcdir" &>/dev/null
|
|
|
|
rm -rf "${dir##*/}"
|
|
|
|
|
2013-05-15 09:58:42 -04:00
|
|
|
if ! { bzr checkout "$dir" "${revision[@]}" --lightweight &&
|
|
|
|
( cd "$repo" && bzr pull "$dir" -q --overwrite "${revision[@]}" ); }; then
|
2013-03-09 11:50:58 -05:00
|
|
|
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "bzr"
|
2012-09-14 22:24:01 -04:00
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd &>/dev/null
|
|
|
|
}
|
|
|
|
|
2012-06-03 20:37:35 -04:00
|
|
|
download_git() {
|
|
|
|
local netfile=$1
|
|
|
|
|
2012-06-03 22:02:36 -04:00
|
|
|
local dir=$(get_filepath "$netfile")
|
|
|
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
2012-06-03 21:39:15 -04:00
|
|
|
|
2013-03-09 11:50:58 -05:00
|
|
|
local repo=$(get_filename "$netfile")
|
2012-06-03 20:37:35 -04:00
|
|
|
|
|
|
|
local url=$(get_url "$netfile")
|
|
|
|
url=${url##*git+}
|
|
|
|
url=${url%%#*}
|
|
|
|
|
2012-08-11 20:24:43 -04:00
|
|
|
if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
|
2012-06-03 20:37:35 -04:00
|
|
|
msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
|
|
|
|
if ! git clone --mirror "$url" "$dir"; then
|
|
|
|
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-07-15 10:16:25 -04:00
|
|
|
elif (( ! HOLDVER )); then
|
2012-06-03 20:37:35 -04:00
|
|
|
cd_safe "$dir"
|
2012-08-11 20:24:57 -04:00
|
|
|
# Make sure we are fetching the right repo
|
2013-07-21 21:09:58 -04:00
|
|
|
if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then
|
2012-08-11 20:24:57 -04:00
|
|
|
error "$(gettext "%s is not a clone of %s")" "$dir" "$url"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
|
2012-06-03 20:37:35 -04:00
|
|
|
if ! git fetch --all -p; then
|
|
|
|
# only warn on failure to allow offline builds
|
|
|
|
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
|
|
|
|
fi
|
|
|
|
fi
|
2013-03-09 15:36:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_git() {
|
|
|
|
local netfile=$1
|
|
|
|
|
|
|
|
local fragment=${netfile#*#}
|
|
|
|
if [[ $fragment = "$netfile" ]]; then
|
|
|
|
unset fragment
|
|
|
|
fi
|
|
|
|
|
|
|
|
local repo=${netfile##*/}
|
|
|
|
repo=${repo%%#*}
|
|
|
|
repo=${repo%%.git*}
|
|
|
|
|
|
|
|
local dir=$(get_filepath "$netfile")
|
|
|
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
2012-06-03 20:37:35 -04:00
|
|
|
|
|
|
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git"
|
|
|
|
pushd "$srcdir" &>/dev/null
|
|
|
|
rm -rf "${dir##*/}"
|
|
|
|
|
2013-03-12 00:05:18 -04:00
|
|
|
if ! git clone "$dir"; then
|
2012-06-03 20:37:35 -04:00
|
|
|
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd_safe "${dir##*/}"
|
|
|
|
|
|
|
|
local ref
|
|
|
|
if [[ -n $fragment ]]; then
|
|
|
|
case ${fragment%%=*} in
|
|
|
|
commit|tag)
|
|
|
|
ref=${fragment##*=}
|
|
|
|
;;
|
|
|
|
branch)
|
|
|
|
ref=origin/${fragment##*=}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $ref ]]; then
|
|
|
|
if ! git checkout -b makepkg $ref; then
|
|
|
|
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd &>/dev/null
|
|
|
|
}
|
|
|
|
|
2012-07-23 06:01:35 -04:00
|
|
|
download_hg() {
|
|
|
|
local netfile=$1
|
|
|
|
|
|
|
|
local dir=$(get_filepath "$netfile")
|
|
|
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
|
|
|
|
2013-03-09 11:50:58 -05:00
|
|
|
local repo=$(get_filename "$netfile")
|
2012-07-23 06:01:35 -04:00
|
|
|
|
|
|
|
local url=$(get_url "$netfile")
|
|
|
|
url=${url##*hg+}
|
|
|
|
url=${url%%#*}
|
|
|
|
|
2012-08-22 09:35:17 -04:00
|
|
|
if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
|
2012-07-23 06:01:35 -04:00
|
|
|
msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg"
|
2012-08-22 09:30:34 -04:00
|
|
|
if ! hg clone -U "$url" "$dir"; then
|
2012-07-23 06:01:35 -04:00
|
|
|
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
elif (( ! HOLDVER )); then
|
|
|
|
msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "hg"
|
|
|
|
cd_safe "$dir"
|
2012-08-22 09:30:34 -04:00
|
|
|
if ! hg pull; then
|
2012-07-23 06:01:35 -04:00
|
|
|
# only warn on failure to allow offline builds
|
|
|
|
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg"
|
|
|
|
fi
|
|
|
|
fi
|
2013-03-09 15:36:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_hg() {
|
|
|
|
local netfile=$1
|
|
|
|
|
|
|
|
local fragment=${netfile#*#}
|
|
|
|
if [[ $fragment = "$netfile" ]]; then
|
|
|
|
unset fragment
|
|
|
|
fi
|
|
|
|
|
|
|
|
local dir=$(get_filepath "$netfile")
|
|
|
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
|
|
|
|
|
|
|
local repo=${netfile##*/}
|
|
|
|
repo=${repo%%#*}
|
2012-07-23 06:01:35 -04:00
|
|
|
|
|
|
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg"
|
|
|
|
pushd "$srcdir" &>/dev/null
|
|
|
|
rm -rf "${dir##*/}"
|
|
|
|
|
|
|
|
local ref
|
|
|
|
if [[ -n $fragment ]]; then
|
|
|
|
case ${fragment%%=*} in
|
|
|
|
branch|revision|tag)
|
|
|
|
ref=('-u' "${fragment##*=}")
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! hg clone "${ref[@]}" "$dir" "${dir##*/}"; then
|
|
|
|
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "hg"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd &>/dev/null
|
|
|
|
}
|
|
|
|
|
2012-06-07 04:12:31 -04:00
|
|
|
download_svn() {
|
|
|
|
local netfile=$1
|
|
|
|
|
2012-08-27 21:42:06 -04:00
|
|
|
local fragment=${netfile#*#}
|
2012-06-07 04:12:31 -04:00
|
|
|
if [[ $fragment = "$netfile" ]]; then
|
|
|
|
unset fragment
|
|
|
|
fi
|
|
|
|
|
|
|
|
local dir=$(get_filepath "$netfile")
|
|
|
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
|
|
|
|
2013-03-09 11:50:58 -05:00
|
|
|
local repo=$(get_filename "$netfile")
|
2012-06-07 04:12:31 -04:00
|
|
|
|
|
|
|
local url=$(get_url "$netfile")
|
|
|
|
if [[ $url != svn+ssh* ]]; then
|
|
|
|
url=${url##*svn+}
|
|
|
|
fi
|
|
|
|
url=${url%%#*}
|
|
|
|
|
2012-08-22 09:35:17 -04:00
|
|
|
if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
|
2012-06-07 04:12:31 -04:00
|
|
|
msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "svn"
|
2013-04-10 21:56:06 -04:00
|
|
|
mkdir -p "$dir/.makepkg"
|
|
|
|
if ! svn checkout --config-dir "$dir/.makepkg" "$url" "$dir"; then
|
2012-06-07 04:12:31 -04:00
|
|
|
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "svn"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-07-15 10:16:25 -04:00
|
|
|
elif (( ! HOLDVER )); then
|
2012-06-07 04:12:31 -04:00
|
|
|
msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "svn"
|
|
|
|
cd_safe "$dir"
|
|
|
|
if ! svn update; then
|
|
|
|
# only warn on failure to allow offline builds
|
|
|
|
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn"
|
|
|
|
fi
|
|
|
|
fi
|
2013-03-09 15:36:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_svn() {
|
|
|
|
local netfile=$1
|
|
|
|
|
|
|
|
local fragment=${netfile#*#}
|
|
|
|
if [[ $fragment = "$netfile" ]]; then
|
|
|
|
unset fragment
|
|
|
|
fi
|
|
|
|
|
|
|
|
local dir=$(get_filepath "$netfile")
|
|
|
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
|
|
|
|
|
|
|
local repo=${netfile##*/}
|
|
|
|
repo=${repo%%#*}
|
2012-06-07 04:12:31 -04:00
|
|
|
|
|
|
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn"
|
|
|
|
pushd "$srcdir" &>/dev/null
|
|
|
|
rm -rf "${dir##*/}"
|
|
|
|
|
|
|
|
local ref
|
|
|
|
if [[ -n $fragment ]]; then
|
|
|
|
case ${fragment%%=*} in
|
|
|
|
revision)
|
2013-04-11 01:46:51 -04:00
|
|
|
ref="${fragment##*=}"
|
2012-06-07 04:12:31 -04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2013-04-11 01:46:51 -04:00
|
|
|
cp -a "$dir" .
|
|
|
|
|
|
|
|
if [[ -n ${ref} ]]; then
|
|
|
|
cd_safe "$(get_filename "$netfile")"
|
|
|
|
if ! svn update -r ${ref}; then
|
|
|
|
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "svn"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
fi
|
2012-06-07 04:12:31 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
popd &>/dev/null
|
|
|
|
}
|
|
|
|
|
2012-06-03 08:08:25 -04:00
|
|
|
download_sources() {
|
2012-11-19 19:13:10 -05:00
|
|
|
msg "$(gettext "Retrieving sources...")"
|
2012-06-03 08:08:25 -04:00
|
|
|
|
2012-07-15 09:57:25 -04:00
|
|
|
local GET_VCS=1
|
|
|
|
if [[ $1 == "fast" ]]; then
|
|
|
|
GET_VCS=0
|
|
|
|
fi
|
|
|
|
|
2012-06-03 08:08:25 -04:00
|
|
|
local netfile
|
|
|
|
for netfile in "${source[@]}"; do
|
2013-03-27 06:11:21 -04:00
|
|
|
pushd "$SRCDEST" &>/dev/null
|
2012-06-03 08:57:35 -04:00
|
|
|
|
2013-03-27 06:11:21 -04:00
|
|
|
local proto=$(get_protocol "$netfile")
|
2012-06-03 08:57:35 -04:00
|
|
|
case "$proto" in
|
|
|
|
local)
|
|
|
|
download_local "$netfile"
|
|
|
|
;;
|
2012-09-14 22:24:01 -04:00
|
|
|
bzr*)
|
|
|
|
(( GET_VCS )) && download_bzr "$netfile"
|
|
|
|
;;
|
2012-06-03 20:37:35 -04:00
|
|
|
git*)
|
2012-07-15 09:57:25 -04:00
|
|
|
(( GET_VCS )) && download_git "$netfile"
|
2012-06-03 20:37:35 -04:00
|
|
|
;;
|
2012-07-23 06:01:35 -04:00
|
|
|
hg*)
|
|
|
|
(( GET_VCS )) && download_hg "$netfile"
|
|
|
|
;;
|
2012-06-07 04:12:31 -04:00
|
|
|
svn*)
|
2012-07-15 09:57:25 -04:00
|
|
|
(( GET_VCS )) && download_svn "$netfile"
|
2012-06-07 04:12:31 -04:00
|
|
|
;;
|
2012-06-03 08:57:35 -04:00
|
|
|
*)
|
2012-08-27 21:35:20 -04:00
|
|
|
download_file "$netfile"
|
2012-06-03 08:57:35 -04:00
|
|
|
;;
|
|
|
|
esac
|
2012-06-03 08:08:25 -04:00
|
|
|
|
2013-03-27 06:11:21 -04:00
|
|
|
popd &>/dev/null
|
|
|
|
done
|
2012-06-03 08:08:25 -04:00
|
|
|
}
|
|
|
|
|
2012-06-04 23:30:08 -04:00
|
|
|
# Automatically update pkgver variable if a pkgver() function is provided
|
|
|
|
# Re-sources the PKGBUILD afterwards to allow for other variables that use $pkgver
|
|
|
|
update_pkgver() {
|
|
|
|
newpkgver=$(run_function_safe pkgver)
|
2013-10-14 09:13:28 -04:00
|
|
|
if ! validate_pkgver "$newpkgver"; then
|
|
|
|
error "$(gettext "pkgver() generated an invalid version: %s")" "$newpkgver"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-06-04 23:30:08 -04:00
|
|
|
|
|
|
|
if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then
|
|
|
|
if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then
|
2013-10-14 09:13:28 -04:00
|
|
|
if ! @SEDINPLACE@ "s:^pkgver=[^ ]*:pkgver=$newpkgver:" "$BUILDFILE"; then
|
|
|
|
error "$(gettext "Failed to update %s from %s to %s")" \
|
|
|
|
"pkgver" "$pkgver" "$newpkgver"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
@SEDINPLACE@ "s:^pkgrel=[^ ]*:pkgrel=1:" "$BUILDFILE"
|
2013-10-14 02:35:09 -04:00
|
|
|
source_safe "$BUILDFILE"
|
2012-12-13 10:56:11 -05:00
|
|
|
local fullver=$(get_full_version)
|
|
|
|
msg "$(gettext "Updated version: %s")" "$pkgbase $fullver"
|
2012-06-04 23:30:08 -04:00
|
|
|
else
|
|
|
|
warning "$(gettext "%s is not writeable -- pkgver will not be updated")" \
|
|
|
|
"$BUILDFILE"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-06-03 08:08:25 -04:00
|
|
|
# Print 'source not found' error message and exit makepkg
|
|
|
|
missing_source_file() {
|
|
|
|
error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_MISSING_FILE
|
|
|
|
}
|
|
|
|
|
2011-01-20 19:16:06 -05:00
|
|
|
##
|
2011-07-22 07:42:53 -04:00
|
|
|
# usage : get_full_version( [$pkgname] )
|
2011-01-20 19:16:06 -05:00
|
|
|
# return : full version spec, including epoch (if necessary), pkgver, pkgrel
|
|
|
|
##
|
|
|
|
get_full_version() {
|
2011-07-22 07:42:53 -04:00
|
|
|
if [[ -z $1 ]]; then
|
2011-08-08 17:20:53 -04:00
|
|
|
if [[ $epoch ]] && (( ! $epoch )); then
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "$pkgver-$pkgrel"
|
2011-07-22 07:42:53 -04:00
|
|
|
else
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "$epoch:$pkgver-$pkgrel"
|
2011-07-22 07:42:53 -04:00
|
|
|
fi
|
2011-01-20 19:16:06 -05:00
|
|
|
else
|
2011-07-22 07:42:53 -04:00
|
|
|
for i in pkgver pkgrel epoch; do
|
|
|
|
local indirect="${i}_override"
|
|
|
|
eval $(declare -f package_$1 | sed -n "s/\(^[[:space:]]*$i=\)/${i}_override=/p")
|
2011-08-18 12:27:12 -04:00
|
|
|
[[ -z ${!indirect} ]] && eval ${indirect}=\"${!i}\"
|
2011-07-22 07:42:53 -04:00
|
|
|
done
|
|
|
|
if (( ! $epoch_override )); then
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "$pkgver_override-$pkgrel_override"
|
2011-07-22 07:42:53 -04:00
|
|
|
else
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "$epoch_override:$pkgver_override-$pkgrel_override"
|
2011-07-22 07:42:53 -04:00
|
|
|
fi
|
2011-01-20 19:16:06 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-03-09 06:09:35 -05:00
|
|
|
##
|
|
|
|
# usage : get_pkg_arch( [$pkgname] )
|
|
|
|
# return : architecture of the package
|
|
|
|
##
|
|
|
|
get_pkg_arch() {
|
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
if [[ $arch = "any" ]]; then
|
|
|
|
printf "%s\n" "any"
|
|
|
|
else
|
|
|
|
printf "%s\n" "$CARCH"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
local arch_override
|
|
|
|
eval $(declare -f package_$1 | sed -n 's/\(^[[:space:]]*arch=\)/arch_override=/p')
|
2012-04-30 20:59:03 -04:00
|
|
|
(( ${#arch_override[@]} == 0 )) && arch_override=("${arch[@]}")
|
2012-03-09 06:09:35 -05:00
|
|
|
if [[ $arch_override = "any" ]]; then
|
|
|
|
printf "%s\n" "any"
|
|
|
|
else
|
|
|
|
printf "%s\n" "$CARCH"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-06-02 13:04:41 -04:00
|
|
|
##
|
|
|
|
# Checks to see if options are present in makepkg.conf or PKGBUILD;
|
|
|
|
# PKGBUILD options always take precedence.
|
|
|
|
#
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
# usage : check_option( $option, $expected_val )
|
|
|
|
# return : 0 - matches expected
|
|
|
|
# 1 - does not match expected
|
|
|
|
# 127 - not found
|
2007-06-02 13:04:41 -04:00
|
|
|
##
|
2006-01-21 21:16:41 -05:00
|
|
|
check_option() {
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
in_opt_array "$1" ${options[@]}
|
|
|
|
case $? in
|
|
|
|
0) # assert enabled
|
|
|
|
[[ $2 = y ]]
|
|
|
|
return ;;
|
|
|
|
1) # assert disabled
|
|
|
|
[[ $2 = n ]]
|
|
|
|
return
|
|
|
|
esac
|
2007-06-02 13:04:41 -04:00
|
|
|
|
|
|
|
# fall back to makepkg.conf options
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
in_opt_array "$1" ${OPTIONS[@]}
|
|
|
|
case $? in
|
|
|
|
0) # assert enabled
|
|
|
|
[[ $2 = y ]]
|
|
|
|
return ;;
|
|
|
|
1) # assert disabled
|
|
|
|
[[ $2 = n ]]
|
|
|
|
return
|
|
|
|
esac
|
2007-06-02 13:04:41 -04:00
|
|
|
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
# not found
|
|
|
|
return 127
|
2007-02-04 13:28:21 -05:00
|
|
|
}
|
|
|
|
|
2007-06-02 13:04:41 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# Check if option is present in BUILDENV
|
|
|
|
#
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
# usage : check_buildenv( $option, $expected_val )
|
|
|
|
# return : 0 - matches expected
|
|
|
|
# 1 - does not match expected
|
|
|
|
# 127 - not found
|
2007-06-02 13:04:41 -04:00
|
|
|
##
|
2007-02-04 13:28:21 -05:00
|
|
|
check_buildenv() {
|
2011-06-28 22:35:10 -04:00
|
|
|
in_opt_array "$1" ${BUILDENV[@]}
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
case $? in
|
|
|
|
0) # assert enabled
|
|
|
|
[[ $2 = "y" ]]
|
|
|
|
return ;;
|
|
|
|
1) # assert disabled
|
|
|
|
[[ $2 = "n" ]]
|
|
|
|
return ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# not found
|
|
|
|
return 127
|
2007-06-02 13:04:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# usage : in_opt_array( $needle, $haystack )
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
# return : 0 - enabled
|
|
|
|
# 1 - disabled
|
|
|
|
# 127 - not found
|
2007-06-02 13:04:41 -04:00
|
|
|
##
|
|
|
|
in_opt_array() {
|
2011-03-30 21:12:58 -04:00
|
|
|
local needle=$1; shift
|
2007-06-02 13:04:41 -04:00
|
|
|
|
2012-09-17 03:02:17 -04:00
|
|
|
local i opt
|
|
|
|
for (( i = $#; i > 0; i-- )); do
|
|
|
|
opt=${!i}
|
2012-03-09 01:19:53 -05:00
|
|
|
if [[ $opt = "$needle" ]]; then
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
# enabled
|
|
|
|
return 0
|
2009-11-12 15:07:34 -05:00
|
|
|
elif [[ $opt = "!$needle" ]]; then
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
# disabled
|
|
|
|
return 1
|
2006-01-21 21:16:41 -05:00
|
|
|
fi
|
|
|
|
done
|
2007-06-02 13:04:41 -04:00
|
|
|
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
# not found
|
|
|
|
return 127
|
2006-01-21 21:16:41 -05:00
|
|
|
}
|
|
|
|
|
2007-06-02 13:04:41 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# usage : in_array( $needle, $haystack )
|
|
|
|
# return : 0 - found
|
|
|
|
# 1 - not found
|
|
|
|
##
|
2006-11-14 02:58:42 -05:00
|
|
|
in_array() {
|
2007-06-02 13:04:41 -04:00
|
|
|
local needle=$1; shift
|
|
|
|
local item
|
|
|
|
for item in "$@"; do
|
2012-03-09 01:19:53 -05:00
|
|
|
[[ $item = "$needle" ]] && return 0 # Found
|
2006-12-20 20:53:40 -05:00
|
|
|
done
|
2007-06-02 13:04:41 -04:00
|
|
|
return 1 # Not Found
|
2006-11-14 02:58:42 -05:00
|
|
|
}
|
|
|
|
|
2011-12-10 23:10:49 -05:00
|
|
|
source_has_signatures() {
|
2011-07-06 07:02:19 -04:00
|
|
|
local file
|
|
|
|
for file in "${source[@]}"; do
|
2011-12-10 23:10:49 -05:00
|
|
|
if [[ ${file%%::*} = *.@(sig?(n)|asc) ]]; then
|
2011-07-06 07:02:19 -04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2009-11-18 17:29:07 -05:00
|
|
|
run_pacman() {
|
2010-06-30 06:42:30 -04:00
|
|
|
local cmd
|
2012-01-20 08:25:57 -05:00
|
|
|
if [[ ! $1 = -@(T|Qq) ]]; then
|
2012-11-12 22:04:21 -05:00
|
|
|
cmd=("$PACMAN_PATH" $PACMAN_OPTS "$@")
|
2012-01-20 08:25:57 -05:00
|
|
|
else
|
2012-11-12 22:04:21 -05:00
|
|
|
cmd=("$PACMAN_PATH" "$@")
|
2012-01-20 08:25:57 -05:00
|
|
|
fi
|
2014-03-08 05:31:46 -05:00
|
|
|
if [[ ! $1 = -@(T|Qq) ]]; then
|
2011-03-24 10:10:05 -04:00
|
|
|
if type -p sudo >/dev/null; then
|
2012-02-29 21:55:44 -05:00
|
|
|
cmd=(sudo "${cmd[@]}")
|
2010-03-04 21:57:46 -05:00
|
|
|
else
|
2012-02-29 21:55:44 -05:00
|
|
|
cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
|
2010-03-04 21:57:46 -05:00
|
|
|
fi
|
2009-11-18 17:29:07 -05:00
|
|
|
fi
|
2012-02-29 21:55:44 -05:00
|
|
|
"${cmd[@]}"
|
2009-11-18 17:29:07 -05:00
|
|
|
}
|
|
|
|
|
2007-06-02 13:39:47 -04:00
|
|
|
check_deps() {
|
2010-06-22 23:16:36 -04:00
|
|
|
(( $# > 0 )) || return 0
|
2006-01-26 18:48:28 -05:00
|
|
|
|
2009-11-18 17:29:07 -05:00
|
|
|
local ret=0
|
2010-06-25 19:16:36 -04:00
|
|
|
local pmout
|
2012-01-26 10:28:31 -05:00
|
|
|
pmout=$(run_pacman -T "$@")
|
|
|
|
ret=$?
|
2011-08-17 17:56:07 -04:00
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ret == 127 )); then #unresolved deps
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "$pmout"
|
2009-11-12 15:07:34 -05:00
|
|
|
elif (( ret )); then
|
2009-12-02 13:04:32 -05:00
|
|
|
error "$(gettext "'%s' returned a fatal error (%i): %s")" "$PACMAN" "$ret" "$pmout"
|
2010-06-25 19:16:37 -04:00
|
|
|
return "$ret"
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-08-07 02:40:04 -04:00
|
|
|
handle_deps() {
|
2007-05-30 12:47:47 -04:00
|
|
|
local R_DEPS_SATISFIED=0
|
|
|
|
local R_DEPS_MISSING=1
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
(( $# == 0 )) && return $R_DEPS_SATISFIED
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-05-30 12:47:47 -04:00
|
|
|
local deplist="$*"
|
2007-03-19 18:48:54 -04:00
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ! DEP_BIN )); then
|
2007-05-30 12:47:47 -04:00
|
|
|
return $R_DEPS_MISSING
|
|
|
|
fi
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( DEP_BIN )); then
|
2007-05-30 12:47:47 -04:00
|
|
|
# install missing deps from binary packages (using pacman -S)
|
|
|
|
msg "$(gettext "Installing missing dependencies...")"
|
|
|
|
|
2009-11-18 17:29:07 -05:00
|
|
|
if ! run_pacman -S --asdeps $deplist; then
|
2009-12-02 13:04:32 -05:00
|
|
|
error "$(gettext "'%s' failed to install missing dependencies.")" "$PACMAN"
|
2007-05-30 12:47:47 -04:00
|
|
|
exit 1 # TODO: error code
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
2006-12-21 12:42:58 -05:00
|
|
|
|
2008-07-24 05:37:36 -04:00
|
|
|
# we might need the new system environment
|
2012-03-31 03:26:39 -04:00
|
|
|
# save our shell options and turn off extglob
|
|
|
|
local shellopts=$(shopt -p)
|
|
|
|
shopt -u extglob
|
2008-07-24 05:37:36 -04:00
|
|
|
source /etc/profile &>/dev/null
|
2012-03-31 03:26:39 -04:00
|
|
|
eval "$shellopts"
|
2006-11-14 02:58:42 -05:00
|
|
|
|
2007-05-30 12:47:47 -04:00
|
|
|
return $R_DEPS_SATISFIED
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-06-02 13:39:47 -04:00
|
|
|
resolve_deps() {
|
2007-05-30 12:47:47 -04:00
|
|
|
local R_DEPS_SATISFIED=0
|
2007-06-02 12:41:15 -04:00
|
|
|
local R_DEPS_MISSING=1
|
2007-05-30 12:47:47 -04:00
|
|
|
|
2010-06-25 19:16:37 -04:00
|
|
|
# deplist cannot be declared like this: local deplist=$(foo)
|
|
|
|
# Otherwise, the return value will depend on the assignment.
|
|
|
|
local deplist
|
|
|
|
deplist="$(set +E; check_deps $*)" || exit 1
|
|
|
|
[[ -z $deplist ]] && return $R_DEPS_SATISFIED
|
2007-05-30 12:47:47 -04:00
|
|
|
|
2009-08-07 02:40:04 -04:00
|
|
|
if handle_deps $deplist; then
|
2007-05-30 12:47:47 -04:00
|
|
|
# check deps again to make sure they were resolved
|
2010-06-25 19:16:37 -04:00
|
|
|
deplist="$(set +E; check_deps $*)" || exit 1
|
2009-11-12 15:07:34 -05:00
|
|
|
[[ -z $deplist ]] && return $R_DEPS_SATISFIED
|
2007-02-14 00:52:49 -05:00
|
|
|
fi
|
|
|
|
|
2012-11-19 19:13:10 -05:00
|
|
|
msg "$(gettext "Missing dependencies:")"
|
2007-05-30 12:47:47 -04:00
|
|
|
local dep
|
|
|
|
for dep in $deplist; do
|
|
|
|
msg2 "$dep"
|
|
|
|
done
|
|
|
|
|
|
|
|
return $R_DEPS_MISSING
|
2007-02-14 00:52:49 -05:00
|
|
|
}
|
|
|
|
|
2007-06-02 13:39:47 -04:00
|
|
|
remove_deps() {
|
2009-11-12 15:07:34 -05:00
|
|
|
(( ! RMDEPS )) && return
|
2007-05-30 12:47:47 -04:00
|
|
|
|
2009-10-23 01:30:47 -04:00
|
|
|
# check for packages removed during dependency install (e.g. due to conflicts)
|
|
|
|
# removing all installed packages is risky in this case
|
2014-02-02 02:30:06 -05:00
|
|
|
if [[ -n $(grep -xvFf <(printf '%s\n' "${current_pkglist[@]}") \
|
2014-02-02 02:37:58 -05:00
|
|
|
<(printf '%s\n' "${original_pkglist[@]}")) ]]; then
|
2011-11-21 23:03:33 -05:00
|
|
|
warning "$(gettext "Failed to remove installed dependencies.")"
|
|
|
|
return 0
|
2009-10-23 01:30:47 -04:00
|
|
|
fi
|
2007-03-19 21:34:16 -04:00
|
|
|
|
2011-11-21 23:03:33 -05:00
|
|
|
local deplist
|
2012-01-20 08:20:52 -05:00
|
|
|
deplist=($(grep -xvFf <(printf "%s\n" "${original_pkglist[@]}") \
|
2014-02-02 02:37:58 -05:00
|
|
|
<(printf "%s\n" "${current_pkglist[@]}")))
|
2012-02-14 15:31:04 -05:00
|
|
|
if [[ -z $deplist ]]; then
|
2014-02-02 02:37:58 -05:00
|
|
|
return 0
|
2011-11-21 23:03:33 -05:00
|
|
|
fi
|
2008-04-02 11:07:25 -04:00
|
|
|
|
2009-10-23 01:30:47 -04:00
|
|
|
msg "Removing installed dependencies..."
|
2009-11-18 17:29:07 -05:00
|
|
|
# exit cleanly on failure to remove deps as package has been built successfully
|
2009-10-23 01:30:47 -04:00
|
|
|
if ! run_pacman -Rn ${deplist[@]}; then
|
2008-04-02 11:07:25 -04:00
|
|
|
warning "$(gettext "Failed to remove installed dependencies.")"
|
|
|
|
return 0
|
2007-01-16 23:54:55 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-10-14 14:07:28 -04:00
|
|
|
get_integlist() {
|
|
|
|
local integ
|
|
|
|
local integlist=()
|
|
|
|
|
2013-09-02 15:53:33 -04:00
|
|
|
for integ in "${known_hash_algos[@]}"; do
|
|
|
|
local sumname="${integ}sums[@]"
|
|
|
|
if [[ -n ${!sumname} ]]; then
|
|
|
|
integlist+=("$integ")
|
2009-10-14 14:07:28 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if (( ${#integlist[@]} > 0 )); then
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "${integlist[@]}"
|
2009-10-14 14:07:28 -04:00
|
|
|
else
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "${INTEGRITY_CHECK[@]}"
|
2009-10-14 14:07:28 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
generate_checksums() {
|
|
|
|
msg "$(gettext "Generating checksums for source files...")"
|
|
|
|
|
2010-05-27 11:06:08 -04:00
|
|
|
if ! type -p openssl >/dev/null; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "Cannot find the %s binary required for generating sourcefile checksums.")" "openssl"
|
2008-08-23 11:19:17 -04:00
|
|
|
exit 1 # $E_MISSING_PROGRAM
|
|
|
|
fi
|
|
|
|
|
2009-10-14 14:07:28 -04:00
|
|
|
local integlist
|
|
|
|
if (( $# == 0 )); then
|
2013-09-17 11:31:17 -04:00
|
|
|
IFS=$'\n' read -rd '' -a integlist < <(get_integlist)
|
2009-10-14 14:07:28 -04:00
|
|
|
else
|
2013-09-02 15:53:33 -04:00
|
|
|
integlist=("$@")
|
2009-10-14 14:07:28 -04:00
|
|
|
fi
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
local integ
|
2013-09-02 15:53:33 -04:00
|
|
|
for integ in "${integlist[@]}"; do
|
|
|
|
if ! in_array "$integ" "${known_hash_algos[@]}"; then
|
|
|
|
error "$(gettext "Invalid integrity algorithm '%s' specified.")" "$integ"
|
|
|
|
exit 1 # $E_CONFIG_ERROR
|
|
|
|
fi
|
2007-06-01 17:10:27 -04:00
|
|
|
|
2013-09-03 20:03:04 -04:00
|
|
|
local indentsz idx numsrc=${#source[@]}
|
2013-09-03 15:47:10 -04:00
|
|
|
printf "%s%n" "${integ}sums=(" indentsz
|
2007-06-01 17:10:27 -04:00
|
|
|
|
2013-09-03 20:03:04 -04:00
|
|
|
for (( idx = 0; idx < numsrc; i++ )); do
|
|
|
|
local netfile=${source[idx]}
|
2012-06-03 21:24:52 -04:00
|
|
|
local proto sum
|
|
|
|
proto="$(get_protocol "$netfile")"
|
|
|
|
|
|
|
|
case $proto in
|
2012-09-14 22:24:01 -04:00
|
|
|
bzr*|git*|hg*|svn*)
|
2012-06-03 21:24:52 -04:00
|
|
|
sum="SKIP"
|
|
|
|
;;
|
|
|
|
*)
|
2012-09-20 08:00:47 -04:00
|
|
|
if [[ ! $netfile = *.@(sig?(n)|asc) ]]; then
|
|
|
|
local file
|
|
|
|
file="$(get_filepath "$netfile")" || missing_source_file "$netfile"
|
|
|
|
sum="$(openssl dgst -${integ} "$file")"
|
|
|
|
sum=${sum##* }
|
|
|
|
else
|
|
|
|
sum="SKIP"
|
|
|
|
fi
|
2012-06-03 21:24:52 -04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2013-09-03 15:47:10 -04:00
|
|
|
# indent checksum on lines after the first
|
2013-09-03 20:03:04 -04:00
|
|
|
printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'"
|
2013-09-03 15:47:10 -04:00
|
|
|
|
|
|
|
# print a newline on lines before the last
|
2013-09-03 20:03:04 -04:00
|
|
|
(( ++idx < numsrc )) && echo
|
2007-06-01 17:10:27 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
echo ")"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
check_checksums() {
|
2011-07-16 08:42:32 -04:00
|
|
|
(( SKIPCHECKSUMS )) && return 0
|
2009-11-12 15:07:34 -05:00
|
|
|
(( ! ${#source[@]} )) && return 0
|
2009-03-14 09:43:05 -04:00
|
|
|
|
2009-01-13 17:59:33 -05:00
|
|
|
local correlation=0
|
2008-08-23 11:19:17 -04:00
|
|
|
local integ required
|
2013-09-02 15:53:33 -04:00
|
|
|
for integ in "${known_hash_algos[@]}"; do
|
|
|
|
local sumname="${integ}sums[@]"
|
|
|
|
local integrity_sums=("${!sumname}")
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ${#integrity_sums[@]} == ${#source[@]} )); then
|
2007-06-02 13:39:48 -04:00
|
|
|
msg "$(gettext "Validating source files with %s...")" "${integ}sums"
|
2009-01-13 17:59:33 -05:00
|
|
|
correlation=1
|
2013-09-03 20:03:04 -04:00
|
|
|
local idx errors=0
|
|
|
|
for (( idx = 0; idx < ${#source[*]}; idx++ )); do
|
|
|
|
local file="$(get_filename "${source[idx]}")"
|
2013-09-02 16:50:08 -04:00
|
|
|
printf ' %s ... ' "$file" >&2
|
2007-06-01 17:10:27 -04:00
|
|
|
|
2013-09-03 20:03:04 -04:00
|
|
|
if [[ ${integrity_sums[idx]} = 'SKIP' ]]; then
|
2013-09-02 16:50:08 -04:00
|
|
|
printf '%s\n' "$(gettext "Skipped")" >&2
|
2012-06-03 20:33:52 -04:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2010-06-03 11:32:50 -04:00
|
|
|
if ! file="$(get_filepath "$file")"; then
|
2013-09-02 16:50:08 -04:00
|
|
|
printf '%s\n' "$(gettext "NOT FOUND")" >&2
|
2010-06-03 11:32:50 -04:00
|
|
|
errors=1
|
2013-09-03 20:03:04 -04:00
|
|
|
continue
|
2007-07-10 08:11:40 -04:00
|
|
|
fi
|
|
|
|
|
2013-09-03 20:03:04 -04:00
|
|
|
local expectedsum="${integrity_sums[idx],,}"
|
|
|
|
local realsum="$(openssl dgst -${integ} "$file")"
|
|
|
|
realsum="${realsum##* }"
|
|
|
|
if [[ $expectedsum = "$realsum" ]]; then
|
|
|
|
printf '%s\n' "$(gettext "Passed")" >&2
|
|
|
|
else
|
|
|
|
printf '%s\n' "$(gettext "FAILED")" >&2
|
|
|
|
errors=1
|
2007-06-01 17:10:27 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( errors )); then
|
2007-06-01 17:10:27 -04:00
|
|
|
error "$(gettext "One or more files did not pass the validity check!")"
|
|
|
|
exit 1 # TODO: error code
|
|
|
|
fi
|
2009-11-12 15:07:34 -05:00
|
|
|
elif (( ${#integrity_sums[@]} )); then
|
2009-01-13 17:59:33 -05:00
|
|
|
error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ"
|
|
|
|
exit 1 # TODO: error code
|
2007-06-01 17:10:27 -04:00
|
|
|
fi
|
|
|
|
done
|
2009-01-13 17:59:33 -05:00
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ! correlation )); then
|
2009-10-11 07:50:45 -04:00
|
|
|
error "$(gettext "Integrity checks are missing.")"
|
|
|
|
exit 1 # TODO: error code
|
2009-01-13 17:59:33 -05:00
|
|
|
fi
|
2007-06-01 17:10:27 -04:00
|
|
|
}
|
|
|
|
|
2011-07-06 07:02:19 -04:00
|
|
|
check_pgpsigs() {
|
|
|
|
(( SKIPPGPCHECK )) && return 0
|
|
|
|
! source_has_signatures && return 0
|
|
|
|
|
|
|
|
msg "$(gettext "Verifying source file signatures with %s...")" "gpg"
|
|
|
|
|
2014-02-27 19:45:05 -05:00
|
|
|
local file pubkey ext decompress found
|
2011-07-06 07:02:19 -04:00
|
|
|
local warning=0
|
|
|
|
local errors=0
|
|
|
|
local statusfile=$(mktemp)
|
|
|
|
|
|
|
|
for file in "${source[@]}"; do
|
|
|
|
file="$(get_filename "$file")"
|
2011-11-06 23:47:58 -05:00
|
|
|
if [[ ! $file = *.@(sig?(n)|asc) ]]; then
|
2011-07-06 07:02:19 -04:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2011-09-04 12:34:57 -04:00
|
|
|
printf " %s ... " "${file%.*}" >&2
|
2011-07-06 07:02:19 -04:00
|
|
|
|
|
|
|
if ! file="$(get_filepath "$file")"; then
|
2011-09-04 12:34:57 -04:00
|
|
|
printf '%s\n' "$(gettext "SIGNATURE NOT FOUND")" >&2
|
2011-07-06 07:02:19 -04:00
|
|
|
errors=1
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2014-02-27 19:45:05 -05:00
|
|
|
found=0
|
|
|
|
for ext in "" gz bz2 xz lrz lzo Z; do
|
|
|
|
if sourcefile="$(get_filepath "${file%.*}${ext:+.$ext}")"; then
|
|
|
|
found=1
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if (( ! found )); then
|
2011-09-04 12:34:57 -04:00
|
|
|
printf '%s\n' "$(gettext "SOURCE FILE NOT FOUND")" >&2
|
2011-07-06 07:02:19 -04:00
|
|
|
errors=1
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2014-02-27 19:45:05 -05:00
|
|
|
case "$ext" in
|
|
|
|
gz) decompress="gzip -c -d -f" ;;
|
|
|
|
bz2) decompress="bzip2 -c -d -f" ;;
|
|
|
|
xz) decompress="xz -c -d" ;;
|
|
|
|
lrz) decompress="lrzip -q -d" ;;
|
|
|
|
lzo) decompress="lzop -c -d -q" ;;
|
|
|
|
Z) decompress="uncompress -c -f" ;;
|
|
|
|
"") decompress="cat" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if ! $decompress < "$sourcefile" | gpg --quiet --batch --status-file "$statusfile" --verify "$file" - 2> /dev/null; then
|
2011-09-04 12:34:57 -04:00
|
|
|
printf '%s' "$(gettext "FAILED")" >&2
|
|
|
|
if ! pubkey=$(awk '/NO_PUBKEY/ { print $3; exit 1; }' "$statusfile"); then
|
|
|
|
printf ' (%s)' "$(gettext "unknown public key") $pubkey" >&2
|
2011-07-06 07:02:19 -04:00
|
|
|
warnings=1
|
|
|
|
else
|
|
|
|
errors=1
|
|
|
|
fi
|
2011-09-04 12:34:57 -04:00
|
|
|
printf '\n' >&2
|
2011-07-06 07:02:19 -04:00
|
|
|
else
|
2011-09-04 12:34:57 -04:00
|
|
|
if grep -q "REVKEYSIG" "$statusfile"; then
|
2011-09-13 16:19:46 -04:00
|
|
|
printf '%s (%s)' "$(gettext "FAILED")" "$(gettext "the key has been revoked.")" >&2
|
2011-07-06 07:02:19 -04:00
|
|
|
errors=1
|
|
|
|
else
|
2011-09-04 12:34:57 -04:00
|
|
|
printf '%s' "$(gettext "Passed")" >&2
|
|
|
|
if grep -q "EXPSIG" "$statusfile"; then
|
2011-09-13 16:19:46 -04:00
|
|
|
printf ' (%s)' "$(gettext "WARNING:") $(gettext "the signature has expired.")" >&2
|
2011-09-04 12:34:57 -04:00
|
|
|
warnings=1
|
|
|
|
elif grep -q "EXPKEYSIG" "$statusfile"; then
|
2011-09-13 16:19:46 -04:00
|
|
|
printf ' (%s)' "$(gettext "WARNING:") $(gettext "the key has expired.")" >&2
|
2011-09-04 12:34:57 -04:00
|
|
|
warnings=1
|
|
|
|
fi
|
2011-07-06 07:02:19 -04:00
|
|
|
fi
|
2011-09-13 16:19:46 -04:00
|
|
|
printf '\n' >&2
|
2011-07-06 07:02:19 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
rm -f "$statusfile"
|
|
|
|
|
|
|
|
if (( errors )); then
|
|
|
|
error "$(gettext "One or more PGP signatures could not be verified!")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( warnings )); then
|
|
|
|
warning "$(gettext "Warnings have occurred while verifying the signatures.")"
|
|
|
|
plain "$(gettext "Please make sure you really trust them.")"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2011-07-18 05:58:54 -04:00
|
|
|
check_source_integrity() {
|
|
|
|
if (( SKIPCHECKSUMS && SKIPPGPCHECK )); then
|
|
|
|
warning "$(gettext "Skipping all source file integrity checks.")"
|
|
|
|
elif (( SKIPCHECKSUMS )); then
|
|
|
|
warning "$(gettext "Skipping verification of source file checksums.")"
|
|
|
|
check_pgpsigs
|
|
|
|
elif (( SKIPPGPCHECK )); then
|
|
|
|
warning "$(gettext "Skipping verification of source file PGP signatures.")"
|
|
|
|
check_checksums
|
|
|
|
else
|
|
|
|
check_checksums
|
|
|
|
check_pgpsigs
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
extract_sources() {
|
2012-11-19 19:13:10 -05:00
|
|
|
msg "$(gettext "Extracting sources...")"
|
2007-06-01 17:10:27 -04:00
|
|
|
local netfile
|
|
|
|
for netfile in "${source[@]}"; do
|
2010-06-25 19:16:36 -04:00
|
|
|
local file=$(get_filename "$netfile")
|
2011-07-16 10:09:19 -04:00
|
|
|
if in_array "$file" "${noextract[@]}"; then
|
2013-11-08 00:44:40 -05:00
|
|
|
# skip source files in the noextract=() array
|
|
|
|
# these are marked explicitly to NOT be extracted
|
2007-06-01 17:10:27 -04:00
|
|
|
continue
|
|
|
|
fi
|
2013-03-09 15:36:55 -05:00
|
|
|
local proto=$(get_protocol "$netfile")
|
|
|
|
case "$proto" in
|
|
|
|
bzr*)
|
|
|
|
extract_bzr "$netfile"
|
|
|
|
;;
|
|
|
|
git*)
|
|
|
|
extract_git "$netfile"
|
|
|
|
;;
|
|
|
|
hg*)
|
|
|
|
extract_hg "$netfile"
|
|
|
|
;;
|
|
|
|
svn*)
|
|
|
|
extract_svn "$netfile"
|
|
|
|
;;
|
2007-06-02 12:41:15 -04:00
|
|
|
*)
|
2013-03-09 15:36:55 -05:00
|
|
|
extract_file "$file"
|
|
|
|
;;
|
2007-06-01 17:10:27 -04:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-08-24 18:19:20 -04:00
|
|
|
error_function() {
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -p $logpipe ]]; then
|
2009-08-23 11:16:21 -04:00
|
|
|
rm "$logpipe"
|
|
|
|
fi
|
|
|
|
# first exit all subshells, then print the error
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ! BASH_SUBSHELL )); then
|
2010-06-30 08:16:25 -04:00
|
|
|
error "$(gettext "A failure occurred in %s().")" "$1"
|
2007-06-02 13:39:48 -04:00
|
|
|
plain "$(gettext "Aborting...")"
|
2007-04-11 15:06:09 -04:00
|
|
|
fi
|
2009-08-23 11:16:21 -04:00
|
|
|
exit 2 # $E_BUILD_FAILED
|
2007-04-11 15:06:09 -04:00
|
|
|
}
|
|
|
|
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe() {
|
|
|
|
if ! cd "$1"; then
|
|
|
|
error "$(gettext "Failed to change to directory %s")" "$1"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-02-10 15:10:32 -05:00
|
|
|
source_safe() {
|
|
|
|
shopt -u extglob
|
|
|
|
if ! source "$@"; then
|
|
|
|
error "$(gettext "Failed to source %s")" "$1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
shopt -s extglob
|
|
|
|
}
|
|
|
|
|
2012-01-26 10:28:31 -05:00
|
|
|
run_function_safe() {
|
|
|
|
local restoretrap
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -E
|
|
|
|
|
|
|
|
restoretrap=$(trap -p ERR)
|
|
|
|
trap 'error_function $pkgfunc' ERR
|
|
|
|
|
|
|
|
run_function "$1"
|
|
|
|
|
|
|
|
eval $restoretrap
|
|
|
|
|
|
|
|
set +E
|
|
|
|
set +e
|
|
|
|
}
|
|
|
|
|
2009-08-24 18:19:20 -04:00
|
|
|
run_function() {
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -z $1 ]]; then
|
2009-08-24 18:19:20 -04:00
|
|
|
return 1
|
2009-01-16 07:26:52 -05:00
|
|
|
fi
|
2010-06-25 19:16:36 -04:00
|
|
|
local pkgfunc="$1"
|
2009-01-16 07:26:52 -05:00
|
|
|
|
2010-12-25 00:43:06 -05:00
|
|
|
# clear user-specified buildflags if requested
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "buildflags" "n"; then
|
2011-12-22 05:19:18 -05:00
|
|
|
unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
|
2010-12-25 00:43:06 -05:00
|
|
|
fi
|
|
|
|
|
2012-09-23 03:06:34 -04:00
|
|
|
if check_option "debug" "y"; then
|
|
|
|
CFLAGS+=" $DEBUG_CFLAGS"
|
|
|
|
CXXFLAGS+=" $DEBUG_CXXFLAGS"
|
|
|
|
fi
|
|
|
|
|
2009-01-16 07:20:05 -05:00
|
|
|
# clear user-specified makeflags if requested
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "makeflags" "n"; then
|
2011-09-06 09:29:52 -04:00
|
|
|
unset MAKEFLAGS
|
2009-01-16 07:20:05 -05:00
|
|
|
fi
|
|
|
|
|
2009-01-16 07:26:52 -05:00
|
|
|
msg "$(gettext "Starting %s()...")" "$pkgfunc"
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "$srcdir"
|
2009-01-16 07:20:05 -05:00
|
|
|
|
|
|
|
# ensure all necessary build variables are exported
|
2011-12-22 05:19:18 -05:00
|
|
|
export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
|
2009-08-24 18:19:20 -04:00
|
|
|
# save our shell options so pkgfunc() can't override what we need
|
|
|
|
local shellopts=$(shopt -p)
|
2009-01-16 07:20:05 -05:00
|
|
|
|
|
|
|
local ret=0
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( LOGGING )); then
|
2011-07-22 07:42:53 -04:00
|
|
|
local fullver=$(get_full_version)
|
2012-11-29 02:08:55 -05:00
|
|
|
local BUILDLOG="$LOGDEST/${pkgbase}-${fullver}-${CARCH}-$pkgfunc.log"
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -f $BUILDLOG ]]; then
|
2009-01-16 07:20:05 -05:00
|
|
|
local i=1
|
|
|
|
while true; do
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -f $BUILDLOG.$i ]]; then
|
2009-01-16 07:20:05 -05:00
|
|
|
i=$(($i +1))
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
mv "$BUILDLOG" "$BUILDLOG.$i"
|
|
|
|
fi
|
|
|
|
|
2009-08-18 16:10:56 -04:00
|
|
|
# ensure overridden package variables survive tee with split packages
|
2013-05-18 09:11:41 -04:00
|
|
|
logpipe=$(mktemp -u "$LOGDEST/logpipe.XXXXXXXX")
|
2010-10-11 15:16:49 -04:00
|
|
|
mkfifo "$logpipe"
|
2008-12-07 21:21:03 -05:00
|
|
|
tee "$BUILDLOG" < "$logpipe" &
|
2011-03-24 08:30:15 -04:00
|
|
|
local teepid=$!
|
|
|
|
|
|
|
|
$pkgfunc &>"$logpipe"
|
|
|
|
|
|
|
|
wait $teepid
|
2008-12-07 21:21:03 -05:00
|
|
|
rm "$logpipe"
|
2009-01-16 07:20:05 -05:00
|
|
|
else
|
2013-04-26 20:32:37 -04:00
|
|
|
"$pkgfunc"
|
2009-01-16 07:20:05 -05:00
|
|
|
fi
|
2009-08-24 18:19:20 -04:00
|
|
|
# reset our shell options
|
|
|
|
eval "$shellopts"
|
|
|
|
}
|
|
|
|
|
2012-07-28 05:20:10 -04:00
|
|
|
run_prepare() {
|
|
|
|
run_function_safe "prepare"
|
|
|
|
}
|
|
|
|
|
2009-08-24 18:19:20 -04:00
|
|
|
run_build() {
|
|
|
|
# use distcc if it is requested (check buildenv and PKGBUILD opts)
|
2013-06-16 02:33:39 -04:00
|
|
|
if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then
|
2009-11-12 15:07:34 -05:00
|
|
|
[[ -d /usr/lib/distcc/bin ]] && export PATH="/usr/lib/distcc/bin:$PATH"
|
2009-08-24 18:19:20 -04:00
|
|
|
export DISTCC_HOSTS
|
|
|
|
fi
|
|
|
|
|
|
|
|
# use ccache if it is requested (check buildenv and PKGBUILD opts)
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_buildenv "ccache" "y" && ! check_option "ccache" "n"; then
|
2009-11-12 15:07:34 -05:00
|
|
|
[[ -d /usr/lib/ccache/bin ]] && export PATH="/usr/lib/ccache/bin:$PATH"
|
2009-08-24 18:19:20 -04:00
|
|
|
fi
|
|
|
|
|
2012-01-26 10:28:31 -05:00
|
|
|
run_function_safe "build"
|
2009-08-24 18:19:20 -04:00
|
|
|
}
|
|
|
|
|
2010-12-15 09:06:43 -05:00
|
|
|
run_check() {
|
2012-01-26 10:28:31 -05:00
|
|
|
run_function_safe "check"
|
2010-12-15 09:06:43 -05:00
|
|
|
}
|
|
|
|
|
2009-08-24 18:19:20 -04:00
|
|
|
run_package() {
|
2010-06-25 19:16:36 -04:00
|
|
|
local pkgfunc
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -z $1 ]]; then
|
2009-08-24 18:19:20 -04:00
|
|
|
pkgfunc="package"
|
|
|
|
else
|
|
|
|
pkgfunc="package_$1"
|
|
|
|
fi
|
|
|
|
|
2012-01-26 10:28:31 -05:00
|
|
|
run_function_safe "$pkgfunc"
|
2009-01-16 07:20:05 -05:00
|
|
|
}
|
|
|
|
|
2012-09-23 09:23:26 -04:00
|
|
|
build_id() {
|
|
|
|
LANG=C readelf -n $1 | sed -n '/Build ID/ { s/.*: //p; q; }'
|
|
|
|
}
|
|
|
|
|
2012-09-23 07:28:03 -04:00
|
|
|
strip_file() {
|
|
|
|
local binary=$1; shift
|
2012-09-23 09:23:26 -04:00
|
|
|
|
|
|
|
if check_option "debug" "y"; then
|
|
|
|
local bid=$(build_id "$binary")
|
|
|
|
|
|
|
|
# has this file already been stripped
|
|
|
|
if [[ -n "$bid" ]]; then
|
2014-04-02 23:56:22 -04:00
|
|
|
if [[ -f "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug" ]]; then
|
2012-09-23 09:23:26 -04:00
|
|
|
return
|
|
|
|
fi
|
2012-09-29 02:44:36 -04:00
|
|
|
elif [[ -f "$dbgdir/$binary.debug" ]]; then
|
2012-09-23 09:23:26 -04:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2012-09-29 02:44:36 -04:00
|
|
|
mkdir -p "$dbgdir/${binary%/*}"
|
|
|
|
objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
|
|
|
|
objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
|
2012-09-23 09:23:26 -04:00
|
|
|
|
|
|
|
# create any needed hardlinks
|
2013-09-03 18:12:53 -04:00
|
|
|
while read -rd '' file ; do
|
2012-09-29 02:44:36 -04:00
|
|
|
if [[ "${binary}" -ef "${file}" && ! -f "$dbgdir/${file}.debug" ]]; then
|
|
|
|
mkdir -p "$dbgdir/${file%/*}"
|
|
|
|
ln "$dbgdir/${binary}.debug" "$dbgdir/${file}.debug"
|
2012-09-23 09:23:26 -04:00
|
|
|
fi
|
|
|
|
done < <(find . -type f -perm -u+w -print0 2>/dev/null)
|
|
|
|
|
|
|
|
if [[ -n "$bid" ]]; then
|
|
|
|
local target
|
2014-04-02 23:56:22 -04:00
|
|
|
mkdir -p "$dbgdir/.build-id/${bid:0:2}"
|
2012-09-23 09:23:26 -04:00
|
|
|
|
|
|
|
target="../../../../../${binary#./}"
|
|
|
|
target="${target/..\/..\/usr\/lib\/}"
|
|
|
|
target="${target/..\/usr\/}"
|
2014-04-02 23:56:22 -04:00
|
|
|
ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}"
|
2012-09-23 09:23:26 -04:00
|
|
|
|
|
|
|
target="../../${binary#./}.debug"
|
2014-04-02 23:56:22 -04:00
|
|
|
ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug"
|
2012-09-23 09:23:26 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-09-23 07:28:03 -04:00
|
|
|
strip $@ "$binary"
|
|
|
|
}
|
|
|
|
|
2007-04-11 15:05:54 -04:00
|
|
|
tidy_install() {
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "$pkgdir"
|
2007-05-14 11:36:04 -04:00
|
|
|
msg "$(gettext "Tidying install...")"
|
2007-04-11 15:06:01 -04:00
|
|
|
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
|
2008-08-12 13:00:18 -04:00
|
|
|
msg2 "$(gettext "Removing doc files...")"
|
2012-03-09 02:15:28 -05:00
|
|
|
rm -rf -- ${DOC_DIRS[@]}
|
2007-04-11 15:05:54 -04:00
|
|
|
fi
|
|
|
|
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
|
2011-06-10 22:00:20 -04:00
|
|
|
msg2 "$(gettext "Purging unwanted files...")"
|
2008-12-07 06:14:32 -05:00
|
|
|
local pt
|
|
|
|
for pt in "${PURGE_TARGETS[@]}"; do
|
2012-03-09 01:19:53 -05:00
|
|
|
if [[ ${pt} = "${pt//\/}" ]]; then
|
2013-03-04 20:03:44 -05:00
|
|
|
find . ! -type d -name "${pt}" -exec rm -f -- '{}' +
|
2008-12-07 06:14:32 -05:00
|
|
|
else
|
|
|
|
rm -f ${pt}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2013-01-28 21:14:02 -05:00
|
|
|
if check_option "libtool" "n"; then
|
|
|
|
msg2 "$(gettext "Removing "%s" files...")" "libtool"
|
2013-03-04 20:03:44 -05:00
|
|
|
find . ! -type d -name "*.la" -exec rm -f -- '{}' +
|
2013-01-28 21:14:02 -05:00
|
|
|
fi
|
|
|
|
|
2013-03-04 20:03:43 -05:00
|
|
|
if check_option "staticlibs" "n"; then
|
2013-10-31 08:28:55 -04:00
|
|
|
msg2 "$(gettext "Removing static library files...")"
|
2013-10-31 09:24:26 -04:00
|
|
|
local l
|
|
|
|
while read -rd '' l; do
|
|
|
|
if [[ -f "${l%.a}.so" ]]; then
|
|
|
|
rm "$l"
|
|
|
|
fi
|
|
|
|
done < <(find . ! -type d -name "*.a" -print0)
|
2013-03-04 20:03:43 -05:00
|
|
|
fi
|
|
|
|
|
2013-01-28 21:14:02 -05:00
|
|
|
if check_option "emptydirs" "n"; then
|
|
|
|
msg2 "$(gettext "Removing empty directories...")"
|
|
|
|
find . -depth -type d -exec rmdir '{}' + 2>/dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check existence of backup files
|
|
|
|
local file
|
|
|
|
for file in "${backup[@]}"; do
|
|
|
|
if [[ ! -f $file ]]; then
|
|
|
|
warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# check for references to the build and package directory
|
2013-07-21 21:09:58 -04:00
|
|
|
if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
|
2013-01-28 21:14:02 -05:00
|
|
|
warning "$(gettext "Package contains reference to %s")" "\$srcdir"
|
|
|
|
fi
|
2013-07-21 21:09:58 -04:00
|
|
|
if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then
|
2013-01-28 21:14:02 -05:00
|
|
|
warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
|
|
|
|
fi
|
|
|
|
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
|
2008-08-12 13:00:18 -04:00
|
|
|
msg2 "$(gettext "Compressing man and info pages...")"
|
2012-05-22 23:18:42 -04:00
|
|
|
local file files inode link
|
|
|
|
while read -rd ' ' inode; do
|
|
|
|
read file
|
|
|
|
find ${MAN_DIRS[@]} -type l 2>/dev/null |
|
2013-09-03 18:12:53 -04:00
|
|
|
while read -r link ; do
|
2012-05-22 23:18:42 -04:00
|
|
|
if [[ "${file}" -ef "${link}" ]] ; then
|
2011-06-26 15:13:48 -04:00
|
|
|
rm -f "$link" "${link}.gz"
|
2012-05-22 23:18:42 -04:00
|
|
|
if [[ ${file%/*} = ${link%/*} ]]; then
|
|
|
|
ln -s -- "${file##*/}.gz" "${link}.gz"
|
|
|
|
else
|
|
|
|
ln -s -- "/${file}.gz" "${link}.gz"
|
|
|
|
fi
|
2008-03-12 19:25:38 -04:00
|
|
|
fi
|
2012-05-22 23:18:42 -04:00
|
|
|
done
|
|
|
|
if [[ -z ${files[$inode]} ]]; then
|
|
|
|
files[$inode]=$file
|
2012-08-22 20:10:06 -04:00
|
|
|
gzip -9 -n -f "$file"
|
2012-05-22 23:18:42 -04:00
|
|
|
else
|
|
|
|
rm -f "$file"
|
|
|
|
ln "${files[$inode]}.gz" "${file}.gz"
|
|
|
|
chmod 644 "${file}.gz"
|
2007-12-04 18:50:29 -05:00
|
|
|
fi
|
2012-05-22 23:18:42 -04:00
|
|
|
done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
|
|
|
|
-exec @INODECMD@ '{}' + 2>/dev/null)
|
2008-03-12 19:25:38 -04:00
|
|
|
fi
|
2007-04-11 15:05:54 -04:00
|
|
|
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "strip" "y"; then
|
2009-12-21 14:26:28 -05:00
|
|
|
msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
|
2010-06-17 00:32:08 -04:00
|
|
|
# make sure library stripping variables are defined to prevent excess stripping
|
|
|
|
[[ -z ${STRIP_SHARED+x} ]] && STRIP_SHARED="-S"
|
|
|
|
[[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
|
2012-09-23 09:23:26 -04:00
|
|
|
|
|
|
|
if check_option "debug" "y"; then
|
2012-09-29 02:44:36 -04:00
|
|
|
dbgdir="$pkgdir-@DEBUGSUFFIX@/usr/lib/debug"
|
|
|
|
mkdir -p "$dbgdir"
|
2012-09-23 09:23:26 -04:00
|
|
|
fi
|
|
|
|
|
2012-09-23 07:28:03 -04:00
|
|
|
local binary strip_flags
|
2013-09-03 18:12:53 -04:00
|
|
|
find . -type f -perm -u+w -print0 2>/dev/null | while read -rd '' binary ; do
|
2010-05-24 17:32:55 -04:00
|
|
|
case "$(file -bi "$binary")" in
|
2008-07-18 00:20:24 -04:00
|
|
|
*application/x-sharedlib*) # Libraries (.so)
|
2012-09-23 07:28:03 -04:00
|
|
|
strip_flags="$STRIP_SHARED";;
|
2008-07-18 00:20:24 -04:00
|
|
|
*application/x-archive*) # Libraries (.a)
|
2012-09-23 07:28:03 -04:00
|
|
|
strip_flags="$STRIP_STATIC";;
|
2014-02-09 18:26:26 -05:00
|
|
|
*application/x-object*)
|
|
|
|
case "$binary" in
|
|
|
|
*.ko) # Kernel module
|
|
|
|
strip_flags="$STRIP_SHARED";;
|
|
|
|
*)
|
|
|
|
continue;;
|
|
|
|
esac;;
|
2007-04-11 15:05:54 -04:00
|
|
|
*application/x-executable*) # Binaries
|
2012-09-23 07:28:03 -04:00
|
|
|
strip_flags="$STRIP_BINARIES";;
|
|
|
|
*)
|
|
|
|
continue ;;
|
2007-04-11 15:05:54 -04:00
|
|
|
esac
|
2012-09-23 07:28:03 -04:00
|
|
|
strip_file "$binary" ${strip_flags}
|
2007-04-11 15:05:54 -04:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "upx" "y"; then
|
2011-06-14 08:01:05 -04:00
|
|
|
msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
|
|
|
|
local binary
|
2013-09-03 18:12:53 -04:00
|
|
|
find . -type f -perm -u+w 2>/dev/null | while read -r binary ; do
|
2011-06-14 08:01:05 -04:00
|
|
|
if [[ $(file -bi "$binary") = *'application/x-executable'* ]]; then
|
|
|
|
upx $UPXFLAGS "$binary" &>/dev/null ||
|
|
|
|
warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2007-04-11 15:05:54 -04:00
|
|
|
}
|
|
|
|
|
2010-02-10 11:11:37 -05:00
|
|
|
find_libdepends() {
|
2012-05-19 09:09:22 -04:00
|
|
|
local d sodepends;
|
|
|
|
|
|
|
|
sodepends=0;
|
|
|
|
for d in "${depends[@]}"; do
|
|
|
|
if [[ $d = *.so ]]; then
|
|
|
|
sodepends=1;
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if (( sodepends == 0 )); then
|
|
|
|
printf '%s\n' "${depends[@]}"
|
|
|
|
return;
|
|
|
|
fi
|
|
|
|
|
|
|
|
local libdeps filename soarch sofile soname soversion;
|
|
|
|
declare -A libdeps;
|
|
|
|
|
2013-09-03 18:12:53 -04:00
|
|
|
while read -r filename; do
|
2010-02-10 11:11:37 -05:00
|
|
|
# get architecture of the file; if soarch is empty it's not an ELF binary
|
|
|
|
soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
|
2012-05-19 09:09:22 -04:00
|
|
|
[[ -n "$soarch" ]] || continue
|
|
|
|
|
2010-02-10 11:11:37 -05:00
|
|
|
# process all libraries needed by the binary
|
|
|
|
for sofile in $(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p')
|
|
|
|
do
|
|
|
|
# extract the library name: libfoo.so
|
2012-03-04 13:17:21 -05:00
|
|
|
soname="${sofile%.so?(+(.+([0-9])))}".so
|
2010-02-10 11:11:37 -05:00
|
|
|
# extract the major version: 1
|
|
|
|
soversion="${sofile##*\.so\.}"
|
2012-05-19 09:09:22 -04:00
|
|
|
|
|
|
|
if [[ ${libdeps[$soname]} ]]; then
|
|
|
|
if [[ ${libdeps[$soname]} != *${soversion}-${soarch}* ]]; then
|
|
|
|
libdeps[$soname]+=" ${soversion}-${soarch}"
|
2010-02-10 11:11:37 -05:00
|
|
|
fi
|
2012-05-19 09:09:22 -04:00
|
|
|
else
|
|
|
|
libdeps[$soname]="${soversion}-${soarch}"
|
2010-02-10 11:11:37 -05:00
|
|
|
fi
|
|
|
|
done
|
2012-05-19 09:09:22 -04:00
|
|
|
done < <(find "$pkgdir" -type f -perm -u+x)
|
|
|
|
|
|
|
|
local libdepends v
|
|
|
|
for d in "${depends[@]}"; do
|
|
|
|
case "$d" in
|
|
|
|
*.so)
|
|
|
|
if [[ ${libdeps[$d]} ]]; then
|
|
|
|
for v in ${libdeps[$d]}; do
|
|
|
|
libdepends+=("$d=$v")
|
|
|
|
done
|
|
|
|
else
|
|
|
|
warning "$(gettext "Library listed in %s is not required by any files: %s")" "'depends'" "$d"
|
|
|
|
libdepends+=("$d")
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
libdepends+=("$d")
|
|
|
|
;;
|
|
|
|
esac
|
2010-02-10 11:11:37 -05:00
|
|
|
done
|
2012-05-19 09:09:22 -04:00
|
|
|
|
|
|
|
printf '%s\n' "${libdepends[@]}"
|
2010-02-10 11:11:37 -05:00
|
|
|
}
|
|
|
|
|
2012-05-19 09:09:22 -04:00
|
|
|
|
2010-02-10 11:07:30 -05:00
|
|
|
find_libprovides() {
|
2012-05-19 09:09:22 -04:00
|
|
|
local p libprovides missing
|
2012-03-11 15:40:11 -04:00
|
|
|
for p in "${provides[@]}"; do
|
2011-07-09 07:52:01 -04:00
|
|
|
missing=0
|
|
|
|
case "$p" in
|
|
|
|
*.so)
|
2012-05-12 22:13:11 -04:00
|
|
|
mapfile -t filename < <(find "$pkgdir" -type f -name $p\*)
|
2011-07-09 07:52:01 -04:00
|
|
|
if [[ $filename ]]; then
|
|
|
|
# packages may provide multiple versions of the same library
|
2012-03-11 15:40:11 -04:00
|
|
|
for fn in "${filename[@]}"; do
|
2011-07-09 07:52:01 -04:00
|
|
|
# check if we really have a shared object
|
|
|
|
if LC_ALL=C readelf -h "$fn" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
|
|
|
|
# get the string binaries link to (e.g. libfoo.so.1.2 -> libfoo.so.1)
|
|
|
|
local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
|
|
|
|
if [[ -z "$sofile" ]]; then
|
|
|
|
warning "$(gettext "Library listed in %s is not versioned: %s")" "'provides'" "$p"
|
2012-03-11 15:33:13 -04:00
|
|
|
libprovides+=("$p")
|
2011-07-09 07:52:01 -04:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# get the library architecture (32 or 64 bit)
|
|
|
|
local soarch=$(LC_ALL=C readelf -h "$fn" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
|
|
|
|
|
|
|
|
# extract the library major version
|
|
|
|
local soversion="${sofile##*\.so\.}"
|
|
|
|
|
2012-03-11 15:33:13 -04:00
|
|
|
libprovides+=("${p}=${soversion}-${soarch}")
|
2011-07-09 07:52:01 -04:00
|
|
|
else
|
|
|
|
warning "$(gettext "Library listed in %s is not a shared object: %s")" "'provides'" "$p"
|
2012-03-11 15:33:13 -04:00
|
|
|
libprovides+=("$p")
|
2011-07-09 07:52:01 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
2012-03-11 15:33:13 -04:00
|
|
|
libprovides+=("$p")
|
2011-07-09 07:52:01 -04:00
|
|
|
missing=1
|
2010-02-10 11:07:30 -05:00
|
|
|
fi
|
2011-07-09 07:52:01 -04:00
|
|
|
;;
|
|
|
|
*)
|
2012-03-11 15:33:13 -04:00
|
|
|
libprovides+=("$p")
|
2011-07-09 07:52:01 -04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if (( missing )); then
|
2012-11-19 19:13:10 -05:00
|
|
|
warning "$(gettext "Cannot find library listed in %s: %s")" "'provides'" "$p"
|
2011-07-09 07:52:01 -04:00
|
|
|
fi
|
2010-02-10 11:07:30 -05:00
|
|
|
done
|
2011-07-09 07:52:01 -04:00
|
|
|
|
2012-04-08 18:28:39 -04:00
|
|
|
printf '%s\n' "${libprovides[@]}"
|
2010-02-10 11:07:30 -05:00
|
|
|
}
|
|
|
|
|
2009-06-22 02:04:44 -04:00
|
|
|
write_pkginfo() {
|
2007-09-19 01:21:56 -04:00
|
|
|
local builddate=$(date -u "+%s")
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -n $PACKAGER ]]; then
|
2007-04-11 15:05:47 -04:00
|
|
|
local packager="$PACKAGER"
|
2007-04-11 15:05:23 -04:00
|
|
|
else
|
2007-12-16 23:00:12 -05:00
|
|
|
local packager="Unknown Packager"
|
2007-04-11 15:05:23 -04:00
|
|
|
fi
|
2012-03-27 23:43:46 -04:00
|
|
|
|
2012-12-16 07:32:54 -05:00
|
|
|
local size="$(@DUPATH@ @DUFLAGS@)"
|
2012-04-07 12:20:08 -04:00
|
|
|
size="$(( ${size%%[^0-9]*} * 1024 ))"
|
2007-04-11 15:05:23 -04:00
|
|
|
|
2011-06-17 22:40:14 -04:00
|
|
|
msg2 "$(gettext "Generating %s file...")" ".PKGINFO"
|
2013-01-15 23:45:42 -05:00
|
|
|
printf "# Generated by makepkg %s\n" "$makepkg_version"
|
2014-03-08 05:46:21 -05:00
|
|
|
printf "# using %s\n" "$(fakeroot -v)"
|
2013-01-15 23:45:42 -05:00
|
|
|
printf "# %s\n" "$(LC_ALL=C date -u)"
|
2013-11-01 07:34:34 -04:00
|
|
|
|
2012-09-23 10:06:36 -04:00
|
|
|
printf "pkgname = %s\n" "$pkgname"
|
2013-11-01 07:34:34 -04:00
|
|
|
if (( SPLITPKG )) || [[ "$pkgbase" != "$pkgname" ]]; then
|
|
|
|
printf "pkgbase = %s\n" "$pkgbase"
|
|
|
|
fi
|
|
|
|
|
|
|
|
local fullver=$(get_full_version)
|
|
|
|
printf "pkgver = %s\n" "$fullver"
|
|
|
|
if [[ "$fullver" != "$basever" ]]; then
|
|
|
|
printf "basever = %s\n" "$basever"
|
|
|
|
fi
|
|
|
|
|
2012-11-25 16:02:47 -05:00
|
|
|
printf "pkgdesc = %s\n" "${pkgdesc//+([[:space:]])/ }"
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "url = %s\n" "$url"
|
|
|
|
printf "builddate = %s\n" "$builddate"
|
|
|
|
printf "packager = %s\n" "$packager"
|
|
|
|
printf "size = %s\n" "$size"
|
2012-03-09 06:09:35 -05:00
|
|
|
printf "arch = %s\n" "$pkgarch"
|
2007-04-11 15:05:23 -04:00
|
|
|
|
2012-05-12 22:13:11 -04:00
|
|
|
mapfile -t provides < <(find_libprovides)
|
2012-05-19 09:09:22 -04:00
|
|
|
mapfile -t depends < <(find_libdepends)
|
|
|
|
|
2012-06-07 02:21:05 -04:00
|
|
|
[[ $license ]] && printf "license = %s\n" "${license[@]}"
|
|
|
|
[[ $replaces ]] && printf "replaces = %s\n" "${replaces[@]}"
|
|
|
|
[[ $groups ]] && printf "group = %s\n" "${groups[@]}"
|
|
|
|
[[ $conflicts ]] && printf "conflict = %s\n" "${conflicts[@]}"
|
|
|
|
[[ $provides ]] && printf "provides = %s\n" "${provides[@]}"
|
|
|
|
[[ $backup ]] && printf "backup = %s\n" "${backup[@]}"
|
|
|
|
[[ $depends ]] && printf "depend = %s\n" "${depends[@]}"
|
|
|
|
[[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]//+([[:space:]])/ }"
|
|
|
|
[[ $makedepends ]] && printf "makedepend = %s\n" "${makedepends[@]}"
|
|
|
|
[[ $checkdepends ]] && printf "checkdepend = %s\n" "${checkdepends[@]}"
|
2010-02-10 11:07:30 -05:00
|
|
|
|
2011-07-09 07:52:01 -04:00
|
|
|
local it
|
2008-09-27 00:47:29 -04:00
|
|
|
for it in "${packaging_options[@]}"; do
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
check_option "$it" "y"
|
|
|
|
case $? in
|
|
|
|
0)
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "makepkgopt = %s\n" "$it"
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
;;
|
|
|
|
1)
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "makepkgopt = %s\n" "!$it"
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
;;
|
|
|
|
esac
|
2008-09-27 00:47:29 -04:00
|
|
|
done
|
2009-06-22 02:04:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
create_package() {
|
2014-03-03 14:29:54 -05:00
|
|
|
(( NOARCHIVE )) && return
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ ! -d $pkgdir ]]; then
|
2013-10-08 23:20:11 -04:00
|
|
|
error "$(gettext "Missing %s directory.")" "\$pkgdir/"
|
2009-06-22 02:04:44 -04:00
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_MISSING_PKGDIR
|
|
|
|
fi
|
|
|
|
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "$pkgdir"
|
2012-09-23 10:06:36 -04:00
|
|
|
msg "$(gettext "Creating package \"%s\"...")" "$pkgname"
|
2009-06-22 02:04:44 -04:00
|
|
|
|
2012-03-09 06:09:35 -05:00
|
|
|
pkgarch=$(get_pkg_arch)
|
2012-09-23 10:06:36 -04:00
|
|
|
write_pkginfo > .PKGINFO
|
2009-06-22 02:04:44 -04:00
|
|
|
|
2012-02-29 21:56:40 -05:00
|
|
|
local comp_files=('.PKGINFO')
|
2007-04-11 15:05:47 -04:00
|
|
|
|
2010-06-25 19:16:40 -04:00
|
|
|
# check for changelog/install files
|
2011-03-29 20:35:48 -04:00
|
|
|
for i in 'changelog/.CHANGELOG' 'install/.INSTALL'; do
|
2011-06-28 22:35:44 -04:00
|
|
|
IFS='/' read -r orig dest < <(printf '%s\n' "$i")
|
2010-06-25 19:16:40 -04:00
|
|
|
|
2011-03-29 20:35:48 -04:00
|
|
|
if [[ -n ${!orig} ]]; then
|
|
|
|
msg2 "$(gettext "Adding %s file...")" "$orig"
|
|
|
|
cp "$startdir/${!orig}" "$dest"
|
2010-06-25 19:16:40 -04:00
|
|
|
chmod 644 "$dest"
|
2012-02-29 21:56:40 -05:00
|
|
|
comp_files+=("$dest")
|
2010-06-25 19:16:40 -04:00
|
|
|
fi
|
|
|
|
done
|
2007-04-11 15:05:23 -04:00
|
|
|
|
|
|
|
# tar it up
|
2011-07-22 07:42:53 -04:00
|
|
|
local fullver=$(get_full_version)
|
2012-09-23 10:06:36 -04:00
|
|
|
local pkg_file="$PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT}"
|
2009-02-19 13:12:34 -05:00
|
|
|
local ret=0
|
2007-04-11 15:05:23 -04:00
|
|
|
|
2009-08-24 14:22:12 -04:00
|
|
|
[[ -f $pkg_file ]] && rm -f "$pkg_file"
|
|
|
|
[[ -f $pkg_file.sig ]] && rm -f "$pkg_file.sig"
|
|
|
|
|
2008-08-01 02:29:46 -04:00
|
|
|
# when fileglobbing, we want * in an empty directory to expand to
|
|
|
|
# the null string rather than itself
|
|
|
|
shopt -s nullglob
|
2012-04-30 02:15:47 -04:00
|
|
|
|
|
|
|
msg2 "$(gettext "Generating .MTREE file...")"
|
|
|
|
bsdtar -czf .MTREE --format=mtree \
|
|
|
|
--options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
|
|
|
|
"${comp_files[@]}" *
|
|
|
|
comp_files+=(".MTREE")
|
|
|
|
|
|
|
|
msg2 "$(gettext "Compressing package...")"
|
2010-08-27 12:23:32 -04:00
|
|
|
# TODO: Maybe this can be set globally for robustness
|
|
|
|
shopt -s -o pipefail
|
2011-10-01 03:31:00 -04:00
|
|
|
# bsdtar's gzip compression always saves the time stamp, making one
|
|
|
|
# archive created using the same command line distinct from another.
|
|
|
|
# Disable bsdtar compression and use gzip -n for now.
|
2012-02-29 21:56:40 -05:00
|
|
|
bsdtar -cf - "${comp_files[@]}" * |
|
2010-08-27 12:23:32 -04:00
|
|
|
case "$PKGEXT" in
|
2012-02-11 04:48:59 -05:00
|
|
|
*tar.gz) ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
|
|
|
|
*tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
|
|
|
|
*tar.xz) ${COMPRESSXZ[@]:-xz -c -z -} ;;
|
2013-02-09 10:04:21 -05:00
|
|
|
*tar.lrz) ${COMPRESSLRZ[@]:-lrzip -q} ;;
|
2013-02-12 21:18:31 -05:00
|
|
|
*tar.lzo) ${COMPRESSLZO[@]:-lzop -q} ;;
|
2012-02-11 04:48:59 -05:00
|
|
|
*tar.Z) ${COMPRESSZ[@]:-compress -c -f} ;;
|
2011-10-01 03:31:00 -04:00
|
|
|
*tar) cat ;;
|
|
|
|
*) warning "$(gettext "'%s' is not a valid archive extension.")" \
|
|
|
|
"$PKGEXT"; cat ;;
|
2011-05-01 20:33:22 -04:00
|
|
|
esac > "${pkg_file}" || ret=$?
|
2008-08-01 02:29:46 -04:00
|
|
|
|
2010-08-27 12:23:32 -04:00
|
|
|
shopt -u nullglob
|
|
|
|
shopt -u -o pipefail
|
2009-02-19 13:12:34 -05:00
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ret )); then
|
2007-04-11 15:05:23 -04:00
|
|
|
error "$(gettext "Failed to create package file.")"
|
2007-04-11 15:05:47 -04:00
|
|
|
exit 1 # TODO: error code
|
2007-04-11 15:05:23 -04:00
|
|
|
fi
|
2009-11-02 23:31:15 -05:00
|
|
|
|
2010-03-31 01:00:33 -04:00
|
|
|
create_signature "$pkg_file"
|
|
|
|
|
2010-10-04 04:42:10 -04:00
|
|
|
if (( ! ret )) && [[ ! "$PKGDEST" -ef "${startdir}" ]]; then
|
2011-06-26 15:13:48 -04:00
|
|
|
rm -f "${pkg_file/$PKGDEST/$startdir}"
|
|
|
|
ln -s "${pkg_file}" "${pkg_file/$PKGDEST/$startdir}"
|
2009-11-02 23:31:15 -05:00
|
|
|
ret=$?
|
2011-06-26 15:13:48 -04:00
|
|
|
if [[ -f $pkg_file.sig ]]; then
|
|
|
|
rm -f "${pkg_file/$PKGDEST/$startdir}.sig"
|
|
|
|
ln -s "$pkg_file.sig" "${pkg_file/$PKGDEST/$startdir}.sig"
|
|
|
|
fi
|
2009-11-02 23:31:15 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
if (( ret )); then
|
|
|
|
warning "$(gettext "Failed to create symlink to package file.")"
|
|
|
|
fi
|
2007-05-30 06:48:18 -04:00
|
|
|
}
|
|
|
|
|
2012-09-23 10:30:46 -04:00
|
|
|
create_debug_package() {
|
|
|
|
# check if a debug package was requested
|
|
|
|
if ! check_option "debug" "y" || ! check_option "strip" "y"; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2012-09-29 02:17:12 -04:00
|
|
|
pkgdir="${pkgdir}-@DEBUGSUFFIX@"
|
2012-09-23 10:30:46 -04:00
|
|
|
|
|
|
|
# check if we have any debug symbols to package
|
|
|
|
if dir_is_empty "$pkgdir/usr/lib/debug"; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
depends=("$pkgname=$(get_full_version)")
|
|
|
|
pkgdesc="Detached debugging symbols for $pkgname"
|
2012-09-29 02:17:12 -04:00
|
|
|
pkgname=$pkgname-@DEBUGSUFFIX@
|
2012-09-23 10:30:46 -04:00
|
|
|
|
|
|
|
unset groups optdepends provides conflicts replaces backup install changelog
|
|
|
|
|
|
|
|
create_package
|
|
|
|
}
|
|
|
|
|
2008-06-02 04:27:00 -04:00
|
|
|
create_signature() {
|
2011-03-25 22:06:06 -04:00
|
|
|
if [[ $SIGNPKG != 'y' ]]; then
|
2008-06-02 04:27:00 -04:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
local ret=0
|
2009-08-24 14:22:12 -04:00
|
|
|
local filename="$1"
|
2008-06-02 04:27:00 -04:00
|
|
|
msg "$(gettext "Signing package...")"
|
2011-03-25 22:06:06 -04:00
|
|
|
|
|
|
|
local SIGNWITHKEY=""
|
2011-04-17 08:38:35 -04:00
|
|
|
if [[ -n $GPGKEY ]]; then
|
|
|
|
SIGNWITHKEY="-u ${GPGKEY}"
|
2011-03-25 22:06:06 -04:00
|
|
|
fi
|
|
|
|
# The signature will be generated directly in ascii-friendly format
|
2014-02-02 01:29:14 -05:00
|
|
|
gpg --detach-sign --use-agent ${SIGNWITHKEY} --no-armor "$filename" &>/dev/null || ret=$?
|
2011-03-25 22:06:06 -04:00
|
|
|
|
|
|
|
|
2008-06-02 04:27:00 -04:00
|
|
|
if (( ! ret )); then
|
2009-08-24 14:22:12 -04:00
|
|
|
msg2 "$(gettext "Created signature file %s.")" "$filename.sig"
|
2008-06-02 04:27:00 -04:00
|
|
|
else
|
|
|
|
warning "$(gettext "Failed to sign package file.")"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-05-30 14:27:13 -04:00
|
|
|
create_srcpackage() {
|
2011-09-30 03:32:49 -04:00
|
|
|
local ret=0
|
2007-05-30 14:27:13 -04:00
|
|
|
msg "$(gettext "Creating source package...")"
|
2008-06-06 21:58:21 -04:00
|
|
|
local srclinks="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)"
|
2009-03-06 03:28:47 -05:00
|
|
|
mkdir "${srclinks}"/${pkgbase}
|
2008-06-06 21:58:21 -04:00
|
|
|
|
2008-02-20 09:08:31 -05:00
|
|
|
msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT"
|
2009-07-12 03:10:11 -04:00
|
|
|
ln -s "${BUILDFILE}" "${srclinks}/${pkgbase}/${BUILDSCRIPT}"
|
2007-05-30 14:27:13 -04:00
|
|
|
|
2010-06-03 11:32:50 -04:00
|
|
|
local file
|
|
|
|
for file in "${source[@]}"; do
|
2012-03-09 01:19:53 -05:00
|
|
|
if [[ "$file" = "$(get_filename "$file")" ]] || (( SOURCEONLY == 2 )); then
|
2012-01-08 06:48:04 -05:00
|
|
|
local absfile
|
|
|
|
absfile=$(get_filepath "$file") || missing_source_file "$file"
|
2010-06-03 11:32:50 -04:00
|
|
|
msg2 "$(gettext "Adding %s...")" "${absfile##*/}"
|
|
|
|
ln -s "$absfile" "$srclinks/$pkgbase"
|
2007-05-30 14:27:13 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-05-25 17:02:07 -04:00
|
|
|
local i
|
|
|
|
for i in 'changelog' 'install'; do
|
2010-04-26 00:59:42 -04:00
|
|
|
local file
|
2011-08-30 10:31:49 -04:00
|
|
|
while read -r file; do
|
2010-04-26 00:59:42 -04:00
|
|
|
# evaluate any bash variables used
|
2011-08-22 20:50:17 -04:00
|
|
|
eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
|
2011-11-10 06:05:11 -05:00
|
|
|
if [[ $file && ! -f "${srclinks}/${pkgbase}/$file" ]]; then
|
2010-06-08 23:45:22 -04:00
|
|
|
msg2 "$(gettext "Adding %s file (%s)...")" "$i" "${file}"
|
2010-04-26 00:59:42 -04:00
|
|
|
ln -s "${startdir}/$file" "${srclinks}/${pkgbase}/"
|
|
|
|
fi
|
2011-08-30 10:31:49 -04:00
|
|
|
done < <(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE")
|
2010-05-25 17:02:07 -04:00
|
|
|
done
|
2010-04-26 00:59:42 -04:00
|
|
|
|
2008-09-04 21:44:19 -04:00
|
|
|
local TAR_OPT
|
|
|
|
case "$SRCEXT" in
|
2013-02-09 10:04:21 -05:00
|
|
|
*tar.gz) TAR_OPT="-z" ;;
|
|
|
|
*tar.bz2) TAR_OPT="-j" ;;
|
|
|
|
*tar.xz) TAR_OPT="-J" ;;
|
|
|
|
*tar.lrz) TAR_OPT="--lrzip" ;;
|
2013-02-12 21:18:31 -05:00
|
|
|
*tar.lzo) TAR_OPT="--lzop" ;;
|
2013-02-09 10:04:21 -05:00
|
|
|
*tar.Z) TAR_OPT="-Z" ;;
|
2010-08-07 06:47:59 -04:00
|
|
|
*tar) TAR_OPT="" ;;
|
2008-09-04 21:44:19 -04:00
|
|
|
*) warning "$(gettext "'%s' is not a valid archive extension.")" \
|
|
|
|
"$SRCEXT" ;;
|
|
|
|
esac
|
|
|
|
|
2011-07-22 07:42:53 -04:00
|
|
|
local fullver=$(get_full_version)
|
2011-01-20 19:16:06 -05:00
|
|
|
local pkg_file="$SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT}"
|
2007-05-30 14:27:13 -04:00
|
|
|
|
|
|
|
# tar it up
|
|
|
|
msg2 "$(gettext "Compressing source package...")"
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "${srclinks}"
|
2013-02-09 10:04:21 -05:00
|
|
|
if ! bsdtar -cL ${TAR_OPT} -f "$pkg_file" ${pkgbase}; then
|
2007-05-30 14:27:13 -04:00
|
|
|
error "$(gettext "Failed to create source package file.")"
|
|
|
|
exit 1 # TODO: error code
|
|
|
|
fi
|
2010-06-23 01:35:56 -04:00
|
|
|
|
2013-11-01 01:47:20 -04:00
|
|
|
create_signature "$pkg_file"
|
|
|
|
|
2011-09-30 03:32:49 -04:00
|
|
|
if [[ ! "$SRCPKGDEST" -ef "${startdir}" ]]; then
|
2011-06-26 15:13:48 -04:00
|
|
|
rm -f "${pkg_file/$SRCPKGDEST/$startdir}"
|
|
|
|
ln -s "${pkg_file}" "${pkg_file/$SRCPKGDEST/$startdir}"
|
2011-02-01 09:59:34 -05:00
|
|
|
ret=$?
|
2013-11-01 01:47:20 -04:00
|
|
|
if [[ -f $pkg_file.sig ]]; then
|
|
|
|
rm -f "${pkg_file/$PKGDEST/$startdir}.sig"
|
|
|
|
ln -s "$pkg_file.sig" "${pkg_file/$PKGDEST/$startdir}.sig"
|
|
|
|
fi
|
2011-02-01 09:59:34 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
if (( ret )); then
|
|
|
|
warning "$(gettext "Failed to create symlink to source package file.")"
|
|
|
|
fi
|
2010-06-23 01:35:56 -04:00
|
|
|
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "${startdir}"
|
2008-06-22 06:11:54 -04:00
|
|
|
rm -rf "${srclinks}"
|
2007-05-30 14:27:13 -04:00
|
|
|
}
|
|
|
|
|
2014-03-05 04:45:22 -05:00
|
|
|
# this function always returns 0 to make sure clean-up will still occur
|
2007-06-02 13:39:47 -04:00
|
|
|
install_package() {
|
2009-11-12 15:09:05 -05:00
|
|
|
(( ! INSTALL )) && return
|
2009-03-25 09:52:27 -04:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! SPLITPKG )); then
|
2011-06-17 22:40:14 -04:00
|
|
|
msg "$(gettext "Installing package %s with %s...")" "$pkgname" "$PACMAN -U"
|
2009-03-25 09:52:27 -04:00
|
|
|
else
|
2011-06-17 22:40:14 -04:00
|
|
|
msg "$(gettext "Installing %s package group with %s...")" "$pkgbase" "$PACMAN -U"
|
2009-03-25 09:52:27 -04:00
|
|
|
fi
|
|
|
|
|
2012-03-09 06:09:35 -05:00
|
|
|
local fullver pkgarch pkg pkglist
|
2012-07-09 01:55:58 -04:00
|
|
|
(( ASDEPS )) && pkglist+=('--asdeps')
|
2013-02-09 13:57:39 -05:00
|
|
|
(( NEEDED )) && pkglist+=('--needed')
|
2012-07-09 01:55:58 -04:00
|
|
|
|
2009-03-25 09:52:27 -04:00
|
|
|
for pkg in ${pkgname[@]}; do
|
2011-07-22 07:42:53 -04:00
|
|
|
fullver=$(get_full_version $pkg)
|
2012-03-09 06:09:35 -05:00
|
|
|
pkgarch=$(get_pkg_arch $pkg)
|
2012-04-09 02:27:00 -04:00
|
|
|
pkglist+=("$PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT}")
|
2012-09-29 02:54:19 -04:00
|
|
|
|
|
|
|
if [[ -f "$PKGDEST/${pkg}-debug-${fullver}-${pkgarch}${PKGEXT}" ]]; then
|
|
|
|
pkglist+=("$PKGDEST/${pkg}-debug-${fullver}-${pkgarch}${PKGEXT}")
|
|
|
|
fi
|
2009-03-25 09:52:27 -04:00
|
|
|
done
|
|
|
|
|
2013-06-19 16:38:57 -04:00
|
|
|
if ! run_pacman -U "${pkglist[@]}"; then
|
2009-03-29 02:49:57 -04:00
|
|
|
warning "$(gettext "Failed to install built package(s).")"
|
|
|
|
return 0
|
2007-02-11 16:47:37 -05:00
|
|
|
fi
|
|
|
|
}
|
2007-01-16 23:54:55 -05:00
|
|
|
|
2013-05-18 09:43:27 -04:00
|
|
|
have_function() {
|
|
|
|
declare -f "$1" >/dev/null
|
|
|
|
}
|
|
|
|
|
2009-06-06 13:49:37 -04:00
|
|
|
check_sanity() {
|
|
|
|
# check for no-no's in the build script
|
2010-06-17 08:44:46 -04:00
|
|
|
local i
|
2011-01-10 14:56:27 -05:00
|
|
|
local ret=0
|
2012-07-16 07:56:32 -04:00
|
|
|
for i in 'pkgname' 'pkgrel'; do
|
2010-06-17 08:44:46 -04:00
|
|
|
if [[ -z ${!i} ]]; then
|
|
|
|
error "$(gettext "%s is not allowed to be empty.")" "$i"
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2010-06-17 08:44:46 -04:00
|
|
|
fi
|
|
|
|
done
|
2009-10-26 08:21:43 -04:00
|
|
|
|
2010-08-05 07:35:54 -04:00
|
|
|
for i in "${pkgname[@]}"; do
|
|
|
|
if [[ ${i:0:1} = "-" ]]; then
|
2009-10-26 08:21:43 -04:00
|
|
|
error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname"
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2009-10-26 08:21:43 -04:00
|
|
|
fi
|
2013-06-03 23:38:48 -04:00
|
|
|
if [[ ${i:0:1} = "." ]]; then
|
|
|
|
error "$(gettext "%s is not allowed to start with a dot.")" "pkgname"
|
|
|
|
ret=1
|
|
|
|
fi
|
2012-04-13 15:40:30 -04:00
|
|
|
if [[ $i = *[^[:alnum:]+_.@-]* ]]; then
|
|
|
|
error "$(gettext "%s contains invalid characters: '%s'")" \
|
|
|
|
'pkgname' "${pkgname//[[:alnum:]+_.@-]}"
|
|
|
|
ret=1
|
|
|
|
fi
|
2009-10-26 08:21:43 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
if [[ ${pkgbase:0:1} = "-" ]]; then
|
|
|
|
error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase"
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2009-06-09 15:33:12 -04:00
|
|
|
fi
|
2011-07-21 22:37:25 -04:00
|
|
|
|
2012-07-16 08:25:24 -04:00
|
|
|
if (( ! PKGVERFUNC )) ; then
|
2012-07-16 07:56:32 -04:00
|
|
|
check_pkgver || ret=1
|
|
|
|
fi
|
2011-07-21 22:37:25 -04:00
|
|
|
|
2011-10-08 05:38:01 -04:00
|
|
|
awk -F'=' '$1 ~ /^[[:space:]]*pkgrel$/' "$BUILDFILE" | sed "s/[[:space:]]*#.*//" |
|
2011-09-06 14:40:29 -04:00
|
|
|
while IFS='=' read -r _ i; do
|
2011-11-18 08:35:21 -05:00
|
|
|
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
|
2012-02-15 00:01:45 -05:00
|
|
|
if [[ $i != +([0-9])?(.+([0-9])) ]]; then
|
|
|
|
error "$(gettext "%s must be a decimal.")" "pkgrel"
|
2011-07-22 02:30:41 -04:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done || ret=1
|
2009-06-06 13:49:37 -04:00
|
|
|
|
2011-09-06 14:40:29 -04:00
|
|
|
awk -F'=' '$1 ~ /^[[:space:]]*epoch$/' "$BUILDFILE" |
|
|
|
|
while IFS='=' read -r _ i; do
|
2011-11-18 08:35:21 -05:00
|
|
|
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
|
2011-09-03 22:24:27 -04:00
|
|
|
if [[ $i != *([[:digit:]]) ]]; then
|
2011-07-22 06:08:39 -04:00
|
|
|
error "$(gettext "%s must be an integer.")" "epoch"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done || ret=1
|
2010-10-11 18:18:05 -04:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ $arch != 'any' ]]; then
|
2013-10-20 08:49:51 -04:00
|
|
|
if ! in_array $CARCH "${arch[@]}"; then
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! IGNOREARCH )); then
|
2009-10-11 10:13:16 -04:00
|
|
|
error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgbase" "$CARCH"
|
|
|
|
plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
|
2011-06-17 22:40:14 -04:00
|
|
|
plain "$(gettext "such as %s.")" "arch=('$CARCH')"
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2009-10-11 10:13:16 -04:00
|
|
|
fi
|
2009-06-06 13:49:37 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-07-22 05:47:07 -04:00
|
|
|
if (( ${#pkgname[@]} > 1 )); then
|
|
|
|
for i in ${pkgname[@]}; do
|
|
|
|
local arch_list=""
|
|
|
|
eval $(declare -f package_${i} | sed -n 's/\(^[[:space:]]*arch=\)/arch_list=/p')
|
|
|
|
if [[ ${arch_list[@]} && ${arch_list} != 'any' ]]; then
|
2013-10-20 08:49:51 -04:00
|
|
|
if ! in_array $CARCH "${arch_list[@]}"; then
|
2011-07-22 05:47:07 -04:00
|
|
|
if (( ! IGNOREARCH )); then
|
|
|
|
error "$(gettext "%s is not available for the '%s' architecture.")" "$i" "$CARCH"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2011-02-02 20:01:01 -05:00
|
|
|
local provides_list=()
|
2011-03-18 01:17:53 -04:00
|
|
|
eval $(awk '/^[[:space:]]*provides=/,/\)/' "$BUILDFILE" | \
|
2011-03-30 21:08:55 -04:00
|
|
|
sed -e "s/provides=/provides_list+=/" -e "s/#.*//" -e 's/\\$//')
|
2010-12-07 02:48:16 -05:00
|
|
|
for i in ${provides_list[@]}; do
|
2011-09-28 14:06:03 -04:00
|
|
|
if [[ $i == *['<>']* ]]; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "%s array cannot contain comparison (< or >) operators.")" "provides"
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2009-06-06 13:49:37 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2011-02-02 20:01:01 -05:00
|
|
|
local backup_list=()
|
2011-03-18 01:17:53 -04:00
|
|
|
eval $(awk '/^[[:space:]]*backup=/,/\)/' "$BUILDFILE" | \
|
2011-03-30 21:08:55 -04:00
|
|
|
sed -e "s/backup=/backup_list+=/" -e "s/#.*//" -e 's/\\$//')
|
2010-12-07 02:48:16 -05:00
|
|
|
for i in "${backup_list[@]}"; do
|
2010-08-05 07:35:54 -04:00
|
|
|
if [[ ${i:0:1} = "/" ]]; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "%s entry should not contain leading slash : %s")" "backup" "$i"
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2009-08-18 14:30:04 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2011-02-02 20:01:01 -05:00
|
|
|
local optdepends_list=()
|
2011-04-02 06:31:19 -04:00
|
|
|
eval $(awk '/^[[:space:]]*optdepends=\(/,/\)[[:space:]]*(#.*)?$/' "$BUILDFILE" | \
|
2011-03-30 21:08:55 -04:00
|
|
|
sed -e "s/optdepends=/optdepends_list+=/" -e "s/#.*//" -e 's/\\$//')
|
2010-12-07 02:48:16 -05:00
|
|
|
for i in "${optdepends_list[@]}"; do
|
2011-09-24 00:53:20 -04:00
|
|
|
local pkg=${i%%:[[:space:]]*}
|
2011-09-27 11:27:54 -04:00
|
|
|
# the '-' character _must_ be first or last in the character range
|
|
|
|
if [[ $pkg != +([-[:alnum:]><=.+_:]) ]]; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "Invalid syntax for %s : '%s'")" "optdepend" "$i"
|
2011-02-02 19:15:36 -05:00
|
|
|
ret=1
|
2009-08-30 16:05:46 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-05-25 17:02:07 -04:00
|
|
|
for i in 'changelog' 'install'; do
|
2010-04-26 00:59:42 -04:00
|
|
|
local file
|
2011-08-30 10:31:49 -04:00
|
|
|
while read -r file; do
|
2010-04-26 00:59:42 -04:00
|
|
|
# evaluate any bash variables used
|
2011-08-22 20:50:17 -04:00
|
|
|
eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
|
2011-09-12 08:27:13 -04:00
|
|
|
if [[ $file && ! -f $file ]]; then
|
2010-06-25 19:16:45 -04:00
|
|
|
error "$(gettext "%s file (%s) does not exist.")" "$i" "$file"
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2010-04-26 00:59:42 -04:00
|
|
|
fi
|
2011-08-30 10:31:49 -04:00
|
|
|
done < <(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE")
|
2010-05-25 17:02:07 -04:00
|
|
|
done
|
2009-10-08 10:10:05 -04:00
|
|
|
|
2009-06-06 13:49:37 -04:00
|
|
|
local valid_options=1
|
2010-12-07 02:48:16 -05:00
|
|
|
local known kopt options_list
|
2011-03-18 01:17:53 -04:00
|
|
|
eval $(awk '/^[[:space:]]*options=/,/\)/' "$BUILDFILE" | \
|
2011-03-30 21:08:55 -04:00
|
|
|
sed -e "s/options=/options_list+=/" -e "s/#.*//" -e 's/\\$//')
|
2010-12-07 02:48:16 -05:00
|
|
|
for i in ${options_list[@]}; do
|
2009-06-06 13:49:37 -04:00
|
|
|
known=0
|
|
|
|
# check if option matches a known option or its inverse
|
|
|
|
for kopt in ${packaging_options[@]} ${other_options[@]}; do
|
2012-03-09 01:19:53 -05:00
|
|
|
if [[ ${i} = "${kopt}" || ${i} = "!${kopt}" ]]; then
|
2009-06-06 13:49:37 -04:00
|
|
|
known=1
|
|
|
|
fi
|
|
|
|
done
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! known )); then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "%s array contains unknown option '%s'")" "options" "$i"
|
2009-06-06 13:49:37 -04:00
|
|
|
valid_options=0
|
|
|
|
fi
|
|
|
|
done
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! valid_options )); then
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2009-06-06 13:49:37 -04:00
|
|
|
fi
|
|
|
|
|
2013-05-18 10:03:36 -04:00
|
|
|
if (( ${#pkgname[@]} == 1 )); then
|
|
|
|
if have_function build && ! ( have_function package || have_function package_${pkgname}); then
|
|
|
|
error "$(gettext "Missing %s function in %s")" "package()" "$BUILDFILE"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
else
|
2010-08-05 07:35:54 -04:00
|
|
|
for i in ${pkgname[@]}; do
|
2013-05-18 09:43:27 -04:00
|
|
|
if ! have_function package_${i}; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "Missing %s function for split package '%s'")" "package_$i()" "$i"
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2009-07-03 13:16:14 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2010-08-05 07:35:54 -04:00
|
|
|
for i in ${PKGLIST[@]}; do
|
|
|
|
if ! in_array $i ${pkgname[@]}; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "Requested package %s is not provided in %s")" "$i" "$BUILDFILE"
|
2011-01-10 14:56:27 -05:00
|
|
|
ret=1
|
2010-08-05 07:12:11 -04:00
|
|
|
fi
|
|
|
|
done
|
2009-10-22 00:40:03 -04:00
|
|
|
|
2013-09-03 20:03:04 -04:00
|
|
|
local idx=("${!source[@]}")
|
2013-10-18 00:32:20 -04:00
|
|
|
if (( ${#source[*]} > 0 && (idx[-1] + 1) != ${#source[*]} )); then
|
2013-09-03 20:03:04 -04:00
|
|
|
error "$(gettext "Sparse arrays are not allowed for source")"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
|
2011-01-10 14:56:27 -05:00
|
|
|
return $ret
|
2009-06-06 13:49:37 -04:00
|
|
|
}
|
|
|
|
|
2013-10-14 09:13:28 -04:00
|
|
|
validate_pkgver() {
|
|
|
|
if [[ $1 = *[[:space:]:-]* ]]; then
|
|
|
|
error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-07-16 07:56:32 -04:00
|
|
|
check_pkgver() {
|
|
|
|
local ret=0
|
|
|
|
|
|
|
|
if [[ -z ${pkgver} ]]; then
|
|
|
|
error "$(gettext "%s is not allowed to be empty.")" "pkgver"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
awk -F'=' '$1 ~ /^[[:space:]]*pkgver$/' "$BUILDFILE" | sed "s/[[:space:]]*#.*//" |
|
|
|
|
while IFS='=' read -r _ i; do
|
|
|
|
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
|
2013-10-14 09:13:28 -04:00
|
|
|
validate_pkgver "$i" || return 1
|
2012-07-16 07:56:32 -04:00
|
|
|
done || ret=1
|
|
|
|
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
2011-06-20 23:02:07 -04:00
|
|
|
check_software() {
|
|
|
|
# check for needed software
|
|
|
|
local ret=0
|
|
|
|
|
2012-11-12 22:04:21 -05:00
|
|
|
# check for PACMAN if we need it
|
2014-03-08 05:46:21 -05:00
|
|
|
if (( ! NODEPS || DEP_BIN || RMDEPS || INSTALL )); then
|
2012-11-12 22:04:21 -05:00
|
|
|
if [[ -z $PACMAN_PATH ]]; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-06-24 22:07:23 -04:00
|
|
|
# check for sudo if we will need it during makepkg execution
|
2014-03-08 05:46:21 -05:00
|
|
|
if (( DEP_BIN || RMDEPS || INSTALL )); then
|
2011-06-24 22:07:23 -04:00
|
|
|
if ! type -p sudo >/dev/null; then
|
2012-04-13 00:34:02 -04:00
|
|
|
warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su"
|
2011-06-24 22:07:23 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-03-08 05:46:21 -05:00
|
|
|
# fakeroot - correct package file permissions
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then
|
2011-06-20 23:02:07 -04:00
|
|
|
if ! type -p fakeroot >/dev/null; then
|
2014-03-08 05:46:21 -05:00
|
|
|
error "$(gettext "Cannot find the %s binary.")" "fakeroot"
|
2011-06-20 23:02:07 -04:00
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# gpg - package signing
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; then
|
2011-06-20 23:02:07 -04:00
|
|
|
if ! type -p gpg >/dev/null; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-07-06 07:02:19 -04:00
|
|
|
# gpg - source verification
|
2011-09-06 14:11:15 -04:00
|
|
|
if (( ! SKIPPGPCHECK )) && source_has_signatures; then
|
2011-07-06 07:02:19 -04:00
|
|
|
if ! type -p gpg >/dev/null; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for verifying source files.")" "gpg"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-06-20 23:02:07 -04:00
|
|
|
# openssl - checksum operations
|
2011-07-16 08:42:32 -04:00
|
|
|
if (( ! SKIPCHECKSUMS )); then
|
2011-06-20 23:02:07 -04:00
|
|
|
if ! type -p openssl >/dev/null; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for validating sourcefile checksums.")" "openssl"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# upx - binary compression
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "upx" "y"; then
|
2011-06-20 23:02:07 -04:00
|
|
|
if ! type -p upx >/dev/null; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for compressing binaries.")" "upx"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-06-23 00:02:33 -04:00
|
|
|
# distcc - compilation with distcc
|
2013-12-20 19:12:53 -05:00
|
|
|
if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then
|
2011-06-23 00:02:33 -04:00
|
|
|
if ! type -p distcc >/dev/null; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ccache - compilation with ccache
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_buildenv "ccache" "y" && ! check_option "ccache" "n"; then
|
2011-06-23 00:02:33 -04:00
|
|
|
if ! type -p ccache >/dev/null; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# strip - strip symbols from binaries/libraries
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "strip" "y"; then
|
2011-06-23 00:02:33 -04:00
|
|
|
if ! type -p strip >/dev/null; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# gzip - compressig man and info pages
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if check_option "zipman" "y"; then
|
2011-06-23 00:02:33 -04:00
|
|
|
if ! type -p gzip >/dev/null; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-06-20 23:02:07 -04:00
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
2012-07-16 08:25:24 -04:00
|
|
|
check_build_status() {
|
|
|
|
if (( ! SPLITPKG )); then
|
|
|
|
fullver=$(get_full_version)
|
|
|
|
pkgarch=$(get_pkg_arch)
|
|
|
|
if [[ -f $PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT} ]] \
|
2014-03-03 14:29:54 -05:00
|
|
|
&& ! (( FORCE || SOURCEONLY || NOBUILD || NOARCHIVE)); then
|
2012-07-16 08:25:24 -04:00
|
|
|
if (( INSTALL )); then
|
|
|
|
warning "$(gettext "A package has already been built, installing existing package...")"
|
|
|
|
install_package
|
2014-03-05 04:45:22 -05:00
|
|
|
exit 0
|
2012-07-16 08:25:24 -04:00
|
|
|
else
|
|
|
|
error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
allpkgbuilt=1
|
|
|
|
somepkgbuilt=0
|
|
|
|
for pkg in ${pkgname[@]}; do
|
|
|
|
fullver=$(get_full_version $pkg)
|
|
|
|
pkgarch=$(get_pkg_arch $pkg)
|
|
|
|
if [[ -f $PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT} ]]; then
|
|
|
|
somepkgbuilt=1
|
|
|
|
else
|
|
|
|
allpkgbuilt=0
|
|
|
|
fi
|
|
|
|
done
|
2014-03-03 14:29:54 -05:00
|
|
|
if ! (( FORCE || SOURCEONLY || NOBUILD || NOARCHIVE)); then
|
2012-07-16 08:25:24 -04:00
|
|
|
if (( allpkgbuilt )); then
|
|
|
|
if (( INSTALL )); then
|
|
|
|
warning "$(gettext "The package group has already been built, installing existing packages...")"
|
|
|
|
install_package
|
2014-03-05 04:45:22 -05:00
|
|
|
exit 0
|
2012-07-16 08:25:24 -04:00
|
|
|
else
|
|
|
|
error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if (( somepkgbuilt && ! PKGVERFUNC )); then
|
|
|
|
error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
unset allpkgbuilt somepkgbuilt
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-01-16 07:22:04 -05:00
|
|
|
backup_package_variables() {
|
2010-06-25 19:16:36 -04:00
|
|
|
local var
|
2009-01-16 07:22:04 -05:00
|
|
|
for var in ${splitpkg_overrides[@]}; do
|
2010-06-25 19:16:36 -04:00
|
|
|
local indirect="${var}_backup"
|
2009-11-05 18:14:09 -05:00
|
|
|
eval "${indirect}=(\"\${$var[@]}\")"
|
2009-01-16 07:22:04 -05:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
restore_package_variables() {
|
2010-06-25 19:16:36 -04:00
|
|
|
local var
|
2009-01-16 07:22:04 -05:00
|
|
|
for var in ${splitpkg_overrides[@]}; do
|
2010-06-25 19:16:36 -04:00
|
|
|
local indirect="${var}_backup"
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -n ${!indirect} ]]; then
|
2009-11-05 18:14:09 -05:00
|
|
|
eval "${var}=(\"\${$indirect[@]}\")"
|
2009-01-16 07:22:04 -05:00
|
|
|
else
|
|
|
|
unset ${var}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2010-06-17 08:44:49 -04:00
|
|
|
run_split_packaging() {
|
2010-12-24 22:14:55 -05:00
|
|
|
local pkgname_backup=${pkgname[@]}
|
|
|
|
for pkgname in ${pkgname_backup[@]}; do
|
2013-02-01 21:13:41 -05:00
|
|
|
pkgdir="$pkgdirbase/$pkgname"
|
|
|
|
mkdir "$pkgdir"
|
2010-06-17 08:44:49 -04:00
|
|
|
backup_package_variables
|
2010-12-24 22:14:55 -05:00
|
|
|
run_package $pkgname
|
2010-06-17 08:44:49 -04:00
|
|
|
tidy_install
|
2012-09-23 10:06:36 -04:00
|
|
|
create_package
|
2012-09-23 10:30:46 -04:00
|
|
|
create_debug_package
|
2010-06-17 08:44:49 -04:00
|
|
|
restore_package_variables
|
|
|
|
done
|
2010-12-24 22:14:55 -05:00
|
|
|
pkgname=${pkgname_backup[@]}
|
2010-06-17 08:44:49 -04:00
|
|
|
}
|
|
|
|
|
2010-09-29 08:24:07 -04:00
|
|
|
# Canonicalize a directory path if it exists
|
|
|
|
canonicalize_path() {
|
|
|
|
local path="$1";
|
|
|
|
|
|
|
|
if [[ -d $path ]]; then
|
|
|
|
(
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "$path"
|
2010-09-29 08:24:07 -04:00
|
|
|
pwd -P
|
|
|
|
)
|
|
|
|
else
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "$path"
|
2010-09-29 08:24:07 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-08-10 20:20:48 -04:00
|
|
|
dir_is_empty() {
|
|
|
|
(
|
|
|
|
shopt -s dotglob nullglob
|
|
|
|
files=("$1"/*)
|
|
|
|
(( ${#files} == 0 ))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2012-04-08 13:13:07 -04:00
|
|
|
m4_include(library/parseopts.sh)
|
2008-12-22 06:28:35 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
usage() {
|
2012-07-15 01:46:29 -04:00
|
|
|
printf "makepkg (pacman) %s\n" "$makepkg_version"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2013-11-08 02:53:33 -05:00
|
|
|
printf -- "$(gettext "Make packages compatible for use with pacman")\n"
|
|
|
|
echo
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext "Usage: %s [options]")\n" "$0"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2012-02-03 08:22:44 -05:00
|
|
|
printf -- "$(gettext "Options:")\n"
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext " -A, --ignorearch Ignore incomplete %s field in %s")\n" "arch" "$BUILDSCRIPT"
|
|
|
|
printf -- "$(gettext " -c, --clean Clean up work files after build")\n"
|
2013-11-08 00:44:40 -05:00
|
|
|
printf -- "$(gettext " -C, --cleanbuild Remove %s dir before building the package")\n" "\$srcdir/"
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext " -d, --nodeps Skip all dependency checks")\n"
|
2013-10-02 23:38:40 -04:00
|
|
|
printf -- "$(gettext " -e, --noextract Do not extract source files (use existing %s dir)")\n" "\$srcdir/"
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext " -f, --force Overwrite existing package")\n"
|
|
|
|
printf -- "$(gettext " -g, --geninteg Generate integrity checks for source files")\n"
|
|
|
|
printf -- "$(gettext " -h, --help Show this help message and exit")\n"
|
|
|
|
printf -- "$(gettext " -i, --install Install package after successful build")\n"
|
|
|
|
printf -- "$(gettext " -L, --log Log package build process")\n"
|
|
|
|
printf -- "$(gettext " -m, --nocolor Disable colorized output messages")\n"
|
|
|
|
printf -- "$(gettext " -o, --nobuild Download and extract files only")\n"
|
|
|
|
printf -- "$(gettext " -p <file> Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT"
|
|
|
|
printf -- "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build")\n"
|
|
|
|
printf -- "$(gettext " -R, --repackage Repackage contents of the package without rebuilding")\n"
|
|
|
|
printf -- "$(gettext " -s, --syncdeps Install missing dependencies with %s")\n" "pacman"
|
|
|
|
printf -- "$(gettext " -S, --source Generate a source-only tarball without downloaded sources")\n"
|
2013-04-28 21:49:01 -04:00
|
|
|
printf -- "$(gettext " -V, --version Show version information and exit")\n"
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext " --allsource Generate a source-only tarball including downloaded sources")\n"
|
|
|
|
printf -- "$(gettext " --check Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
|
|
|
|
printf -- "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
|
2012-07-15 10:16:25 -04:00
|
|
|
printf -- "$(gettext " --holdver Do not update VCS sources")\n"
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext " --key <key> Specify a key to use for %s signing instead of the default")\n" "gpg"
|
2014-03-03 14:29:54 -05:00
|
|
|
printf -- "$(gettext " --noarchive Do not create package archive")\n"
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext " --nocheck Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
|
2013-04-28 22:42:22 -04:00
|
|
|
printf -- "$(gettext " --noprepare Do not run the %s function in the %s")\n" "prepare()" "$BUILDSCRIPT"
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext " --nosign Do not create a signature for the package")\n"
|
|
|
|
printf -- "$(gettext " --pkg <list> Only build listed packages from a split package")\n"
|
|
|
|
printf -- "$(gettext " --sign Sign the resulting package with %s")\n" "gpg"
|
|
|
|
printf -- "$(gettext " --skipchecksums Do not verify checksums of the source files")\n"
|
|
|
|
printf -- "$(gettext " --skipinteg Do not perform any verification checks on source files")\n"
|
|
|
|
printf -- "$(gettext " --skippgpcheck Do not verify source files with PGP signatures")\n"
|
2014-03-05 04:45:21 -05:00
|
|
|
printf -- "$(gettext " --verifysource Download source files (if needed) and perform integrity checks")\n"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext "These options can be passed to %s:")\n" "pacman"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2012-07-09 01:55:58 -04:00
|
|
|
printf -- "$(gettext " --asdeps Install packages as non-explicitly installed")\n"
|
2012-11-19 19:51:06 -05:00
|
|
|
printf -- "$(gettext " --needed Do not reinstall the targets that are already up to date")\n"
|
2014-03-05 04:45:21 -05:00
|
|
|
printf -- "$(gettext " --noconfirm Do not ask for confirmation when resolving dependencies")\n"
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext " --noprogressbar Do not show a progress bar when downloading files")\n"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext "If %s is not specified, %s will look for '%s'")\n" "-p" "makepkg" "$BUILDSCRIPT"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2007-05-29 16:53:15 -04:00
|
|
|
version() {
|
2012-07-15 01:46:29 -04:00
|
|
|
printf "makepkg (pacman) %s\n" "$makepkg_version"
|
2012-01-23 17:14:25 -05:00
|
|
|
printf -- "$(gettext "\
|
2014-01-01 05:24:48 -05:00
|
|
|
Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>.\n\
|
2009-07-01 03:08:33 -04:00
|
|
|
Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>.\n\n\
|
2007-07-06 19:35:32 -04:00
|
|
|
This is free software; see the source for copying conditions.\n\
|
|
|
|
There is NO WARRANTY, to the extent permitted by law.\n")"
|
2007-05-29 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
2008-02-17 22:15:06 -05:00
|
|
|
# PROGRAM START
|
|
|
|
|
2013-12-09 19:59:24 -05:00
|
|
|
# ensure we have a sane umask set
|
|
|
|
umask 0022
|
|
|
|
|
2008-02-17 22:15:06 -05:00
|
|
|
# determine whether we have gettext; make it a no-op if we do not
|
2010-05-27 11:06:08 -04:00
|
|
|
if ! type -p gettext >/dev/null; then
|
2008-02-17 22:15:06 -05:00
|
|
|
gettext() {
|
2012-03-09 01:39:01 -05:00
|
|
|
printf "%s\n" "$@"
|
2008-02-17 22:15:06 -05:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2009-10-22 00:25:24 -04:00
|
|
|
ARGLIST=("$@")
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-06-05 06:58:25 -04:00
|
|
|
# Parse Command Line Options.
|
2013-10-04 09:57:08 -04:00
|
|
|
OPT_SHORT="AcCdefFghiLmop:rRsSV"
|
2014-03-08 05:31:46 -05:00
|
|
|
OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'force' 'geninteg'
|
2014-03-03 14:29:54 -05:00
|
|
|
'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'noarchive' 'nobuild'
|
|
|
|
'nocolor' 'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign' 'pkg:' 'repackage'
|
|
|
|
'rmdeps' 'sign' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'source' 'syncdeps'
|
2013-03-20 03:07:16 -04:00
|
|
|
'verifysource' 'version')
|
2011-07-16 08:42:32 -04:00
|
|
|
|
2007-06-05 06:58:25 -04:00
|
|
|
# Pacman Options
|
2012-11-19 19:51:06 -05:00
|
|
|
OPT_LONG+=('asdeps' 'noconfirm' 'needed' 'noprogressbar')
|
2012-04-08 13:13:07 -04:00
|
|
|
|
|
|
|
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
|
2012-04-17 00:27:37 -04:00
|
|
|
exit 1 # E_INVALID_OPTION;
|
2007-06-05 06:58:25 -04:00
|
|
|
fi
|
2012-04-08 13:13:07 -04:00
|
|
|
set -- "${OPTRET[@]}"
|
|
|
|
unset OPT_SHORT OPT_LONG OPTRET
|
2007-06-05 06:58:25 -04:00
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
# Pacman Options
|
2012-07-09 01:55:58 -04:00
|
|
|
--asdeps) ASDEPS=1;;
|
2013-02-09 13:57:39 -05:00
|
|
|
--needed) NEEDED=1;;
|
2014-03-05 04:45:21 -05:00
|
|
|
--noconfirm) PACMAN_OPTS+=" --noconfirm" ;;
|
2010-06-17 08:44:48 -04:00
|
|
|
--noprogressbar) PACMAN_OPTS+=" --noprogressbar" ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
|
|
|
|
# Makepkg Options
|
2008-06-06 21:58:21 -04:00
|
|
|
--allsource) SOURCEONLY=2 ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-A|--ignorearch) IGNOREARCH=1 ;;
|
|
|
|
-c|--clean) CLEANUP=1 ;;
|
2013-10-04 09:57:08 -04:00
|
|
|
-C|--cleanbuild) CLEANBUILD=1 ;;
|
2010-12-15 09:06:43 -05:00
|
|
|
--check) RUN_CHECK='y' ;;
|
2008-08-07 11:08:33 -04:00
|
|
|
--config) shift; MAKEPKG_CONF=$1 ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-d|--nodeps) NODEPS=1 ;;
|
|
|
|
-e|--noextract) NOEXTRACT=1 ;;
|
|
|
|
-f|--force) FORCE=1 ;;
|
2007-06-13 05:48:22 -04:00
|
|
|
-F) INFAKEROOT=1 ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-g|--geninteg) GENINTEG=1 ;;
|
2012-07-15 10:16:25 -04:00
|
|
|
--holdver) HOLDVER=1 ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-i|--install) INSTALL=1 ;;
|
2011-04-17 08:38:35 -04:00
|
|
|
--key) shift; GPGKEY=$1 ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-L|--log) LOGGING=1 ;;
|
|
|
|
-m|--nocolor) USE_COLOR='n' ;;
|
2014-03-03 14:29:54 -05:00
|
|
|
--noarchive) NOARCHIVE=1 ;;
|
2010-12-15 09:06:43 -05:00
|
|
|
--nocheck) RUN_CHECK='n' ;;
|
2013-04-28 22:42:22 -04:00
|
|
|
--noprepare) RUN_PREPARE='n' ;;
|
2011-03-25 22:06:06 -04:00
|
|
|
--nosign) SIGNPKG='n' ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-o|--nobuild) NOBUILD=1 ;;
|
2009-07-12 03:10:11 -04:00
|
|
|
-p) shift; BUILDFILE=$1 ;;
|
2012-04-08 13:26:41 -04:00
|
|
|
--pkg) shift; IFS=, read -ra p <<<"$1"; PKGLIST+=("${p[@]}"); unset p ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-r|--rmdeps) RMDEPS=1 ;;
|
|
|
|
-R|--repackage) REPKG=1 ;;
|
2014-03-05 04:45:21 -05:00
|
|
|
--sign) SIGNPKG='y' ;;
|
2011-07-16 08:42:32 -04:00
|
|
|
--skipchecksums) SKIPCHECKSUMS=1 ;;
|
|
|
|
--skipinteg) SKIPCHECKSUMS=1; SKIPPGPCHECK=1 ;;
|
2011-07-06 07:02:19 -04:00
|
|
|
--skippgpcheck) SKIPPGPCHECK=1;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-s|--syncdeps) DEP_BIN=1 ;;
|
2011-08-18 06:46:19 -04:00
|
|
|
-S|--source) SOURCEONLY=1 ;;
|
2013-02-23 07:08:44 -05:00
|
|
|
--verifysource) VERIFYSOURCE=1 ;;
|
2007-06-02 13:39:48 -04:00
|
|
|
|
2007-06-05 06:58:25 -04:00
|
|
|
-h|--help) usage; exit 0 ;; # E_OK
|
|
|
|
-V|--version) version; exit 0 ;; # E_OK
|
|
|
|
|
2012-04-08 13:13:07 -04:00
|
|
|
--) OPT_IND=0; shift; break 2;;
|
2005-03-14 20:51:43 -05:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2013-08-05 18:04:37 -04:00
|
|
|
# attempt to consume any extra argv as environment variables. this supports
|
|
|
|
# overriding (e.g. CC=clang) as well as overriding (e.g. CFLAGS+=' -g').
|
|
|
|
extra_environment=()
|
|
|
|
while [[ $1 ]]; do
|
|
|
|
if [[ $1 = [_[:alpha:]]*([[:alnum:]_])?(+)=* ]]; then
|
|
|
|
extra_environment+=("$1")
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2011-10-13 18:26:17 -04:00
|
|
|
# setup signal traps
|
|
|
|
trap 'clean_up' 0
|
|
|
|
for signal in TERM HUP QUIT; do
|
2012-03-02 19:25:15 -05:00
|
|
|
trap "trap_exit $signal \"$(gettext "%s signal caught. Exiting...")\" \"$signal\"" "$signal"
|
2011-10-13 18:26:17 -04:00
|
|
|
done
|
2012-03-02 19:25:15 -05:00
|
|
|
trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
|
|
|
|
trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
2011-10-13 18:26:17 -04:00
|
|
|
|
2010-09-29 08:24:07 -04:00
|
|
|
# preserve environment variables and canonicalize path
|
|
|
|
[[ -n ${PKGDEST} ]] && _PKGDEST=$(canonicalize_path ${PKGDEST})
|
|
|
|
[[ -n ${SRCDEST} ]] && _SRCDEST=$(canonicalize_path ${SRCDEST})
|
|
|
|
[[ -n ${SRCPKGDEST} ]] && _SRCPKGDEST=$(canonicalize_path ${SRCPKGDEST})
|
2012-11-29 02:08:55 -05:00
|
|
|
[[ -n ${LOGDEST} ]] && _LOGDEST=$(canonicalize_path ${LOGDEST})
|
2011-06-15 00:32:42 -04:00
|
|
|
[[ -n ${BUILDDIR} ]] && _BUILDDIR=$(canonicalize_path ${BUILDDIR})
|
2011-03-25 21:32:21 -04:00
|
|
|
[[ -n ${PKGEXT} ]] && _PKGEXT=${PKGEXT}
|
|
|
|
[[ -n ${SRCEXT} ]] && _SRCEXT=${SRCEXT}
|
2011-04-17 08:38:35 -04:00
|
|
|
[[ -n ${GPGKEY} ]] && _GPGKEY=${GPGKEY}
|
2011-10-31 21:00:47 -04:00
|
|
|
[[ -n ${PACKAGER} ]] && _PACKAGER=${PACKAGER}
|
2013-04-29 19:10:08 -04:00
|
|
|
[[ -n ${CARCH} ]] && _CARCH=${CARCH}
|
2008-08-07 11:08:33 -04:00
|
|
|
|
|
|
|
# default config is makepkg.conf
|
|
|
|
MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf}
|
|
|
|
|
|
|
|
# Source the config file; fail if it is not found
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -r $MAKEPKG_CONF ]]; then
|
2012-02-10 15:10:32 -05:00
|
|
|
source_safe "$MAKEPKG_CONF"
|
2008-08-07 11:08:33 -04:00
|
|
|
else
|
|
|
|
error "$(gettext "%s not found.")" "$MAKEPKG_CONF"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_CONFIG_ERROR
|
|
|
|
fi
|
|
|
|
|
2011-06-28 22:35:48 -04:00
|
|
|
# Source user-specific makepkg.conf overrides, but only if no override config
|
|
|
|
# file was specified
|
|
|
|
if [[ $MAKEPKG_CONF = "$confdir/makepkg.conf" && -r ~/.makepkg.conf ]]; then
|
2012-02-10 15:10:32 -05:00
|
|
|
source_safe ~/.makepkg.conf
|
2008-08-07 11:08:33 -04:00
|
|
|
fi
|
|
|
|
|
2009-12-02 13:04:32 -05:00
|
|
|
# set pacman command if not already defined
|
|
|
|
PACMAN=${PACMAN:-pacman}
|
2012-11-12 22:04:21 -05:00
|
|
|
# save full path to command as PATH may change when sourcing /etc/profile
|
2014-02-02 02:37:58 -05:00
|
|
|
PACMAN_PATH=$(type -P $PACMAN)
|
2009-12-02 13:04:32 -05:00
|
|
|
|
2009-03-14 09:51:58 -04:00
|
|
|
# check if messages are to be printed using color
|
2009-10-23 11:11:38 -04:00
|
|
|
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if [[ -t 2 && ! $USE_COLOR = "n" ]] && check_buildenv "color" "y"; then
|
2010-08-03 00:29:26 -04:00
|
|
|
# prefer terminal safe colored and bold text when tput is supported
|
|
|
|
if tput setaf 0 &>/dev/null; then
|
|
|
|
ALL_OFF="$(tput sgr0)"
|
|
|
|
BOLD="$(tput bold)"
|
|
|
|
BLUE="${BOLD}$(tput setaf 4)"
|
|
|
|
GREEN="${BOLD}$(tput setaf 2)"
|
|
|
|
RED="${BOLD}$(tput setaf 1)"
|
|
|
|
YELLOW="${BOLD}$(tput setaf 3)"
|
|
|
|
else
|
2013-04-02 19:53:43 -04:00
|
|
|
ALL_OFF="\e[0m"
|
|
|
|
BOLD="\e[1m"
|
|
|
|
BLUE="${BOLD}\e[34m"
|
|
|
|
GREEN="${BOLD}\e[32m"
|
|
|
|
RED="${BOLD}\e[31m"
|
|
|
|
YELLOW="${BOLD}\e[33m"
|
2010-08-03 00:29:26 -04:00
|
|
|
fi
|
2009-03-14 09:51:58 -04:00
|
|
|
fi
|
2009-10-23 11:11:38 -04:00
|
|
|
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
|
2009-03-14 09:51:58 -04:00
|
|
|
|
2008-08-07 11:08:33 -04:00
|
|
|
# override settings with an environment variable for batch processing
|
2011-06-15 00:32:42 -04:00
|
|
|
BUILDDIR=${_BUILDDIR:-$BUILDDIR}
|
|
|
|
BUILDDIR=${BUILDDIR:-$startdir} #default to $startdir if undefined
|
|
|
|
if [[ ! -d $BUILDDIR ]]; then
|
2012-03-09 02:27:43 -05:00
|
|
|
if ! mkdir -p "$BUILDDIR"; then
|
|
|
|
error "$(gettext "You do not have write permission to create packages in %s.")" "$BUILDDIR"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-06-15 00:32:42 -04:00
|
|
|
chmod a-s "$BUILDDIR"
|
|
|
|
fi
|
|
|
|
if [[ ! -w $BUILDDIR ]]; then
|
|
|
|
error "$(gettext "You do not have write permission to create packages in %s.")" "$BUILDDIR"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-08-05 18:04:37 -04:00
|
|
|
# override settings from extra variables on commandline, if any
|
|
|
|
if (( ${#extra_environment[*]} )); then
|
|
|
|
export "${extra_environment[@]}"
|
|
|
|
fi
|
|
|
|
|
2008-08-07 11:08:33 -04:00
|
|
|
PKGDEST=${_PKGDEST:-$PKGDEST}
|
|
|
|
PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
|
2011-06-16 04:40:40 -04:00
|
|
|
if (( ! (NOBUILD || GENINTEG) )) && [[ ! -w $PKGDEST ]]; then
|
2010-03-07 02:31:26 -05:00
|
|
|
error "$(gettext "You do not have write permission to store packages in %s.")" "$PKGDEST"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-08-07 11:08:33 -04:00
|
|
|
SRCDEST=${_SRCDEST:-$SRCDEST}
|
|
|
|
SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
|
2010-03-07 02:31:26 -05:00
|
|
|
if [[ ! -w $SRCDEST ]] ; then
|
|
|
|
error "$(gettext "You do not have write permission to store downloads in %s.")" "$SRCDEST"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-01-19 13:05:06 -05:00
|
|
|
SRCPKGDEST=${_SRCPKGDEST:-$SRCPKGDEST}
|
2011-02-01 09:59:35 -05:00
|
|
|
SRCPKGDEST=${SRCPKGDEST:-$startdir} #default to $startdir if undefined
|
2012-01-31 08:25:19 -05:00
|
|
|
if (( SOURCEONLY )) && [[ ! -w $SRCPKGDEST ]]; then
|
|
|
|
error "$(gettext "You do not have write permission to store source tarballs in %s.")" "$SRCPKGDEST"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
2008-08-07 11:08:33 -04:00
|
|
|
|
2012-11-29 02:08:55 -05:00
|
|
|
LOGDEST=${_LOGDEST:-$LOGDEST}
|
|
|
|
LOGDEST=${LOGDEST:-$startdir} #default to $startdir if undefined
|
|
|
|
if (( LOGGING )) && [[ ! -w $LOGDEST ]]; then
|
|
|
|
error "$(gettext "You do not have write permission to store logs in %s.")" "$LOGDEST"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-03-25 21:32:21 -04:00
|
|
|
PKGEXT=${_PKGEXT:-$PKGEXT}
|
|
|
|
SRCEXT=${_SRCEXT:-$SRCEXT}
|
2011-04-17 08:38:35 -04:00
|
|
|
GPGKEY=${_GPGKEY:-$GPGKEY}
|
2011-10-31 21:00:47 -04:00
|
|
|
PACKAGER=${_PACKAGER:-$PACKAGER}
|
2013-04-29 19:10:08 -04:00
|
|
|
CARCH=${_CARCH:-$CARCH}
|
2008-08-07 11:08:33 -04:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! INFAKEROOT )); then
|
2014-03-08 05:31:46 -05:00
|
|
|
if (( EUID == 0 )); then
|
|
|
|
error "$(gettext "Running %s as root is not allowed as it can cause permanent,\n\
|
|
|
|
catastrophic damage to your system.")"
|
2007-04-11 15:06:25 -04:00
|
|
|
exit 1 # $E_USER_ABORT
|
|
|
|
fi
|
|
|
|
else
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -z $FAKEROOTKEY ]]; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "Do not use the %s option. This option is only for use by %s.")" "'-F'" "makepkg"
|
2007-04-11 15:06:25 -04:00
|
|
|
exit 1 # TODO: error code
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-01-20 19:16:06 -05:00
|
|
|
unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
|
2009-10-08 10:10:05 -04:00
|
|
|
unset md5sums replaces depends conflicts backup source install changelog build
|
2009-03-06 03:28:47 -05:00
|
|
|
unset makedepends optdepends options noextract
|
2006-11-14 02:58:42 -05:00
|
|
|
|
2009-07-12 03:10:11 -04:00
|
|
|
BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ ! -f $BUILDFILE ]]; then
|
2013-05-18 08:47:35 -04:00
|
|
|
error "$(gettext "%s does not exist.")" "$BUILDFILE"
|
|
|
|
exit 1
|
2008-12-07 00:32:34 -05:00
|
|
|
else
|
2013-03-24 15:09:18 -04:00
|
|
|
if [[ $(<"$BUILDFILE") = *$'\r'* ]]; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "%s contains %s characters and cannot be sourced.")" "$BUILDFILE" "CRLF"
|
2008-12-07 00:32:34 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ ${BUILDFILE:0:1} != "/" ]]; then
|
2009-07-12 03:10:11 -04:00
|
|
|
BUILDFILE="$startdir/$BUILDFILE"
|
|
|
|
fi
|
2012-02-10 15:10:32 -05:00
|
|
|
source_safe "$BUILDFILE"
|
2009-05-15 23:48:10 -04:00
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2011-02-09 08:54:42 -05:00
|
|
|
# set defaults if they weren't specified in buildfile
|
|
|
|
pkgbase=${pkgbase:-${pkgname[0]}}
|
|
|
|
epoch=${epoch:-0}
|
2013-11-01 07:34:34 -04:00
|
|
|
basever=$(get_full_version)
|
2011-02-09 08:54:42 -05:00
|
|
|
|
2012-03-09 01:01:28 -05:00
|
|
|
if [[ $BUILDDIR = "$startdir" ]]; then
|
|
|
|
srcdir="$BUILDDIR/src"
|
2013-02-01 21:13:41 -05:00
|
|
|
pkgdirbase="$BUILDDIR/pkg"
|
2012-03-09 01:01:28 -05:00
|
|
|
else
|
|
|
|
srcdir="$BUILDDIR/$pkgbase/src"
|
2013-02-01 21:13:41 -05:00
|
|
|
pkgdirbase="$BUILDDIR/$pkgbase/pkg"
|
|
|
|
|
2012-03-09 01:01:28 -05:00
|
|
|
fi
|
|
|
|
|
2013-02-01 21:13:41 -05:00
|
|
|
# set pkgdir to something "sensible" for (not recommended) use during build()
|
|
|
|
pkgdir="$pkgdirbase/$pkgbase"
|
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( GENINTEG )); then
|
2008-05-26 02:27:22 -04:00
|
|
|
mkdir -p "$srcdir"
|
2010-03-06 07:02:36 -05:00
|
|
|
chmod a-s "$srcdir"
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "$srcdir"
|
2012-07-15 09:57:25 -04:00
|
|
|
download_sources fast
|
2008-05-26 02:27:22 -04:00
|
|
|
generate_checksums
|
|
|
|
exit 0 # $E_OK
|
|
|
|
fi
|
|
|
|
|
2013-05-18 09:43:27 -04:00
|
|
|
if have_function pkgver; then
|
2012-07-16 08:25:24 -04:00
|
|
|
PKGVERFUNC=1
|
|
|
|
fi
|
|
|
|
|
2009-06-06 13:49:37 -04:00
|
|
|
# check the PKGBUILD for some basic requirements
|
2009-06-13 09:54:23 -04:00
|
|
|
check_sanity || exit 1
|
2008-05-13 06:26:11 -04:00
|
|
|
|
2011-06-20 23:02:07 -04:00
|
|
|
# check we have the software required to process the PKGBUILD
|
2011-06-22 12:51:58 -04:00
|
|
|
check_software || exit 1
|
2011-06-20 23:02:07 -04:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ${#pkgname[@]} > 1 )); then
|
2009-03-06 03:28:47 -05:00
|
|
|
SPLITPKG=1
|
|
|
|
fi
|
|
|
|
|
2009-10-27 07:56:13 -04:00
|
|
|
# test for available PKGBUILD functions
|
2013-05-18 09:43:27 -04:00
|
|
|
if have_function prepare; then
|
2013-04-28 22:42:22 -04:00
|
|
|
# "Hide" prepare() function if not going to be run
|
|
|
|
if [[ $RUN_PREPARE != "n" ]]; then
|
|
|
|
PREPAREFUNC=1
|
|
|
|
fi
|
2012-07-28 05:20:10 -04:00
|
|
|
fi
|
2013-05-18 09:43:27 -04:00
|
|
|
if have_function build; then
|
2009-10-27 07:56:13 -04:00
|
|
|
BUILDFUNC=1
|
|
|
|
fi
|
2013-05-18 09:43:27 -04:00
|
|
|
if have_function check; then
|
2010-12-15 09:06:43 -05:00
|
|
|
# "Hide" check() function if not going to be run
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if [[ $RUN_CHECK = 'y' ]] || { ! check_buildenv "check" "n" && [[ $RUN_CHECK != "n" ]]; }; then
|
2010-12-15 09:06:43 -05:00
|
|
|
CHECKFUNC=1
|
|
|
|
fi
|
|
|
|
fi
|
2013-05-18 09:43:27 -04:00
|
|
|
if have_function package; then
|
2009-10-25 00:33:47 -04:00
|
|
|
PKGFUNC=1
|
2013-05-18 09:43:27 -04:00
|
|
|
elif [[ $SPLITPKG -eq 0 ]] && have_function package_${pkgname}; then
|
2009-10-25 00:33:47 -04:00
|
|
|
SPLITPKG=1
|
|
|
|
fi
|
|
|
|
|
2009-10-22 00:40:03 -04:00
|
|
|
if [[ -n "${PKGLIST[@]}" ]]; then
|
|
|
|
unset pkgname
|
2010-07-24 17:13:01 -04:00
|
|
|
pkgname=("${PKGLIST[@]}")
|
2009-10-22 00:40:03 -04:00
|
|
|
fi
|
|
|
|
|
2011-03-25 22:06:06 -04:00
|
|
|
# check if gpg signature is to be created and if signing key is valid
|
makepkg: remove subshelling from check_option and friends
Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).
For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:
336 before
180 after
So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-24 23:36:08 -04:00
|
|
|
if { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } || [[ $SIGNPKG == 'y' ]]; then
|
2012-11-03 01:43:44 -04:00
|
|
|
SIGNPKG='y'
|
2011-04-17 08:38:35 -04:00
|
|
|
if ! gpg --list-key ${GPGKEY} &>/dev/null; then
|
|
|
|
if [[ ! -z $GPGKEY ]]; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "The key %s does not exist in your keyring.")" "${GPGKEY}"
|
2011-03-25 22:06:06 -04:00
|
|
|
else
|
|
|
|
error "$(gettext "There is no key in your keyring.")"
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-07-16 08:25:24 -04:00
|
|
|
if (( ! PKGVERFUNC )); then
|
|
|
|
check_build_status
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2007-10-26 22:32:09 -04:00
|
|
|
# Run the bare minimum in fakeroot
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( INFAKEROOT )); then
|
2011-06-15 02:02:22 -04:00
|
|
|
if (( SOURCEONLY )); then
|
|
|
|
create_srcpackage
|
2011-06-17 22:40:14 -04:00
|
|
|
msg "$(gettext "Leaving %s environment.")" "fakeroot"
|
2011-06-15 02:02:22 -04:00
|
|
|
exit 0 # $E_OK
|
|
|
|
fi
|
|
|
|
|
2013-02-01 21:13:41 -05:00
|
|
|
chmod 755 "$pkgdirbase"
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! SPLITPKG )); then
|
2013-02-01 21:13:41 -05:00
|
|
|
pkgdir="$pkgdirbase/$pkgname"
|
|
|
|
mkdir "$pkgdir"
|
2013-05-18 10:03:36 -04:00
|
|
|
if (( PKGFUNC )); then
|
2009-01-17 01:41:01 -05:00
|
|
|
run_package
|
2009-01-16 07:20:05 -05:00
|
|
|
fi
|
2012-09-23 07:52:40 -04:00
|
|
|
tidy_install
|
2009-01-16 07:32:05 -05:00
|
|
|
create_package
|
2012-09-23 10:30:46 -04:00
|
|
|
create_debug_package
|
2009-01-16 07:32:05 -05:00
|
|
|
else
|
2010-06-17 08:44:49 -04:00
|
|
|
run_split_packaging
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
2007-04-11 15:06:25 -04:00
|
|
|
|
2011-06-17 22:40:14 -04:00
|
|
|
msg "$(gettext "Leaving %s environment.")" "fakeroot"
|
2007-04-11 15:06:25 -04:00
|
|
|
exit 0 # $E_OK
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2013-11-01 07:34:34 -04:00
|
|
|
msg "$(gettext "Making package: %s")" "$pkgbase $basever ($(date))"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-05-30 14:27:13 -04:00
|
|
|
# if we are creating a source-only package, go no further
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( SOURCEONLY )); then
|
2013-11-01 07:34:34 -04:00
|
|
|
if [[ -f $SRCPKGDEST/${pkgbase}-${basever}${SRCEXT} ]] \
|
2013-07-21 21:09:58 -04:00
|
|
|
&& (( ! FORCE )); then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "A source package has already been built. (use %s to overwrite)")" "-f"
|
2007-05-30 14:27:13 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2011-06-15 02:02:22 -04:00
|
|
|
|
|
|
|
# Get back to our src directory so we can begin with sources.
|
|
|
|
mkdir -p "$srcdir"
|
|
|
|
chmod a-s "$srcdir"
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "$srcdir"
|
2012-07-15 09:57:25 -04:00
|
|
|
if (( SOURCEONLY == 2 )); then
|
2011-06-15 02:02:22 -04:00
|
|
|
download_sources
|
2012-07-15 09:57:25 -04:00
|
|
|
elif ( (( ! SKIPCHECKSUMS )) || \
|
|
|
|
( (( ! SKIPPGPCHECK )) && source_has_signatures ) ); then
|
|
|
|
download_sources fast
|
2011-06-15 02:02:22 -04:00
|
|
|
fi
|
2011-07-18 05:58:54 -04:00
|
|
|
check_source_integrity
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "$startdir"
|
2011-06-15 02:02:22 -04:00
|
|
|
|
2014-03-08 05:46:21 -05:00
|
|
|
enter_fakeroot
|
2011-06-15 02:02:22 -04:00
|
|
|
|
2009-03-06 03:28:47 -05:00
|
|
|
msg "$(gettext "Source package created: %s")" "$pkgbase ($(date))"
|
2007-05-30 14:27:13 -04:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2012-06-07 02:09:46 -04:00
|
|
|
if (( NODEPS || (NOBUILD && !DEP_BIN ) )); then
|
|
|
|
# no warning message needed for nobuild
|
|
|
|
if (( NODEPS )); then
|
2007-06-02 13:39:48 -04:00
|
|
|
warning "$(gettext "Skipping dependency checks.")"
|
2007-01-31 21:12:49 -05:00
|
|
|
fi
|
2012-11-12 22:04:21 -05:00
|
|
|
else
|
2012-02-04 09:07:02 -05:00
|
|
|
if (( RMDEPS && ! INSTALL )); then
|
2010-06-18 19:51:10 -04:00
|
|
|
original_pkglist=($(run_pacman -Qq)) # required by remove_dep
|
2009-10-23 01:30:47 -04:00
|
|
|
fi
|
2007-02-14 00:52:49 -05:00
|
|
|
deperr=0
|
|
|
|
|
2010-06-17 08:44:51 -04:00
|
|
|
msg "$(gettext "Checking runtime dependencies...")"
|
2007-06-02 12:41:15 -04:00
|
|
|
resolve_deps ${depends[@]} || deperr=1
|
2007-02-14 00:52:49 -05:00
|
|
|
|
2012-02-04 09:07:02 -05:00
|
|
|
if (( RMDEPS && INSTALL )); then
|
|
|
|
original_pkglist=($(run_pacman -Qq)) # required by remove_dep
|
|
|
|
fi
|
|
|
|
|
2010-06-17 08:44:51 -04:00
|
|
|
msg "$(gettext "Checking buildtime dependencies...")"
|
2010-12-15 09:06:43 -05:00
|
|
|
if (( CHECKFUNC )); then
|
2013-07-12 06:06:38 -04:00
|
|
|
resolve_deps "${makedepends[@]}" "${checkdepends[@]}" || deperr=1
|
|
|
|
else
|
|
|
|
resolve_deps "${makedepends[@]}" || deperr=1
|
2010-12-15 09:06:43 -05:00
|
|
|
fi
|
|
|
|
|
2009-10-23 01:30:47 -04:00
|
|
|
if (( RMDEPS )); then
|
2010-06-18 19:51:10 -04:00
|
|
|
current_pkglist=($(run_pacman -Qq)) # required by remove_deps
|
2009-10-23 01:30:47 -04:00
|
|
|
fi
|
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( deperr )); then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "Could not resolve all dependencies.")"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-06-02 11:45:17 -04:00
|
|
|
# get back to our src directory so we can begin with sources
|
2007-06-02 22:33:17 -04:00
|
|
|
mkdir -p "$srcdir"
|
2010-03-06 07:02:36 -05:00
|
|
|
chmod a-s "$srcdir"
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "$srcdir"
|
2007-04-04 22:30:05 -04:00
|
|
|
|
2013-02-23 07:08:44 -05:00
|
|
|
if (( NOEXTRACT && ! VERIFYSOURCE )); then
|
2013-10-08 23:20:11 -04:00
|
|
|
warning "$(gettext "Using existing %s tree")" "\$srcdir/"
|
2013-05-18 10:03:36 -04:00
|
|
|
elif (( !REPKG )); then
|
2007-06-02 11:45:17 -04:00
|
|
|
download_sources
|
2011-07-18 05:58:54 -04:00
|
|
|
check_source_integrity
|
2013-02-23 07:08:44 -05:00
|
|
|
(( VERIFYSOURCE )) && exit 0 # $E_OK
|
2013-10-04 09:57:08 -04:00
|
|
|
|
|
|
|
if (( CLEANBUILD )); then
|
2013-10-08 23:20:11 -04:00
|
|
|
msg "$(gettext "Removing existing %s directory...")" "\$srcdir/"
|
2013-10-04 09:57:08 -04:00
|
|
|
rm -rf "$srcdir"/*
|
|
|
|
fi
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
extract_sources
|
2013-11-01 07:24:46 -04:00
|
|
|
if (( PKGVERFUNC )); then
|
|
|
|
update_pkgver
|
2013-11-01 07:34:34 -04:00
|
|
|
basever=$(get_full_version)
|
2013-11-01 07:24:46 -04:00
|
|
|
check_build_status
|
|
|
|
fi
|
2012-07-28 05:20:10 -04:00
|
|
|
if (( PREPAREFUNC )); then
|
|
|
|
run_prepare
|
|
|
|
fi
|
2006-12-21 14:11:22 -05:00
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( NOBUILD )); then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Sources are ready.")"
|
2007-06-02 11:45:17 -04:00
|
|
|
exit 0 #E_OK
|
2006-12-21 14:11:22 -05:00
|
|
|
else
|
2013-05-18 10:03:36 -04:00
|
|
|
# clean existing pkg directory
|
|
|
|
if [[ -d $pkgdirbase ]]; then
|
2013-10-08 23:20:11 -04:00
|
|
|
msg "$(gettext "Removing existing %s directory...")" "\$pkgdir/"
|
2013-02-01 21:13:41 -05:00
|
|
|
rm -rf "$pkgdirbase"
|
2006-12-21 12:42:58 -05:00
|
|
|
fi
|
2013-02-01 21:13:41 -05:00
|
|
|
mkdir -p "$pkgdirbase"
|
|
|
|
chmod a-srwx "$pkgdirbase"
|
2012-03-09 02:43:47 -05:00
|
|
|
cd_safe "$startdir"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2014-03-08 05:46:21 -05:00
|
|
|
if (( ! REPKG )); then
|
|
|
|
(( BUILDFUNC )) && run_build
|
|
|
|
(( CHECKFUNC )) && run_check
|
|
|
|
cd_safe "$startdir"
|
2007-04-11 15:06:25 -04:00
|
|
|
fi
|
2014-03-08 05:46:21 -05:00
|
|
|
|
|
|
|
enter_fakeroot
|
2007-04-11 15:06:25 -04:00
|
|
|
fi
|
2006-12-05 02:43:42 -05:00
|
|
|
|
2014-03-03 14:29:54 -05:00
|
|
|
# if inhibiting archive creation, go no further
|
|
|
|
if (( NOARCHIVE )); then
|
|
|
|
msg "$(gettext "Package folder is ready.")"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2013-11-01 07:34:34 -04:00
|
|
|
msg "$(gettext "Finished making: %s")" "$pkgbase $basever ($(date))"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-06-02 13:39:47 -04:00
|
|
|
install_package
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-06-02 11:45:17 -04:00
|
|
|
exit 0 #E_OK
|
2007-03-31 20:07:37 -04:00
|
|
|
|
2014-01-22 18:06:11 -05:00
|
|
|
# vim: set noet:
|