2005-03-14 20:51:43 -05:00
|
|
|
#!/bin/bash
|
2006-12-21 14:11:22 -05:00
|
|
|
#
|
2006-12-21 12:42:58 -05:00
|
|
|
# makepkg - make packages compatable for use with pacman
|
2006-12-21 14:11:22 -05:00
|
|
|
#
|
2006-02-16 17:57:25 -05: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
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
|
|
# USA.
|
|
|
|
#
|
|
|
|
|
2007-03-31 20:07:37 -04:00
|
|
|
# gettext initialization
|
|
|
|
source gettext.sh
|
|
|
|
|
|
|
|
TEXTDOMAIN=makepkg
|
|
|
|
export TEXTDOMAIN
|
|
|
|
TEXTDOMAINDIR='@LOCALEDIR@'
|
|
|
|
export TEXTDOMAINDIR
|
|
|
|
|
2006-12-14 00:23:08 -05:00
|
|
|
myver='3.0.0'
|
2006-12-20 20:53:40 -05:00
|
|
|
startdir=$(pwd)
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-04-01 19:55:01 -04:00
|
|
|
# Only use ABSROOT if we haven't been passed a SRCROOT on the command line.
|
|
|
|
if [ -z "$SRCROOT" ]; then
|
|
|
|
if [ -r /etc/abs/abs.conf ]; then
|
|
|
|
source /etc/abs/abs.conf
|
|
|
|
fi
|
|
|
|
if [ -r ~/.abs.conf ]; then
|
|
|
|
source ~/.abs.conf
|
|
|
|
fi
|
|
|
|
SRCROOT=$ABSROOT
|
|
|
|
fi
|
2006-12-14 00:23:08 -05:00
|
|
|
|
2006-01-21 21:16:41 -05:00
|
|
|
# Options
|
|
|
|
CLEANUP=0
|
|
|
|
CLEANCACHE=0
|
|
|
|
DEP_BIN=0
|
|
|
|
DEP_SRC=0
|
2007-02-11 16:47:37 -05:00
|
|
|
SUDO=0
|
2006-01-21 21:16:41 -05:00
|
|
|
FORCE=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
|
2006-01-21 21:16:41 -05:00
|
|
|
|
2006-02-16 17:57:25 -05:00
|
|
|
PACMAN_OPTS=
|
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
#determine if we are running with fakeroot
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$1" = "-F" ]; then
|
|
|
|
INFAKEROOT=1
|
|
|
|
shift
|
2006-12-21 12:42:58 -05:00
|
|
|
else
|
|
|
|
INFAKEROOT=0
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
### SUBROUTINES ###
|
|
|
|
|
|
|
|
plain() {
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
echo -e " \033[1;1m$1\033[1;0m" >&2
|
|
|
|
else
|
|
|
|
echo " $1" >&2
|
|
|
|
fi
|
|
|
|
}
|
2006-12-21 12:42:58 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
msg() {
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2
|
|
|
|
else
|
|
|
|
echo "==> $1" >&2
|
|
|
|
fi
|
|
|
|
}
|
2006-11-14 02:58:42 -05:00
|
|
|
|
|
|
|
msg2() {
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2006-12-20 20:53:40 -05:00
|
|
|
echo -e " \033[1;34m->\033[1;0m \033[1;1m$1\033[1;0m" >&2
|
|
|
|
else
|
|
|
|
echo " -> $1" >&2
|
|
|
|
fi
|
2006-11-14 02:58:42 -05:00
|
|
|
}
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
warning() {
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
echo -e "\033[1;33m==> WARNING:\033[1;0m \033[1;1m$1\033[1;0m" >&2
|
|
|
|
else
|
|
|
|
echo "==> WARNING: $1" >&2
|
|
|
|
fi
|
|
|
|
}
|
2006-12-21 12:42:58 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
error() {
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2
|
|
|
|
else
|
|
|
|
echo "==> ERROR: $1" >&2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
strip_url() {
|
2006-11-14 02:58:42 -05:00
|
|
|
echo "$1" | sed 's|^.*://.*/||g'
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-02-04 13:28:21 -05:00
|
|
|
# checks to see if options are present in makepkg.conf or PKGBUILD;
|
|
|
|
# PKGBUILD options always take precedence
|
2006-01-21 21:16:41 -05:00
|
|
|
check_option() {
|
2007-02-04 13:28:21 -05:00
|
|
|
local needle=$(echo $1 | tr [:upper:] [:lower:])
|
2006-01-21 21:16:41 -05:00
|
|
|
local i
|
2007-02-04 13:28:21 -05:00
|
|
|
# loop PKGBUILD opts first so it overrides makepkg.conf
|
2006-01-21 21:16:41 -05:00
|
|
|
for i in ${options[@]}; do
|
2006-12-20 20:53:40 -05:00
|
|
|
local lc=$(echo $i | tr [:upper:] [:lower:])
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ "$lc" = "$needle" ]; then
|
|
|
|
echo "y"
|
|
|
|
return
|
|
|
|
elif [ "$lc" = "!$needle" ]; then
|
|
|
|
echo "n"
|
|
|
|
return
|
2007-02-11 16:47:37 -05:00
|
|
|
# START DEPRECATED
|
2007-02-06 01:54:13 -05:00
|
|
|
# TODO This code should be removed in the next release of makepkg
|
|
|
|
elif [ "$lc" = "no$needle" ]; then
|
2007-04-05 11:36:38 -04:00
|
|
|
warning "$(gettext "Options beginning with 'no' will be deprecated in the next version of makepkg!")"
|
2007-03-31 20:07:37 -04:00
|
|
|
plain "$(eval_gettext "Please replace 'no' with '!': no\$needle -> !\$needle.")"
|
2007-02-06 01:54:13 -05:00
|
|
|
echo "n"
|
|
|
|
return
|
|
|
|
elif [ "$lc" = "keepdocs" -a "$needle" = "docs" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "Option 'keepdocs' may not work as intended. Please replace with 'docs'.")"
|
2007-02-11 16:47:37 -05:00
|
|
|
# END DEPRECATED
|
2007-02-04 13:28:21 -05:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
# fall back to makepkg.conf options
|
|
|
|
for i in ${OPTIONS[@]}; do
|
|
|
|
local lc=$(echo $i | tr [:upper:] [:lower:])
|
|
|
|
if [ "$lc" = "$needle" ]; then
|
|
|
|
echo "y"
|
|
|
|
return
|
|
|
|
elif [ "$lc" = "!$needle" ]; then
|
|
|
|
echo "n"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext "unknown")"
|
2007-02-04 13:28:21 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# check if option is present in BUILDENV
|
|
|
|
check_buildenv() {
|
|
|
|
local needle=$(echo $1 | tr [:upper:] [:lower:])
|
|
|
|
local i
|
|
|
|
# use options from makepkg.conf
|
|
|
|
for i in ${BUILDENV[@]}; do
|
|
|
|
local lc=$(echo $i | tr [:upper:] [:lower:])
|
|
|
|
if [ "$lc" = "$needle" ]; then
|
|
|
|
echo "y"
|
|
|
|
return
|
|
|
|
elif [ "$lc" = "!$needle" ]; then
|
|
|
|
echo "n"
|
2006-01-21 21:16:41 -05:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext "unknown")"
|
2007-02-04 13:28:21 -05:00
|
|
|
return
|
2006-01-21 21:16:41 -05:00
|
|
|
}
|
|
|
|
|
2006-11-14 02:58:42 -05:00
|
|
|
in_array() {
|
2006-12-21 15:50:24 -05:00
|
|
|
local needle=$1
|
2006-12-20 20:53:40 -05:00
|
|
|
shift 1
|
|
|
|
[ -z "$1" ] && return 1
|
|
|
|
for i in $*; do
|
2007-02-04 13:28:21 -05:00
|
|
|
[ "$i" = "$needle" ] && return 0
|
2006-12-20 20:53:40 -05:00
|
|
|
done
|
|
|
|
return 1
|
2006-11-14 02:58:42 -05:00
|
|
|
}
|
|
|
|
|
2007-04-04 22:30:05 -04:00
|
|
|
getdownloadclient() {
|
|
|
|
# $1 = url with valid protocol prefix
|
|
|
|
local url=$1
|
|
|
|
local proto=$(echo $netfile | sed 's|://.*||')
|
|
|
|
|
|
|
|
# loop through DOWNLOAD_AGENTS variable looking for protocol
|
|
|
|
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
|
|
|
|
error "$(eval_gettext "There is no agent set up to handle \$proto URLs. Check /etc/makepkg.conf.")"
|
|
|
|
error "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_CONFIG_ERROR # TODO: error code
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ensure specified program is installed
|
|
|
|
local program="$(echo $agent | awk '{print $1 }')"
|
|
|
|
if [ ! -x "$program" ]; then
|
|
|
|
local baseprog=$(basename $program)
|
|
|
|
error "$(eval_gettext "The download program \$baseprog is not installed.")"
|
|
|
|
error "$(gettext "Aborting...")"
|
|
|
|
exit 1 # $E_MISSING_PROGRAM # TODO: error code
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$agent"
|
|
|
|
}
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
checkdeps() {
|
2006-01-26 18:48:28 -05:00
|
|
|
[ $# -gt 0 ] || return
|
|
|
|
|
2007-02-14 00:52:49 -05:00
|
|
|
pmout=$(pacman $PACMAN_OPTS -T $*)
|
2005-03-14 20:51:43 -05:00
|
|
|
ret=$?
|
2007-02-26 03:43:02 -05:00
|
|
|
if [ $ret -eq 1 ]; 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-03-31 20:07:37 -04:00
|
|
|
error "$(eval_gettext "pacman returned a fatal error (\$ret): \$pmout")"
|
2007-02-14 00:52:49 -05:00
|
|
|
exit 1
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
handledeps() {
|
|
|
|
local missingdeps=0
|
|
|
|
local deplist="$*"
|
2007-03-19 21:34:16 -04:00
|
|
|
local depstrip=""
|
|
|
|
local striplist=""
|
2005-03-14 20:51:43 -05:00
|
|
|
local haveperm=0
|
2007-02-11 16:47:37 -05:00
|
|
|
if [ \( "$EUID" = "0" -a "$INFAKEROOT" != "1" \) -o "$SUDO" = 1 ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
haveperm=1
|
|
|
|
fi
|
|
|
|
|
2007-03-19 18:48:54 -04:00
|
|
|
for dep in $deplist; do
|
|
|
|
depstrip=$(echo $dep | sed 's|=.*$||' | sed 's|>.*$||' | sed 's|<.*$||')
|
|
|
|
striplist="$striplist $depstrip"
|
|
|
|
done
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$deplist" != "" -a $haveperm -eq 1 ]; then
|
2007-02-11 16:47:37 -05:00
|
|
|
if [ "$DEP_BIN" = "1" -a "$SUDO" = "1" ]; then
|
2005-10-20 16:46:35 -04:00
|
|
|
# install missing deps from binary packages (using pacman -S and sudo)
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Installing missing dependencies...")"
|
2005-10-20 16:46:35 -04:00
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
# kinda hacky, but we need to make pacman think that we're NOT
|
|
|
|
# in fakeroot so it will go ahead and install the dependencies.
|
|
|
|
FAKEROOTKEY2=$FAKEROOTKEY
|
|
|
|
unset FAKEROOTKEY
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
2007-03-19 18:48:54 -04:00
|
|
|
sudo pacman $PACMAN_OPTS -S $striplist
|
2007-02-26 03:43:02 -05:00
|
|
|
if [ $? -eq 1 ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "Pacman failed to install missing dependencies.")"
|
2005-10-20 16:46:35 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2006-11-14 02:58:42 -05:00
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
export FAKEROOTKEY=$FAKEROOTKEY2
|
|
|
|
unset FAKEROOTKEY2
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
2007-02-11 16:47:37 -05:00
|
|
|
elif [ "$DEP_BIN" = "1" ]; then
|
|
|
|
# install missing deps from binary packages (using pacman -S)
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Installing missing dependencies...")"
|
2007-03-19 18:48:54 -04:00
|
|
|
pacman $PACMAN_OPTS -S $striplist
|
2007-02-26 03:43:02 -05:00
|
|
|
if [ $? -eq 1 ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "Pacman failed to install missing dependencies.")"
|
2007-02-11 16:47:37 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
elif [ "$DEP_SRC" = "1" ]; then
|
|
|
|
# install missing deps by building them from source.
|
2006-11-14 02:58:42 -05:00
|
|
|
# we look for each package name in $SRCROOT and build it.
|
|
|
|
if [ "$SRCROOT" = "" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "Source root cannot be found - please make sure it is specified in /etc/makepkg.conf")"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# TODO: handle version comparators (eg, glibc>=2.2.5)
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Building missing dependencies...")"
|
2007-03-19 18:48:54 -04:00
|
|
|
for dep in $striplist; do
|
2006-11-14 02:58:42 -05:00
|
|
|
candidates=$(find $SRCROOT -type d -name "$dep")
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$candidates" = "" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(eval_gettext "Could not find \"\$dep\" under \$SRCROOT")"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
success=0
|
|
|
|
for pkgdir in $candidates; do
|
2007-03-18 19:09:50 -04:00
|
|
|
if [ -f "$pkgdir/$BUILDSCRIPT" ]; then
|
|
|
|
cd "$pkgdir"
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$RMDEPS" = "1" ]; then
|
2007-03-24 13:11:18 -04:00
|
|
|
PKGDEST="$PKGDEST" makepkg -i -c -b -r
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2007-03-24 13:11:18 -04:00
|
|
|
PKGDEST="$PKGDEST" makepkg -i -c -b
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
success=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ "$success" = "0" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(eval_gettext "Failed to build \"\$dep\"")"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
missingdeps=1
|
|
|
|
fi
|
|
|
|
elif [ "$deplist" != "" -a $haveperm -eq 0 ]; then
|
|
|
|
if [ "$DEP_SRC" = "1" -o "$DEP_BIN" = "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "Cannot auto-install missing dependencies as a normal user without sudo!")"
|
|
|
|
plain "$(gettext "Run makepkg as root or with -S to resolve dependencies automatically.")"
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
missingdeps=1
|
|
|
|
fi
|
2006-12-21 12:42:58 -05:00
|
|
|
|
2006-11-14 02:58:42 -05:00
|
|
|
# rerun any additional sh scripts found in /etc/profile.d/
|
|
|
|
for i in /etc/profile.d/*.sh
|
|
|
|
do
|
|
|
|
if [ -x $i ]; then
|
|
|
|
. $i &>/dev/null
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
return $missingdeps
|
|
|
|
}
|
|
|
|
|
2007-02-14 00:52:49 -05:00
|
|
|
resolvedeps() {
|
2007-03-19 22:13:44 -04:00
|
|
|
deplist=""
|
|
|
|
newdeplist=""
|
|
|
|
|
2007-02-14 00:52:49 -05:00
|
|
|
deplist=$(checkdeps $*)
|
|
|
|
if [ -n "${deplist}" ]; then
|
|
|
|
handledeps $deplist
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
# check deps again to make sure they were resolved
|
2007-03-19 22:13:44 -04:00
|
|
|
newdeplist=$(checkdeps $*)
|
2007-03-19 21:34:16 -04:00
|
|
|
if [ -n "${newdeplist}" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "Failed to install all missing dependencies.")"
|
2007-02-14 00:52:49 -05:00
|
|
|
fi
|
2007-03-19 22:13:44 -04:00
|
|
|
else
|
|
|
|
newdeplist="$deplist"
|
2007-02-14 00:52:49 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-03-19 22:13:44 -04:00
|
|
|
# if new dep list is not empty, print the list
|
2007-03-19 21:34:16 -04:00
|
|
|
if [ -n "${newdeplist}" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Missing Dependencies:")"
|
2007-03-19 21:34:16 -04:00
|
|
|
for dep in ${newdeplist}; do
|
2007-02-14 00:52:49 -05:00
|
|
|
msg2 "${dep}"
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-01-16 23:54:55 -05:00
|
|
|
# fix flyspray bug #5923
|
|
|
|
removedeps() {
|
2007-03-19 22:13:44 -04:00
|
|
|
# runtimedeps and buildtimedeps are set when resolving deps
|
|
|
|
local deplist="$runtimedeps $buildtimedeps"
|
2007-03-19 21:34:16 -04:00
|
|
|
local depstrip=""
|
|
|
|
local striplist=""
|
|
|
|
|
|
|
|
for dep in $deplist; do
|
|
|
|
depstrip=$(echo $dep | sed 's|=.*$||' | sed 's|>.*$||' | sed 's|<.*$||')
|
|
|
|
striplist="$striplist $depstrip"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$RMDEPS" = "1" -a "$SUDO" = "1" -a -n "$deplist" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Removing installed dependencies...")"
|
2007-01-16 23:54:55 -05:00
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
export FAKEROOTKEY2=$FAKEROOTKEY
|
2007-01-17 00:29:54 -05:00
|
|
|
unset FAKEROOTKEY
|
2007-01-16 23:54:55 -05:00
|
|
|
fi
|
2007-03-19 21:34:16 -04:00
|
|
|
sudo pacman $PACMAN_OPTS -Rs $striplist
|
2007-01-16 23:54:55 -05:00
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
export FAKEROOTKEY=$FAKEROOTKEY2
|
2007-01-17 00:29:54 -05:00
|
|
|
unset FAKEROOTKEY2
|
2007-01-16 23:54:55 -05:00
|
|
|
fi
|
2007-03-19 21:34:16 -04:00
|
|
|
elif [ "$RMDEPS" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" -a -n "$deplist" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Removing installed dependencies...")"
|
2007-03-19 21:34:16 -04:00
|
|
|
pacman $PACMAN_OPTS -Rs $striplist
|
2007-01-16 23:54:55 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-02-11 16:47:37 -05:00
|
|
|
installpackage() {
|
|
|
|
if [ "$INSTALL" = "1" -a "$SUDO" = "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Installing package with pacman -U...")"
|
2007-02-11 16:47:37 -05:00
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
FAKEROOTKEY2=$FAKEROOTKEY
|
|
|
|
unset FAKEROOTKEY
|
|
|
|
fi
|
|
|
|
sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
|
|
|
|
local exitcode=$?
|
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
export FAKEROOTKEY=$FAKEROOTKEY2
|
|
|
|
unset FAKEROOTKEY2
|
|
|
|
fi
|
|
|
|
exit $exitcode
|
|
|
|
elif [ "$INSTALL" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Installing package with pacman -U...")"
|
2007-02-11 16:47:37 -05:00
|
|
|
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
|
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
}
|
2007-01-16 23:54:55 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
usage() {
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(eval_gettext "makepkg version \$myver")"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2007-03-31 20:07:37 -04:00
|
|
|
makepkg=$0
|
|
|
|
echo "$(eval_gettext "Usage: \$makepkg [options]")"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext "Options:")"
|
|
|
|
echo "$(gettext " -b, --builddeps Build missing dependencies from source")"
|
|
|
|
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")"
|
|
|
|
echo "$(eval_gettext " -p <buildscript> Use an alternate build script (instead of \'\$BUILDSCRIPT\')")"
|
|
|
|
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")"
|
|
|
|
echo "$(gettext " -S, --usesudo When calling pacman, use sudo")"
|
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-03-31 20:07:37 -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-03-31 20:07:37 -04:00
|
|
|
echo "$(eval_gettext "If -p is not specified, makepkg will look for \'\$BUILDSCRIPT\'")"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
if [ -r /etc/makepkg.conf ]; then
|
2006-12-20 20:53:40 -05:00
|
|
|
source /etc/makepkg.conf
|
2006-11-14 02:58:42 -05:00
|
|
|
else
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "/etc/makepkg.conf not found. cannot continue")"
|
2007-04-01 19:55:01 -04:00
|
|
|
exit 1 # $E_CONFIG_ERROR # TODO: error codes
|
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
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
while [ "$#" -ne "0" ]; do
|
|
|
|
case $1 in
|
2006-12-20 20:53:40 -05:00
|
|
|
# pacman
|
2006-02-16 17:57:25 -05:00
|
|
|
--noconfirm) PACMAN_OPTS="$PACMAN_OPTS --noconfirm" ;;
|
|
|
|
--noprogressbar) PACMAN_OPTS="$PACMAN_OPTS --noprogressbar" ;;
|
2006-12-20 20:53:40 -05:00
|
|
|
# makepkg
|
2005-03-14 20:51:43 -05:00
|
|
|
--clean) CLEANUP=1 ;;
|
|
|
|
--cleancache) CLEANCACHE=1 ;;
|
|
|
|
--syncdeps) DEP_BIN=1 ;;
|
2007-02-11 16:47:37 -05:00
|
|
|
--usesudo) SUDO=1 ;;
|
2005-03-14 20:51:43 -05:00
|
|
|
--builddeps) DEP_SRC=1 ;;
|
|
|
|
--nodeps) NODEPS=1 ;;
|
|
|
|
--noextract) NOEXTRACT=1 ;;
|
|
|
|
--install) INSTALL=1 ;;
|
|
|
|
--force) FORCE=1 ;;
|
|
|
|
--nobuild) NOBUILD=1 ;;
|
|
|
|
--nocolor) USE_COLOR="n" ;;
|
2006-11-14 02:58:42 -05:00
|
|
|
--geninteg) GENINTEG=1 ;;
|
2005-03-14 20:51:43 -05:00
|
|
|
--rmdeps) RMDEPS=1 ;;
|
2006-12-21 12:42:58 -05:00
|
|
|
--repackage) REPKG=1 ;;
|
2006-12-20 20:53:40 -05:00
|
|
|
--log) LOGGING=1 ;;
|
2005-03-14 20:51:43 -05:00
|
|
|
--help)
|
2006-12-21 14:11:22 -05:00
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2005-03-14 20:51:43 -05:00
|
|
|
--*)
|
2006-12-21 14:11:22 -05:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
2005-03-14 20:51:43 -05:00
|
|
|
-*)
|
2007-02-23 14:51:24 -05:00
|
|
|
while getopts "bcCdefghiLmop:rRsS-" opt; do
|
2006-12-20 20:53:40 -05:00
|
|
|
case $opt in
|
|
|
|
b) DEP_SRC=1 ;;
|
|
|
|
c) CLEANUP=1 ;;
|
|
|
|
C) CLEANCACHE=1 ;;
|
|
|
|
d) NODEPS=1 ;;
|
|
|
|
e) NOEXTRACT=1 ;;
|
|
|
|
f) FORCE=1 ;;
|
|
|
|
g) GENINTEG=1 ;;
|
|
|
|
h)
|
2006-12-21 14:11:22 -05:00
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2006-12-20 20:53:40 -05:00
|
|
|
i) INSTALL=1 ;;
|
|
|
|
L) LOGGING=1 ;;
|
|
|
|
m) USE_COLOR="n" ;;
|
|
|
|
o) NOBUILD=1 ;;
|
|
|
|
p) BUILDSCRIPT=$OPTARG ;;
|
|
|
|
r) RMDEPS=1 ;;
|
2006-12-21 12:42:58 -05:00
|
|
|
R) REPKG=1 ;;
|
2006-12-20 20:53:40 -05:00
|
|
|
s) DEP_BIN=1 ;;
|
2007-02-11 16:47:37 -05:00
|
|
|
S) SUDO=1 ;;
|
2006-12-20 20:53:40 -05:00
|
|
|
-)
|
2006-12-21 14:11:22 -05:00
|
|
|
OPTIND=0
|
|
|
|
break
|
|
|
|
;;
|
2006-12-20 20:53:40 -05:00
|
|
|
*)
|
2006-12-21 14:11:22 -05:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
2006-12-20 20:53:40 -05:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
;;
|
2005-03-14 20:51:43 -05:00
|
|
|
*)
|
2006-12-21 14:11:22 -05:00
|
|
|
true
|
|
|
|
;;
|
2005-03-14 20:51:43 -05:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2005-10-20 16:46:35 -04:00
|
|
|
# check for sudo
|
2007-02-11 16:47:37 -05:00
|
|
|
if [ "$SUDO" = "1" -a ! "$(type -p sudo)" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "Cannot find the sudo binary! Is sudo installed?")"
|
2005-10-20 16:46:35 -04: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-03-31 20:07:37 -04:00
|
|
|
msg "$(eval_gettext "Cleaning up ALL files from \$SRCDEST.")"
|
|
|
|
echo -n "$(gettext " Are you sure you wish to do this? [Y/n] ")"
|
2007-03-08 23:35:04 -05:00
|
|
|
read answer
|
|
|
|
answer=$(echo $answer | tr [:upper:] [:lower:])
|
|
|
|
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-03-31 20:07:37 -04:00
|
|
|
error "$(eval_gettext "Problem removing files; you may not have correct permissions in \$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
|
|
|
|
|
|
|
|
unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums force
|
|
|
|
unset replaces depends conflicts backup source install build makedepends
|
2007-01-23 11:02:37 -05:00
|
|
|
unset options noextract
|
2006-11-14 02:58:42 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ ! -f $BUILDSCRIPT ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(eval_gettext "\$BUILDSCRIPT does not exist.")"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
2006-12-20 20:53:40 -05:00
|
|
|
#TODO this is an attempt at a generic way to unset all package specific
|
|
|
|
#variables in a PKGBUILD
|
|
|
|
#else
|
|
|
|
# #this is fun.... we'll unset
|
|
|
|
# for var in $(grep "=" $BUILDSCRIPT | sed "s|.*\(\<.*\>\)=.*|\1|g"); do
|
|
|
|
# unset $var
|
|
|
|
# done
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
source $BUILDSCRIPT
|
|
|
|
|
2007-02-23 14:51:24 -05:00
|
|
|
# check for no-no's in the build script
|
2006-11-14 02:58:42 -05:00
|
|
|
if [ -z "$pkgver" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "pkgver is not allowed to be empty.")"
|
2006-11-14 02:58:42 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$pkgrel" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "pkgrel is not allowed to be empty.")"
|
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-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "pkgver is not allowed to contain hyphens.")"
|
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-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "pkgrel is not allowed to contain hyphens.")"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2006-12-21 15:50:24 -05:00
|
|
|
if ! in_array $CARCH ${arch[@]}; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(eval_gettext "\$pkgname is not available for the \'\$CARCH\' architecture.")"
|
|
|
|
plain "$(eval_gettext "Note that many packages may need a line added to their \$BUILDSCRIPT")"
|
|
|
|
plain "$(eval_gettext "such as arch=(\'\$CARCH\').")"
|
2006-11-14 02:58:42 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-10-20 16:46:35 -04:00
|
|
|
if [ "$install" -a ! -f "$install" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(eval_gettext "install scriptlet (\$install) does not exist.")"
|
2005-10-20 16:46:35 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-03-18 19:09:50 -04:00
|
|
|
if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}" \
|
2007-02-23 14:51:24 -05:00
|
|
|
-a "$FORCE" = "0" -a "$GENINTEG" = "0" ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$INSTALL" = "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "a package has already been built, installing existing package.")"
|
2007-02-11 16:47:37 -05:00
|
|
|
installpackage
|
2005-03-14 20:51:43 -05:00
|
|
|
exit $?
|
|
|
|
else
|
2007-03-31 20:07:37 -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-02-23 14:51:24 -05:00
|
|
|
# Enter the fakeroot environment if necessary. This will call the makepkg
|
|
|
|
# script again as the fake root user. We detect this by passing a sentinel
|
|
|
|
# option (-F) to makepkg.
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ "$EUID" != "0" ]; then
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ "$(check_buildenv fakeroot)" = "y" ]; then
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ $(type -p fakeroot) ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Entering fakeroot environment")"
|
2005-03-14 20:51:43 -05:00
|
|
|
fakeroot -- $0 -F $ARGLIST
|
|
|
|
exit $?
|
|
|
|
else
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "Fakeroot is not installed. Building as an unprivileged user")"
|
|
|
|
plain "$(gettext "will result in non-root ownership of the packaged files. Install")"
|
|
|
|
plain "$(gettext "the fakeroot package to correctly build as a non-root user.")"
|
2005-03-14 20:51:43 -05:00
|
|
|
plain ""
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
else
|
2007-03-31 20:07:37 -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")"
|
|
|
|
plain "$(gettext "by placing 'fakeroot' in the BUILDENV array in makepkg.conf.")"
|
2005-03-14 20:51:43 -05:00
|
|
|
plain ""
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-03-31 20:07:37 -04:00
|
|
|
date=$(date)
|
|
|
|
msg "$(eval_gettext "Making package: \$pkgname \$pkgver-\$pkgrel (\$date)")"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
# fix flyspray bug #5973
|
2006-12-21 15:03:41 -05:00
|
|
|
if [ "$NODEPS" = "1" -o "$GENINTEG" = "1" -o "$NOBUILD" = "1" -o "$REPKG" = "1" ]; then
|
2007-01-31 21:12:49 -05:00
|
|
|
if [ "$NODEPS" = "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "skipping dependency checks")"
|
2007-01-31 21:12:49 -05:00
|
|
|
fi
|
|
|
|
# skip printing a warning message for the others: geninteg, nobuild, repkg
|
2006-12-21 14:11:22 -05:00
|
|
|
elif [ $(type -p pacman) ]; then
|
2007-02-14 00:52:49 -05:00
|
|
|
deperr=0
|
2007-03-19 21:34:16 -04:00
|
|
|
# these two variables are needed later by removedeps
|
2007-03-19 22:13:44 -04:00
|
|
|
unset runtimedeps buildtimedeps
|
2007-02-14 00:52:49 -05:00
|
|
|
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Checking Runtime Dependencies...")"
|
2007-02-14 00:52:49 -05:00
|
|
|
resolvedeps ${depends[@]}
|
2007-03-19 22:13:44 -04:00
|
|
|
ret=$?
|
2007-03-19 21:34:16 -04:00
|
|
|
# deplist is a global variable set by resolvedeps
|
|
|
|
runtimedeps="$deplist"
|
2007-03-19 22:13:44 -04:00
|
|
|
if [ "$ret" != "0" ]; then
|
2007-02-14 00:52:49 -05:00
|
|
|
deperr=1
|
2006-02-17 16:07:50 -05:00
|
|
|
fi
|
2007-02-14 00:52:49 -05:00
|
|
|
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Checking Buildtime Dependencies...")"
|
2007-02-14 00:52:49 -05:00
|
|
|
resolvedeps ${makedepends[@]}
|
2007-03-19 22:13:44 -04:00
|
|
|
ret=$?
|
2007-03-19 21:34:16 -04:00
|
|
|
# deplist is a global variable set by resolvedeps
|
2007-03-19 22:13:44 -04:00
|
|
|
buildtimedeps="$deplist"
|
|
|
|
if [ "$ret" != "0" ]; then
|
2007-02-14 00:52:49 -05:00
|
|
|
deperr=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $deperr -eq 1 ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "could not resolve all dependencies.")"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "pacman was not found in PATH. skipping dependency checks.")"
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2007-03-18 19:09:50 -04:00
|
|
|
cd "$startdir"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
mkdir -p src
|
2007-03-18 19:09:50 -04:00
|
|
|
cd "$startdir/src"
|
2007-04-04 22:30:05 -04:00
|
|
|
|
|
|
|
msg "$(gettext "Retrieving Sources...")"
|
2005-03-14 20:51:43 -05:00
|
|
|
for netfile in ${source[@]}; do
|
2006-12-21 12:42:58 -05:00
|
|
|
file=$(strip_url "$netfile")
|
2006-12-14 00:23:08 -05:00
|
|
|
if [ -f "../$file" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg2 "$(eval_gettext "Found \$file in build dir")"
|
2006-12-14 00:23:08 -05:00
|
|
|
cp "../$file" .
|
2007-04-04 22:30:05 -04:00
|
|
|
continue
|
2006-12-14 00:23:08 -05:00
|
|
|
elif [ -f "$SRCDEST/$file" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg2 "$(eval_gettext "Using cached copy of \$file")"
|
2006-12-21 12:42:58 -05:00
|
|
|
cp "$SRCDEST/$file" .
|
2007-04-04 22:30:05 -04:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# find the client we should use for this URL
|
|
|
|
dlclient=$(getdownloadclient $netfile) || exit $?
|
|
|
|
|
|
|
|
msg2 "$(eval_gettext "Downloading \$file")"
|
|
|
|
# fix flyspray bug #3289
|
|
|
|
ret=0
|
|
|
|
$dlclient "$netfile" || ret=$?
|
|
|
|
if [ $ret -gt 0 ]; then
|
|
|
|
error "$(gettext "Failure while downloading $file")"
|
|
|
|
msg "$(gettext "Aborting...")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$SRCDEST" ]; then
|
|
|
|
mkdir -p "$SRCDEST" && cp "$file" "$SRCDEST" || ret=$?
|
|
|
|
if [ $ret -gt 0 ]; then
|
|
|
|
warning "$(eval_gettext "You do not have correct permissions to cache source in \$SRCDEST")"
|
2006-12-21 12:42:58 -05:00
|
|
|
cp "$file" ..
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
2007-04-04 22:30:05 -04:00
|
|
|
else
|
|
|
|
cp "$file" ..
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
done
|
2007-04-04 22:30:05 -04:00
|
|
|
unset netfile file dlclient ret
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-12-21 14:11:22 -05:00
|
|
|
if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "Skipping source integrity checks -- using existing src/ tree")"
|
2006-12-20 20:53:40 -05:00
|
|
|
else
|
2007-02-28 00:08:25 -05:00
|
|
|
# TODO we end up checking $GENINTEG 3 times, could probably be refactored
|
|
|
|
if [ "$GENINTEG" = "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Generating checksums for source files")"
|
2007-02-28 00:08:25 -05:00
|
|
|
plain ""
|
|
|
|
fi
|
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
for integ in ${INTEGRITY_CHECK[@]}; do
|
|
|
|
integ="$(echo $integ | tr A-Z a-z)"
|
|
|
|
case "$integ" in
|
|
|
|
md5) integrity_name="md5sum" ;;
|
|
|
|
sha1) integrity_name="sha1sum" ;;
|
|
|
|
sha256) integrity_name="sha256sum" ;;
|
|
|
|
sha384) integrity_name="sha384sum" ;;
|
|
|
|
sha512) integrity_name="sha512sum" ;;
|
2007-03-31 20:07:37 -04:00
|
|
|
*) error "$(eval_gettext "Invalid integrity algorithm \'\$integ\' specified")"; exit 1;;
|
2006-12-20 20:53:40 -05:00
|
|
|
esac
|
|
|
|
if [ ! $(type -p $integrity_name) ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(eval_gettext "Cannot find the \$integrity_name program.")"
|
2006-12-20 20:53:40 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Generate integrity checks
|
|
|
|
if [ "$GENINTEG" = "1" ]; then
|
|
|
|
ct=0
|
|
|
|
numsrc=${#source[@]}
|
|
|
|
for netfile in "${source[@]}"; do
|
|
|
|
file=$(strip_url "$netfile")
|
|
|
|
sum=$(eval "$integrity_name '$file' | cut -d' ' -f 1")
|
|
|
|
if [ $ct -eq 0 ]; then
|
|
|
|
echo -n "${integrity_name}s=("
|
|
|
|
else
|
2007-04-04 01:30:14 -04:00
|
|
|
indent=0
|
|
|
|
while [ $indent -lt $((${#integrity_name}+3)) ]; do
|
|
|
|
echo -n " "
|
|
|
|
indent=$(($indent+1))
|
|
|
|
done
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
|
|
|
echo -n "'$sum'"
|
|
|
|
ct=$(($ct+1))
|
|
|
|
if [ $ct -eq $numsrc ]; then
|
|
|
|
echo ')'
|
|
|
|
else
|
2007-01-31 20:18:22 -05:00
|
|
|
echo
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
|
|
|
done
|
2006-12-21 12:42:58 -05:00
|
|
|
#Validate integrity checks
|
2006-12-20 20:53:40 -05:00
|
|
|
else
|
|
|
|
integrity_sums=($(eval echo \${${integrity_name}s[@]}))
|
|
|
|
|
|
|
|
if [ ${#integrity_sums[@]} -eq ${#source[@]} ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(eval_gettext "Validating source files with \${integrity_name}s")"
|
2006-12-20 20:53:40 -05:00
|
|
|
errors=0
|
|
|
|
idx=0
|
|
|
|
for netfile in "${source[@]}"; do
|
|
|
|
file=$(strip_url "$netfile")
|
|
|
|
echo -n " $file ... " >&2
|
|
|
|
echo "${integrity_sums[$idx]} $file" | $integrity_name -c - >/dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext "FAILED")" >&2
|
2006-12-20 20:53:40 -05:00
|
|
|
errors=1
|
|
|
|
else
|
2007-03-31 20:07:37 -04:00
|
|
|
echo "$(gettext "Passed")" >&2
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
|
|
|
idx=$(($idx+1))
|
|
|
|
done
|
|
|
|
if [ $errors -gt 0 ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "One or more files did not pass the validity check!")"
|
2006-12-20 20:53:40 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(eval_gettext "Integrity checks (\$integ) are missing or incomplete.")"
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$GENINTEG" = "1" ]; then
|
2007-02-28 00:08:25 -05:00
|
|
|
plain ""
|
2006-12-20 20:53:40 -05:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Extract sources
|
2006-12-21 12:42:58 -05:00
|
|
|
if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "Skipping source extraction -- using existing src/ tree")"
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Extracting Sources...")"
|
2006-12-20 20:53:40 -05:00
|
|
|
for netfile in "${source[@]}"; do
|
|
|
|
unziphack=0
|
|
|
|
file=$(strip_url "$netfile")
|
2007-01-23 11:02:37 -05:00
|
|
|
if in_array "$file" ${noextract[@]}; then
|
|
|
|
#skip source files in the noextract=() array
|
|
|
|
# these are marked explicitly to NOT be extracted
|
|
|
|
continue
|
|
|
|
fi
|
2007-01-22 03:45:12 -05:00
|
|
|
# fix flyspray #6246
|
|
|
|
file_type=$(file -biz "$file")
|
2006-12-20 20:53:40 -05:00
|
|
|
unset cmd
|
2007-01-22 03:45:12 -05:00
|
|
|
case "$file_type" in
|
2007-03-29 22:26:58 -04:00
|
|
|
*application/x-tar*application/x-compress*)
|
|
|
|
cmd="tar -xzf $file" ;;
|
2007-01-22 03:45:12 -05:00
|
|
|
*application/x-tar*)
|
2007-03-03 13:38:57 -05:00
|
|
|
cmd="tar -xf $file" ;;
|
2007-01-22 03:45:12 -05:00
|
|
|
*application/x-zip*)
|
2007-03-03 13:38:57 -05:00
|
|
|
unziphack=1
|
|
|
|
cmd="unzip -qqo $file" ;;
|
2007-01-22 03:45:12 -05:00
|
|
|
*application/x-cpio*)
|
2007-03-03 13:38:57 -05:00
|
|
|
cmd="bsdtar -x -f $file" ;;
|
2007-01-22 03:45:12 -05:00
|
|
|
*application/x-gzip*)
|
2007-04-18 00:52:59 -04:00
|
|
|
cmd="gunzip -d -f $file" ;;
|
2007-01-22 03:45:12 -05:00
|
|
|
*application/x-bzip*)
|
2007-03-03 13:38:57 -05:00
|
|
|
cmd="bunzip2 -f $file" ;;
|
2006-12-20 20:53:40 -05:00
|
|
|
esac
|
|
|
|
if [ "$cmd" != "" ]; then
|
2006-12-21 12:42:58 -05:00
|
|
|
msg2 "$cmd"
|
2006-12-20 20:53:40 -05:00
|
|
|
$cmd
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
# unzip will return a 1 as a warning, it is not an error
|
|
|
|
if [ "$unziphack" != "1" -o $? -ne 1 ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(eval_gettext "Failed to extract \$file")"
|
|
|
|
msg "$(gettext "Aborting...")"
|
2006-12-20 20:53:40 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2006-12-21 14:11:22 -05:00
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
if [ "$EUID" = "0" ]; then
|
|
|
|
# chown all source files to root.root
|
2007-03-18 19:09:50 -04:00
|
|
|
chown -R root.root "$startdir/src"
|
2006-12-21 12:42:58 -05:00
|
|
|
fi
|
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.")"
|
2006-12-21 14:11:22 -05:00
|
|
|
exit 0
|
|
|
|
elif [ "$REPKG" = "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(gettext "Skipping build")"
|
2006-12-21 14:11:22 -05:00
|
|
|
else
|
2006-12-21 12:42:58 -05:00
|
|
|
# check for existing pkg directory
|
2007-03-18 19:09:50 -04:00
|
|
|
if [ -d "$startdir/pkg" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Removing existing pkg/ directory...")"
|
2007-03-18 19:09:50 -04:00
|
|
|
rm -rf "$startdir/pkg"
|
2006-12-21 12:42:58 -05:00
|
|
|
fi
|
2007-03-18 19:09:50 -04:00
|
|
|
mkdir -p "$startdir/pkg"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-02-23 14:51:24 -05:00
|
|
|
# use distcc if it is requested (check buildenv and PKGBUILD opts)
|
|
|
|
if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then
|
2006-12-21 12:42:58 -05:00
|
|
|
[ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
|
2007-02-23 21:11:52 -05:00
|
|
|
elif [ "$(check_option distcc)" = "n" ]; then
|
2007-02-23 14:51:24 -05:00
|
|
|
# if it is not wanted, clear the makeflags too
|
2007-04-11 12:44:42 -04:00
|
|
|
MAKEFLAGS=""
|
2006-12-21 12:42:58 -05:00
|
|
|
fi
|
2005-12-13 21:40:01 -05:00
|
|
|
|
2007-02-23 14:51:24 -05:00
|
|
|
# use ccache if it is requested (check buildenv and PKGBUILD opts)
|
|
|
|
if [ "$(check_buildenv ccache)" = "y" -a "$(check_option ccache)" != "n" ]; then
|
2006-12-21 12:42:58 -05:00
|
|
|
[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-02-23 14:51:24 -05:00
|
|
|
# clear user-specified makeflags if requested
|
|
|
|
if [ "$(check_option makeflags)" = "n" ]; then
|
2007-04-11 12:44:42 -04:00
|
|
|
MAKEFLAGS=""
|
2007-02-23 14:51:24 -05:00
|
|
|
fi
|
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
# build
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Starting build()...")"
|
2006-11-16 17:43:58 -05:00
|
|
|
|
2007-02-13 15:47:34 -05:00
|
|
|
# some applications (eg, blackbox) will not build with some languages
|
2007-04-16 23:58:07 -04:00
|
|
|
unset LC_ALL LC_MESSAGES LANG
|
2007-02-13 15:47:34 -05:00
|
|
|
umask 0022
|
|
|
|
|
2007-04-11 12:44:42 -04:00
|
|
|
# ensure CFLAGS and CXXFLAGS are used
|
|
|
|
export CFLAGS
|
|
|
|
export CXXFLAGS
|
|
|
|
export MAKEFLAGS
|
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
#check for "exit on syntax error" shell option
|
|
|
|
echo $SHELLOPTS | grep errexit 2>&1 >/dev/null
|
|
|
|
set_e=$?
|
2006-12-19 02:39:44 -05:00
|
|
|
|
2007-03-25 13:37:42 -04:00
|
|
|
ret=0
|
2006-12-21 12:42:58 -05:00
|
|
|
if [ "$LOGGING" = "1" ]; then
|
|
|
|
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
|
|
|
|
if [ -f "$BUILDLOG" ]; then
|
|
|
|
i=1
|
|
|
|
while true; do
|
|
|
|
if [ -f "$BUILDLOG.$i" ]; then
|
|
|
|
i=$(($i +1))
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
mv "$BUILDLOG" "$BUILDLOG.$i"
|
|
|
|
fi
|
2006-12-20 20:53:40 -05:00
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
#use 'errexit' to bail on syntax error
|
|
|
|
[ $set_e -eq 1 ] && set -e
|
2007-03-25 13:37:42 -04:00
|
|
|
build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
|
2006-12-21 12:42:58 -05:00
|
|
|
[ $set_e -eq 1 ] && set +e
|
|
|
|
else
|
|
|
|
#use 'errexit' to bail on syntax error
|
|
|
|
[ $set_e -eq 1 ] && set -e
|
2007-03-25 13:37:42 -04:00
|
|
|
build 2>&1 || ret=$?
|
2006-12-21 12:42:58 -05:00
|
|
|
[ $set_e -eq 1 ] && set +e
|
2007-03-25 13:37:42 -04:00
|
|
|
fi
|
|
|
|
if [ $ret -gt 0 ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "Build Failed. Aborting...")"
|
2007-03-25 13:37:42 -04:00
|
|
|
removedeps
|
|
|
|
exit 2
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ "$(check_option docs)" = "n" ]; then
|
2006-01-21 21:16:41 -05:00
|
|
|
# remove info/doc files
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Removing info/doc files...")"
|
2007-03-18 19:09:50 -04:00
|
|
|
cd "$startdir/pkg"
|
2006-12-21 12:42:58 -05:00
|
|
|
#fix flyspray bug #5021
|
|
|
|
rm -rf ${DOC_DIRS[@]}
|
2006-01-21 21:16:41 -05:00
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
# move /usr/share/man files to /usr/man
|
2007-02-06 17:36:13 -05:00
|
|
|
if [ -d $startdir/pkg/usr/share/man ]; then
|
2007-03-18 19:09:50 -04:00
|
|
|
cd "$startdir"
|
2005-03-14 20:51:43 -05:00
|
|
|
mkdir -p pkg/usr/man
|
|
|
|
cp -a pkg/usr/share/man/* pkg/usr/man/
|
|
|
|
rm -rf pkg/usr/share/man
|
|
|
|
fi
|
|
|
|
|
|
|
|
# compress man pages
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Compressing man pages...")"
|
2007-03-18 19:09:50 -04:00
|
|
|
find "$startdir"/pkg/{usr{,/local},opt/*}/man -type f 2>/dev/null | while read i ; do
|
2006-12-21 14:11:22 -05:00
|
|
|
ext="${i##*.}"
|
|
|
|
fn="${i##*/}"
|
|
|
|
if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
|
|
|
|
# update symlinks to this manpage
|
2007-03-18 19:09:50 -04:00
|
|
|
find "$startdir"/pkg/{usr{,/local},opt/*}/man -lname "$fn" 2> /dev/null | while read ln ; do
|
2007-01-17 00:29:54 -05:00
|
|
|
rm -f "$ln"
|
|
|
|
ln -sf "${fn}.gz" "${ln}.gz"
|
|
|
|
done
|
|
|
|
# compress the original
|
|
|
|
gzip -9 "$i"
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2007-03-18 19:09:50 -04:00
|
|
|
cd "$startdir"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
# strip binaries
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ "$(check_option strip)" = "y" ]; then
|
2007-04-16 22:12:15 -04:00
|
|
|
msg "$(gettext "Stripping symbols from binaries and libraries...")"
|
|
|
|
for file in $(find pkg/*/{bin,lib,sbin} -type f 2>/dev/null || true ); do
|
|
|
|
case "$(file -biz "$file")" in
|
|
|
|
*application/x-sharedlib*) # Libraries
|
|
|
|
/usr/bin/strip --strip-debug "$file";;
|
|
|
|
*application/x-executable*) # Binaries
|
|
|
|
/usr/bin/strip "$file";;
|
|
|
|
esac
|
|
|
|
done
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2006-02-16 17:57:25 -05:00
|
|
|
# remove libtool (.la) files
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ "$(check_option libtool)" = "n" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Removing libtool .la files...")"
|
2006-02-16 17:57:25 -05:00
|
|
|
find pkg -type f -name "*.la" -exec rm -f -- '{}' \;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# remove empty directories
|
2007-02-04 13:28:21 -05:00
|
|
|
if [ "$(check_option emptydirs)" = "n" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Removing empty directories...")"
|
2007-02-04 13:28:21 -05:00
|
|
|
cd "$startdir/pkg"
|
|
|
|
find -depth -type d -empty -delete;
|
2006-02-16 17:57:25 -05:00
|
|
|
fi
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
# get some package meta info
|
2006-12-20 20:53:40 -05:00
|
|
|
builddate=$(LC_ALL= ; LANG= ; date -u "+%a %b %e %H:%M:%S %Y")
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$PACKAGER" != "" ]; then
|
|
|
|
packager="$PACKAGER"
|
|
|
|
else
|
|
|
|
packager="Arch Linux (http://www.archlinux.org)"
|
|
|
|
fi
|
2007-03-18 19:09:50 -04:00
|
|
|
size=$(du -cb "$startdir/pkg" | tail -n 1 | awk '{print $1}')
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-31 20:59:26 -05:00
|
|
|
# build a filelist - do this first to keep meta files out of the list
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Generating .FILELIST file...")"
|
2007-01-31 20:59:26 -05:00
|
|
|
cd "$startdir/pkg"
|
|
|
|
tar cvf /dev/null * | sort >.FILELIST
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
# write the .PKGINFO file
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Generating .PKGINFO file...")"
|
2007-03-18 19:09:50 -04:00
|
|
|
cd "$startdir/pkg"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo "# Generated by makepkg $myver" >.PKGINFO
|
|
|
|
echo -n "# " >>.PKGINFO
|
|
|
|
date >>.PKGINFO
|
|
|
|
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
|
|
|
|
|
2005-10-20 16:46:35 -04:00
|
|
|
for it in "${license[@]}"; do
|
|
|
|
echo "license = $it" >>.PKGINFO
|
|
|
|
done
|
2005-03-14 20:51:43 -05:00
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2007-02-06 17:36:13 -05:00
|
|
|
# TODO maybe remove this at some point
|
|
|
|
# warn if license array is not present or empty
|
|
|
|
if [ "$license" = "" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
warning "$(eval_gettext "Please add a license line to your \$BUILDSCRIPT!")"
|
|
|
|
plain "$(gettext "example for GPL\'ed software: license=(\'GPL\').")"
|
2007-02-06 17:36:13 -05:00
|
|
|
fi
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
# check for an install script
|
|
|
|
if [ "$install" != "" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Copying install script...")"
|
2007-01-22 04:57:20 -05:00
|
|
|
cp "$startdir/$install" "$startdir/pkg/.INSTALL"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# do we have a changelog?
|
|
|
|
have_changelog=0
|
2007-01-22 12:53:56 -05:00
|
|
|
if [ -f "$startdir/ChangeLog" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Copying package changelog")"
|
2007-01-22 12:53:56 -05:00
|
|
|
cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG"
|
2007-01-22 04:57:20 -05:00
|
|
|
have_changelog=1
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
# tar it up
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Compressing package...")"
|
2007-01-22 04:57:20 -05:00
|
|
|
cd "$startdir/pkg"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-12-21 15:50:24 -05:00
|
|
|
pkg_file="$PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT}"
|
2007-01-31 21:34:03 -05:00
|
|
|
comp_files=".PKGINFO .FILELIST ${install:+.INSTALL}"
|
2007-01-22 04:57:20 -05:00
|
|
|
[ $have_changelog -eq 1 ] && comp_files=".CHANGELOG $comp_files"
|
2006-12-21 15:50:24 -05:00
|
|
|
|
|
|
|
if ! tar czf $pkg_file $comp_files *; then
|
2007-03-31 20:07:37 -04:00
|
|
|
error "$(gettext "Failed to create package file.")"
|
2006-12-21 15:50:24 -05:00
|
|
|
exit 1
|
2006-12-05 02:43:42 -05:00
|
|
|
fi
|
|
|
|
|
2007-01-22 04:57:20 -05:00
|
|
|
cd "$startdir"
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$CLEANUP" = "1" ]; then
|
2007-03-31 20:07:37 -04:00
|
|
|
msg "$(gettext "Cleaning up...")"
|
2006-12-21 15:50:24 -05:00
|
|
|
rm -rf src pkg
|
2006-12-20 20:53:40 -05:00
|
|
|
rm -rf ${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2007-01-16 23:54:55 -05:00
|
|
|
removedeps
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-03-31 20:07:37 -04:00
|
|
|
date=$(date)
|
|
|
|
msg "$(eval_gettext "Finished making: \$pkgname (\$date)")"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-02-11 16:47:37 -05:00
|
|
|
installpackage
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
exit 0
|
2007-03-31 20:07:37 -04:00
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
# vim: set ts=2 sw=2 noet:
|
|
|
|
|