2011-06-30 11:07:54 -04:00
|
|
|
#!/bin/bash -e
|
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
|
|
|
#
|
2011-01-05 23:45:15 -05:00
|
|
|
# Copyright (c) 2006-2011 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'
|
|
|
|
|
2007-04-11 15:35:29 -04:00
|
|
|
myver='@PACKAGE_VERSION@'
|
2007-06-01 10:28:52 -04:00
|
|
|
confdir='@sysconfdir@'
|
2008-12-27 01:35:06 -05:00
|
|
|
BUILDSCRIPT='@BUILDSCRIPT@'
|
2007-06-01 10:28:52 -04:00
|
|
|
startdir="$PWD"
|
2009-01-16 07:22:04 -05:00
|
|
|
|
2011-06-14 08:01:05 -04:00
|
|
|
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx')
|
2010-12-25 00:43:06 -05:00
|
|
|
other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
|
2011-07-22 06:08:39 -04:00
|
|
|
splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'license' \
|
|
|
|
'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
|
|
|
|
2006-01-21 21:16:41 -05:00
|
|
|
# Options
|
2007-04-11 15:06:25 -04:00
|
|
|
ASROOT=0
|
2006-01-21 21:16:41 -05:00
|
|
|
CLEANUP=0
|
|
|
|
DEP_BIN=0
|
|
|
|
FORCE=0
|
2007-04-11 15:06:25 -04:00
|
|
|
INFAKEROOT=0
|
2006-11-14 02:58:42 -05:00
|
|
|
GENINTEG=0
|
2011-07-16 08:42:32 -04:00
|
|
|
SKIPCHECKSUMS=0
|
2011-07-06 07:02:19 -04:00
|
|
|
SKIPPGPCHECK=0
|
2006-01-21 21:16:41 -05:00
|
|
|
INSTALL=0
|
|
|
|
NOBUILD=0
|
|
|
|
NODEPS=0
|
|
|
|
NOEXTRACT=0
|
|
|
|
RMDEPS=0
|
2006-12-21 12:42:58 -05:00
|
|
|
REPKG=0
|
2006-11-14 02:58:42 -05:00
|
|
|
LOGGING=0
|
2007-05-30 14:27:13 -04:00
|
|
|
SOURCEONLY=0
|
2007-06-04 17:06:11 -04:00
|
|
|
IGNOREARCH=0
|
2008-01-13 18:39:06 -05:00
|
|
|
HOLDVER=0
|
2009-10-27 07:56:13 -04:00
|
|
|
BUILDFUNC=0
|
2010-12-15 09:06:43 -05:00
|
|
|
CHECKFUNC=0
|
2009-01-17 01:41:01 -05:00
|
|
|
PKGFUNC=0
|
2009-01-16 07:32:05 -05:00
|
|
|
SPLITPKG=0
|
2010-07-24 17:13:01 -04:00
|
|
|
PKGLIST=()
|
2011-03-25 22:06:06 -04:00
|
|
|
SIGNPKG=''
|
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=
|
|
|
|
|
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() {
|
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"
|
2007-06-02 20:59:54 -04:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# 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...")"
|
2008-06-22 06:11:54 -04:00
|
|
|
rm -rf "$pkgdir" "$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
|
2010-06-23 01:35:56 -04:00
|
|
|
for file in ${pkg}-*-*-${CARCH}{${PKGEXT},${SRCEXT}}; do
|
2009-11-02 23:31:15 -05:00
|
|
|
if [[ -h $file && ! -e $file ]]; then
|
|
|
|
rm -f $file
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2007-06-02 20:59:54 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
remove_deps
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Signal Traps
|
|
|
|
##
|
2009-08-23 11:16:21 -04:00
|
|
|
set -E
|
2007-06-02 20:59:54 -04:00
|
|
|
trap 'clean_up' 0
|
|
|
|
trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT
|
|
|
|
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
|
2009-08-18 16:10:56 -04:00
|
|
|
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
2007-06-02 20:59:54 -04:00
|
|
|
|
2011-06-15 02:02:22 -04:00
|
|
|
enter_fakeroot() {
|
2011-06-17 22:40:14 -04:00
|
|
|
msg "$(gettext "Entering %s environment...")" "fakeroot"
|
2011-06-15 02:02:22 -04:00
|
|
|
|
|
|
|
if [[ -n $newpkgver ]]; then
|
|
|
|
fakeroot -- $0 --forcever $newpkgver -F "${ARGLIST[@]}" || exit $?
|
|
|
|
else
|
|
|
|
fakeroot -- $0 -F "${ARGLIST[@]}" || exit $?
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
#
|
|
|
|
# This function accepts a source entry or the already extracted filename of a
|
|
|
|
# source entry as input
|
|
|
|
get_filepath() {
|
|
|
|
local file="$(get_filename "$1")"
|
|
|
|
|
|
|
|
if [[ -f "$startdir/$file" ]]; then
|
|
|
|
file="$startdir/$file"
|
|
|
|
elif [[ -f "$SRCDEST/$file" ]]; then
|
|
|
|
file="$SRCDEST/$file"
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$file"
|
|
|
|
}
|
|
|
|
|
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2008-08-23 10:34:42 -04:00
|
|
|
# extract the filename from a source entry
|
|
|
|
get_filename() {
|
|
|
|
# if a filename is specified, use it
|
2009-10-20 09:44:00 -04:00
|
|
|
local filename="${1%%::*}"
|
2009-08-18 16:10:56 -04:00
|
|
|
# if it is just an URL, we only keep the last component
|
2009-10-20 09:44:00 -04:00
|
|
|
echo "${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
|
2009-10-20 09:44:00 -04:00
|
|
|
echo "${1#*::}"
|
2008-08-23 10:34:42 -04:00
|
|
|
}
|
2007-06-02 13:04:41 -04:00
|
|
|
|
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
|
2011-07-22 07:42:53 -04:00
|
|
|
echo $pkgver-$pkgrel
|
|
|
|
else
|
|
|
|
echo $epoch:$pkgver-$pkgrel
|
|
|
|
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")
|
|
|
|
[[ -z ${!indirect} ]] && eval "${indirect}=\${${i}}"
|
|
|
|
done
|
|
|
|
if (( ! $epoch_override )); then
|
|
|
|
echo $pkgver_override-$pkgrel_override
|
|
|
|
else
|
|
|
|
echo $epoch_override:$pkgver_override-$pkgrel_override
|
|
|
|
fi
|
2011-01-20 19:16:06 -05:00
|
|
|
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.
|
|
|
|
#
|
|
|
|
# usage : check_option( $option )
|
|
|
|
# return : y - enabled
|
|
|
|
# n - disabled
|
|
|
|
# ? - not found
|
|
|
|
##
|
2006-01-21 21:16:41 -05:00
|
|
|
check_option() {
|
2007-06-02 13:04:41 -04:00
|
|
|
local ret=$(in_opt_array "$1" ${options[@]})
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $ret != '?' ]]; then
|
2007-06-02 13:04:41 -04:00
|
|
|
echo $ret
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# fall back to makepkg.conf options
|
|
|
|
ret=$(in_opt_array "$1" ${OPTIONS[@]})
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $ret != '?' ]]; then
|
2007-06-02 13:04:41 -04:00
|
|
|
echo $ret
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo '?' # Not Found
|
2007-02-04 13:28:21 -05:00
|
|
|
}
|
|
|
|
|
2007-06-02 13:04:41 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# Check if option is present in BUILDENV
|
|
|
|
#
|
|
|
|
# usage : check_buildenv( $option )
|
|
|
|
# return : y - enabled
|
|
|
|
# n - disabled
|
|
|
|
# ? - not found
|
|
|
|
##
|
2007-02-04 13:28:21 -05:00
|
|
|
check_buildenv() {
|
2011-06-28 22:35:10 -04:00
|
|
|
in_opt_array "$1" ${BUILDENV[@]}
|
2007-06-02 13:04:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# usage : in_opt_array( $needle, $haystack )
|
|
|
|
# return : y - enabled
|
|
|
|
# n - disabled
|
|
|
|
# ? - not found
|
|
|
|
##
|
|
|
|
in_opt_array() {
|
2011-03-30 21:12:58 -04:00
|
|
|
local needle=$1; shift
|
2007-06-02 13:04:41 -04:00
|
|
|
|
|
|
|
local opt
|
|
|
|
for opt in "$@"; do
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $opt = $needle ]]; then
|
2007-06-02 13:04:41 -04:00
|
|
|
echo 'y' # Enabled
|
2007-02-04 13:28:21 -05:00
|
|
|
return
|
2009-11-12 15:07:34 -05:00
|
|
|
elif [[ $opt = "!$needle" ]]; then
|
2007-06-02 13:04:41 -04:00
|
|
|
echo 'n' # Disabled
|
2006-01-21 21:16:41 -05:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
2007-06-02 13:04:41 -04:00
|
|
|
|
|
|
|
echo '?' # Not Found
|
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
|
2009-11-12 15:07:34 -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-07-06 07:02:19 -04:00
|
|
|
source_has_signatures(){
|
|
|
|
local file
|
|
|
|
for file in "${source[@]}"; do
|
|
|
|
if [[ $file =~ .*(sig|asc) ]]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2007-06-02 13:39:47 -04:00
|
|
|
get_downloadclient() {
|
2009-08-18 16:10:56 -04:00
|
|
|
# $1 = URL with valid protocol prefix
|
2007-04-04 22:30:05 -04:00
|
|
|
local url=$1
|
2009-10-20 09:44:00 -04:00
|
|
|
local proto="${url%%://*}"
|
2007-04-04 22:30:05 -04:00
|
|
|
|
|
|
|
# loop through DOWNLOAD_AGENTS variable looking for protocol
|
2007-06-01 10:28:52 -04:00
|
|
|
local i
|
2007-04-04 22:30:05 -04:00
|
|
|
for i in "${DLAGENTS[@]}"; do
|
2009-10-20 09:44:00 -04:00
|
|
|
local handler="${i%%::*}"
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $proto = $handler ]]; then
|
2010-06-25 19:16:36 -04:00
|
|
|
local agent="${i##*::}"
|
2007-04-04 22:30:05 -04:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# if we didn't find an agent, return an error
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -z $agent ]]; then
|
2008-08-07 11:08:33 -04:00
|
|
|
error "$(gettext "There is no agent set up to handle %s URLs. Check %s.")" "$proto" "$MAKEPKG_CONF"
|
2007-06-02 13:39:48 -04:00
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_CONFIG_ERROR
|
2007-04-04 22:30:05 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ensure specified program is installed
|
2009-10-20 09:44:00 -04:00
|
|
|
local program="${agent%% *}"
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ ! -x $program ]]; then
|
2010-06-18 19:51:09 -04:00
|
|
|
local baseprog="${program##*/}"
|
2007-05-28 15:21:58 -04:00
|
|
|
error "$(gettext "The download program %s is not installed.")" "$baseprog"
|
2007-06-02 13:39:48 -04:00
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_MISSING_PROGRAM
|
2007-04-04 22:30:05 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$agent"
|
|
|
|
}
|
|
|
|
|
2008-08-01 02:29:46 -04:00
|
|
|
download_file() {
|
2008-08-23 10:34:42 -04:00
|
|
|
# download command
|
2008-08-01 02:29:46 -04:00
|
|
|
local dlcmd=$1
|
2009-08-18 16:10:56 -04:00
|
|
|
# URL of the file
|
2008-08-23 10:34:42 -04:00
|
|
|
local url=$2
|
|
|
|
# destination file
|
2008-02-10 11:56:47 -05:00
|
|
|
local file=$3
|
2009-08-18 16:10:56 -04:00
|
|
|
# temporary download file, default to last component of the URL
|
2009-10-20 09:44:00 -04:00
|
|
|
local dlfile="${url##*/}"
|
2008-02-10 11:56:47 -05:00
|
|
|
|
2008-08-23 10:34:42 -04:00
|
|
|
# replace %o by the temporary dlfile if it exists
|
2010-05-22 01:06:52 -04:00
|
|
|
if [[ $dlcmd = *%o* ]]; then
|
2009-07-11 11:07:46 -04:00
|
|
|
dlcmd=${dlcmd//\%o/\"$file.part\"}
|
2008-08-23 10:34:42 -04:00
|
|
|
dlfile="$file.part"
|
|
|
|
fi
|
2009-08-18 16:10:56 -04:00
|
|
|
# add the URL, either in place of %u or at the end
|
2010-05-22 01:06:52 -04:00
|
|
|
if [[ $dlcmd = *%u* ]]; then
|
2009-07-11 11:07:46 -04:00
|
|
|
dlcmd=${dlcmd//\%u/\"$url\"}
|
2008-02-10 11:56:47 -05:00
|
|
|
else
|
2009-07-11 11:07:46 -04:00
|
|
|
dlcmd="$dlcmd \"$url\""
|
2008-02-10 11:56:47 -05:00
|
|
|
fi
|
|
|
|
|
2009-10-21 13:13:36 -04:00
|
|
|
local ret=0
|
|
|
|
eval "$dlcmd || ret=\$?"
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ret )); then
|
|
|
|
[[ ! -s $dlfile ]] && rm -f -- "$dlfile"
|
2009-10-21 13:13:36 -04:00
|
|
|
return $ret
|
|
|
|
fi
|
2008-08-23 10:34:42 -04:00
|
|
|
|
|
|
|
# rename the temporary download file to the final destination
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $dlfile != $file ]]; then
|
2008-08-23 10:34:42 -04:00
|
|
|
mv -f "$SRCDEST/$dlfile" "$SRCDEST/$file"
|
|
|
|
fi
|
2008-02-10 11:56:47 -05:00
|
|
|
}
|
|
|
|
|
2009-11-18 17:29:07 -05:00
|
|
|
run_pacman() {
|
2010-06-30 06:42:30 -04:00
|
|
|
local cmd
|
|
|
|
printf -v cmd "%q " "$PACMAN" $PACMAN_OPTS "$@"
|
2010-08-27 11:52:05 -04:00
|
|
|
if (( ! ASROOT )) && [[ ! $1 =~ ^-(T|Qq)$ ]]; then
|
2011-03-24 10:10:05 -04:00
|
|
|
if type -p sudo >/dev/null; then
|
2010-06-30 06:42:30 -04:00
|
|
|
cmd="sudo $cmd"
|
2010-03-04 21:57:46 -05:00
|
|
|
else
|
2011-04-12 15:30:19 -04:00
|
|
|
cmd="su root -c '$cmd'"
|
2010-03-04 21:57:46 -05:00
|
|
|
fi
|
2009-11-18 17:29:07 -05:00
|
|
|
fi
|
2010-06-30 06:42:30 -04:00
|
|
|
eval "$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
|
|
|
|
2010-06-22 23:16:36 -04:00
|
|
|
# Disable error trap in pacman subshell call as this breaks bash-3.2 compatibility
|
|
|
|
# Also, a non-zero return value is not unexpected and we are manually dealing them
|
|
|
|
set +E
|
2009-11-18 17:29:07 -05:00
|
|
|
local ret=0
|
2010-06-25 19:16:36 -04:00
|
|
|
local pmout
|
2010-06-22 23:16:36 -04:00
|
|
|
pmout=$(run_pacman -T "$@") || ret=$?
|
|
|
|
set -E
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ret == 127 )); then #unresolved deps
|
2007-04-16 21:51:18 -04:00
|
|
|
echo "$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
|
2009-11-10 14:47:09 -05:00
|
|
|
# avoid triggering the ERR trap
|
|
|
|
local restoretrap=$(trap -p ERR)
|
|
|
|
trap - ERR
|
2008-07-24 05:37:36 -04:00
|
|
|
source /etc/profile &>/dev/null
|
2009-11-10 14:47:09 -05:00
|
|
|
eval $restoretrap
|
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
|
|
|
|
|
2007-05-30 12:47:47 -04:00
|
|
|
msg "$(gettext "Missing Dependencies:")"
|
|
|
|
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
|
|
|
|
if [[ -n $(comm -23 <(printf "%s\n" "${original_pkglist[@]}") \
|
|
|
|
<(printf "%s\n" "${current_pkglist[@]}")) ]]; then
|
|
|
|
warning "$(gettext "Failed to remove installed dependencies.")"
|
|
|
|
return 0
|
|
|
|
fi
|
2007-03-19 21:34:16 -04:00
|
|
|
|
2009-10-23 01:30:47 -04:00
|
|
|
local deplist=($(comm -13 <(printf "%s\n" "${original_pkglist[@]}") \
|
|
|
|
<(printf "%s\n" "${current_pkglist[@]}")))
|
|
|
|
(( ${#deplist[@]} == 0 )) && return
|
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
|
|
|
|
}
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
download_sources() {
|
|
|
|
msg "$(gettext "Retrieving Sources...")"
|
2007-07-10 08:11:40 -04:00
|
|
|
|
|
|
|
pushd "$SRCDEST" &>/dev/null
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
local netfile
|
2008-06-15 06:10:31 -04:00
|
|
|
for netfile in "${source[@]}"; do
|
2011-02-04 19:24:58 -05:00
|
|
|
local file=$(get_filepath "$netfile" || true)
|
|
|
|
if [[ -n "$file" ]]; then
|
2010-06-03 11:32:50 -04:00
|
|
|
msg2 "$(gettext "Found %s")" "${file##*/}"
|
2011-06-28 08:47:35 -04:00
|
|
|
rm -f "$srcdir/${file##*/}"
|
2011-06-26 15:13:48 -04:00
|
|
|
ln -s "$file" "$srcdir/"
|
2007-06-01 17:10:27 -04:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2010-06-03 11:32:50 -04:00
|
|
|
file=$(get_filename "$netfile")
|
|
|
|
local url=$(get_url "$netfile")
|
|
|
|
|
2008-01-16 00:03:51 -05:00
|
|
|
# if we get here, check to make sure it was a URL, else fail
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $file = $url ]]; then
|
2008-08-23 10:34:42 -04:00
|
|
|
error "$(gettext "%s was not found in the build directory and is not a URL.")" "$file"
|
2008-01-16 00:03:51 -05:00
|
|
|
exit 1 # $E_MISSING_FILE
|
|
|
|
fi
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
# find the client we should use for this URL
|
2008-08-23 10:34:42 -04:00
|
|
|
local dlclient=$(get_downloadclient "$url") || exit $?
|
2007-06-01 17:10:27 -04:00
|
|
|
|
2007-06-02 13:39:48 -04:00
|
|
|
msg2 "$(gettext "Downloading %s...")" "$file"
|
2007-06-01 17:10:27 -04:00
|
|
|
# fix flyspray bug #3289
|
|
|
|
local ret=0
|
2008-08-23 10:34:42 -04:00
|
|
|
download_file "$dlclient" "$url" "$file" || ret=$?
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ret )); then
|
2007-06-01 17:10:27 -04:00
|
|
|
error "$(gettext "Failure while downloading %s")" "$file"
|
2007-06-02 13:39:48 -04:00
|
|
|
plain "$(gettext "Aborting...")"
|
2007-06-01 17:10:27 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-05-20 13:51:38 -04:00
|
|
|
rm -f "$srcdir/$file"
|
|
|
|
ln -s "$SRCDEST/$file" "$srcdir/"
|
2007-06-01 17:10:27 -04:00
|
|
|
done
|
2007-07-10 08:11:40 -04:00
|
|
|
|
|
|
|
popd &>/dev/null
|
2007-06-01 17:10:27 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 14:07:28 -04:00
|
|
|
get_integlist() {
|
|
|
|
local integ
|
|
|
|
local integlist=()
|
|
|
|
|
|
|
|
for integ in md5 sha1 sha256 sha384 sha512; do
|
|
|
|
local integrity_sums=($(eval echo "\${${integ}sums[@]}"))
|
|
|
|
if [[ -n "$integrity_sums" ]]; then
|
|
|
|
integlist=(${integlist[@]} $integ)
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if (( ${#integlist[@]} > 0 )); then
|
|
|
|
echo ${integlist[@]}
|
|
|
|
else
|
|
|
|
echo ${INTEGRITY_CHECK[@]}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
generate_checksums() {
|
|
|
|
msg "$(gettext "Generating checksums for source files...")"
|
|
|
|
plain ""
|
|
|
|
|
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
|
|
|
|
integlist=$(get_integlist)
|
|
|
|
else
|
|
|
|
integlist=$@
|
|
|
|
fi
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
local integ
|
2009-10-14 14:07:28 -04:00
|
|
|
for integ in ${integlist[@]}; do
|
2007-06-01 17:10:27 -04:00
|
|
|
case "$integ" in
|
|
|
|
md5|sha1|sha256|sha384|sha512) : ;;
|
|
|
|
*)
|
|
|
|
error "$(gettext "Invalid integrity algorithm '%s' specified.")" "$integ"
|
|
|
|
exit 1;; # $E_CONFIG_ERROR
|
|
|
|
esac
|
|
|
|
|
|
|
|
local ct=0
|
|
|
|
local numsrc=${#source[@]}
|
|
|
|
echo -n "${integ}sums=("
|
|
|
|
|
2009-11-17 14:16:48 -05:00
|
|
|
local i
|
2007-06-01 17:10:27 -04:00
|
|
|
local indent=''
|
2009-11-17 14:16:48 -05:00
|
|
|
for (( i = 0; i < ${#integ} + 6; i++ )); do
|
2007-06-01 17:10:27 -04:00
|
|
|
indent="$indent "
|
|
|
|
done
|
|
|
|
|
|
|
|
local netfile
|
2008-06-15 06:10:31 -04:00
|
|
|
for netfile in "${source[@]}"; do
|
2010-06-03 11:32:50 -04:00
|
|
|
local file="$(get_filepath "$netfile")" || missing_source_file "$netfile"
|
2009-10-20 09:44:00 -04:00
|
|
|
local sum="$(openssl dgst -${integ} "$file")"
|
|
|
|
sum=${sum##* }
|
2009-11-12 15:07:34 -05:00
|
|
|
(( ct )) && echo -n "$indent"
|
2007-06-01 17:10:27 -04:00
|
|
|
echo -n "'$sum'"
|
|
|
|
ct=$(($ct+1))
|
2009-11-12 15:07:34 -05:00
|
|
|
(( $ct < $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
|
|
|
|
for integ in md5 sha1 sha256 sha384 sha512; do
|
2008-06-15 06:56:40 -04:00
|
|
|
local integrity_sums=($(eval echo "\${${integ}sums[@]}"))
|
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
|
2007-06-01 17:10:27 -04:00
|
|
|
local errors=0
|
|
|
|
local idx=0
|
|
|
|
local file
|
|
|
|
for file in "${source[@]}"; do
|
2009-04-07 00:15:45 -04:00
|
|
|
local found=1
|
2008-08-23 10:34:42 -04:00
|
|
|
file="$(get_filename "$file")"
|
2007-06-01 17:10:27 -04:00
|
|
|
echo -n " $file ... " >&2
|
|
|
|
|
2010-06-03 11:32:50 -04:00
|
|
|
if ! file="$(get_filepath "$file")"; then
|
|
|
|
echo "$(gettext "NOT FOUND")" >&2
|
|
|
|
errors=1
|
|
|
|
found=0
|
2007-07-10 08:11:40 -04:00
|
|
|
fi
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( $found )) ; then
|
2010-06-20 09:26:47 -04:00
|
|
|
local expectedsum=$(tr '[:upper:]' '[:lower:]' <<< "${integrity_sums[$idx]}")
|
2009-10-20 09:44:00 -04:00
|
|
|
local realsum="$(openssl dgst -${integ} "$file")"
|
|
|
|
realsum="${realsum##* }"
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $expectedsum = $realsum ]]; then
|
2009-04-07 00:15:45 -04:00
|
|
|
echo "$(gettext "Passed")" >&2
|
|
|
|
else
|
|
|
|
echo "$(gettext "FAILED")" >&2
|
|
|
|
errors=1
|
|
|
|
fi
|
2007-06-01 17:10:27 -04:00
|
|
|
fi
|
2007-08-03 20:17:54 -04:00
|
|
|
|
|
|
|
idx=$((idx + 1))
|
2007-06-01 17:10:27 -04:00
|
|
|
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"
|
|
|
|
|
|
|
|
local file
|
|
|
|
local warning=0
|
|
|
|
local errors=0
|
|
|
|
local statusfile=$(mktemp)
|
|
|
|
|
|
|
|
for file in "${source[@]}"; do
|
|
|
|
file="$(get_filename "$file")"
|
|
|
|
if [[ ! $file =~ .*(sig|asc) ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -n " ${file%.*} ... " >&2
|
|
|
|
|
|
|
|
if ! file="$(get_filepath "$file")"; then
|
|
|
|
echo "$(gettext "SIGNATURE NOT FOUND")" >&2
|
|
|
|
errors=1
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! sourcefile="$(get_filepath "${file%.*}")"; then
|
|
|
|
echo "$(gettext "SOURCE FILE NOT FOUND")" >&2
|
|
|
|
errors=1
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! gpg --quiet --batch --status-file "$statusfile" --verify "$file" "$sourcefile" 2> /dev/null; then
|
|
|
|
if grep "NO_PUBKEY" "$statusfile" > /dev/null; then
|
2011-08-08 20:01:26 -04:00
|
|
|
warning "$(gettext "Unknown public key") $(awk '/NO_PUBKEY/ {print $3}' $statusfile)" >&2
|
2011-07-06 07:02:19 -04:00
|
|
|
warnings=1
|
|
|
|
else
|
|
|
|
echo "$(gettext "FAILED")" >&2
|
|
|
|
errors=1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if grep "REVKEYSIG" "$statusfile" > /dev/null; then
|
|
|
|
echo "$(gettext "Passed")" "-" "$(gettext "Warning: the key has been revoked.")" >&2
|
|
|
|
errors=1
|
|
|
|
elif grep "EXPSIG" "$statusfile" > /dev/null; then
|
|
|
|
echo "$(gettext "Passed")" "-" "$(gettext "Warning: the signature has expired.")" >&2
|
|
|
|
warnings=1
|
|
|
|
elif grep "EXPKEYSIG" "$statusfile" > /dev/null; then
|
|
|
|
echo "$(gettext "Passed")" "-" "$(gettext "Warning: the key has expired.")" >&2
|
|
|
|
warnings=1
|
|
|
|
else
|
|
|
|
echo $(gettext "Passed") >&2
|
|
|
|
fi
|
|
|
|
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() {
|
|
|
|
msg "$(gettext "Extracting Sources...")"
|
|
|
|
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
|
2007-06-01 17:10:27 -04:00
|
|
|
#skip source files in the noextract=() array
|
|
|
|
# these are marked explicitly to NOT be extracted
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2007-07-10 08:11:40 -04:00
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
# fix flyspray #6246
|
2007-08-23 14:00:41 -04:00
|
|
|
local file_type=$(file -bizL "$file")
|
2009-08-05 10:12:46 -04:00
|
|
|
local ext=${file##*.}
|
2007-06-01 17:10:27 -04:00
|
|
|
local cmd=''
|
|
|
|
case "$file_type" in
|
2008-01-05 17:37:55 -05:00
|
|
|
*application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*)
|
2009-08-05 10:12:46 -04:00
|
|
|
cmd="bsdtar" ;;
|
2007-06-01 17:10:27 -04:00
|
|
|
*application/x-gzip*)
|
2009-08-05 10:12:46 -04:00
|
|
|
case "$ext" in
|
|
|
|
gz|z|Z) cmd="gzip" ;;
|
|
|
|
*) continue;;
|
|
|
|
esac ;;
|
2007-06-01 17:10:27 -04:00
|
|
|
*application/x-bzip*)
|
2009-08-05 10:12:46 -04:00
|
|
|
case "$ext" in
|
|
|
|
bz2|bz) cmd="bzip2" ;;
|
|
|
|
*) continue;;
|
|
|
|
esac ;;
|
2009-05-13 02:21:11 -04:00
|
|
|
*application/x-xz*)
|
2009-08-05 10:12:46 -04:00
|
|
|
case "$ext" in
|
|
|
|
xz) cmd="xz" ;;
|
|
|
|
*) continue;;
|
|
|
|
esac ;;
|
2007-06-02 12:41:15 -04:00
|
|
|
*)
|
2010-06-02 20:40:38 -04:00
|
|
|
# See if bsdtar can recognize the file
|
|
|
|
if bsdtar -tf "$file" -q '*' &>/dev/null; then
|
|
|
|
cmd="bsdtar"
|
|
|
|
else
|
|
|
|
continue
|
|
|
|
fi ;;
|
2007-06-01 17:10:27 -04:00
|
|
|
esac
|
|
|
|
|
2007-06-02 12:41:15 -04:00
|
|
|
local ret=0
|
2009-09-16 20:03:23 -04:00
|
|
|
msg2 "$(gettext "Extracting %s with %s")" "$file" "$cmd"
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $cmd = bsdtar ]]; then
|
2010-05-15 15:06:42 -04:00
|
|
|
$cmd -xf "$file" || ret=$?
|
2009-08-05 10:12:46 -04:00
|
|
|
else
|
|
|
|
rm -f "${file%.*}"
|
2010-05-15 15:06:42 -04:00
|
|
|
$cmd -dcf "$file" > "${file%.*}" || ret=$?
|
2009-08-05 10:12:46 -04:00
|
|
|
fi
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( ret )); then
|
2007-06-22 14:23:28 -04:00
|
|
|
error "$(gettext "Failed to extract %s")" "$file"
|
|
|
|
plain "$(gettext "Aborting...")"
|
2007-06-27 07:04:33 -04:00
|
|
|
exit 1
|
2007-06-01 17:10:27 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( EUID == 0 )); then
|
2008-05-27 15:22:08 -04:00
|
|
|
# change perms of all source files to root user & root group
|
|
|
|
chown -R 0:0 "$srcdir"
|
2007-06-01 17:10:27 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
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-06-02 13:39:47 -04:00
|
|
|
remove_deps
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
if [[ $(check_option buildflags) = "n" ]]; then
|
|
|
|
CFLAGS=""
|
|
|
|
CXXFLAGS=""
|
|
|
|
LDFLAGS=""
|
|
|
|
fi
|
|
|
|
|
2009-01-16 07:20:05 -05:00
|
|
|
# clear user-specified makeflags if requested
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $(check_option makeflags) = "n" ]]; then
|
2009-01-16 07:20:05 -05:00
|
|
|
MAKEFLAGS=""
|
|
|
|
fi
|
|
|
|
|
2009-01-16 07:26:52 -05:00
|
|
|
msg "$(gettext "Starting %s()...")" "$pkgfunc"
|
2009-01-16 07:20:05 -05:00
|
|
|
cd "$srcdir"
|
|
|
|
|
|
|
|
# ensure all necessary build variables are exported
|
|
|
|
export 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
|
2010-06-25 19:16:36 -04:00
|
|
|
local restoretrap
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( LOGGING )); then
|
2011-07-22 07:42:53 -04:00
|
|
|
local fullver=$(get_full_version)
|
2011-01-20 19:16:06 -05:00
|
|
|
local BUILDLOG="${startdir}/${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
|
2008-12-07 21:21:03 -05:00
|
|
|
logpipe=$(mktemp -u "$startdir/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=$!
|
|
|
|
|
2009-08-23 11:16:21 -04:00
|
|
|
restoretrap=$(trap -p ERR)
|
2010-06-30 08:16:25 -04:00
|
|
|
trap 'error_function $pkgfunc' ERR
|
2011-03-24 08:30:15 -04:00
|
|
|
$pkgfunc &>"$logpipe"
|
2009-08-23 11:16:21 -04:00
|
|
|
eval $restoretrap
|
2011-03-24 08:30:15 -04:00
|
|
|
|
|
|
|
wait $teepid
|
2008-12-07 21:21:03 -05:00
|
|
|
rm "$logpipe"
|
2009-01-16 07:20:05 -05:00
|
|
|
else
|
2009-08-23 11:16:21 -04:00
|
|
|
restoretrap=$(trap -p ERR)
|
2010-06-30 08:16:25 -04:00
|
|
|
trap 'error_function $pkgfunc' ERR
|
2009-08-23 11:16:21 -04:00
|
|
|
$pkgfunc 2>&1
|
|
|
|
eval $restoretrap
|
2009-01-16 07:20:05 -05:00
|
|
|
fi
|
2009-08-24 18:19:20 -04:00
|
|
|
# reset our shell options
|
|
|
|
eval "$shellopts"
|
|
|
|
}
|
|
|
|
|
|
|
|
run_build() {
|
|
|
|
# use distcc if it is requested (check buildenv and PKGBUILD opts)
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $(check_buildenv distcc) = "y" && $(check_option distcc) != "n" ]]; then
|
|
|
|
[[ -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)
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $(check_buildenv ccache) = "y" && $(check_option ccache) != "n" ]]; then
|
|
|
|
[[ -d /usr/lib/ccache/bin ]] && export PATH="/usr/lib/ccache/bin:$PATH"
|
2009-08-24 18:19:20 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
run_function "build"
|
|
|
|
}
|
|
|
|
|
2010-12-15 09:06:43 -05:00
|
|
|
run_check() {
|
|
|
|
run_function "check"
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
run_function "$pkgfunc"
|
2009-01-16 07:20:05 -05:00
|
|
|
}
|
|
|
|
|
2007-04-11 15:05:54 -04:00
|
|
|
tidy_install() {
|
2007-05-31 00:02:32 -04:00
|
|
|
cd "$pkgdir"
|
2007-05-14 11:36:04 -04:00
|
|
|
msg "$(gettext "Tidying install...")"
|
2007-04-11 15:06:01 -04:00
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $(check_option docs) = "n" && -n ${DOC_DIRS[*]} ]]; then
|
2008-08-12 13:00:18 -04:00
|
|
|
msg2 "$(gettext "Removing doc files...")"
|
2007-04-11 15:05:54 -04:00
|
|
|
rm -rf ${DOC_DIRS[@]}
|
|
|
|
fi
|
|
|
|
|
2009-11-12 15:07:34 -05: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
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ ${pt} = ${pt//\/} ]]; then
|
2008-12-07 06:14:32 -05:00
|
|
|
find . -type f -name "${pt}" -exec rm -f -- '{}' \;
|
|
|
|
else
|
|
|
|
rm -f ${pt}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2009-11-12 15:07:34 -05: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...")"
|
2008-11-23 06:17:15 -05:00
|
|
|
local manpage ext file link hardlinks hl
|
|
|
|
find ${MAN_DIRS[@]} -type f 2>/dev/null |
|
2008-03-12 19:25:38 -04:00
|
|
|
while read manpage ; do
|
2010-03-04 23:17:57 -05:00
|
|
|
ext="${manpage##*.}"
|
|
|
|
file="${manpage##*/}"
|
|
|
|
if [[ $ext != gz && $ext != bz2 ]]; then
|
|
|
|
# update symlinks to this manpage
|
|
|
|
find ${MAN_DIRS[@]} -lname "$file" 2>/dev/null |
|
|
|
|
while read link ; do
|
2011-06-26 15:13:48 -04:00
|
|
|
rm -f "$link" "${link}.gz"
|
|
|
|
ln -s "${file}.gz" "${link}.gz"
|
2010-03-04 23:17:57 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
# check file still exists (potentially already compressed due to hardlink)
|
|
|
|
if [[ -f ${manpage} ]]; then
|
2008-03-12 19:25:38 -04:00
|
|
|
# find hard links and remove them
|
|
|
|
# the '|| true' part keeps the script from bailing if find returned an
|
|
|
|
# error, such as when one of the man directories doesn't exist
|
2008-11-23 06:17:15 -05:00
|
|
|
hardlinks="$(find ${MAN_DIRS[@]} \! -name "$file" -samefile "$manpage" 2>/dev/null)" || true
|
2008-03-12 19:25:38 -04:00
|
|
|
for hl in ${hardlinks}; do
|
|
|
|
rm -f "${hl}";
|
|
|
|
done
|
|
|
|
# compress the original
|
|
|
|
gzip -9 "$manpage"
|
|
|
|
# recreate hard links removed earlier
|
|
|
|
for hl in ${hardlinks}; do
|
|
|
|
ln "${manpage}.gz" "${hl}.gz"
|
|
|
|
chmod 644 ${hl}.gz
|
|
|
|
done
|
|
|
|
fi
|
2007-12-04 18:50:29 -05:00
|
|
|
fi
|
2008-03-12 19:25:38 -04:00
|
|
|
done
|
|
|
|
fi
|
2007-04-11 15:05:54 -04:00
|
|
|
|
2010-09-29 07:22:30 -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"
|
2008-07-20 01:57:03 -04:00
|
|
|
local binary
|
2010-09-29 07:22:30 -04:00
|
|
|
find . -type f -perm -u+w 2>/dev/null | while read 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)
|
2009-12-21 14:26:28 -05:00
|
|
|
/usr/bin/strip $STRIP_SHARED "$binary";;
|
2008-07-18 00:20:24 -04:00
|
|
|
*application/x-archive*) # Libraries (.a)
|
2009-12-21 14:26:28 -05:00
|
|
|
/usr/bin/strip $STRIP_STATIC "$binary";;
|
2007-04-11 15:05:54 -04:00
|
|
|
*application/x-executable*) # Binaries
|
2009-12-21 14:26:28 -05:00
|
|
|
/usr/bin/strip $STRIP_BINARIES "$binary";;
|
2007-04-11 15:05:54 -04:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $(check_option libtool) = "n" ]]; then
|
2011-06-17 22:40:14 -04:00
|
|
|
msg2 "$(gettext "Removing "%s" files...")" "libtool"
|
2008-06-27 01:01:02 -04:00
|
|
|
find . ! -type d -name "*.la" -exec rm -f -- '{}' \;
|
2007-04-11 15:05:54 -04:00
|
|
|
fi
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $(check_option emptydirs) = "n" ]]; then
|
2007-04-11 15:06:01 -04:00
|
|
|
msg2 "$(gettext "Removing empty directories...")"
|
2007-10-28 22:18:39 -04:00
|
|
|
find . -depth -type d -empty -delete
|
2007-04-11 15:05:54 -04:00
|
|
|
fi
|
2011-06-14 08:01:05 -04:00
|
|
|
|
|
|
|
if [[ $(check_option upx) = "y" ]]; then
|
|
|
|
msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
|
|
|
|
local binary
|
|
|
|
find . -type f -perm -u+w 2>/dev/null | while read binary ; do
|
|
|
|
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() {
|
|
|
|
local libdepends
|
|
|
|
find "$pkgdir" -type f -perm -u+x | while read filename
|
|
|
|
do
|
|
|
|
# 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')
|
|
|
|
[ -n "$soarch" ] || continue
|
|
|
|
# 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
|
|
|
|
soname="${sofile%%\.so\.*}.so"
|
|
|
|
# extract the major version: 1
|
|
|
|
soversion="${sofile##*\.so\.}"
|
|
|
|
if in_array "${soname}" ${depends[@]}; then
|
|
|
|
if ! in_array "${soname}=${soversion}-${soarch}" ${libdepends[@]}; then
|
|
|
|
# libfoo.so=1-64
|
|
|
|
echo "${soname}=${soversion}-${soarch}"
|
|
|
|
libdepends=(${libdepends[@]} "${soname}=${soversion}-${soarch}")
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2010-02-10 11:07:30 -05:00
|
|
|
find_libprovides() {
|
|
|
|
local libprovides
|
|
|
|
find "$pkgdir" -type f -name \*.so\* | while read filename
|
|
|
|
do
|
|
|
|
# check if we really have a shared object
|
|
|
|
if LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
|
|
|
|
# 64
|
|
|
|
soarch=$(LC_ALL=C readelf -h "$filename" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
|
|
|
|
# get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
|
|
|
|
sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
|
2011-06-17 16:06:44 -04:00
|
|
|
[ -z "$sofile" ] && sofile="${filename##*/}"
|
2010-02-10 11:07:30 -05:00
|
|
|
|
|
|
|
# extract the library name: libfoo.so
|
|
|
|
soname="${sofile%%\.so\.*}.so"
|
|
|
|
# extract the major version: 1
|
|
|
|
soversion="${sofile##*\.so\.}"
|
|
|
|
if in_array "${soname}" ${provides[@]}; then
|
|
|
|
if ! in_array "${soname}=${soversion}-${soarch}" ${libprovides[@]}; then
|
|
|
|
# libfoo.so=1-64
|
|
|
|
echo "${soname}=${soversion}-${soarch}"
|
|
|
|
libprovides=(${libprovides[@]} "${soname}=${soversion}-${soarch}")
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
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
|
2010-06-29 23:29:26 -04:00
|
|
|
local size="$(@DUPATH@ -sk)"
|
2009-10-20 09:44:00 -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"
|
2010-05-27 12:34:22 -04:00
|
|
|
echo "# Generated by makepkg $myver"
|
2009-11-12 15:07:34 -05:00
|
|
|
if (( INFAKEROOT )); then
|
2010-05-27 12:34:22 -04:00
|
|
|
echo "# using $(fakeroot -v)"
|
2007-06-12 18:30:56 -04:00
|
|
|
fi
|
2010-05-27 12:34:22 -04:00
|
|
|
echo "# $(LC_ALL=C date -u)"
|
|
|
|
echo "pkgname = $1"
|
|
|
|
(( SPLITPKG )) && echo pkgbase = $pkgbase
|
2011-07-22 07:42:53 -04:00
|
|
|
echo "pkgver = $(get_full_version)"
|
2010-05-27 12:34:22 -04:00
|
|
|
echo "pkgdesc = $pkgdesc"
|
|
|
|
echo "url = $url"
|
|
|
|
echo "builddate = $builddate"
|
|
|
|
echo "packager = $packager"
|
|
|
|
echo "size = $size"
|
|
|
|
echo "arch = $PKGARCH"
|
2007-04-11 15:05:23 -04:00
|
|
|
|
2010-06-17 08:44:41 -04:00
|
|
|
[[ $license ]] && printf "license = %s\n" "${license[@]}"
|
|
|
|
[[ $replaces ]] && printf "replaces = %s\n" "${replaces[@]}"
|
|
|
|
[[ $groups ]] && printf "group = %s\n" "${groups[@]}"
|
|
|
|
[[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]}"
|
|
|
|
[[ $conflicts ]] && printf "conflict = %s\n" "${conflicts[@]}"
|
|
|
|
[[ $backup ]] && printf "backup = %s\n" "${backup[@]}"
|
2010-05-23 09:32:57 -04:00
|
|
|
|
2010-06-25 19:16:36 -04:00
|
|
|
local it
|
2010-02-10 11:07:30 -05:00
|
|
|
|
|
|
|
libprovides=$(find_libprovides)
|
2010-02-10 11:11:37 -05:00
|
|
|
libdepends=$(find_libdepends)
|
2010-02-10 11:07:30 -05:00
|
|
|
provides=("${provides[@]}" ${libprovides})
|
2010-02-10 11:11:37 -05:00
|
|
|
depends=("${depends[@]}" ${libdepends})
|
|
|
|
|
|
|
|
for it in "${depends[@]}"; do
|
|
|
|
if [[ $it = *.so ]]; then
|
|
|
|
# check if the entry has been found by find_libdepends
|
|
|
|
# if not, it's unneeded; tell the user so he can remove it
|
|
|
|
if [[ ! $libdepends =~ (^|\s)${it}=.* ]]; then
|
2011-06-15 07:59:06 -04:00
|
|
|
error "$(gettext "Cannot find library listed in %s: %s")" "'depends'" "$it"
|
2010-02-10 11:11:37 -05:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "depend = $it"
|
|
|
|
fi
|
|
|
|
done
|
2010-02-10 11:07:30 -05:00
|
|
|
|
|
|
|
for it in "${provides[@]}"; do
|
|
|
|
# ignore versionless entires (those come from the PKGBUILD)
|
|
|
|
if [[ $it = *.so ]]; then
|
|
|
|
# check if the entry has been found by find_libprovides
|
|
|
|
# if not, it's unneeded; tell the user so he can remove it
|
|
|
|
if [[ ! $libprovides =~ (^|\s)${it}=.* ]]; then
|
2011-06-15 07:59:06 -04:00
|
|
|
error "$(gettext "Cannot find library listed in %s: %s")" "'provides'" "$it"
|
2010-02-10 11:07:30 -05:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "provides = $it"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2008-09-27 00:47:29 -04:00
|
|
|
for it in "${packaging_options[@]}"; do
|
|
|
|
local ret="$(check_option $it)"
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $ret != "?" ]]; then
|
|
|
|
if [[ $ret = y ]]; then
|
2010-05-27 12:34:22 -04:00
|
|
|
echo "makepkgopt = $it"
|
2008-09-27 00:47:29 -04:00
|
|
|
else
|
2010-05-27 12:34:22 -04:00
|
|
|
echo "makepkgopt = !$it"
|
2008-09-27 00:47:29 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2007-04-11 15:05:23 -04:00
|
|
|
|
|
|
|
# TODO maybe remove this at some point
|
|
|
|
# warn if license array is not present or empty
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -z $license ]]; then
|
2007-05-28 15:21:58 -04:00
|
|
|
warning "$(gettext "Please add a license line to your %s!")" "$BUILDSCRIPT"
|
2011-06-17 22:40:14 -04:00
|
|
|
plain "$(gettext "Example for GPL\'ed software: %s.")" "license=('GPL')"
|
2007-04-11 15:05:23 -04:00
|
|
|
fi
|
2009-06-22 02:04:44 -04:00
|
|
|
}
|
|
|
|
|
2009-08-18 14:30:04 -04:00
|
|
|
check_package() {
|
|
|
|
cd "$pkgdir"
|
|
|
|
|
|
|
|
# check existence of backup files
|
|
|
|
local file
|
|
|
|
for file in "${backup[@]}"; do
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ ! -f $file ]]; then
|
2011-06-17 22:40:14 -04:00
|
|
|
warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
|
2009-08-18 14:30:04 -04:00
|
|
|
fi
|
|
|
|
done
|
2009-10-24 23:57:20 -04:00
|
|
|
|
2010-09-29 07:54:31 -04:00
|
|
|
# check for references to the build and package directory
|
2011-02-01 12:02:50 -05:00
|
|
|
if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
|
2009-10-24 23:57:20 -04:00
|
|
|
warning "$(gettext "Package contains reference to %s")" "\$srcdir"
|
|
|
|
fi
|
2011-02-01 12:02:50 -05:00
|
|
|
if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdir}" ; then
|
2010-09-29 07:54:31 -04:00
|
|
|
warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
|
|
|
|
fi
|
|
|
|
|
2009-08-18 14:30:04 -04:00
|
|
|
}
|
|
|
|
|
2009-06-22 02:04:44 -04:00
|
|
|
create_package() {
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ ! -d $pkgdir ]]; then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "Missing %s directory.")" "pkg/"
|
2009-06-22 02:04:44 -04:00
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_MISSING_PKGDIR
|
|
|
|
fi
|
|
|
|
|
2009-08-18 14:30:04 -04:00
|
|
|
check_package
|
|
|
|
|
2009-08-08 05:21:50 -04:00
|
|
|
cd "$pkgdir"
|
|
|
|
msg "$(gettext "Creating package...")"
|
|
|
|
|
2010-06-25 19:16:36 -04:00
|
|
|
local nameofpkg
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ -z $1 ]]; then
|
2009-06-22 02:04:44 -04:00
|
|
|
nameofpkg="$pkgname"
|
|
|
|
else
|
|
|
|
nameofpkg="$1"
|
|
|
|
fi
|
|
|
|
|
2009-11-12 15:07:34 -05:00
|
|
|
if [[ $arch = "any" ]]; then
|
2009-10-11 10:13:16 -04:00
|
|
|
PKGARCH="any"
|
|
|
|
else
|
|
|
|
PKGARCH=$CARCH
|
|
|
|
fi
|
|
|
|
|
2010-05-27 12:34:22 -04:00
|
|
|
write_pkginfo $nameofpkg > .PKGINFO
|
2009-06-22 02:04:44 -04:00
|
|
|
|
2007-12-29 12:24:57 -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"
|
|
|
|
comp_files+=" $dest"
|
|
|
|
fi
|
|
|
|
done
|
2007-04-11 15:05:23 -04:00
|
|
|
|
|
|
|
# tar it up
|
2007-04-11 15:05:47 -04:00
|
|
|
msg2 "$(gettext "Compressing package...")"
|
2007-04-11 15:05:23 -04:00
|
|
|
|
2010-06-25 19:16:36 -04:00
|
|
|
local EXT
|
2008-09-04 21:44:19 -04:00
|
|
|
case "$PKGEXT" in
|
2009-02-19 13:12:34 -05:00
|
|
|
*tar.gz) EXT=${PKGEXT%.gz} ;;
|
|
|
|
*tar.bz2) EXT=${PKGEXT%.bz2} ;;
|
2009-05-13 02:21:11 -04:00
|
|
|
*tar.xz) EXT=${PKGEXT%.xz} ;;
|
2011-07-14 15:58:46 -04:00
|
|
|
*tar.Z) EXT=${PKGEXT%.Z} ;;
|
2010-08-07 06:47:59 -04:00
|
|
|
*tar) EXT=${PKGEXT} ;;
|
2008-09-04 21:44:19 -04:00
|
|
|
*) warning "$(gettext "'%s' is not a valid archive extension.")" \
|
2009-02-19 13:12:34 -05:00
|
|
|
"$PKGEXT" ; EXT=$PKGEXT ;;
|
2008-09-04 21:44:19 -04:00
|
|
|
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="$PKGDEST/${nameofpkg}-${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
|
2010-08-27 12:23:32 -04:00
|
|
|
# TODO: Maybe this can be set globally for robustness
|
|
|
|
shopt -s -o pipefail
|
|
|
|
bsdtar -cf - $comp_files * |
|
|
|
|
case "$PKGEXT" in
|
|
|
|
*tar.gz) gzip -c -f -n ;;
|
|
|
|
*tar.bz2) bzip2 -c -f ;;
|
|
|
|
*tar.xz) xz -c -z - ;;
|
2011-07-14 15:58:46 -04:00
|
|
|
*tar.Z) compress -c -f ;;
|
2010-08-27 12:23:32 -04:00
|
|
|
*tar) 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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
gpg --detach-sign --use-agent ${SIGNWITHKEY} "$filename" &>/dev/null || ret=$?
|
|
|
|
|
|
|
|
|
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() {
|
|
|
|
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
|
|
|
|
if [[ -f $file ]]; then
|
2008-06-06 21:58:21 -04:00
|
|
|
msg2 "$(gettext "Adding %s...")" "$file"
|
2010-06-08 23:45:22 -04:00
|
|
|
ln -s "${startdir}/$file" "$srclinks/$pkgbase"
|
2010-06-03 11:32:50 -04:00
|
|
|
elif (( SOURCEONLY == 2 )); then
|
|
|
|
local absfile=$(get_filepath "$file") || missing_source_file "$file"
|
|
|
|
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
|
2011-06-04 03:15:09 -04:00
|
|
|
local filelist=$(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE")
|
2010-04-26 00:59:42 -04:00
|
|
|
local file
|
2010-06-09 01:31:30 -04:00
|
|
|
for file in $filelist; do
|
2010-04-26 00:59:42 -04:00
|
|
|
# evaluate any bash variables used
|
2010-06-08 23:45:22 -04:00
|
|
|
eval file=${file}
|
|
|
|
if [[ ! -f "${srclinks}/${pkgbase}/$file" ]]; then
|
|
|
|
msg2 "$(gettext "Adding %s file (%s)...")" "$i" "${file}"
|
2010-04-26 00:59:42 -04:00
|
|
|
ln -s "${startdir}/$file" "${srclinks}/${pkgbase}/"
|
|
|
|
fi
|
|
|
|
done
|
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
|
|
|
|
*tar.gz) TAR_OPT="z" ;;
|
|
|
|
*tar.bz2) TAR_OPT="j" ;;
|
2009-05-13 02:21:11 -04:00
|
|
|
*tar.xz) TAR_OPT="J" ;;
|
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...")"
|
2008-06-22 06:11:54 -04:00
|
|
|
cd "${srclinks}"
|
2009-03-06 03:28:47 -05:00
|
|
|
if ! bsdtar -c${TAR_OPT}Lf "$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
|
|
|
|
2011-02-01 09:59:34 -05:00
|
|
|
if (( ! ret )) && [[ ! "$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=$?
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( ret )); then
|
|
|
|
warning "$(gettext "Failed to create symlink to source package file.")"
|
|
|
|
fi
|
2010-06-23 01:35:56 -04:00
|
|
|
|
2008-06-22 06:11:54 -04:00
|
|
|
cd "${startdir}"
|
|
|
|
rm -rf "${srclinks}"
|
2007-05-30 14:27:13 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2011-01-20 19:16:06 -05:00
|
|
|
local fullver pkg pkglist
|
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)
|
2011-01-20 19:16:06 -05:00
|
|
|
if [[ -f $PKGDEST/${pkg}-${fullver}-${CARCH}${PKGEXT} ]]; then
|
|
|
|
pkglist+=" $PKGDEST/${pkg}-${fullver}-${CARCH}${PKGEXT}"
|
2009-10-11 10:13:16 -04:00
|
|
|
else
|
2011-01-20 19:16:06 -05:00
|
|
|
pkglist+=" $PKGDEST/${pkg}-${fullver}-any${PKGEXT}"
|
2009-10-11 10:13:16 -04:00
|
|
|
fi
|
2009-03-25 09:52:27 -04:00
|
|
|
done
|
|
|
|
|
2009-11-18 17:29:07 -05: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
|
|
|
|
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
|
2010-06-17 08:44:46 -04:00
|
|
|
for i in 'pkgname' 'pkgrel' 'pkgver'; do
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2011-07-22 02:30:41 -04:00
|
|
|
awk -F'=' '/^[[:space:]]*pkgver=/ { $1=""; print $0 }' "$BUILDFILE" |
|
|
|
|
while read i _; do
|
|
|
|
if [[ $i =~ [[:space:]:-] ]]; then
|
|
|
|
error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done || ret=1
|
2011-07-21 22:37:25 -04:00
|
|
|
|
2011-07-22 02:30:41 -04:00
|
|
|
awk -F'=' '/^[[:space:]]*pkgrel=/ { $1=""; print $0 }' "$BUILDFILE" |
|
|
|
|
while read i _; do
|
|
|
|
if [[ $i =~ [[:space:]-] ]]; then
|
|
|
|
error "$(gettext "%s is not allowed to contain hyphens or whitespace.")" "pkgrel"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done || ret=1
|
2009-06-06 13:49:37 -04:00
|
|
|
|
2011-07-22 06:08:39 -04:00
|
|
|
awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" |
|
|
|
|
while read i _; do
|
|
|
|
if [[ ! $i =~ ^[0-9]*$ ]]; then
|
|
|
|
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
|
2009-10-11 10:13:16 -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
|
|
|
|
if ! in_array $CARCH ${arch_list[@]}; then
|
|
|
|
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
|
2010-08-05 07:35:54 -04:00
|
|
|
if [[ $i != ${i//</} || $i != ${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
|
2010-08-05 07:35:54 -04:00
|
|
|
local pkg=${i%%:*}
|
2010-08-05 07:37:22 -04:00
|
|
|
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-06-09 02:48:50 -04:00
|
|
|
local filelist=$(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE")
|
2010-04-26 00:59:42 -04:00
|
|
|
local file
|
2010-06-09 01:31:30 -04:00
|
|
|
for file in $filelist; do
|
2010-04-26 00:59:42 -04:00
|
|
|
# evaluate any bash variables used
|
|
|
|
eval file=${file}
|
|
|
|
if [[ ! -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
|
|
|
|
done
|
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
|
2010-08-05 07:35:54 -04: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
|
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ${#pkgname[@]} > 1 )); then
|
2010-08-05 07:35:54 -04:00
|
|
|
for i in ${pkgname[@]}; do
|
|
|
|
if ! declare -f package_${i} >/dev/null; 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
|
|
|
|
2011-01-10 14:56:27 -05:00
|
|
|
return $ret
|
2009-06-06 13:49:37 -04:00
|
|
|
}
|
|
|
|
|
2011-06-20 23:02:07 -04:00
|
|
|
check_software() {
|
|
|
|
# check for needed software
|
|
|
|
local ret=0
|
|
|
|
|
2011-06-24 22:07:23 -04:00
|
|
|
# check for sudo if we will need it during makepkg execution
|
|
|
|
if (( ! ( ASROOT || INFAKEROOT ) && ( DEP_BIN || RMDEPS || INSTALL ) )); then
|
|
|
|
if ! type -p sudo >/dev/null; then
|
|
|
|
warning "$(gettext "Sudo can not be found. Will use su to acquire root privileges.")"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-06-20 23:02:07 -04:00
|
|
|
# fakeroot - building as non-root user
|
|
|
|
if [[ $(check_buildenv fakeroot) = "y" ]] && (( EUID > 0 )); then
|
|
|
|
if ! type -p fakeroot >/dev/null; then
|
|
|
|
error "$(gettext "Cannot find the %s binary required for building as non-root user.")" "fakeroot"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# gpg - package signing
|
|
|
|
if [[ $SIGNPKG == 'y' || (-z "$SIGNPKG" && $(check_buildenv sign) == 'y') ]]; then
|
|
|
|
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
|
|
|
|
if (( ! SKIPPGPCHECK )) && [[ source_has_signatures ]]; then
|
|
|
|
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
|
|
|
|
if [[ $(check_option upx) == 'y' ]]; then
|
|
|
|
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
|
|
|
|
if [[ $(check_buildenv distcc) = "y" && $(check_option distcc) != "n" ]]; then
|
|
|
|
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
|
|
|
|
if [[ $(check_buildenv ccache) = "y" && $(check_option ccache) != "n" ]]; then
|
|
|
|
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
|
|
|
|
if [[ $(check_option strip) = "y" ]]; then
|
|
|
|
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
|
|
|
|
if [[ $(check_option zipman) = "y" ]]; then
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2007-10-26 22:32:09 -04:00
|
|
|
devel_check() {
|
|
|
|
newpkgver=""
|
2009-04-26 05:52:29 -04:00
|
|
|
|
2009-12-11 18:25:32 -05:00
|
|
|
# Do not update pkgver if --holdver is set, when building a source package, repackaging,
|
|
|
|
# reading PKGBUILD from pipe (-f), or if we cannot write to the file (-w)
|
2011-07-10 19:36:00 -04:00
|
|
|
if (( HOLDVER || SOURCEONLY || REPKG )) ||
|
|
|
|
[[ ! -f $BUILDFILE || ! -w $BUILDFILE || $BUILDFILE = /dev/stdin ]]; then
|
2008-10-28 08:04:39 -04:00
|
|
|
return
|
|
|
|
fi
|
2009-04-26 05:52:29 -04:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -z $FORCE_VER ]]; then
|
2007-10-26 22:32:09 -04:00
|
|
|
# Check if this is a svn/cvs/etc PKGBUILD; set $newpkgver if so.
|
|
|
|
# This will only be used on the first call to makepkg; subsequent
|
|
|
|
# calls to makepkg via fakeroot will explicitly pass the version
|
|
|
|
# number to avoid having to determine the version number twice.
|
2011-06-25 00:31:42 -04:00
|
|
|
# Also do a check to make sure we have the VCS tool available.
|
2007-10-26 22:32:09 -04:00
|
|
|
oldpkgver=$pkgver
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -n ${_darcstrunk} && -n ${_darcsmod} ]] ; then
|
2011-06-25 00:31:42 -04:00
|
|
|
if ! type -p darcs >/dev/null; then
|
|
|
|
warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "darcs" "darcs"
|
|
|
|
return 0
|
|
|
|
fi
|
2011-02-28 18:50:23 -05:00
|
|
|
msg "$(gettext "Determining latest %s revision...")" 'darcs'
|
2007-10-26 22:32:09 -04:00
|
|
|
newpkgver=$(date +%Y%m%d)
|
2009-11-12 15:09:05 -05:00
|
|
|
elif [[ -n ${_cvsroot} && -n ${_cvsmod} ]] ; then
|
2011-06-25 00:31:42 -04:00
|
|
|
if ! type -p cvs >/dev/null; then
|
|
|
|
warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "cvs" "cvs"
|
|
|
|
return 0
|
|
|
|
fi
|
2011-02-28 18:50:23 -05:00
|
|
|
msg "$(gettext "Determining latest %s revision...")" 'cvs'
|
2007-10-26 22:32:09 -04:00
|
|
|
newpkgver=$(date +%Y%m%d)
|
2009-11-12 15:09:05 -05:00
|
|
|
elif [[ -n ${_gitroot} && -n ${_gitname} ]] ; then
|
2011-06-25 00:31:42 -04:00
|
|
|
if ! type -p git >/dev/null; then
|
2011-06-28 02:22:57 -04:00
|
|
|
warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "git" "git"
|
2011-06-25 00:31:42 -04:00
|
|
|
return 0
|
|
|
|
fi
|
2011-02-28 18:50:23 -05:00
|
|
|
msg "$(gettext "Determining latest %s revision...")" 'git'
|
2007-10-26 22:32:09 -04:00
|
|
|
newpkgver=$(date +%Y%m%d)
|
2009-11-12 15:09:05 -05:00
|
|
|
elif [[ -n ${_svntrunk} && -n ${_svnmod} ]] ; then
|
2011-06-25 00:31:42 -04:00
|
|
|
if ! type -p svn >/dev/null; then
|
|
|
|
warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "svn" "svn"
|
|
|
|
return 0
|
|
|
|
fi
|
2011-02-28 18:50:23 -05:00
|
|
|
msg "$(gettext "Determining latest %s revision...")" 'svn'
|
2008-07-17 23:38:34 -04:00
|
|
|
newpkgver=$(LC_ALL=C svn info $_svntrunk | sed -n 's/^Last Changed Rev: \([0-9]*\)$/\1/p')
|
2009-11-12 15:09:05 -05:00
|
|
|
elif [[ -n ${_bzrtrunk} && -n ${_bzrmod} ]] ; then
|
2011-06-25 00:31:42 -04:00
|
|
|
if ! type -p bzr >/dev/null; then
|
2011-06-28 02:22:57 -04:00
|
|
|
warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "bzr" "bzr"
|
2011-06-25 00:31:42 -04:00
|
|
|
return 0
|
|
|
|
fi
|
2011-02-28 18:50:23 -05:00
|
|
|
msg "$(gettext "Determining latest %s revision...")" 'bzr'
|
2007-10-26 22:32:09 -04:00
|
|
|
newpkgver=$(bzr revno ${_bzrtrunk})
|
2009-11-12 15:09:05 -05:00
|
|
|
elif [[ -n ${_hgroot} && -n ${_hgrepo} ]] ; then
|
2011-06-25 00:31:42 -04:00
|
|
|
if ! type -p hg >/dev/null; then
|
|
|
|
warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "hg" "hg"
|
|
|
|
return 0
|
|
|
|
fi
|
2011-02-28 18:50:23 -05:00
|
|
|
msg "$(gettext "Determining latest %s revision...")" 'hg'
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -d ./src/$_hgrepo ]] ; then
|
2007-10-26 22:32:09 -04:00
|
|
|
cd ./src/$_hgrepo
|
|
|
|
hg pull
|
|
|
|
hg update
|
|
|
|
else
|
2007-11-05 02:37:37 -05:00
|
|
|
[[ ! -d ./src/ ]] && mkdir ./src/
|
2007-10-26 22:32:09 -04:00
|
|
|
hg clone $_hgroot/$_hgrepo ./src/$_hgrepo
|
|
|
|
cd ./src/$_hgrepo
|
|
|
|
fi
|
2008-11-30 17:07:06 -05:00
|
|
|
newpkgver=$(hg tip --template "{rev}")
|
2007-10-26 22:32:09 -04:00
|
|
|
cd ../../
|
|
|
|
fi
|
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -n $newpkgver ]]; then
|
2007-10-26 22:32:09 -04:00
|
|
|
msg2 "$(gettext "Version found: %s")" "$newpkgver"
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
# Version number retrieved from fakeroot->makepkg argument
|
|
|
|
newpkgver=$FORCE_VER
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
devel_update() {
|
|
|
|
# This is lame, but if we're wanting to use an updated pkgver for
|
|
|
|
# retrieving svn/cvs/etc sources, we'll update the PKGBUILD with
|
|
|
|
# the new pkgver and then re-source it. This is the most robust
|
|
|
|
# method for dealing with PKGBUILDs that use, e.g.:
|
|
|
|
#
|
|
|
|
# pkgver=23
|
|
|
|
# ...
|
|
|
|
# _foo=pkgver
|
|
|
|
#
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -n $newpkgver ]]; then
|
|
|
|
if [[ $newpkgver != $pkgver ]]; then
|
|
|
|
if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then
|
2009-07-12 03:10:11 -04:00
|
|
|
@SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE"
|
|
|
|
@SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE"
|
|
|
|
source "$BUILDFILE"
|
2008-10-28 08:04:39 -04:00
|
|
|
fi
|
2007-10-26 22:32:09 -04:00
|
|
|
fi
|
|
|
|
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
|
|
|
|
pkgdir="$pkgdir/$pkgname"
|
2010-06-17 08:44:49 -04:00
|
|
|
mkdir -p "$pkgdir"
|
|
|
|
chmod a-s "$pkgdir"
|
|
|
|
backup_package_variables
|
2010-12-24 22:14:55 -05:00
|
|
|
run_package $pkgname
|
2010-06-17 08:44:49 -04:00
|
|
|
tidy_install
|
2010-12-24 22:14:55 -05:00
|
|
|
create_package $pkgname
|
2010-06-17 08:44:49 -04:00
|
|
|
restore_package_variables
|
|
|
|
pkgdir="${pkgdir%/*}"
|
|
|
|
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
|
|
|
|
(
|
|
|
|
cd "$path"
|
|
|
|
pwd -P
|
|
|
|
)
|
|
|
|
else
|
|
|
|
echo "$path"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2011-06-08 09:36:46 -04:00
|
|
|
m4_include(library/parse_options.sh)
|
2008-12-22 06:28:35 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
usage() {
|
2007-06-04 01:21:14 -04:00
|
|
|
printf "makepkg (pacman) %s\n" "$myver"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2007-05-28 15:21:58 -04:00
|
|
|
printf "$(gettext "Usage: %s [options]")\n" "$0"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext "Options:")"
|
2011-06-17 22:40:14 -04:00
|
|
|
printf "$(gettext " -A, --ignorearch Ignore incomplete %s field in %s")\n" "arch" "$BUILDSCRIPT"
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext " -c, --clean Clean up work files after build")"
|
|
|
|
echo "$(gettext " -d, --nodeps Skip all dependency checks")"
|
2011-06-17 22:40:14 -04:00
|
|
|
printf "$(gettext " -e, --noextract Do not extract source files (use existing %s dir)")\n" "src/"
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext " -f, --force Overwrite existing package")"
|
|
|
|
echo "$(gettext " -g, --geninteg Generate integrity checks for source files")"
|
2011-04-21 09:59:05 -04:00
|
|
|
echo "$(gettext " -h, --help Show this help message and exit")"
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext " -i, --install Install package after successful build")"
|
|
|
|
echo "$(gettext " -L, --log Log package build process")"
|
|
|
|
echo "$(gettext " -m, --nocolor Disable colorized output messages")"
|
|
|
|
echo "$(gettext " -o, --nobuild Download and extract files only")"
|
2009-09-21 00:47:16 -04:00
|
|
|
printf "$(gettext " -p <file> Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT"
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build")"
|
2009-05-10 11:16:51 -04:00
|
|
|
echo "$(gettext " -R, --repackage Repackage contents of the package without rebuilding")"
|
2011-06-17 22:40:14 -04:00
|
|
|
printf "$(gettext " -s, --syncdeps Install missing dependencies with %s")\n" "pacman"
|
2009-09-21 00:47:16 -04:00
|
|
|
echo "$(gettext " --allsource Generate a source-only tarball including downloaded sources")"
|
2011-06-17 22:40:14 -04:00
|
|
|
printf "$(gettext " --asroot Allow %s to run as root user")\n" "makepkg"
|
|
|
|
printf "$(gettext " --check Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
|
2009-09-21 00:47:16 -04:00
|
|
|
printf "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
|
2010-12-15 09:42:23 -05:00
|
|
|
printf "$(gettext " --holdver Prevent automatic version bumping for development %ss")\n" "$BUILDSCRIPT"
|
2011-06-17 22:40:14 -04:00
|
|
|
printf "$(gettext " --key <key> Specify a key to use for %s signing instead of the default")\n" "gpg"
|
|
|
|
printf "$(gettext " --nocheck Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
|
2011-03-25 22:06:06 -04:00
|
|
|
echo "$(gettext " --nosign Do not create a signature for the package")"
|
2009-10-22 00:40:03 -04:00
|
|
|
echo "$(gettext " --pkg <list> Only build listed packages from a split package")"
|
2011-06-17 22:40:14 -04:00
|
|
|
printf "$(gettext " --sign Sign the resulting package with %s")\n" "gpg"
|
2011-07-16 08:42:32 -04:00
|
|
|
echo "$(gettext " --skipchecksums Do not verify checksums of the source files")"
|
|
|
|
echo "$(gettext " --skipinteg Do not perform any verification checks on source files")"
|
2011-08-08 20:01:26 -04:00
|
|
|
echo "$(gettext " --skippgpcheck Do not verify source files with PGP signatures")"
|
2009-09-21 00:47:16 -04:00
|
|
|
echo "$(gettext " --source Generate a source-only tarball without downloaded sources")"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo
|
2011-06-17 22:40:14 -04:00
|
|
|
printf "$(gettext "These options can be passed to %s:")\n" "pacman"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2009-09-21 00:47:16 -04:00
|
|
|
echo "$(gettext " --noconfirm Do not ask for confirmation when resolving dependencies")"
|
|
|
|
echo "$(gettext " --noprogressbar Do not show a progress bar when downloading files")"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2011-06-17 22:40:14 -04: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() {
|
2007-07-06 19:35:32 -04:00
|
|
|
printf "makepkg (pacman) %s\n" "$myver"
|
|
|
|
printf "$(gettext "\
|
2011-01-05 23:45:15 -05:00
|
|
|
Copyright (c) 2006-2011 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
|
|
|
|
|
|
|
|
# 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() {
|
|
|
|
echo "$@"
|
|
|
|
}
|
|
|
|
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.
|
2011-07-08 09:01:37 -04:00
|
|
|
OPT_SHORT="AcdefFghiLmop:rRsV"
|
2011-06-24 03:19:32 -04:00
|
|
|
OPT_LONG="allsource,asroot,ignorearch,check,clean,nodeps"
|
2011-07-06 07:02:19 -04:00
|
|
|
OPT_LONG+=",noextract,force,forcever:,geninteg,help,holdver,skippgpcheck"
|
2011-03-25 22:06:06 -04:00
|
|
|
OPT_LONG+=",install,key:,log,nocolor,nobuild,nocheck,nosign,pkg:,rmdeps"
|
2011-07-16 08:42:32 -04:00
|
|
|
OPT_LONG+=",repackage,skipchecksums,skipinteg,skippgpcheck,sign,source,syncdeps"
|
|
|
|
OPT_LONG+=",version,config:"
|
|
|
|
|
2007-06-05 06:58:25 -04:00
|
|
|
# Pacman Options
|
2010-06-17 08:44:48 -04:00
|
|
|
OPT_LONG+=",noconfirm,noprogressbar"
|
2011-07-08 00:31:23 -04:00
|
|
|
if ! OPT_TEMP="$(parse_options $OPT_SHORT $OPT_LONG "$@")"; then
|
2007-06-05 06:58:25 -04:00
|
|
|
echo; usage; exit 1 # E_INVALID_OPTION;
|
|
|
|
fi
|
|
|
|
eval set -- "$OPT_TEMP"
|
|
|
|
unset OPT_SHORT OPT_LONG OPT_TEMP
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
# Pacman Options
|
2010-06-17 08:44:48 -04:00
|
|
|
--noconfirm) PACMAN_OPTS+=" --noconfirm" ;;
|
|
|
|
--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
|
|
|
--asroot) ASROOT=1 ;;
|
|
|
|
-A|--ignorearch) IGNOREARCH=1 ;;
|
|
|
|
-c|--clean) CLEANUP=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 ;;
|
2008-01-13 18:39:06 -05:00
|
|
|
#hidden opt used by fakeroot call for svn/cvs/etc PKGBUILDs to set pkgver
|
|
|
|
--forcever) shift; FORCE_VER=$1;;
|
2007-06-13 05:48:22 -04:00
|
|
|
-F) INFAKEROOT=1 ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-g|--geninteg) GENINTEG=1 ;;
|
2008-01-13 18:39:06 -05: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' ;;
|
2010-12-15 09:06:43 -05:00
|
|
|
--nocheck) RUN_CHECK='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 ;;
|
2010-07-24 17:13:01 -04:00
|
|
|
--pkg) shift; PKGLIST=($1) ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-r|--rmdeps) RMDEPS=1 ;;
|
|
|
|
-R|--repackage) REPKG=1 ;;
|
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;;
|
2011-03-25 22:06:06 -04:00
|
|
|
--sign) SIGNPKG='y' ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
--source) SOURCEONLY=1 ;;
|
|
|
|
-s|--syncdeps) DEP_BIN=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
|
|
|
|
|
2007-06-13 05:48:22 -04:00
|
|
|
--) OPT_IND=0; shift; break;;
|
2007-06-05 06:58:25 -04:00
|
|
|
*) usage; exit 1 ;; # E_INVALID_OPTION
|
2005-03-14 20:51:43 -05:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
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})
|
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}
|
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
|
2008-08-07 11:08:33 -04:00
|
|
|
source "$MAKEPKG_CONF"
|
|
|
|
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
|
2008-08-07 11:08:33 -04:00
|
|
|
source ~/.makepkg.conf
|
|
|
|
fi
|
|
|
|
|
2009-12-02 13:04:32 -05:00
|
|
|
# set pacman command if not already defined
|
|
|
|
PACMAN=${PACMAN:-pacman}
|
|
|
|
|
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
|
2009-11-12 15:09:05 -05: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
|
2010-10-14 12:32:46 -04:00
|
|
|
ALL_OFF="\e[1;0m"
|
|
|
|
BOLD="\e[1;1m"
|
|
|
|
BLUE="${BOLD}\e[1;34m"
|
|
|
|
GREEN="${BOLD}\e[1;32m"
|
|
|
|
RED="${BOLD}\e[1;31m"
|
|
|
|
YELLOW="${BOLD}\e[1;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
|
|
|
|
mkdir -p "$BUILDDIR" ||
|
|
|
|
error "$(gettext "You do not have write permission to create packages in %s.")" "$BUILDDIR"
|
|
|
|
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
|
|
|
|
srcdir="$BUILDDIR/src"
|
|
|
|
pkgdir="$BUILDDIR/pkg"
|
|
|
|
|
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
|
2008-08-07 11:08:33 -04:00
|
|
|
|
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}
|
2008-08-07 11:08:33 -04:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( HOLDVER )) && [[ -n $FORCE_VER ]]; then
|
2008-05-26 02:27:22 -04:00
|
|
|
# The '\\0' is here to prevent gettext from thinking --holdver is an option
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "\\0%s and %s cannot both be specified" )" "--holdver" "--forcever"
|
2008-01-13 18:39:06 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! INFAKEROOT )); then
|
|
|
|
if (( EUID == 0 && ! ASROOT )); then
|
2007-04-11 15:06:25 -04:00
|
|
|
# Warn those who like to live dangerously.
|
2011-08-08 20:01:26 -04:00
|
|
|
error "$(gettext "Running %s as root is a BAD idea and can cause permanent,\n\
|
|
|
|
catastrophic damage to your system. If you wish to run as root, please\n\
|
|
|
|
use the %s option.")" "makepkg" "--asroot"
|
2007-06-01 13:43:41 -04:00
|
|
|
exit 1 # $E_USER_ABORT
|
2009-11-12 15:09:05 -05:00
|
|
|
elif (( EUID > 0 && ASROOT )); then
|
2007-06-01 13:43:41 -04:00
|
|
|
# Warn those who try to use the --asroot option when they are not root
|
2011-08-08 20:01:26 -04:00
|
|
|
error "$(gettext "The %s option is meant for the root user only. Please\n\
|
|
|
|
rerun %s without the %s flag.")" "--asroot" "makepkg" "--asroot"
|
2007-04-11 15:06:25 -04:00
|
|
|
exit 1 # $E_USER_ABORT
|
2011-06-20 23:02:07 -04:00
|
|
|
elif (( EUID > 0 )) && [[ $(check_buildenv fakeroot) != "y" ]]; then
|
2011-08-08 20:01:26 -04:00
|
|
|
warning "$(gettext "Running %s as an unprivileged user will result in non-root\n\
|
|
|
|
ownership of the packaged files. Try using the %s environment by\n\
|
|
|
|
placing %s in the %s array in %s.")" "makepkg" "fakeroot" "'fakeroot'" "BUILDENV" "$MAKEPKG_CONF"
|
2007-04-11 15:06:25 -04:00
|
|
|
sleep 1
|
|
|
|
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
|
|
|
|
if [[ -t 0 ]]; then
|
2009-07-12 03:10:11 -04:00
|
|
|
error "$(gettext "%s does not exist.")" "$BUILDFILE"
|
2008-10-29 00:21:28 -04:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
# PKGBUILD passed through a pipe
|
2009-07-12 03:10:11 -04:00
|
|
|
BUILDFILE=/dev/stdin
|
|
|
|
source "$BUILDFILE"
|
2008-10-29 00:21:28 -04:00
|
|
|
fi
|
2008-12-07 00:32:34 -05:00
|
|
|
else
|
2009-07-12 03:10:11 -04:00
|
|
|
crlftest=$(file "$BUILDFILE" | grep -F 'CRLF' || true)
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -n $crlftest ]]; 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
|
|
|
|
source "$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}
|
|
|
|
|
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"
|
2008-05-26 02:27:22 -04:00
|
|
|
cd "$srcdir"
|
|
|
|
download_sources
|
|
|
|
generate_checksums
|
|
|
|
exit 0 # $E_OK
|
|
|
|
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
|
|
|
|
2008-01-13 18:39:06 -05:00
|
|
|
# We need to run devel_update regardless of whether we are in the fakeroot
|
|
|
|
# build process so that if the user runs makepkg --forcever manually, we
|
|
|
|
# 1) output the correct pkgver, and 2) use the correct filename when
|
|
|
|
# checking if the package file already exists - fixes FS #9194
|
2007-11-08 02:26:01 -05:00
|
|
|
devel_check
|
2008-01-13 18:39:06 -05:00
|
|
|
devel_update
|
2007-11-08 02:26:01 -05: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
|
2010-06-17 08:44:42 -04:00
|
|
|
if declare -f build >/dev/null; then
|
2009-10-27 07:56:13 -04:00
|
|
|
BUILDFUNC=1
|
|
|
|
fi
|
2010-12-15 09:06:43 -05:00
|
|
|
if declare -f check >/dev/null; then
|
|
|
|
# "Hide" check() function if not going to be run
|
|
|
|
if [[ $RUN_CHECK = 'y' || (! $(check_buildenv check) = "n" && ! $RUN_CHECK = "n") ]]; then
|
|
|
|
CHECKFUNC=1
|
|
|
|
fi
|
|
|
|
fi
|
2010-06-17 08:44:42 -04:00
|
|
|
if declare -f package >/dev/null; then
|
2009-10-25 00:33:47 -04:00
|
|
|
PKGFUNC=1
|
2010-06-17 08:44:42 -04:00
|
|
|
elif [[ $SPLITPKG -eq 0 ]] && declare -f package_${pkgname} >/dev/null; 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
|
2011-06-28 22:36:41 -04:00
|
|
|
[[ -z $SIGNPKG ]] && SIGNPKG=$(check_buildenv sign)
|
2011-03-25 22:06:06 -04:00
|
|
|
if [[ $SIGNPKG == 'y' ]]; then
|
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
|
|
|
|
|
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! SPLITPKG )); then
|
2011-07-22 07:42:53 -04:00
|
|
|
fullver=$(get_full_version)
|
2011-01-20 19:16:06 -05:00
|
|
|
if [[ -f $PKGDEST/${pkgname}-${fullver}-${CARCH}${PKGEXT} \
|
|
|
|
|| -f $PKGDEST/${pkgname}-${fullver}-any${PKGEXT} ]] \
|
2009-11-12 15:09:05 -05:00
|
|
|
&& ! (( FORCE || SOURCEONLY || NOBUILD )); then
|
|
|
|
if (( INSTALL )); then
|
2009-07-01 23:53:29 -04:00
|
|
|
warning "$(gettext "A package has already been built, installing existing package...")"
|
|
|
|
install_package
|
|
|
|
exit $?
|
|
|
|
else
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f"
|
2009-07-01 23:53:29 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
allpkgbuilt=1
|
|
|
|
somepkgbuilt=0
|
|
|
|
for pkg in ${pkgname[@]}; do
|
2011-07-22 07:42:53 -04:00
|
|
|
fullver=$(get_full_version $pkg)
|
2011-01-20 19:16:06 -05:00
|
|
|
if [[ -f $PKGDEST/${pkg}-${fullver}-${CARCH}${PKGEXT} \
|
|
|
|
|| -f $PKGDEST/${pkg}-${fullver}-any${PKGEXT} ]]; then
|
2009-07-01 23:53:29 -04:00
|
|
|
somepkgbuilt=1
|
|
|
|
else
|
|
|
|
allpkgbuilt=0
|
|
|
|
fi
|
|
|
|
done
|
2009-11-12 15:09:05 -05:00
|
|
|
if ! (( FORCE || SOURCEONLY || NOBUILD )); then
|
|
|
|
if (( allpkgbuilt )); then
|
|
|
|
if (( INSTALL )); then
|
2009-07-01 23:53:29 -04:00
|
|
|
warning "$(gettext "The package group has already been built, installing existing packages...")"
|
|
|
|
install_package
|
|
|
|
exit $?
|
|
|
|
else
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f"
|
2009-07-01 23:53:29 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( somepkgbuilt )); then
|
2011-06-17 22:40:14 -04:00
|
|
|
error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f"
|
2009-07-01 23:53:29 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
2009-07-01 23:53:29 -04:00
|
|
|
unset allpkgbuilt somepkgbuilt
|
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
|
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! SPLITPKG )); then
|
|
|
|
if (( ! PKGFUNC )); then
|
2010-04-14 02:22:43 -04:00
|
|
|
if (( ! REPKG )); then
|
|
|
|
if (( BUILDFUNC )); then
|
|
|
|
run_build
|
2010-12-15 09:06:43 -05:00
|
|
|
(( CHECKFUNC )) && run_check
|
2010-04-14 02:22:43 -04:00
|
|
|
tidy_install
|
|
|
|
fi
|
|
|
|
else
|
2011-06-27 22:42:22 -04:00
|
|
|
warning "$(gettext "Repackaging without the use of a %s function is deprecated.")" "package()"
|
2010-04-14 02:22:43 -04:00
|
|
|
plain "$(gettext "File permissions may not be preserved.")"
|
2009-01-16 07:32:05 -05:00
|
|
|
fi
|
2009-01-17 01:41:01 -05:00
|
|
|
else
|
|
|
|
run_package
|
2009-01-16 07:32:05 -05:00
|
|
|
tidy_install
|
2009-01-16 07:20:05 -05:00
|
|
|
fi
|
2009-01-16 07:32:05 -05:00
|
|
|
create_package
|
|
|
|
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
|
|
|
|
|
2011-07-22 07:42:53 -04:00
|
|
|
fullver=$(get_full_version)
|
2011-01-20 19:16:06 -05:00
|
|
|
msg "$(gettext "Making package: %s")" "$pkgbase $fullver ($(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
|
2011-01-20 19:16:06 -05:00
|
|
|
if [[ -f $SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT} ]] \
|
2009-11-12 15:09:05 -05: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"
|
|
|
|
cd "$srcdir"
|
2011-07-16 08:42:32 -04:00
|
|
|
if ( (( ! SKIPCHECKSUMS )) || \
|
|
|
|
( (( ! SKIPPGPCHECK )) && source_has_signatures ) ) || \
|
|
|
|
(( SOURCEONLY == 2 )); then
|
2011-06-15 02:02:22 -04:00
|
|
|
download_sources
|
|
|
|
fi
|
2011-07-18 05:58:54 -04:00
|
|
|
check_source_integrity
|
2011-06-15 02:02:22 -04:00
|
|
|
cd "$startdir"
|
|
|
|
|
|
|
|
# if we are root or if fakeroot is not enabled, then we don't use it
|
|
|
|
if [[ $(check_buildenv fakeroot) != "y" ]] || (( EUID == 0 )); then
|
|
|
|
create_srcpackage
|
|
|
|
else
|
|
|
|
enter_fakeroot
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
2010-05-17 10:52:38 -04:00
|
|
|
if (( NODEPS || ( (NOBUILD || REPKG) && !DEP_BIN ) )); then
|
2008-11-13 12:08:52 -05:00
|
|
|
# no warning message needed for nobuild, repkg
|
2010-05-17 10:52:38 -04:00
|
|
|
if (( NODEPS || ( REPKG && PKGFUNC ) )); then
|
2007-06-02 13:39:48 -04:00
|
|
|
warning "$(gettext "Skipping dependency checks.")"
|
2007-01-31 21:12:49 -05:00
|
|
|
fi
|
2010-05-27 11:06:08 -04:00
|
|
|
elif type -p "${PACMAN%% *}" >/dev/null; then
|
2009-10-23 01:30:47 -04:00
|
|
|
if (( RMDEPS )); 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
|
|
|
|
2010-06-17 08:44:51 -04:00
|
|
|
msg "$(gettext "Checking buildtime dependencies...")"
|
2007-06-02 12:41:15 -04:00
|
|
|
resolve_deps ${makedepends[@]} || deperr=1
|
2007-02-14 00:52:49 -05:00
|
|
|
|
2010-12-15 09:06:43 -05:00
|
|
|
if (( CHECKFUNC )); then
|
|
|
|
resolve_deps ${checkdepends[@]} || deperr=1
|
|
|
|
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
|
|
|
|
else
|
2011-06-17 22:40:14 -04:00
|
|
|
warning "$(gettext "%s was not found in %s; skipping dependency checks.")" "${PACMAN%% *}" "PATH"
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2008-02-08 16:34:51 -05:00
|
|
|
# ensure we have a sane umask set
|
|
|
|
umask 0022
|
|
|
|
|
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"
|
2007-05-31 00:02:32 -04:00
|
|
|
cd "$srcdir"
|
2007-04-04 22:30:05 -04:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( NOEXTRACT )); then
|
2011-06-17 22:40:14 -04:00
|
|
|
warning "$(gettext "Skipping source retrieval -- using existing %s tree")" "src/"
|
|
|
|
warning "$(gettext "Skipping source integrity checks -- using existing %s tree")" "src/"
|
|
|
|
warning "$(gettext "Skipping source extraction -- using existing %s tree")" "src/"
|
2007-06-02 22:33:17 -04:00
|
|
|
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( NOEXTRACT )) && [[ -z $(ls "$srcdir" 2>/dev/null) ]]; then
|
2007-06-02 22:33:17 -04:00
|
|
|
error "$(gettext "The source directory is empty, there is nothing to build!")"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-11-12 15:09:05 -05:00
|
|
|
elif (( REPKG )); then
|
|
|
|
if (( ! PKGFUNC && ! SPLITPKG )) \
|
|
|
|
&& [[ ! -d $pkgdir || -z $(ls "$pkgdir" 2>/dev/null) ]]; then
|
2009-01-17 01:41:01 -05:00
|
|
|
error "$(gettext "The package directory is empty, there is nothing to repackage!")"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2007-06-02 11:45:17 -04:00
|
|
|
download_sources
|
2011-07-18 05:58:54 -04:00
|
|
|
check_source_integrity
|
2007-06-01 17:10:27 -04:00
|
|
|
extract_sources
|
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
|
2007-04-11 15:06:25 -04:00
|
|
|
# check for existing pkg directory; don't remove if we are repackaging
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ -d $pkgdir ]] && (( ! REPKG || PKGFUNC || SPLITPKG )); then
|
2011-06-17 22:40:14 -04:00
|
|
|
msg "$(gettext "Removing existing %s directory...")" "pkg/"
|
2007-05-31 00:02:32 -04:00
|
|
|
rm -rf "$pkgdir"
|
2006-12-21 12:42:58 -05:00
|
|
|
fi
|
2007-05-31 00:02:32 -04:00
|
|
|
mkdir -p "$pkgdir"
|
2010-03-06 07:02:36 -05:00
|
|
|
chmod a-s "$pkgdir"
|
2008-01-08 10:10:45 -05:00
|
|
|
cd "$startdir"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2008-11-13 12:08:52 -05:00
|
|
|
# if we are root or if fakeroot is not enabled, then we don't use it
|
2009-11-12 15:09:05 -05:00
|
|
|
if [[ $(check_buildenv fakeroot) != "y" ]] || (( EUID == 0 )); then
|
|
|
|
if (( ! REPKG )); then
|
2009-01-17 01:41:01 -05:00
|
|
|
devel_update
|
2009-10-27 07:56:13 -04:00
|
|
|
(( BUILDFUNC )) && run_build
|
2010-12-15 09:06:43 -05:00
|
|
|
(( CHECKFUNC )) && run_check
|
2009-01-17 01:41:01 -05:00
|
|
|
fi
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! SPLITPKG )); then
|
|
|
|
if (( PKGFUNC )); then
|
2009-01-17 01:41:01 -05:00
|
|
|
run_package
|
|
|
|
tidy_install
|
2010-04-14 02:22:43 -04:00
|
|
|
else
|
|
|
|
if (( ! REPKG )); then
|
|
|
|
tidy_install
|
|
|
|
else
|
2011-06-24 06:59:20 -04:00
|
|
|
warning "$(gettext "Repackaging without the use of a %s function is deprecated.")" "package()"
|
2010-04-14 02:22:43 -04:00
|
|
|
plain "$(gettext "File permissions may not be preserved.")"
|
|
|
|
fi
|
2009-01-16 07:32:05 -05:00
|
|
|
fi
|
|
|
|
create_package
|
|
|
|
else
|
2010-06-17 08:44:49 -04:00
|
|
|
run_split_packaging
|
2007-04-11 15:06:25 -04:00
|
|
|
fi
|
|
|
|
else
|
2009-11-12 15:09:05 -05:00
|
|
|
if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then
|
2009-01-16 07:20:05 -05:00
|
|
|
devel_update
|
2009-10-27 07:56:13 -04:00
|
|
|
(( BUILDFUNC )) && run_build
|
2010-12-15 09:06:43 -05:00
|
|
|
(( CHECKFUNC )) && run_check
|
2009-01-16 07:20:05 -05:00
|
|
|
cd "$startdir"
|
|
|
|
fi
|
|
|
|
|
2011-06-15 02:02:22 -04:00
|
|
|
enter_fakeroot
|
2007-04-11 15:06:25 -04:00
|
|
|
fi
|
|
|
|
fi
|
2006-12-05 02:43:42 -05:00
|
|
|
|
2011-07-22 07:42:53 -04:00
|
|
|
fullver=$(get_full_version)
|
2011-01-20 19:16:06 -05:00
|
|
|
msg "$(gettext "Finished making: %s")" "$pkgbase $fullver ($(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
|
|
|
|
2007-04-11 15:05:54 -04:00
|
|
|
# vim: set ts=2 sw=2 noet:
|