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.
|
|
|
|
#
|
|
|
|
|
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
|
|
|
|
2006-12-14 00:23:08 -05:00
|
|
|
BUILDSCRIPT="PKGBUILD"
|
|
|
|
PKGEXT="pkg.tar.gz"
|
|
|
|
|
|
|
|
source "/etc/abs/abs.conf"
|
|
|
|
SRCROOT=$ABSROOT
|
|
|
|
|
2006-01-21 21:16:41 -05:00
|
|
|
# Options
|
|
|
|
CLEANUP=0
|
|
|
|
CLEANCACHE=0
|
|
|
|
DEP_BIN=0
|
|
|
|
DEP_SRC=0
|
|
|
|
DEP_SUDO=0
|
|
|
|
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() {
|
|
|
|
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
|
|
|
|
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() {
|
|
|
|
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
|
|
|
|
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() {
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
|
|
|
|
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() {
|
|
|
|
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
|
|
|
|
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() {
|
|
|
|
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2006-01-21 21:16:41 -05:00
|
|
|
check_option() {
|
|
|
|
local i
|
|
|
|
for i in ${options[@]}; do
|
2006-12-20 20:53:40 -05:00
|
|
|
local uc=$(echo $i | tr [:lower:] [:upper:])
|
|
|
|
local lc=$(echo $i | tr [:upper:] [:lower:])
|
2006-01-21 21:16:41 -05:00
|
|
|
if [ "$uc" = "$1" -o "$lc" = "$1" ]; then
|
|
|
|
echo $1
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
[ "$i" == "$needle" ] && return 0
|
|
|
|
done
|
|
|
|
return 1
|
2006-11-14 02:58:42 -05:00
|
|
|
}
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
checkdeps() {
|
|
|
|
local missdep=""
|
|
|
|
local deplist=""
|
|
|
|
|
2006-01-26 18:48:28 -05:00
|
|
|
[ $# -gt 0 ] || return
|
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
missdep=$(pacman $PACMAN_OPTS -T $*)
|
2005-03-14 20:51:43 -05:00
|
|
|
ret=$?
|
|
|
|
if [ "$ret" != "0" ]; then
|
|
|
|
if [ "$ret" = "127" ]; then
|
|
|
|
msg "Missing Dependencies:"
|
|
|
|
msg ""
|
|
|
|
nl=0
|
|
|
|
for dep in $missdep; do
|
|
|
|
echo -ne "$dep " >&2
|
|
|
|
if [ "$nl" = "1" ]; then
|
|
|
|
nl=0
|
|
|
|
echo -ne "\n" >&2
|
|
|
|
# add this dep to the list
|
2006-12-20 20:53:40 -05:00
|
|
|
depname=$(echo $dep | sed 's|=.*$||' | sed 's|>.*$||' | sed 's|<.*$||')
|
2005-03-14 20:51:43 -05:00
|
|
|
deplist="$deplist $depname"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
nl=1
|
|
|
|
done
|
|
|
|
msg ""
|
|
|
|
else
|
|
|
|
error "pacman returned a fatal error."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo $deplist
|
|
|
|
}
|
|
|
|
|
|
|
|
handledeps() {
|
|
|
|
local missingdeps=0
|
|
|
|
local deplist="$*"
|
|
|
|
local haveperm=0
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ \( "$EUID" = "0" -a "$INFAKEROOT" != "1" \) -o "$DEP_SUDO" = 1 ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
haveperm=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$deplist" != "" -a $haveperm -eq 1 ]; then
|
|
|
|
if [ "$DEP_BIN" = "1" ]; then
|
|
|
|
# install missing deps from binary packages (using pacman -S)
|
|
|
|
msg "Installing missing dependencies..."
|
2006-12-20 20:53:40 -05:00
|
|
|
pacman $PACMAN_OPTS -D $deplist
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$?" = "127" ]; then
|
|
|
|
error "Failed to install missing dependencies."
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-10-20 16:46:35 -04:00
|
|
|
elif [ "$DEP_SUDO" = "1" ]; then
|
|
|
|
# install missing deps from binary packages (using pacman -S and sudo)
|
|
|
|
msg "Installing missing dependencies..."
|
|
|
|
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
|
|
|
|
sudo pacman $PACMAN_OPTS -D $deplist
|
2005-10-20 16:46:35 -04:00
|
|
|
if [ "$?" = "127" ]; then
|
|
|
|
error "Failed to install missing dependencies."
|
|
|
|
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
|
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
|
2006-12-20 20:53:40 -05:00
|
|
|
error "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)
|
|
|
|
msg "Building missing dependencies..."
|
|
|
|
for dep in $deplist; 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
|
2006-11-14 02:58:42 -05:00
|
|
|
error "Could not find \"$dep\" under $SRCROOT"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
success=0
|
|
|
|
for pkgdir in $candidates; do
|
2006-11-14 02:58:42 -05:00
|
|
|
if [ -f $pkgdir/$BUILDSCRIPT ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
cd $pkgdir
|
|
|
|
if [ "$RMDEPS" = "1" ]; then
|
|
|
|
makepkg -i -c -b -r -w $PKGDEST
|
|
|
|
else
|
|
|
|
makepkg -i -c -b -w $PKGDEST
|
|
|
|
fi
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
success=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ "$success" = "0" ]; then
|
|
|
|
error "Failed to build \"$dep\""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
missingdeps=1
|
|
|
|
fi
|
|
|
|
elif [ "$deplist" != "" -a $haveperm -eq 0 ]; then
|
|
|
|
if [ "$DEP_SRC" = "1" -o "$DEP_BIN" = "1" ]; then
|
2005-10-20 16:46:35 -04:00
|
|
|
warning "Cannot auto-install missing dependencies as a normal user without sudo!"
|
|
|
|
plain "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-01-16 23:54:55 -05:00
|
|
|
# fix flyspray bug #5923
|
|
|
|
removedeps() {
|
|
|
|
if [ "$RMDEPS" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" -a \( ! -z "$deplist" -o ! -z "$makedeplist" \) ]; then
|
|
|
|
msg "Removing installed dependencies..."
|
|
|
|
pacman3 $PACMAN_OPTS -R $makedeplist $deplist
|
|
|
|
# fixes bug #6215
|
|
|
|
elif [ "$RMDEPS" = "1" -a "$DEP_SUDO" = "1" -a \( ! -z "$deplist" -o ! -z "$makedeplist" \) ]; then
|
|
|
|
msg "Removing installed dependencies..."
|
|
|
|
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
|
|
|
|
sudo pacman3 $PACMAN_OPTS -R $makedeplist $deplist
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
usage() {
|
|
|
|
echo "makepkg version $myver"
|
2006-02-16 17:57:25 -05:00
|
|
|
echo
|
|
|
|
echo "Usage: $0 [options]"
|
|
|
|
echo
|
|
|
|
echo "Options:"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo " -b, --builddeps Build missing dependencies from source"
|
2005-10-20 16:46:35 -04:00
|
|
|
echo " -B, --noccache Do not use ccache during build"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo " -c, --clean Clean up work files after build"
|
|
|
|
echo " -C, --cleancache Clean up source files from the cache"
|
|
|
|
echo " -d, --nodeps Skip all dependency checks"
|
|
|
|
echo " -e, --noextract Do not extract source files (use existing src/ dir)"
|
|
|
|
echo " -f, --force Overwrite existing package"
|
2006-11-14 02:58:42 -05:00
|
|
|
echo " -g, --geninteg Generate integrity checks for source files"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo " -h, --help This help"
|
|
|
|
echo " -i, --install Install package after successful build"
|
|
|
|
echo " -j <jobs> Set MAKEFLAGS to \"-j<jobs>\" before building"
|
2006-11-14 02:58:42 -05:00
|
|
|
echo " -L, --log Log package build process"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo " -m, --nocolor Disable colorized output messages"
|
|
|
|
echo " -o, --nobuild Download and extract files only"
|
2006-11-14 02:58:42 -05:00
|
|
|
echo " -p <buildscript> Use an alternate build script (instead of '$BUILDSCRIPT')"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo " -r, --rmdeps Remove installed dependencies after a successful build"
|
2006-12-21 12:42:58 -05:00
|
|
|
# fix flyspray feature request #2978
|
|
|
|
echo " -R, --repackage Repackage contents of <startdir>/pkg without building"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo " -s, --syncdeps Install missing dependencies with pacman"
|
2005-10-20 16:46:35 -04:00
|
|
|
echo " -S, --sudosync Install missing dependencies with pacman and sudo"
|
2005-03-14 20:51:43 -05:00
|
|
|
echo
|
2006-02-16 17:57:25 -05:00
|
|
|
echo "These options can be passed to pacman:"
|
|
|
|
echo
|
|
|
|
echo " --noconfirm Do not ask for confirmation when resolving dependencies"
|
|
|
|
echo " --noprogressbar Do not show a progress bar when downloading files"
|
|
|
|
echo
|
2006-12-14 00:23:08 -05:00
|
|
|
echo "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:-$startdir} #default to $startdir if undefined
|
|
|
|
_PKGDEST=${PKGDEST}
|
|
|
|
_SRCDEST=$SRCDEST
|
|
|
|
|
2006-12-21 15:03:41 -05:00
|
|
|
#Source makepkg.conf; fail if it is not found
|
2006-12-14 00:23:08 -05:00
|
|
|
if [ -f /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
|
2006-12-20 20:53:40 -05:00
|
|
|
error "/etc/makepkg.conf not found. cannot continue"
|
|
|
|
exit 1
|
2006-11-14 02:58:42 -05:00
|
|
|
fi
|
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
#Source user-specific makepkg.conf overrides
|
|
|
|
if [ -f ~/.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}
|
|
|
|
SRCDEST=${_SRCDEST:-$SRCDEST}
|
|
|
|
|
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 ;;
|
2005-10-20 16:46:35 -04:00
|
|
|
--sudosync) DEP_SUDO=1 ;;
|
2005-03-14 20:51:43 -05:00
|
|
|
--builddeps) DEP_SRC=1 ;;
|
2006-11-15 12:18:31 -05:00
|
|
|
--noccache) USE_CCACHE=0 ;;
|
2005-03-14 20:51:43 -05:00
|
|
|
--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
|
|
|
-*)
|
2006-12-21 12:42:58 -05:00
|
|
|
while getopts "bBcCdefghij:Lmop:rRsS-" opt; do
|
2006-12-20 20:53:40 -05:00
|
|
|
case $opt in
|
|
|
|
b) DEP_SRC=1 ;;
|
|
|
|
B) USE_CCACHE=0 ;;
|
|
|
|
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 ;;
|
|
|
|
j) export MAKEFLAGS="-j$OPTARG" ;;
|
|
|
|
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 ;;
|
|
|
|
S) DEP_SUDO=1 ;;
|
|
|
|
-)
|
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
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ "$DEP_SUDO" = "1" -a ! "$(type -p sudo)" ]; then
|
2006-11-14 02:58:42 -05:00
|
|
|
error "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
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ -n "$SRCDEST" ]; then
|
|
|
|
msg "Cleaning up source files from the cache."
|
2006-12-21 12:42:58 -05:00
|
|
|
rm -rf "$SRCDEST"/*
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
error "Problem removing files; you may not have correct permissions in $SRCDEST"
|
2006-12-20 20:53:40 -05:00
|
|
|
exit 1
|
2006-12-21 12:42:58 -05:00
|
|
|
else
|
|
|
|
exit 0
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
2006-12-21 12:42:58 -05:00
|
|
|
else
|
|
|
|
error "Source destination must be defined in makepkg.conf."
|
|
|
|
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-12-09 13:49:34 -05:00
|
|
|
# some applications (eg, blackbox) will not build with some languages
|
|
|
|
unset LC_ALL LANG
|
2005-03-14 20:51:43 -05:00
|
|
|
umask 0022
|
|
|
|
|
|
|
|
if [ ! -f $BUILDSCRIPT ]; then
|
|
|
|
error "$BUILDSCRIPT does not exist."
|
|
|
|
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
|
|
|
|
|
|
|
|
# check for no-no's
|
2006-11-14 02:58:42 -05:00
|
|
|
if [ -z "$pkgver" ]; then
|
|
|
|
error "pkgver is not allowed to be empty."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$pkgrel" ]; then
|
|
|
|
error "pkgrel is not allowed to be empty."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ $(echo $pkgver | grep '-') ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
error "pkgver is not allowed to contain hyphens."
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-11-14 02:58:42 -05:00
|
|
|
if [ $(echo $pkgrel | grep '-') ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
error "pkgrel is not allowed to contain hyphens."
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-12-21 15:50:24 -05:00
|
|
|
if ! in_array $CARCH ${arch[@]}; then
|
2006-11-14 02:58:42 -05:00
|
|
|
error "$pkgname is not available for the '$CARCH' architecture."
|
2006-12-20 20:53:40 -05:00
|
|
|
plain "Note that many packages may need a line added to their $BUILDSCRIPT"
|
|
|
|
plain "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
|
|
|
|
error "install scriptlet ($install) does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-11-14 02:58:42 -05:00
|
|
|
if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT} -a "$FORCE" = "0" -a "$GENINTEG" = "0" ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$INSTALL" = "1" ]; then
|
|
|
|
warning "a package has already been built, installing existing package."
|
2006-11-14 02:58:42 -05:00
|
|
|
echo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
|
|
|
|
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
|
2005-03-14 20:51:43 -05:00
|
|
|
exit $?
|
|
|
|
else
|
|
|
|
error "a package has already been built. (use -f to overwrite)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 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
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$USE_FAKEROOT" = "y" -o "$USE_FAKEROOT" = "Y" ]; then
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ $(type -p fakeroot) ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
msg "Entering fakeroot environment"
|
|
|
|
fakeroot -- $0 -F $ARGLIST
|
|
|
|
exit $?
|
|
|
|
else
|
|
|
|
warning "Fakeroot is not installed. Building as an unprivileged user"
|
|
|
|
plain "will result in non-root ownership of the packaged files."
|
|
|
|
plain "Install the fakeroot package to correctly build as a non-root"
|
|
|
|
plain "user."
|
|
|
|
plain ""
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
warning "Running makepkg as an unprivileged user will result in non-root"
|
|
|
|
plain "ownership of the packaged files. Try using the fakeroot"
|
|
|
|
plain "environment. (USE_FAKEROOT=y in makepkg.conf)"
|
|
|
|
plain ""
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
msg "Making package: $pkgname $pkgver-$pkgrel ($(date))"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
unset deplist makedeplist
|
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-17 00:29:54 -05:00
|
|
|
warning "skipping dependency checks"
|
2006-12-21 14:11:22 -05:00
|
|
|
elif [ $(type -p pacman) ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
msg "Checking Runtime Dependencies..."
|
2006-12-20 20:53:40 -05:00
|
|
|
deplist=$(checkdeps ${depends[@]})
|
2005-03-14 20:51:43 -05:00
|
|
|
handledeps $deplist
|
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-02-17 16:07:50 -05:00
|
|
|
# check deps again to make sure they were resolved
|
2006-12-20 20:53:40 -05:00
|
|
|
deplist=$(checkdeps ${depends[@]})
|
2006-02-17 16:07:50 -05:00
|
|
|
if [ ! -z "$deplist" ]; then
|
|
|
|
error "Failed to install missing dependencies."
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
msg "Checking Buildtime Dependencies..."
|
2006-12-20 20:53:40 -05:00
|
|
|
makedeplist=$(checkdeps ${makedepends[@]})
|
2005-03-14 20:51:43 -05:00
|
|
|
handledeps $makedeplist
|
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
warning "pacman was not found in PATH. skipping dependency checks."
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $startdir
|
|
|
|
|
|
|
|
# retrieve sources
|
|
|
|
msg "Retrieving Sources..."
|
|
|
|
mkdir -p src
|
|
|
|
cd $startdir/src
|
|
|
|
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
|
2006-12-21 12:42:58 -05:00
|
|
|
msg2 "Found $file in build dir"
|
2006-12-14 00:23:08 -05:00
|
|
|
cp "../$file" .
|
|
|
|
elif [ -f "$SRCDEST/$file" ]; then
|
2006-12-21 12:42:58 -05:00
|
|
|
msg2 "Using cached copy of $file"
|
|
|
|
cp "$SRCDEST/$file" .
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
|
|
|
# check for a download utility
|
|
|
|
if [ -z "$FTPAGENT" ]; then
|
|
|
|
error "FTPAGENT is not configured. Check the /etc/makepkg.conf file."
|
|
|
|
msg "Aborting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-12-20 20:53:40 -05:00
|
|
|
ftpclient=$(echo $FTPAGENT | awk {'print $1'})
|
2006-12-14 00:23:08 -05:00
|
|
|
if [ ! -x "$ftpclient" ]; then
|
2006-12-20 20:53:40 -05:00
|
|
|
error "ftpclient $(basename $ftpclient) is not installed."
|
2005-03-14 20:51:43 -05:00
|
|
|
msg "Aborting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-12-14 00:23:08 -05:00
|
|
|
proto=$(echo "$netfile" | sed 's|://.*||')
|
2005-03-14 20:51:43 -05:00
|
|
|
if [ "$proto" != "ftp" -a "$proto" != "http" -a "$proto" != "https" ]; then
|
|
|
|
error "$netfile was not found in the build directory and is not a proper URL."
|
|
|
|
msg "Aborting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-12-21 12:42:58 -05:00
|
|
|
msg2 "Downloading $file"
|
2006-12-14 00:23:08 -05:00
|
|
|
$FTPAGENT "$netfile" 2>&1
|
2006-12-20 20:53:40 -05:00
|
|
|
# fix flyspray bug #3289
|
|
|
|
ftpret=$?
|
|
|
|
if [ $ftpret -gt 0 ]; then
|
|
|
|
error "Failure while downloading $file"
|
|
|
|
msg "Aborting..."
|
2006-12-21 12:42:58 -05:00
|
|
|
#rm "$file"
|
2005-03-14 20:51:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2006-12-21 12:42:58 -05:00
|
|
|
if [ -n "$SRCDEST" ]; then
|
|
|
|
mkdir -p $SRCDEST && cp "$file" $SRCDEST
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
warning "You do not have correct permissions to cache source in $SRCDEST"
|
2006-12-20 20:53:40 -05:00
|
|
|
cp "$file" ..
|
|
|
|
fi
|
2006-12-21 12:42:58 -05:00
|
|
|
else
|
|
|
|
cp "$file" ..
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2006-12-21 14:11:22 -05:00
|
|
|
if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
|
2006-12-20 20:53:40 -05:00
|
|
|
warning "Skipping source integrity checks -- using existing src/ tree"
|
|
|
|
else
|
|
|
|
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" ;;
|
|
|
|
*) error "Invalid integrity algorithm '$integ' specified"; exit 1;;
|
|
|
|
esac
|
|
|
|
if [ ! $(type -p $integrity_name) ]; then
|
|
|
|
error "Cannot find the $integrity_name program."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Generate integrity checks
|
|
|
|
if [ "$GENINTEG" = "1" ]; then
|
|
|
|
msg "Generating ${integrity_name}s for source files"
|
|
|
|
plain ""
|
|
|
|
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
|
|
|
|
echo -ne "\t "
|
|
|
|
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
|
|
|
|
plain ""
|
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
|
|
|
|
msg "Validating source files with ${integrity_name}s"
|
|
|
|
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
|
|
|
|
echo "FAILED" >&2
|
|
|
|
errors=1
|
|
|
|
else
|
|
|
|
echo "Passed" >&2
|
|
|
|
fi
|
|
|
|
idx=$(($idx+1))
|
|
|
|
done
|
|
|
|
if [ $errors -gt 0 ]; then
|
|
|
|
error "One or more files did not pass the validity check!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
warning "Integrity checks ($integ) are missing or incomplete."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$GENINTEG" = "1" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Extract sources
|
2006-12-21 12:42:58 -05:00
|
|
|
if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
|
|
|
|
warning "Skipping source extraction -- using existing src/ tree"
|
2005-03-14 20:51:43 -05:00
|
|
|
else
|
2006-12-20 20:53:40 -05:00
|
|
|
msg "Extracting Sources..."
|
|
|
|
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
|
|
|
|
*application/x-tar*)
|
2006-12-20 20:53:40 -05:00
|
|
|
cmd="tar -xf $file" ;;
|
2007-01-22 03:45:12 -05:00
|
|
|
*application/x-zip*)
|
2006-12-20 20:53:40 -05:00
|
|
|
unziphack=1
|
|
|
|
cmd="unzip -qqo $file" ;;
|
2007-01-22 03:45:12 -05:00
|
|
|
*application/x-cpio*)
|
2006-12-20 20:53:40 -05:00
|
|
|
cmd="bsdtar -x -f $file" ;;
|
2007-01-22 03:45:12 -05:00
|
|
|
*application/x-gzip*)
|
2006-12-20 20:53:40 -05:00
|
|
|
cmd="gunzip -f $file" ;;
|
2007-01-22 03:45:12 -05:00
|
|
|
*application/x-bzip*)
|
2006-12-20 20:53:40 -05:00
|
|
|
cmd="bunzip2 -f $file" ;;
|
|
|
|
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
|
|
|
|
error "Failed to extract $file"
|
|
|
|
msg "Aborting..."
|
|
|
|
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
|
|
|
|
chown -R root.root $startdir/src
|
|
|
|
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
|
|
|
|
msg "Sources are ready."
|
|
|
|
exit 0
|
|
|
|
elif [ "$REPKG" = "1" ]; then
|
|
|
|
warning "Skipping build"
|
|
|
|
else
|
2006-12-21 12:42:58 -05:00
|
|
|
# check for existing pkg directory
|
|
|
|
if [ -d $startdir/pkg ]; then
|
|
|
|
msg "Removing existing pkg/ directory..."
|
|
|
|
rm -rf $startdir/pkg
|
|
|
|
fi
|
|
|
|
mkdir -p $startdir/pkg
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
# use distcc if requested
|
|
|
|
if [ "$USE_DISTCC" = "y" ]; then
|
|
|
|
[ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
|
|
|
|
fi
|
2005-12-13 21:40:01 -05:00
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
# use ccache if it's available
|
|
|
|
if [ "$USE_CCACHE" = "1" ]; then
|
|
|
|
[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
# build
|
|
|
|
msg "Starting build()..."
|
2006-11-16 17:43:58 -05:00
|
|
|
|
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
|
|
|
|
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
|
|
|
|
build 2>&1 | tee "$BUILDLOG"
|
|
|
|
[ $set_e -eq 1 ] && set +e
|
2006-12-20 20:53:40 -05:00
|
|
|
|
2006-12-21 12:42:58 -05:00
|
|
|
if [ ${PIPESTATUS[0]} -gt 0 ]; then
|
|
|
|
error "Build Failed. Aborting..."
|
2007-01-16 23:54:55 -05:00
|
|
|
removedeps
|
2006-12-21 12:42:58 -05:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
#use 'errexit' to bail on syntax error
|
|
|
|
[ $set_e -eq 1 ] && set -e
|
|
|
|
build 2>&1
|
|
|
|
[ $set_e -eq 1 ] && set +e
|
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
error "Build Failed. Aborting..."
|
2007-01-16 23:54:55 -05:00
|
|
|
removedeps
|
2006-12-21 12:42:58 -05:00
|
|
|
exit 2
|
|
|
|
fi
|
2006-12-20 20:53:40 -05:00
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ ! "$(check_option KEEPDOCS)" -a "$KEEPDOCS" = "0" ]; then
|
2006-01-21 21:16:41 -05:00
|
|
|
# remove info/doc files
|
|
|
|
msg "Removing info/doc files..."
|
2006-12-21 12:42:58 -05:00
|
|
|
cd $startdir/pkg
|
|
|
|
#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
|
|
|
|
if [ -d pkg/usr/share/man ]; then
|
|
|
|
mkdir -p pkg/usr/man
|
|
|
|
cp -a pkg/usr/share/man/* pkg/usr/man/
|
|
|
|
rm -rf pkg/usr/share/man
|
|
|
|
fi
|
|
|
|
|
|
|
|
# compress man pages
|
|
|
|
msg "Compressing man pages..."
|
2006-12-14 00:23:08 -05: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
|
|
|
|
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
|
|
|
|
|
|
|
|
cd $startdir
|
|
|
|
|
|
|
|
# strip binaries
|
2006-12-21 14:11:22 -05:00
|
|
|
if [ ! "$(check_option NOSTRIP)" -a "$NOSTRIP" = "0" ]; then
|
2005-03-14 20:51:43 -05:00
|
|
|
msg "Stripping debugging symbols from libraries..."
|
|
|
|
find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
|
2006-12-20 20:53:40 -05:00
|
|
|
-exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \
|
|
|
|
| grep -v "No such file" | grep -v "format not recognized"
|
2005-03-14 20:51:43 -05:00
|
|
|
msg "Stripping symbols from binaries..."
|
|
|
|
find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -not -name "*.dll" -not -name "*.exe" \
|
2006-12-20 20:53:40 -05:00
|
|
|
-exec /usr/bin/strip '{}' \; 2>&1 \
|
|
|
|
| grep -v "No such file" | grep -v "format not recognized"
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
2006-02-16 17:57:25 -05:00
|
|
|
# remove libtool (.la) files
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ "$(check_option NOLIBTOOL)" -a "$NOLIBTOOL" = "1" ]; then
|
2006-02-16 17:57:25 -05:00
|
|
|
msg "Removing libtool .la files..."
|
|
|
|
find pkg -type f -name "*.la" -exec rm -f -- '{}' \;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# remove empty directories
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ "$(check_option NOEMPTYDIRS)" -a "$NOEMPTYDIRS" = 1 ]; then
|
2006-02-16 17:57:25 -05:00
|
|
|
msg "Removing empty directories..."
|
2006-11-16 17:43:58 -05:00
|
|
|
find pkg -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
|
2006-12-20 20:53:40 -05:00
|
|
|
size=$(du -cb $startdir/pkg | tail -n 1 | awk '{print $1}')
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
# write the .PKGINFO file
|
|
|
|
msg "Generating .PKGINFO file..."
|
|
|
|
cd $startdir/pkg
|
|
|
|
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
|
|
|
|
|
|
|
|
# check for an install script
|
|
|
|
if [ "$install" != "" ]; then
|
|
|
|
msg "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-01-22 14:26:23 -05:00
|
|
|
msg "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
|
|
|
|
|
|
|
|
# build a filelist
|
|
|
|
msg "Generating .FILELIST file..."
|
2007-01-22 04:57:20 -05:00
|
|
|
cd "$startdir/pkg"
|
2005-03-14 20:51:43 -05:00
|
|
|
tar cvf /dev/null * | sort >.FILELIST
|
|
|
|
|
|
|
|
# tar it up
|
|
|
|
msg "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}"
|
|
|
|
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
|
|
|
|
error "Failed to create package file."
|
|
|
|
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
|
|
|
|
msg "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
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
msg "Finished making: $pkgname ($(date))"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
if [ "$INSTALL" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
|
2006-02-16 17:57:25 -05:00
|
|
|
msg "Installing package with pacman -U..."
|
2006-11-14 02:58:42 -05:00
|
|
|
pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
|
2005-03-14 20:51:43 -05:00
|
|
|
exit $?
|
2006-01-27 21:24:25 -05:00
|
|
|
elif [ "$INSTALL" = "1" -a "$DEP_SUDO" = "1" ]; then
|
2006-02-16 17:57:25 -05:00
|
|
|
msg "Installing package with pacman -U..."
|
2006-01-27 21:24:25 -05:00
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
FAKEROOTKEY2=$FAKEROOTKEY
|
|
|
|
unset FAKEROOTKEY
|
|
|
|
fi
|
2006-11-14 02:58:42 -05:00
|
|
|
sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
|
2006-01-27 21:24:25 -05:00
|
|
|
if [ "$INFAKEROOT" = "1" ]; then
|
|
|
|
export FAKEROOTKEY=$FAKEROOTKEY2
|
|
|
|
unset FAKEROOTKEY2
|
|
|
|
fi
|
2005-03-14 20:51:43 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|
2006-12-20 20:53:40 -05:00
|
|
|
# vim: set ts=2 sw=2 noet:
|
|
|
|
|