2007-06-02 20:59:54 -04:00
|
|
|
#!/bin/bash -e
|
2006-12-21 14:11:22 -05:00
|
|
|
#
|
2006-12-21 12:42:58 -05:00
|
|
|
# makepkg - make packages compatable for use with pacman
|
2007-05-30 11:04:49 -04:00
|
|
|
# @configure_input@
|
2006-12-21 14:11:22 -05:00
|
|
|
#
|
2008-01-08 10:10:45 -05:00
|
|
|
# Copyright (c) 2002-2008 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:
|
|
|
|
# awk, bsdtar (libarchive), bzip2, coreutils, fakeroot, find (findutils),
|
2008-05-31 02:35:16 -04:00
|
|
|
# getopt (util-linux), gettext, grep, gzip, openssl, sed
|
2007-07-15 22:31:29 -04:00
|
|
|
|
2007-03-31 20:07:37 -04:00
|
|
|
# gettext initialization
|
2007-06-01 10:28:52 -04:00
|
|
|
export TEXTDOMAIN='pacman'
|
|
|
|
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@'
|
|
|
|
startdir="$PWD"
|
2007-05-30 14:32:04 -04:00
|
|
|
srcdir="$startdir/src"
|
|
|
|
pkgdir="$startdir/pkg"
|
2008-05-13 06:26:11 -04:00
|
|
|
known_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'ccache' 'distcc' 'makeflags' 'force')
|
|
|
|
readonly -a known_options
|
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
|
|
|
|
CLEANCACHE=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
|
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
|
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
|
2007-08-29 05:49:24 -04:00
|
|
|
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2007-09-28 13:45:14 -04:00
|
|
|
printf "\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2007-05-28 15:21:58 -04:00
|
|
|
printf " ${mesg}\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
}
|
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
|
2007-08-29 05:49:24 -04:00
|
|
|
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2007-09-28 13:45:14 -04:00
|
|
|
printf "\033[1;32m==>\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2007-05-28 15:21:58 -04:00
|
|
|
printf "==> ${mesg}\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
}
|
2006-11-14 02:58:42 -05:00
|
|
|
|
|
|
|
msg2() {
|
2007-05-28 15:21:58 -04:00
|
|
|
local mesg=$1; shift
|
2007-08-29 05:49:24 -04:00
|
|
|
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2007-09-28 13:45:14 -04:00
|
|
|
printf "\033[1;34m ->\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
2006-12-20 20:53:40 -05:00
|
|
|
else
|
2007-05-28 15:21:58 -04:00
|
|
|
printf " -> ${mesg}\n" "$@" >&2
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
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
|
2007-08-29 05:49:24 -04:00
|
|
|
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2007-09-28 13:45:14 -04:00
|
|
|
printf "\033[1;33m==> $(gettext "WARNING:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2007-06-04 16:47:40 -04:00
|
|
|
printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
}
|
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
|
2007-08-29 05:49:24 -04:00
|
|
|
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2007-09-28 13:45:14 -04:00
|
|
|
printf "\033[1;31m==> $(gettext "ERROR:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2007-06-04 16:47:40 -04:00
|
|
|
printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
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() {
|
|
|
|
if [ "$INFAKEROOT" = "0" ]; then
|
|
|
|
echo
|
|
|
|
error "$@"
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Clean up function. Called automatically when the script exits.
|
|
|
|
##
|
|
|
|
clean_up() {
|
|
|
|
local EXIT_CODE=$?
|
|
|
|
|
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
# Don't clean up when leaving fakeroot, we're not done yet.
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $EXIT_CODE -eq 0 -a "$CLEANUP" = "1" ]; then
|
|
|
|
# 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"
|
2007-06-02 20:59:54 -04:00
|
|
|
if [ "$pkgname" != "" ]; then
|
|
|
|
# Can't do this unless the BUILDSCRIPT has been sourced.
|
|
|
|
rm -f "${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
remove_deps
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Signal Traps
|
|
|
|
##
|
|
|
|
trap 'clean_up' 0
|
|
|
|
trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT
|
|
|
|
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
|
|
|
|
trap 'trap_exit "$(gettext "An unknown error has occured. Exiting...")"' ERR
|
|
|
|
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
strip_url() {
|
2006-11-14 02:58:42 -05:00
|
|
|
echo "$1" | sed 's|^.*://.*/||g'
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
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[@]})
|
|
|
|
if [ "$ret" != '?' ]; then
|
|
|
|
echo $ret
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# fall back to makepkg.conf options
|
|
|
|
ret=$(in_opt_array "$1" ${OPTIONS[@]})
|
|
|
|
if [ "$ret" != '?' ]; then
|
|
|
|
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() {
|
2007-06-02 13:04:41 -04:00
|
|
|
echo $(in_opt_array "$1" ${BUILDENV[@]})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# usage : in_opt_array( $needle, $haystack )
|
|
|
|
# return : y - enabled
|
|
|
|
# n - disabled
|
|
|
|
# ? - not found
|
|
|
|
##
|
|
|
|
in_opt_array() {
|
2008-06-15 06:56:40 -04:00
|
|
|
local needle=$(echo $1 | tr '[:upper:]' '[:lower:]'); shift
|
2007-06-02 13:04:41 -04:00
|
|
|
|
|
|
|
local opt
|
|
|
|
for opt in "$@"; do
|
2008-06-15 06:56:40 -04:00
|
|
|
opt=$(echo $opt | tr '[:upper:]' '[:lower:]')
|
2007-06-02 13:04:41 -04:00
|
|
|
if [ "$opt" = "$needle" ]; then
|
|
|
|
echo 'y' # Enabled
|
2007-02-04 13:28:21 -05:00
|
|
|
return
|
2007-06-02 13:04:41 -04:00
|
|
|
elif [ "$opt" = "!$needle" ]; then
|
|
|
|
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
|
|
|
|
[ -z "$1" ] && return 1 # Not Found
|
|
|
|
local item
|
|
|
|
for item in "$@"; do
|
|
|
|
[ "$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
|
|
|
}
|
|
|
|
|
2007-06-02 13:39:47 -04:00
|
|
|
get_downloadclient() {
|
2007-04-04 22:30:05 -04:00
|
|
|
# $1 = url with valid protocol prefix
|
|
|
|
local url=$1
|
2008-08-01 02:29:46 -04:00
|
|
|
local proto=$(echo "$url" | sed 's|://.*||')
|
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
|
|
|
|
local handler=$(echo $i | sed 's|::.*||')
|
|
|
|
if [ "$proto" == "$handler" ]; then
|
|
|
|
agent=$(echo $i | sed 's|^.*::||')
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# if we didn't find an agent, return an error
|
|
|
|
if [ -z "$agent" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "There is no agent set up to handle %s URLs. Check %s.")" "$proto" "$confdir/makepkg.conf"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_CONFIG_ERROR
|
2007-04-04 22:30:05 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ensure specified program is installed
|
|
|
|
local program="$(echo $agent | awk '{print $1 }')"
|
|
|
|
if [ ! -x "$program" ]; then
|
|
|
|
local baseprog=$(basename $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() {
|
|
|
|
local dlcmd=$1
|
2008-02-10 11:56:47 -05:00
|
|
|
local netfile=$2
|
|
|
|
local file=$3
|
|
|
|
|
2008-08-01 02:29:46 -04:00
|
|
|
if echo "$dlcmd" | grep -q "%u" ; then
|
|
|
|
dlcmd=${dlcmd//%o/$file.part}
|
|
|
|
dlcmd=${dlcmd//%u/$netfile}
|
2008-02-10 11:56:47 -05:00
|
|
|
else
|
2008-08-01 02:29:46 -04:00
|
|
|
dlcmd="$dlcmd $netfile"
|
2008-02-10 11:56:47 -05:00
|
|
|
fi
|
|
|
|
|
2008-08-01 02:29:46 -04:00
|
|
|
$dlcmd
|
2008-02-10 11:56:47 -05:00
|
|
|
}
|
|
|
|
|
2007-06-02 13:39:47 -04:00
|
|
|
check_deps() {
|
2006-01-26 18:48:28 -05:00
|
|
|
[ $# -gt 0 ] || return
|
|
|
|
|
2007-06-29 05:41:48 -04:00
|
|
|
pmout=$(pacman $PACMAN_OPTS -T "$@")
|
2005-03-14 20:51:43 -05:00
|
|
|
ret=$?
|
2007-07-02 13:28:39 -04:00
|
|
|
if [ $ret -eq 127 ]; then #unresolved deps
|
2007-04-16 21:51:18 -04:00
|
|
|
echo "$pmout"
|
2007-02-14 00:52:49 -05:00
|
|
|
elif [ $ret -ne 0 ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "Pacman returned a fatal error (%i): %s")" "$ret" "$pmout"
|
2007-02-14 00:52:49 -05:00
|
|
|
exit 1
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
handledeps() {
|
2007-05-30 12:47:47 -04:00
|
|
|
local R_DEPS_SATISFIED=0
|
|
|
|
local R_DEPS_MISSING=1
|
|
|
|
|
|
|
|
[ $# -eq 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
|
|
|
|
2008-05-03 10:35:37 -04:00
|
|
|
if [ "$DEP_BIN" = "0" ]; then
|
2007-05-30 12:47:47 -04:00
|
|
|
return $R_DEPS_MISSING
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$DEP_BIN" = "1" ]; then
|
|
|
|
# install missing deps from binary packages (using pacman -S)
|
|
|
|
msg "$(gettext "Installing missing dependencies...")"
|
|
|
|
local ret=0
|
|
|
|
|
2007-06-01 13:43:41 -04:00
|
|
|
if [ "$ASROOT" = 0 ]; then
|
2008-07-08 04:57:57 -04:00
|
|
|
sudo pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2008-07-08 04:57:57 -04:00
|
|
|
pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
2007-05-30 12:47:47 -04:00
|
|
|
|
|
|
|
if [ $ret -ne 0 ]; then
|
|
|
|
error "$(gettext "Pacman failed to install missing dependencies.")"
|
|
|
|
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
|
|
|
|
source /etc/profile &>/dev/null
|
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-06-02 12:41:15 -04:00
|
|
|
# $pkgdeps is a GLOBAL variable, used by remove_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
|
|
|
|
2007-06-02 12:41:15 -04:00
|
|
|
local deplist="$(check_deps $*)"
|
|
|
|
if [ "$deplist" = "" ]; then
|
|
|
|
return $R_DEPS_SATISFIED
|
|
|
|
fi
|
2007-05-30 12:47:47 -04:00
|
|
|
|
|
|
|
if handledeps $deplist; then
|
2008-07-23 09:01:35 -04:00
|
|
|
pkgdeps="$pkgdeps $deplist"
|
2007-05-30 12:47:47 -04:00
|
|
|
# check deps again to make sure they were resolved
|
2007-06-02 13:39:47 -04:00
|
|
|
deplist="$(check_deps $*)"
|
2007-05-30 12:47:47 -04:00
|
|
|
[ "$deplist" = "" ] && return $R_DEPS_SATISFIED
|
2008-05-03 10:35:37 -04:00
|
|
|
elif [ "$DEP_BIN" = "1" ]; then
|
2007-05-30 12:47:47 -04:00
|
|
|
error "$(gettext "Failed to install all missing dependencies.")"
|
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-01-16 23:54:55 -05:00
|
|
|
# fix flyspray bug #5923
|
2007-06-02 13:39:47 -04:00
|
|
|
remove_deps() {
|
2007-06-02 12:41:15 -04:00
|
|
|
# $pkgdeps is a GLOBAL variable, set by resolve_deps()
|
2007-05-30 12:47:47 -04:00
|
|
|
[ "$RMDEPS" = "0" ] && return
|
2007-06-02 12:41:15 -04:00
|
|
|
[ "$pkgdeps" = "" ] && return
|
2007-05-30 12:47:47 -04:00
|
|
|
|
2007-06-02 12:41:15 -04:00
|
|
|
local dep depstrip deplist
|
2008-07-23 09:01:35 -04:00
|
|
|
deplist=""
|
2007-06-02 12:41:15 -04:00
|
|
|
for dep in $pkgdeps; do
|
|
|
|
depstrip=$(echo $dep | sed -e 's|=.*$||' -e 's|>.*$||' -e 's|<.*$||')
|
|
|
|
deplist="$deplist $depstrip"
|
2007-03-19 21:34:16 -04:00
|
|
|
done
|
|
|
|
|
2007-05-30 12:47:47 -04:00
|
|
|
msg "Removing installed dependencies..."
|
2008-04-02 11:07:25 -04:00
|
|
|
local ret=0
|
2007-06-01 13:43:41 -04:00
|
|
|
if [ "$ASROOT" = "0" ]; then
|
2008-04-02 11:07:25 -04:00
|
|
|
sudo pacman $PACMAN_OPTS -Rns $deplist || ret=$?
|
2007-05-30 12:47:47 -04:00
|
|
|
else
|
2008-04-02 11:07:25 -04:00
|
|
|
pacman $PACMAN_OPTS -Rns $deplist || ret=$?
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Fixes FS#10039 - exit cleanly as package has built successfully
|
|
|
|
if [ $ret -ne 0 ]; then
|
|
|
|
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
|
|
|
|
|
|
|
if [ ! -w "$SRCDEST" ] ; then
|
|
|
|
error "$(gettext "You do not have write permission to store downloads in %s.")" "$SRCDEST"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
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
|
2007-06-01 17:10:27 -04:00
|
|
|
local file=$(strip_url "$netfile")
|
2007-07-10 08:11:40 -04:00
|
|
|
if [ -f "$startdir/$file" ]; then
|
2007-06-01 17:10:27 -04:00
|
|
|
msg2 "$(gettext "Found %s in build dir")" "$file"
|
2008-05-20 13:51:38 -04:00
|
|
|
rm -f "$srcdir/$file"
|
|
|
|
ln -s "$startdir/$file" "$srcdir/"
|
2007-06-01 17:10:27 -04:00
|
|
|
continue
|
|
|
|
elif [ -f "$SRCDEST/$file" ]; then
|
|
|
|
msg2 "$(gettext "Using cached copy of %s")" "$file"
|
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
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2008-01-16 00:03:51 -05:00
|
|
|
# if we get here, check to make sure it was a URL, else fail
|
|
|
|
if [ "$file" = "$netfile" ]; then
|
|
|
|
error "$(gettext "%s was not found in the build directory and is not a URL.")" "$netfile"
|
|
|
|
exit 1 # $E_MISSING_FILE
|
|
|
|
fi
|
|
|
|
|
2007-06-01 17:10:27 -04:00
|
|
|
# find the client we should use for this URL
|
2008-02-10 11:56:47 -05:00
|
|
|
local dlclient=$(get_downloadclient "$netfile") || 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-01 02:29:46 -04:00
|
|
|
download_file "$dlclient" "$netfile" "$file" || ret=$?
|
2007-06-01 17:10:27 -04:00
|
|
|
if [ $ret -gt 0 ]; then
|
|
|
|
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-02-10 11:56:47 -05:00
|
|
|
if echo "$dlclient" | grep -q "%o" ; then
|
|
|
|
mv -f "$SRCDEST/$file.part" "$SRCDEST/$file"
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
generate_checksums() {
|
|
|
|
msg "$(gettext "Generating checksums for source files...")"
|
|
|
|
plain ""
|
|
|
|
|
|
|
|
local integ
|
|
|
|
for integ in ${INTEGRITY_CHECK[@]}; do
|
2008-06-15 06:56:40 -04:00
|
|
|
integ="$(echo $integ | tr '[:upper:]' '[:lower:]')"
|
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
|
|
|
|
|
2008-05-31 02:35:16 -04:00
|
|
|
if [ ! $(type -p openssl) ]; then
|
|
|
|
error "$(gettext "Cannot find openssl.")"
|
2007-06-01 17:10:27 -04:00
|
|
|
exit 1 # $E_MISSING_PROGRAM
|
|
|
|
fi
|
|
|
|
|
|
|
|
local ct=0
|
|
|
|
local numsrc=${#source[@]}
|
|
|
|
echo -n "${integ}sums=("
|
|
|
|
|
|
|
|
local i=0;
|
|
|
|
local indent=''
|
|
|
|
while [ $i -lt $((${#integ}+6)) ]; do
|
|
|
|
indent="$indent "
|
|
|
|
i=$(($i+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
local netfile
|
2008-06-15 06:10:31 -04:00
|
|
|
for netfile in "${source[@]}"; do
|
2007-06-01 17:10:27 -04:00
|
|
|
local file="$(strip_url "$netfile")"
|
2007-07-10 08:11:40 -04:00
|
|
|
|
|
|
|
if [ ! -f "$file" ] ; then
|
|
|
|
if [ ! -f "$SRCDEST/$file" ] ; then
|
|
|
|
error "$(gettext "Unable to find source file %s to generate checksum.")" "$file"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
else
|
2008-06-22 06:11:54 -04:00
|
|
|
file="$SRCDEST/$file"
|
2007-07-10 08:11:40 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-05-31 02:35:16 -04:00
|
|
|
local sum="$(openssl dgst -${integ} "$file" | awk '{print $NF}')"
|
2007-06-01 17:10:27 -04:00
|
|
|
[ $ct -gt 0 ] && echo -n "$indent"
|
|
|
|
echo -n "'$sum'"
|
|
|
|
ct=$(($ct+1))
|
|
|
|
[ $ct -lt $numsrc ] && echo
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ")"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
check_checksums() {
|
|
|
|
local integ
|
|
|
|
for integ in ${INTEGRITY_CHECK[@]}; do
|
2008-06-15 06:56:40 -04:00
|
|
|
integ="$(echo $integ | tr '[:upper:]' '[:lower:]')"
|
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
|
|
|
|
|
2008-05-31 02:35:16 -04:00
|
|
|
if [ ! $(type -p openssl) ]; then
|
|
|
|
error "$(gettext "Cannot find openssl.")"
|
2007-06-01 17:10:27 -04:00
|
|
|
exit 1 # $E_MISSING_PROGRAM
|
|
|
|
fi
|
|
|
|
|
2008-06-15 06:56:40 -04:00
|
|
|
local integrity_sums=($(eval echo "\${${integ}sums[@]}"))
|
2007-06-01 17:10:27 -04:00
|
|
|
if [ ${#integrity_sums[@]} -eq ${#source[@]} ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
msg "$(gettext "Validating source files with %s...")" "${integ}sums"
|
2007-06-01 17:10:27 -04:00
|
|
|
local errors=0
|
|
|
|
local idx=0
|
|
|
|
local file
|
|
|
|
for file in "${source[@]}"; do
|
|
|
|
file="$(strip_url "$file")"
|
|
|
|
echo -n " $file ... " >&2
|
|
|
|
|
2007-07-10 08:11:40 -04:00
|
|
|
if [ ! -f "$file" ] ; then
|
|
|
|
if [ ! -f "$file" ] ; then
|
|
|
|
echo "$(gettext "NOT FOUND")" >&2
|
|
|
|
errors=1
|
|
|
|
continue
|
|
|
|
else
|
2008-06-22 06:11:54 -04:00
|
|
|
file="$SRCDEST/$file"
|
2007-07-10 08:11:40 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-05-31 02:35:16 -04:00
|
|
|
if [ "${integrity_sums[$idx]}" = "$(openssl dgst -${integ} "$file" | awk '{print $NF}')" ]; then
|
2007-06-01 17:10:27 -04:00
|
|
|
echo "$(gettext "Passed")" >&2
|
|
|
|
else
|
|
|
|
echo "$(gettext "FAILED")" >&2
|
|
|
|
errors=1
|
|
|
|
fi
|
2007-08-03 20:17:54 -04:00
|
|
|
|
|
|
|
idx=$((idx + 1))
|
2007-06-01 17:10:27 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ $errors -gt 0 ]; then
|
|
|
|
error "$(gettext "One or more files did not pass the validity check!")"
|
|
|
|
exit 1 # TODO: error code
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
warning "$(gettext "Integrity checks (%s) are missing or incomplete.")" "$integ"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
extract_sources() {
|
|
|
|
msg "$(gettext "Extracting Sources...")"
|
|
|
|
local netfile
|
|
|
|
for netfile in "${source[@]}"; do
|
|
|
|
file=$(strip_url "$netfile")
|
|
|
|
if in_array "$file" ${noextract[@]}; then
|
|
|
|
#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
|
|
|
if [ ! -f "$file" ] ; then
|
|
|
|
if [ ! -f "$SRCDEST/$file" ] ; then
|
|
|
|
error "$(gettext "Unable to find source file %s for extraction.")" "$file"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
else
|
2008-06-22 06:11:54 -04:00
|
|
|
file="$SRCDEST/$file"
|
2007-07-10 08:11:40 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
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")
|
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*)
|
2007-06-01 17:10:27 -04:00
|
|
|
cmd="bsdtar -x -f $file" ;;
|
|
|
|
*application/x-gzip*)
|
|
|
|
cmd="gunzip -d -f $file" ;;
|
|
|
|
*application/x-bzip*)
|
|
|
|
cmd="bunzip2 -f $file" ;;
|
2007-06-02 12:41:15 -04:00
|
|
|
*)
|
|
|
|
# Don't know what to use to extract this file,
|
|
|
|
# skip to the next file
|
|
|
|
continue;;
|
2007-06-01 17:10:27 -04:00
|
|
|
esac
|
|
|
|
|
2007-06-02 12:41:15 -04:00
|
|
|
local ret=0
|
|
|
|
msg2 "$cmd"
|
|
|
|
$cmd || ret=$?
|
|
|
|
if [ $ret -ne 0 ]; 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
|
|
|
|
|
|
|
|
if [ $EUID -eq 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
|
|
|
|
}
|
|
|
|
|
2007-04-11 15:06:09 -04:00
|
|
|
run_build() {
|
|
|
|
# use distcc if it is requested (check buildenv and PKGBUILD opts)
|
|
|
|
if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then
|
2007-04-11 15:06:17 -04:00
|
|
|
[ -d /usr/lib/distcc/bin ] && export PATH="/usr/lib/distcc/bin:$PATH"
|
2007-05-16 13:18:19 -04:00
|
|
|
export DISTCC_HOSTS
|
2007-04-11 15:06:09 -04:00
|
|
|
elif [ "$(check_option distcc)" = "n" ]; then
|
|
|
|
# if it is not wanted, clear the makeflags too
|
|
|
|
MAKEFLAGS=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
# use ccache if it is requested (check buildenv and PKGBUILD opts)
|
|
|
|
if [ "$(check_buildenv ccache)" = "y" -a "$(check_option ccache)" != "n" ]; then
|
2007-04-11 15:06:17 -04:00
|
|
|
[ -d /usr/lib/ccache/bin ] && export PATH="/usr/lib/ccache/bin:$PATH"
|
2007-04-11 15:06:09 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# clear user-specified makeflags if requested
|
|
|
|
if [ "$(check_option makeflags)" = "n" ]; then
|
|
|
|
MAKEFLAGS=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
msg "$(gettext "Starting build()...")"
|
2007-05-31 00:02:32 -04:00
|
|
|
cd "$srcdir"
|
2007-04-11 15:06:09 -04:00
|
|
|
|
2007-05-16 13:18:19 -04:00
|
|
|
# ensure all necessary build variables are exported
|
2007-07-10 09:16:21 -04:00
|
|
|
export CFLAGS CXXFLAGS MAKEFLAGS CHOST
|
2007-04-11 15:06:09 -04:00
|
|
|
|
2007-04-11 15:06:17 -04:00
|
|
|
local ret=0
|
2007-04-11 15:06:09 -04:00
|
|
|
if [ "$LOGGING" = "1" ]; then
|
|
|
|
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
|
|
|
|
if [ -f "$BUILDLOG" ]; then
|
2007-04-11 15:06:17 -04:00
|
|
|
local i=1
|
2007-04-11 15:06:09 -04:00
|
|
|
while true; do
|
|
|
|
if [ -f "$BUILDLOG.$i" ]; then
|
|
|
|
i=$(($i +1))
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
mv "$BUILDLOG" "$BUILDLOG.$i"
|
|
|
|
fi
|
|
|
|
|
|
|
|
build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
|
|
|
|
else
|
|
|
|
build 2>&1 || ret=$?
|
|
|
|
fi
|
2007-04-11 15:06:17 -04:00
|
|
|
|
2007-04-11 15:06:09 -04:00
|
|
|
if [ $ret -gt 0 ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "Build Failed.")"
|
|
|
|
plain "$(gettext "Aborting...")"
|
2007-06-02 13:39:47 -04:00
|
|
|
remove_deps
|
2007-06-02 13:39:48 -04:00
|
|
|
exit 2 # $E_BUILD_FAILED
|
2007-04-11 15:06:09 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2007-04-11 15:05:54 -04:00
|
|
|
if [ "$(check_option docs)" = "n" ]; then
|
2007-04-11 15:06:01 -04:00
|
|
|
msg2 "$(gettext "Removing info/doc files...")"
|
2007-04-11 15:05:54 -04:00
|
|
|
#fix flyspray bug #5021
|
|
|
|
rm -rf ${DOC_DIRS[@]}
|
|
|
|
fi
|
|
|
|
|
2008-03-12 19:25:38 -04:00
|
|
|
if [ "$(check_option zipman)" = "y" ]; then
|
|
|
|
msg2 "$(gettext "Compressing man pages...")"
|
|
|
|
local manpage mandirs ext file link hardlinks hl
|
|
|
|
mandirs="usr/man usr/share/man usr/local/man usr/local/share/man opt/*/man"
|
|
|
|
find ${mandirs} -type f 2>/dev/null |
|
|
|
|
while read manpage ; do
|
|
|
|
# check file still exists (potentially compressed with hard link)
|
|
|
|
if [ -f ${manpage} ]; then
|
|
|
|
ext="${manpage##*.}"
|
|
|
|
file="${manpage##*/}"
|
|
|
|
if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
|
|
|
|
# update symlinks to this manpage
|
|
|
|
find ${mandirs} -lname "$file" 2>/dev/null |
|
|
|
|
while read link ; do
|
|
|
|
rm -f "$link"
|
|
|
|
ln -sf "${file}.gz" "${link}.gz"
|
|
|
|
done
|
|
|
|
# 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
|
|
|
|
hardlinks="$(find ${mandirs} \! -name "$file" -samefile "$manpage" 2>/dev/null)" || true
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
if [ "$(check_option strip)" = "y" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
msg2 "$(gettext "Stripping debugging symbols from binaries and libraries...")"
|
2008-07-20 01:57:03 -04:00
|
|
|
local binary
|
2008-07-28 16:37:08 -04:00
|
|
|
if [ -z "${STRIP_DIRS[*]}" ]; then
|
2008-07-20 01:57:03 -04:00
|
|
|
# fall back to default value
|
2008-07-28 16:37:08 -04:00
|
|
|
STRIP_DIRS=(bin lib sbin usr/{bin,lib,sbin,local/{bin,lib,sbin}}
|
|
|
|
opt/*/{bin,lib,sbin})
|
2008-07-20 01:57:03 -04:00
|
|
|
fi
|
|
|
|
find ${STRIP_DIRS[@]} -type f 2>/dev/null | while read binary ; do
|
2008-04-27 12:43:41 -04:00
|
|
|
case "$(file -biz "$binary")" in
|
2008-07-18 00:20:24 -04:00
|
|
|
*application/x-sharedlib*) # Libraries (.so)
|
|
|
|
/usr/bin/strip --strip-debug "$binary";;
|
|
|
|
*application/x-archive*) # Libraries (.a)
|
2008-04-27 12:43:41 -04:00
|
|
|
/usr/bin/strip --strip-debug "$binary";;
|
2007-04-11 15:05:54 -04:00
|
|
|
*application/x-executable*) # Binaries
|
2008-04-27 12:43:41 -04:00
|
|
|
/usr/bin/strip "$binary";;
|
2007-04-11 15:05:54 -04:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$(check_option libtool)" = "n" ]; then
|
2007-04-11 15:06:01 -04:00
|
|
|
msg2 "$(gettext "Removing libtool .la files...")"
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2007-04-11 15:05:23 -04:00
|
|
|
create_package() {
|
2007-05-30 18:18:37 -04:00
|
|
|
if [ ! -d "$pkgdir" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "Missing pkg/ directory.")"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_MISSING_PKGDIR
|
2007-05-30 18:18:37 -04:00
|
|
|
fi
|
|
|
|
|
2007-05-31 00:02:32 -04:00
|
|
|
cd "$pkgdir"
|
2007-05-14 11:36:04 -04:00
|
|
|
msg "$(gettext "Creating package...")"
|
2007-04-11 15:05:47 -04:00
|
|
|
|
2007-09-19 01:21:56 -04:00
|
|
|
local builddate=$(date -u "+%s")
|
2007-04-11 15:05:23 -04:00
|
|
|
if [ "$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
|
2008-05-26 17:46:01 -04:00
|
|
|
local size=$(du -sk | awk '{print $1 * 1024}')
|
2007-04-11 15:05:23 -04:00
|
|
|
|
|
|
|
# write the .PKGINFO file
|
2007-04-11 15:05:47 -04:00
|
|
|
msg2 "$(gettext "Generating .PKGINFO file...")"
|
2007-04-11 15:05:23 -04:00
|
|
|
echo "# Generated by makepkg $myver" >.PKGINFO
|
2007-06-12 18:30:56 -04:00
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
echo "# using $(fakeroot -v)" >>.PKGINFO
|
|
|
|
fi
|
2008-07-17 23:38:34 -04:00
|
|
|
echo "# $(LC_ALL=C date -u)" >>.PKGINFO
|
2007-04-11 15:05:23 -04:00
|
|
|
echo "pkgname = $pkgname" >>.PKGINFO
|
|
|
|
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
|
|
|
|
echo "pkgdesc = $pkgdesc" >>.PKGINFO
|
|
|
|
echo "url = $url" >>.PKGINFO
|
|
|
|
echo "builddate = $builddate" >>.PKGINFO
|
|
|
|
echo "packager = $packager" >>.PKGINFO
|
|
|
|
echo "size = $size" >>.PKGINFO
|
|
|
|
if [ "$CARCH" != "" ]; then
|
|
|
|
echo "arch = $CARCH" >>.PKGINFO
|
|
|
|
fi
|
2008-02-02 15:52:19 -05:00
|
|
|
if [ "$(check_option force)" = "y" ]; then
|
|
|
|
echo "force = true" >> .PKGINFO
|
|
|
|
fi
|
2007-04-11 15:05:23 -04:00
|
|
|
|
2007-04-11 15:05:47 -04:00
|
|
|
local it
|
2007-04-11 15:05:23 -04:00
|
|
|
for it in "${license[@]}"; do
|
|
|
|
echo "license = $it" >>.PKGINFO
|
|
|
|
done
|
|
|
|
for it in "${replaces[@]}"; do
|
|
|
|
echo "replaces = $it" >>.PKGINFO
|
|
|
|
done
|
|
|
|
for it in "${groups[@]}"; do
|
|
|
|
echo "group = $it" >>.PKGINFO
|
|
|
|
done
|
|
|
|
for it in "${depends[@]}"; do
|
|
|
|
echo "depend = $it" >>.PKGINFO
|
|
|
|
done
|
2007-09-26 00:02:30 -04:00
|
|
|
for it in "${optdepends[@]}"; do
|
|
|
|
echo "optdepend = $it" >>.PKGINFO
|
|
|
|
done
|
2007-04-11 15:05:23 -04:00
|
|
|
for it in "${conflicts[@]}"; do
|
|
|
|
echo "conflict = $it" >>.PKGINFO
|
|
|
|
done
|
|
|
|
for it in "${provides[@]}"; do
|
|
|
|
echo "provides = $it" >>.PKGINFO
|
|
|
|
done
|
|
|
|
for it in "${backup[@]}"; do
|
|
|
|
echo "backup = $it" >>.PKGINFO
|
|
|
|
done
|
|
|
|
|
|
|
|
# TODO maybe remove this at some point
|
|
|
|
# warn if license array is not present or empty
|
|
|
|
if [ "$license" = "" ]; then
|
2007-05-28 15:21:58 -04:00
|
|
|
warning "$(gettext "Please add a license line to your %s!")" "$BUILDSCRIPT"
|
2007-06-02 13:39:48 -04:00
|
|
|
plain "$(gettext "Example for GPL'ed software: license=('GPL').")"
|
2007-04-11 15:05:23 -04:00
|
|
|
fi
|
|
|
|
|
2007-12-29 12:24:57 -05:00
|
|
|
local comp_files=".PKGINFO"
|
2007-04-11 15:05:47 -04:00
|
|
|
|
2007-04-11 15:05:23 -04:00
|
|
|
# check for an install script
|
|
|
|
if [ "$install" != "" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
msg2 "$(gettext "Adding install script...")"
|
2007-04-11 15:05:47 -04:00
|
|
|
cp "$startdir/$install" .INSTALL
|
|
|
|
comp_files="$comp_files .INSTALL"
|
2007-04-11 15:05:23 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# do we have a changelog?
|
|
|
|
if [ -f "$startdir/ChangeLog" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
msg2 "$(gettext "Adding package changelog...")"
|
2007-04-11 15:05:47 -04:00
|
|
|
cp "$startdir/ChangeLog" .CHANGELOG
|
|
|
|
comp_files="$comp_files .CHANGELOG"
|
2007-04-11 15:05:23 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# tar it up
|
2007-04-11 15:05:47 -04:00
|
|
|
msg2 "$(gettext "Compressing package...")"
|
2007-04-11 15:05:23 -04:00
|
|
|
|
2007-05-29 17:46:20 -04:00
|
|
|
local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
|
2007-04-11 15:05:23 -04:00
|
|
|
|
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
|
|
|
|
|
2008-06-12 20:06:14 -04:00
|
|
|
if ! bsdtar -czf "$pkg_file" $comp_files *; 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
|
2008-08-01 02:29:46 -04:00
|
|
|
shopt -u nullglob
|
2007-05-30 06:48:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
create_xdelta() {
|
|
|
|
if [ "$(check_buildenv xdelta)" != "y" ]; then
|
|
|
|
return
|
2007-05-30 06:50:42 -04:00
|
|
|
elif [ ! "$(type -p xdelta)" ]; then
|
|
|
|
error "$(gettext "Cannot find the xdelta binary! Is xdelta installed?")"
|
|
|
|
return
|
2007-05-30 06:48:18 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
local pkg_file=$1
|
2007-05-30 06:50:42 -04:00
|
|
|
local cache_dir="/var/cache/pacman/pkg" # TODO: autoconf me
|
2007-06-27 07:04:33 -04:00
|
|
|
local pkginfo="$(mktemp "$startdir"/xdelta-pkginfo.XXXXXXXXX)"
|
2007-06-03 08:43:44 -04:00
|
|
|
|
|
|
|
local old_file old_version
|
|
|
|
for old_file in $(ls {"$cache_dir","$PKGDEST"}/${pkgname}-*-*{,-$CARCH}$PKGEXT 2>/dev/null); do
|
2007-10-04 18:50:29 -04:00
|
|
|
bsdtar -xOf "$old_file" .PKGINFO > "$pkginfo" || continue
|
2007-06-27 07:04:33 -04:00
|
|
|
if [ "$(cat "$pkginfo" | grep '^pkgname = ')" != "pkgname = $pkgname" ]; then
|
|
|
|
continue # Package name does not match.
|
|
|
|
elif [ "$(cat "$pkginfo" | grep '^arch = ')" != "arch = $CARCH" ] ; then
|
|
|
|
continue # Not same arch.
|
2007-06-03 08:43:44 -04:00
|
|
|
fi
|
|
|
|
|
2007-06-27 07:04:33 -04:00
|
|
|
old_version="$(cat "$pkginfo" | grep '^pkgver = ' | sed 's/^pkgver = //')"
|
2007-06-03 08:43:44 -04:00
|
|
|
|
2007-05-30 06:48:18 -04:00
|
|
|
# old_version may include the target package, only use the old versions
|
2007-06-03 08:43:44 -04:00
|
|
|
local vercmp=$(vercmp "$old_version" "$latest_version")
|
|
|
|
if [ "$old_version" != "$pkgver-$pkgrel" -a $vercmp -gt 0 ]; then
|
|
|
|
local latest_version=$old_version
|
|
|
|
local base_file=$old_file
|
2007-05-30 06:48:18 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2007-06-27 07:04:33 -04:00
|
|
|
rm -f "$pkginfo"
|
|
|
|
|
2007-05-30 06:50:42 -04:00
|
|
|
if [ "$base_file" != "" ]; then
|
2007-06-02 12:42:36 -04:00
|
|
|
msg "$(gettext "Making delta from version %s...")" "$latest_version"
|
2007-06-03 08:43:44 -04:00
|
|
|
local delta_file="$PKGDEST/$pkgname-${latest_version}_to_$pkgver-$pkgrel-$CARCH.delta"
|
2007-10-14 11:59:38 -04:00
|
|
|
local ret=0
|
2007-05-30 06:50:42 -04:00
|
|
|
|
2007-06-02 12:42:36 -04:00
|
|
|
# xdelta will decompress base_file & pkg_file into TMP_DIR (or /tmp if
|
|
|
|
# TMP_DIR is unset) then perform the delta on the resulting tars
|
2007-10-14 11:59:38 -04:00
|
|
|
xdelta delta "$base_file" "$pkg_file" "$delta_file" || ret=$?
|
|
|
|
|
|
|
|
if [ $ret -eq 0 -o $ret -eq 1 ]; then
|
|
|
|
# Generate the final gz using xdelta for compression. xdelta will be our
|
|
|
|
# common denominator compression utility between the packager and the
|
|
|
|
# users. makepkg and pacman must use the same compression algorithm or
|
|
|
|
# the delta generated package may not match, producing md5 checksum
|
|
|
|
# errors.
|
|
|
|
msg2 "$(gettext "Recreating package tarball from delta to match md5 signatures")"
|
|
|
|
msg2 "$(gettext "NOTE: the delta should ONLY be distributed with this tarball")"
|
|
|
|
ret=0
|
|
|
|
xdelta patch "$delta_file" "$base_file" "$pkg_file" || ret=$?
|
|
|
|
if [ $ret -ne 0 ]; then
|
|
|
|
error "$(gettext "Could not generate the package from the delta.")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
warning "$(gettext "Delta was not able to be created.")"
|
|
|
|
fi
|
2007-05-30 06:48:18 -04:00
|
|
|
else
|
2007-06-02 12:42:36 -04:00
|
|
|
warning "$(gettext "No previous version found, skipping xdelta.")"
|
2007-05-30 06:48:18 -04:00
|
|
|
fi
|
2007-04-11 15:05:23 -04:00
|
|
|
}
|
|
|
|
|
2007-05-30 14:27:13 -04:00
|
|
|
create_srcpackage() {
|
|
|
|
cd "$startdir"
|
2008-06-06 21:58:21 -04:00
|
|
|
if [ "$SOURCEONLY" = "2" ]; then
|
|
|
|
# get back to our src directory so we can begin with sources
|
|
|
|
mkdir -p "$srcdir"
|
|
|
|
cd "$srcdir"
|
|
|
|
download_sources
|
|
|
|
# we can only check checksums if we have all files
|
|
|
|
check_checksums
|
|
|
|
cd "$startdir"
|
|
|
|
fi
|
2007-05-30 14:27:13 -04:00
|
|
|
msg "$(gettext "Creating source package...")"
|
2008-06-06 21:58:21 -04:00
|
|
|
local srclinks="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)"
|
|
|
|
mkdir "${srclinks}"/${pkgname}
|
|
|
|
|
2008-02-20 09:08:31 -05:00
|
|
|
msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT"
|
2008-06-06 21:58:21 -04:00
|
|
|
ln -s "${startdir}/${BUILDSCRIPT}" "${srclinks}/${pkgname}/"
|
2007-05-30 14:27:13 -04:00
|
|
|
|
|
|
|
if [ "$install" != "" ]; then
|
|
|
|
if [ -f $install ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
msg2 "$(gettext "Adding install script...")"
|
2008-06-06 21:58:21 -04:00
|
|
|
ln -s "${startdir}/$install" "${srclinks}/${pkgname}/"
|
2007-05-30 14:27:13 -04:00
|
|
|
else
|
2007-06-01 10:28:52 -04:00
|
|
|
error "$(gettext "Install script %s not found.")" "$install"
|
2007-05-30 14:27:13 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-06-02 22:33:17 -04:00
|
|
|
if [ -f ChangeLog ]; then
|
|
|
|
msg2 "$(gettext "Adding %s...")" "ChangeLog"
|
2008-06-06 21:58:21 -04:00
|
|
|
ln -s "${startdir}/ChangeLog" "${srclinks}/${pkgname}"
|
2007-06-02 22:33:17 -04:00
|
|
|
fi
|
|
|
|
|
2008-06-06 21:58:21 -04:00
|
|
|
local netfile
|
2008-06-15 06:10:31 -04:00
|
|
|
for netfile in "${source[@]}"; do
|
2008-06-06 21:58:21 -04:00
|
|
|
local file=$(strip_url "$netfile")
|
2008-06-15 06:10:31 -04:00
|
|
|
if [ -f "$netfile" ]; then
|
2008-06-06 21:58:21 -04:00
|
|
|
msg2 "$(gettext "Adding %s...")" "$netfile"
|
2008-06-22 06:11:54 -04:00
|
|
|
ln -s $netfile "${srclinks}/${pkgname}"
|
2008-06-06 21:58:21 -04:00
|
|
|
elif [ "$SOURCEONLY" = "2" -a -f "$SRCDEST/$file" ]; then
|
|
|
|
msg2 "$(gettext "Adding %s...")" "$file"
|
|
|
|
ln -s "$SRCDEST/$file" "${srclinks}/${pkgname}/"
|
2007-05-30 14:27:13 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2007-05-31 12:21:37 -04:00
|
|
|
local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${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}"
|
2008-06-06 21:58:21 -04:00
|
|
|
if ! bsdtar -czLf "$pkg_file" ${pkgname}; then
|
2007-05-30 14:27:13 -04:00
|
|
|
error "$(gettext "Failed to create source package file.")"
|
|
|
|
exit 1 # TODO: error code
|
|
|
|
fi
|
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() {
|
2007-06-01 13:43:41 -04:00
|
|
|
[ "$INSTALL" = "0" ] && return
|
2008-01-09 19:08:43 -05:00
|
|
|
msg "$(gettext "Installing package ${pkgname} with pacman -U...")"
|
2007-06-01 13:43:41 -04:00
|
|
|
if [ "$ASROOT" = "0" ]; then
|
2007-06-02 22:33:17 -04:00
|
|
|
sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $?
|
2007-06-01 13:43:41 -04:00
|
|
|
else
|
2007-06-02 22:33:17 -04:00
|
|
|
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $?
|
2007-02-11 16:47:37 -05:00
|
|
|
fi
|
|
|
|
}
|
2007-01-16 23:54:55 -05:00
|
|
|
|
2007-10-26 22:32:09 -04:00
|
|
|
devel_check() {
|
|
|
|
newpkgver=""
|
2008-01-13 18:39:06 -05:00
|
|
|
# Only update pkgver if --holdver is not set
|
|
|
|
if [ "$HOLDVER" = "1" ]; then
|
|
|
|
return
|
|
|
|
fi
|
2007-10-26 22:32:09 -04:00
|
|
|
if [ "$FORCE_VER" = "" ]; then
|
|
|
|
# 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.
|
2008-02-07 20:43:52 -05:00
|
|
|
# Also do a brief check to make sure we have the VCS tool available.
|
2007-10-26 22:32:09 -04:00
|
|
|
oldpkgver=$pkgver
|
|
|
|
if [ ! -z ${_darcstrunk} ] && [ ! -z ${_darcsmod} ] ; then
|
2008-02-07 20:43:52 -05:00
|
|
|
[ $(type -p darcs) ] || return 0
|
2007-10-26 22:32:09 -04:00
|
|
|
msg "$(gettext "Determining latest darcs revision...")"
|
|
|
|
newpkgver=$(date +%Y%m%d)
|
|
|
|
elif [ ! -z ${_cvsroot} ] && [ ! -z ${_cvsmod} ] ; then
|
2008-02-07 20:43:52 -05:00
|
|
|
[ $(type -p cvs) ] || return 0
|
2007-10-26 22:32:09 -04:00
|
|
|
msg "$(gettext "Determining latest cvs revision...")"
|
|
|
|
newpkgver=$(date +%Y%m%d)
|
|
|
|
elif [ ! -z ${_gitroot} ] && [ ! -z ${_gitname} ] ; then
|
2008-02-07 20:43:52 -05:00
|
|
|
[ $(type -p git) ] || return 0
|
2007-10-26 22:32:09 -04:00
|
|
|
msg "$(gettext "Determining latest git revision...")"
|
|
|
|
newpkgver=$(date +%Y%m%d)
|
|
|
|
elif [ ! -z ${_svntrunk} ] && [ ! -z ${_svnmod} ] ; then
|
2008-02-07 20:43:52 -05:00
|
|
|
[ $(type -p svn) ] || return 0
|
2007-10-26 22:32:09 -04:00
|
|
|
msg "$(gettext "Determining latest svn revision...")"
|
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')
|
2007-10-26 22:32:09 -04:00
|
|
|
elif [ ! -z ${_bzrtrunk} ] && [ ! -z ${_bzrmod} ] ; then
|
2008-02-07 20:43:52 -05:00
|
|
|
[ $(type -p bzr) ] || return 0
|
2007-10-26 22:32:09 -04:00
|
|
|
msg "$(gettext "Determining latest bzr revision...")"
|
|
|
|
newpkgver=$(bzr revno ${_bzrtrunk})
|
|
|
|
elif [ ! -z ${_hgroot} ] && [ ! -z ${_hgrepo} ] ; then
|
2008-02-07 20:43:52 -05:00
|
|
|
[ $(type -p hg) ] || return 0
|
2007-10-26 22:32:09 -04:00
|
|
|
msg "$(gettext "Determining latest hg revision...")"
|
|
|
|
if [ -d ./src/$_hgrepo ] ; then
|
|
|
|
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
|
|
|
|
newpkgver=$(hg tip | sed -n '1s/[^0-9]*\([^:]*\):.*$/\1/p')
|
|
|
|
cd ../../
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$newpkgver" != "" ]; then
|
|
|
|
msg2 "$(gettext "Version found: %s")" "$newpkgver"
|
|
|
|
pkgver=$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
|
|
|
|
#
|
|
|
|
if [ "$newpkgver" != "" ]; then
|
|
|
|
if [ "newpkgver" != "$pkgver" ]; then
|
|
|
|
sed -i "s/^pkgver=[^ ]*/pkgver=$newpkgver/" ./$BUILDSCRIPT
|
|
|
|
source $BUILDSCRIPT
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
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:")"
|
2007-06-04 17:06:11 -04:00
|
|
|
printf "$(gettext " -A, --ignorearch Ignore incomplete arch field in %s")\n" "$BUILDSCRIPT"
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext " -c, --clean Clean up work files after build")"
|
|
|
|
echo "$(gettext " -C, --cleancache Clean up source files from the cache")"
|
|
|
|
echo "$(gettext " -d, --nodeps Skip all dependency checks")"
|
|
|
|
echo "$(gettext " -e, --noextract Do not extract source files (use existing src/ dir)")"
|
|
|
|
echo "$(gettext " -f, --force Overwrite existing package")"
|
|
|
|
echo "$(gettext " -g, --geninteg Generate integrity checks for source files")"
|
|
|
|
echo "$(gettext " -h, --help This help")"
|
|
|
|
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")"
|
2007-05-28 15:21:58 -04:00
|
|
|
printf "$(gettext " -p <buildscript> 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")"
|
2006-12-21 12:42:58 -05:00
|
|
|
# fix flyspray feature request #2978
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext " -R, --repackage Repackage contents of pkg/ without building")"
|
|
|
|
echo "$(gettext " -s, --syncdeps Install missing dependencies with pacman")"
|
2008-07-30 22:53:02 -04:00
|
|
|
echo "$(gettext " --allsource Generate a source-only tarball including downloaded sources")"
|
2007-06-01 13:43:41 -04:00
|
|
|
echo "$(gettext " --asroot Allow makepkg to run as root user")"
|
2008-01-13 18:39:06 -05:00
|
|
|
echo "$(gettext " --holdver Prevent automatic version bumping for development PKGBUILDs")"
|
2008-07-30 22:53:02 -04:00
|
|
|
echo "$(gettext " --source Generate a source-only tarball without downloaded sources")"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext "These options can be passed to pacman:")"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2007-05-30 14:27:13 -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
|
2007-05-28 15:21:58 -04:00
|
|
|
printf "$(gettext "If -p is not specified, makepkg will look for '%s'")\n" "$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 "\
|
|
|
|
Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>.\n\n\
|
|
|
|
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
|
|
|
|
if [ ! $(type -t gettext) ]; then
|
|
|
|
gettext() {
|
|
|
|
echo "$@"
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
ARGLIST=$@
|
|
|
|
|
2007-01-25 20:26:08 -05:00
|
|
|
#preserve environment variables
|
|
|
|
_PKGDEST=${PKGDEST}
|
2007-02-03 00:21:55 -05:00
|
|
|
_SRCDEST=${SRCDEST}
|
2007-01-25 20:26:08 -05:00
|
|
|
|
2007-04-01 19:55:01 -04:00
|
|
|
# Source makepkg.conf; fail if it is not found
|
2007-06-01 10:28:52 -04:00
|
|
|
if [ -r "$confdir/makepkg.conf" ]; then
|
2007-06-01 13:43:41 -04:00
|
|
|
source "$confdir/makepkg.conf"
|
2006-11-14 02:58:42 -05:00
|
|
|
else
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "%s not found.")" "$confdir/makepkg.conf"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_CONFIG_ERROR
|
2006-11-14 02:58:42 -05:00
|
|
|
fi
|
|
|
|
|
2007-04-01 19:55:01 -04:00
|
|
|
# Source user-specific makepkg.conf overrides
|
|
|
|
if [ -r ~/.makepkg.conf ]; then
|
2006-12-21 15:03:41 -05:00
|
|
|
source ~/.makepkg.conf
|
2006-12-21 12:42:58 -05:00
|
|
|
fi
|
2006-11-14 02:58:42 -05:00
|
|
|
|
2007-01-25 20:26:08 -05:00
|
|
|
# override settings with an environment variable for batch processing
|
|
|
|
PKGDEST=${_PKGDEST:-$PKGDEST}
|
2007-02-03 00:21:55 -05:00
|
|
|
PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
|
2007-01-25 20:26:08 -05:00
|
|
|
SRCDEST=${_SRCDEST:-$SRCDEST}
|
2007-02-03 00:21:55 -05:00
|
|
|
SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
|
2007-01-25 20:26:08 -05:00
|
|
|
|
2007-06-05 06:58:25 -04:00
|
|
|
# Parse Command Line Options.
|
2008-06-02 01:05:50 -04:00
|
|
|
OPT_SHORT="AbcCdefFghiLmop:rRsV"
|
2008-06-06 21:58:21 -04:00
|
|
|
OPT_LONG="allsource,asroot,ignorearch,builddeps,clean,cleancache,nodeps"
|
|
|
|
OPT_LONG="$OPT_LONG,noextract,force,forcever:,geninteg,help,holdver"
|
|
|
|
OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,rmdeps,repackage,source"
|
2008-06-02 01:05:50 -04:00
|
|
|
OPT_LONG="$OPT_LONG,syncdeps,version"
|
2007-06-05 06:58:25 -04:00
|
|
|
# Pacman Options
|
|
|
|
OPT_LONG="$OPT_LONG,noconfirm,noprogressbar"
|
|
|
|
OPT_TEMP="$(getopt -o "$OPT_SHORT" -l "$OPT_LONG" -n "$(basename "$0")" -- "$@" || echo 'GETOPT GO BANG!')"
|
|
|
|
if echo "$OPT_TEMP" | grep -q 'GETOPT GO BANG!'; then
|
|
|
|
# This is a small hack to stop the script bailing with 'set -e'
|
|
|
|
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
|
2006-02-16 17:57:25 -05:00
|
|
|
--noconfirm) PACMAN_OPTS="$PACMAN_OPTS --noconfirm" ;;
|
|
|
|
--noprogressbar) PACMAN_OPTS="$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 ;;
|
|
|
|
-C|--cleancache) CLEANCACHE=1 ;;
|
|
|
|
-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 ;;
|
|
|
|
-L|--log) LOGGING=1 ;;
|
|
|
|
-m|--nocolor) USE_COLOR='n' ;;
|
|
|
|
-o|--nobuild) NOBUILD=1 ;;
|
2007-10-26 19:36:08 -04:00
|
|
|
-p) shift; BUILDSCRIPT=$1 ;;
|
2007-06-05 06:58:25 -04:00
|
|
|
-r|--rmdeps) RMDEPS=1 ;;
|
|
|
|
-R|--repackage) REPKG=1 ;;
|
|
|
|
--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
|
|
|
|
|
2008-01-13 18:39:06 -05:00
|
|
|
if [ "$HOLDVER" = "1" -a "$FORCE_VER" != "" ]; then
|
2008-05-26 02:27:22 -04:00
|
|
|
# The '\\0' is here to prevent gettext from thinking --holdver is an option
|
2008-01-20 08:08:55 -05:00
|
|
|
error "$(gettext "\\0--holdver and --forcever cannot both be specified" )"
|
2008-01-13 18:39:06 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$CLEANCACHE" = "1" ]; then
|
2006-12-21 12:42:58 -05:00
|
|
|
#fix flyspray feature request #5223
|
2007-03-08 23:35:04 -05:00
|
|
|
if [ -n "$SRCDEST" -a "$SRCDEST" != "$startdir" ]; then
|
2007-05-28 15:21:58 -04:00
|
|
|
msg "$(gettext "Cleaning up ALL files from %s.")" "$SRCDEST"
|
2007-03-31 20:07:37 -04:00
|
|
|
echo -n "$(gettext " Are you sure you wish to do this? [Y/n] ")"
|
2007-03-08 23:35:04 -05:00
|
|
|
read answer
|
2008-06-15 06:56:40 -04:00
|
|
|
answer=$(echo $answer | tr '[:upper:]' '[:lower:]')
|
2007-03-08 23:35:04 -05:00
|
|
|
if [ "$answer" = "yes" -o "$answer" = "y" ]; then
|
2007-03-09 00:11:47 -05:00
|
|
|
rm "$SRCDEST"/*
|
2007-03-08 23:35:04 -05:00
|
|
|
if [ $? -ne 0 ]; then
|
2007-05-28 15:21:58 -04:00
|
|
|
error "$(gettext "Problem removing files; you may not have correct permissions in %s")" "$SRCDEST"
|
2007-03-08 23:35:04 -05:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
# removal worked
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Source cache cleaned.")"
|
2007-03-08 23:35:04 -05:00
|
|
|
exit 0
|
|
|
|
fi
|
2006-12-21 12:42:58 -05:00
|
|
|
else
|
2007-03-08 23:35:04 -05:00
|
|
|
# answer = no
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "No files have been removed.")"
|
2006-12-21 12:42:58 -05:00
|
|
|
exit 0
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
2006-12-21 12:42:58 -05:00
|
|
|
else
|
2007-03-09 00:11:47 -05:00
|
|
|
# $SRCDEST is $startdir, two possibilities
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "Source destination must be defined in makepkg.conf.")"
|
|
|
|
plain "$(gettext "In addition, please run makepkg -C outside of your cache directory.")"
|
2006-12-21 12:42:58 -05:00
|
|
|
exit 1
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2007-05-27 17:01:49 -04:00
|
|
|
if [ -z $BUILDSCRIPT ]; then
|
2007-06-01 17:21:31 -04:00
|
|
|
error "$(gettext "BUILDSCRIPT is undefined! Ensure you have updated %s.")" "$confdir/makepkg.conf"
|
2007-05-27 17:01:49 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2007-04-11 15:06:25 -04:00
|
|
|
if [ "$INFAKEROOT" = "0" ]; then
|
2007-06-01 13:43:41 -04:00
|
|
|
if [ $EUID -eq 0 -a "$ASROOT" = "0" ]; then
|
2007-04-11 15:06:25 -04:00
|
|
|
# Warn those who like to live dangerously.
|
2007-05-27 17:01:49 -04:00
|
|
|
error "$(gettext "Running makepkg as root is a BAD idea and can cause")"
|
2007-04-11 15:06:25 -04:00
|
|
|
plain "$(gettext "permanent, catastrophic damage to your system. If you")"
|
2007-05-30 18:26:29 -04:00
|
|
|
plain "$(gettext "wish to run as root, please use the --asroot option.")"
|
2007-06-01 13:43:41 -04:00
|
|
|
exit 1 # $E_USER_ABORT
|
|
|
|
elif [ $EUID -gt 0 -a "$ASROOT" = "1" ]; then
|
|
|
|
# Warn those who try to use the --asroot option when they are not root
|
|
|
|
error "$(gettext "The --asroot option is meant for the root user only.")"
|
|
|
|
plain "$(gettext "Please rerun makepkg without the --asroot flag.")"
|
2007-04-11 15:06:25 -04:00
|
|
|
exit 1 # $E_USER_ABORT
|
2007-07-10 10:31:03 -04:00
|
|
|
elif [ "$(check_buildenv fakeroot)" = "y" -a $EUID -gt 0 ]; then
|
2007-05-27 17:01:49 -04:00
|
|
|
if [ ! $(type -p fakeroot) ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "Fakeroot must be installed if using the 'fakeroot' option")"
|
|
|
|
plain "$(gettext "in the BUILDENV array in %s.")" "$confdir/makepkg.conf"
|
2007-05-27 17:01:49 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2007-07-10 10:31:03 -04:00
|
|
|
elif [ $EUID -gt 0 ]; then
|
2007-04-11 15:06:25 -04:00
|
|
|
warning "$(gettext "Running makepkg as an unprivileged user will result in non-root")"
|
|
|
|
plain "$(gettext "ownership of the packaged files. Try using the fakeroot environment by")"
|
2007-05-27 17:01:49 -04:00
|
|
|
plain "$(gettext "placing 'fakeroot' in the BUILDENV array in makepkg.conf.")"
|
2007-04-11 15:06:25 -04:00
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ "$FAKEROOTKEY" = "" ]; then
|
|
|
|
error "$(gettext "Do not use the '-F' option. This option is only for use by makepkg.")"
|
|
|
|
exit 1 # TODO: error code
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-06-01 13:43:41 -04:00
|
|
|
# check for sudo if we will need it during makepkg execution
|
2008-05-03 10:35:37 -04:00
|
|
|
if [ "$ASROOT" = "0" -a \( "$DEP_BIN" = "1" \
|
2007-06-01 17:10:27 -04:00
|
|
|
-o "$RMDEPS" = "1" -o "$INSTALL" = "1" \) ]; then
|
2007-06-01 13:43:41 -04:00
|
|
|
if [ ! "$(type -p sudo)" ]; then
|
|
|
|
error "$(gettext "Cannot find the sudo binary! Is sudo installed?")"
|
|
|
|
plain "$(gettext "Missing dependencies cannot be installed or removed as a normal user")"
|
|
|
|
plain "$(gettext "without sudo; install and configure sudo to auto-resolve dependencies.")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-02-27 14:14:05 -05:00
|
|
|
unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums
|
2005-03-14 20:51:43 -05:00
|
|
|
unset replaces depends conflicts backup source install build makedepends
|
2007-09-26 00:02:30 -04:00
|
|
|
unset optdepends options noextract
|
2006-11-14 02:58:42 -05:00
|
|
|
|
2007-06-02 22:33:17 -04:00
|
|
|
if [ ! -f "$BUILDSCRIPT" ]; then
|
2007-05-28 15:21:58 -04:00
|
|
|
error "$(gettext "%s does not exist.")" "$BUILDSCRIPT"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2007-06-02 22:33:17 -04:00
|
|
|
source "$BUILDSCRIPT"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2008-05-26 02:27:22 -04:00
|
|
|
if [ "$GENINTEG" = "1" ]; then
|
|
|
|
mkdir -p "$srcdir"
|
|
|
|
cd "$srcdir"
|
|
|
|
download_sources
|
|
|
|
generate_checksums
|
|
|
|
exit 0 # $E_OK
|
|
|
|
fi
|
|
|
|
|
2007-02-23 14:51:24 -05:00
|
|
|
# check for no-no's in the build script
|
2007-12-22 18:58:49 -05:00
|
|
|
if [ -z "$pkgname" ]; then
|
|
|
|
error "$(gettext "%s is not allowed to be empty.")" "pkgname"
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-11-14 02:58:42 -05:00
|
|
|
if [ -z "$pkgver" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "%s is not allowed to be empty.")" "pkgver"
|
2006-11-14 02:58:42 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$pkgrel" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "%s is not allowed to be empty.")" "pkgrel"
|
2006-11-14 02:58:42 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2007-03-18 19:09:50 -04:00
|
|
|
if [ $(echo "$pkgver" | grep '-') ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "%s is not allowed to contain hyphens.")" "pkgver"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2007-03-18 19:09:50 -04:00
|
|
|
if [ $(echo "$pkgrel" | grep '-') ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "%s is not allowed to contain hyphens.")" "pkgrel"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2007-06-04 17:06:11 -04:00
|
|
|
|
2007-10-31 12:41:17 -04:00
|
|
|
if [ "$arch" = 'any' ]; then
|
|
|
|
CARCH='any'
|
|
|
|
fi
|
|
|
|
|
2006-12-21 15:50:24 -05:00
|
|
|
if ! in_array $CARCH ${arch[@]}; then
|
2007-08-25 12:01:14 -04:00
|
|
|
if [ "$IGNOREARCH" = "0" ]; then
|
2007-06-04 17:06:11 -04:00
|
|
|
error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgname" "$CARCH"
|
|
|
|
plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
|
|
|
|
plain "$(gettext "such as arch=('%s').")" "$CARCH"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
warning "$(gettext "%s is not available for the '%s' architecture.")" "$pkgname" "$CARCH"
|
|
|
|
plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
|
|
|
|
plain "$(gettext "such as arch=('%s').")" "$CARCH"
|
|
|
|
fi
|
2006-11-14 02:58:42 -05:00
|
|
|
fi
|
|
|
|
|
2005-10-20 16:46:35 -04:00
|
|
|
if [ "$install" -a ! -f "$install" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "Install scriptlet (%s) does not exist.")" "$install"
|
2005-10-20 16:46:35 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2008-05-13 06:26:11 -04:00
|
|
|
valid_options=1
|
|
|
|
for opt in ${options[@]}; do
|
|
|
|
known=0
|
|
|
|
# check if option matches a known option or its inverse
|
|
|
|
for kopt in ${known_options[@]}; do
|
|
|
|
if [ "${opt}" = "${kopt}" -o "${opt}" = "!${kopt}" ]; then
|
|
|
|
known=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ $known -eq 0 ]; then
|
|
|
|
error "$(gettext "options array contains unknown option '%s'")" "$opt"
|
|
|
|
valid_options=0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ $valid_options -eq 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
unset valid_options opt known kopt
|
|
|
|
|
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
|
|
|
|
2007-05-29 17:46:20 -04:00
|
|
|
if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \
|
2008-05-26 02:27:22 -04:00
|
|
|
-a "$FORCE" = "0" -a "$SOURCEONLY" = "0" -a "$NOBUILD" = "0" ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$INSTALL" = "1" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
warning "$(gettext "A package has already been built, installing existing package...")"
|
2007-06-02 13:39:47 -04:00
|
|
|
install_package
|
2005-03-14 20:51:43 -05:00
|
|
|
exit $?
|
|
|
|
else
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "A package has already been built. (use -f to overwrite)")"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-10-26 22:32:09 -04:00
|
|
|
# Run the bare minimum in fakeroot
|
2007-04-11 15:06:25 -04:00
|
|
|
# fix flyspray bug 6208 -- using makepkg with fakeroot gives an error
|
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
if [ "$REPKG" = "1" ]; then
|
|
|
|
warning "$(gettext "Skipping build.")"
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2007-04-11 15:06:25 -04:00
|
|
|
run_build
|
|
|
|
tidy_install
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
2007-04-11 15:06:25 -04:00
|
|
|
|
|
|
|
create_package
|
|
|
|
|
|
|
|
msg "$(gettext "Leaving fakeroot environment.")"
|
|
|
|
exit 0 # $E_OK
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2008-05-08 22:48:44 -04:00
|
|
|
msg "$(gettext "Making package: %s")" "$pkgname $pkgver-$pkgrel $CARCH ($(date))"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-06-01 13:43:41 -04:00
|
|
|
if [ $EUID -eq 0 ]; then
|
|
|
|
warning "$(gettext "Running makepkg as root...")"
|
|
|
|
fi
|
|
|
|
|
2007-05-30 14:27:13 -04:00
|
|
|
# if we are creating a source-only package, go no further
|
2008-06-06 21:58:21 -04:00
|
|
|
if [ "$SOURCEONLY" != "0" ]; then
|
2007-05-31 12:21:37 -04:00
|
|
|
if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}" \
|
2007-05-30 14:27:13 -04:00
|
|
|
-a "$FORCE" = "0" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
error "$(gettext "A package has already been built. (use -f to overwrite)")"
|
2007-05-30 14:27:13 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
create_srcpackage
|
2007-06-01 17:21:31 -04:00
|
|
|
msg "$(gettext "Source package created: %s")" "$pkgname ($(date))"
|
2007-05-30 14:27:13 -04:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
# fix flyspray bug #5973
|
2008-05-26 02:27:22 -04:00
|
|
|
if [ "$NODEPS" = "1" -o "$NOBUILD" = "1" -o "$REPKG" = "1" ]; then
|
2007-01-31 21:12:49 -05:00
|
|
|
if [ "$NODEPS" = "1" ]; then
|
2007-06-02 13:39:48 -04:00
|
|
|
warning "$(gettext "Skipping dependency checks.")"
|
2007-01-31 21:12:49 -05:00
|
|
|
fi
|
2008-05-26 02:27:22 -04:00
|
|
|
# skip printing a warning message for the others: nobuild, repkg
|
2006-12-21 14:11:22 -05:00
|
|
|
elif [ $(type -p pacman) ]; then
|
2007-06-02 12:41:15 -04:00
|
|
|
unset pkgdeps # Set by resolve_deps() and used by remove_deps()
|
2007-02-14 00:52:49 -05:00
|
|
|
deperr=0
|
|
|
|
|
2007-03-31 20:07:37 -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
|
|
|
|
2007-03-31 20:07:37 -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
|
|
|
|
|
|
|
if [ $deperr -eq 1 ]; 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
|
2007-04-11 15:06:25 -04:00
|
|
|
warning "$(gettext "pacman was not found in PATH; skipping dependency checks.")"
|
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"
|
2007-05-31 00:02:32 -04:00
|
|
|
cd "$srcdir"
|
2007-04-04 22:30:05 -04:00
|
|
|
|
2006-12-21 14:11:22 -05:00
|
|
|
if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
|
2007-06-02 11:45:17 -04:00
|
|
|
warning "$(gettext "Skipping source retrieval -- using existing src/ tree")"
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "Skipping source integrity checks -- using existing src/ tree")"
|
|
|
|
warning "$(gettext "Skipping source extraction -- using existing src/ tree")"
|
2007-06-02 22:33:17 -04:00
|
|
|
|
|
|
|
if [ "$NOEXTRACT" = "1" -a "$(ls "$srcdir" 2>/dev/null)" = "" ]; then
|
|
|
|
error "$(gettext "The source directory is empty, there is nothing to build!")"
|
|
|
|
plain "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
elif [ "$REPKG" = "1" -a \( ! -d "$pkgdir" -o "$(ls "$pkgdir" 2>/dev/null)" = "" \) ]; then
|
|
|
|
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
|
|
|
|
check_checksums
|
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
|
|
|
|
2006-12-21 14:11:22 -05:00
|
|
|
if [ "$NOBUILD" = "1" ]; 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
|
2007-05-31 00:02:32 -04:00
|
|
|
if [ -d "$pkgdir" -a "$REPKG" = "0" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Removing existing pkg/ directory...")"
|
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"
|
2008-01-08 10:10:45 -05:00
|
|
|
cd "$startdir"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2008-05-27 02:00:51 -04:00
|
|
|
if [ "$(check_buildenv fakeroot)" != "y" -o $EUID -eq 0 ]; then
|
|
|
|
# if we are root or if fakeroot is not enabled, then we don't use it
|
2007-04-11 15:06:25 -04:00
|
|
|
if [ "$REPKG" = "1" ]; then
|
|
|
|
warning "$(gettext "Skipping build.")"
|
|
|
|
else
|
2007-10-26 22:32:09 -04:00
|
|
|
devel_update
|
2007-04-11 15:06:25 -04:00
|
|
|
run_build
|
|
|
|
tidy_install
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-04-11 15:06:25 -04:00
|
|
|
create_package
|
|
|
|
else
|
|
|
|
msg "$(gettext "Entering fakeroot environment...")"
|
|
|
|
|
2007-10-26 22:32:09 -04:00
|
|
|
if [ "$newpkgver" != "" ]; then
|
|
|
|
fakeroot -- $0 --forcever $newpkgver -F $ARGLIST || exit $?
|
|
|
|
else
|
|
|
|
fakeroot -- $0 -F $ARGLIST || exit $?
|
|
|
|
fi
|
2007-04-11 15:06:25 -04:00
|
|
|
fi
|
2007-06-02 12:41:15 -04:00
|
|
|
|
|
|
|
create_xdelta "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
|
2007-04-11 15:06:25 -04:00
|
|
|
fi
|
2006-12-05 02:43:42 -05:00
|
|
|
|
2008-05-08 22:48:44 -04:00
|
|
|
msg "$(gettext "Finished making: %s")" "$pkgname $pkgver-$pkgrel $CARCH ($(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:
|