pacman/scripts/makepkg

679 lines
16 KiB
Text
Raw Normal View History

2002-08-09 18:03:48 +00:00
#!/bin/bash
2003-09-03 02:09:29 +00:00
#
# makepkg
#
2004-04-15 05:05:54 +00:00
# Copyright (c) 2002-2004 by Judd Vinet <jvinet@zeroflux.org>
2003-09-03 02:09:29 +00: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.
#
# 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.
#
# 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.
#
2004-04-30 03:37:13 +00:00
myver='2.7.9'
2002-08-09 18:03:48 +00:00
startdir=`pwd`
2004-04-29 19:43:18 +00:00
PKGDEST=$startdir
2003-12-21 01:34:32 +00:00
USE_COLOR="n"
2002-08-09 18:03:48 +00:00
2003-09-15 04:58:02 +00:00
# source Arch's abs.conf if it's present
[ -f /etc/abs/abs.conf ] && source /etc/abs/abs.conf
2003-09-03 02:09:29 +00:00
2003-09-15 04:58:02 +00:00
# makepkg configuration
2002-08-09 18:03:48 +00:00
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf
2003-09-03 02:09:29 +00:00
INFAKEROOT=
if [ "$1" = "-F" ]; then
INFAKEROOT=1
shift
fi
2003-09-15 04:58:02 +00:00
### SUBROUTINES ###
2003-09-03 02:09:29 +00:00
2003-12-21 01:34:32 +00:00
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
}
2003-09-15 04:58:02 +00:00
msg() {
2003-12-21 01:34:32 +00:00
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
}
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
}
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
2003-09-15 04:58:02 +00:00
}
2003-09-03 02:09:29 +00:00
2002-08-09 18:03:48 +00:00
strip_url() {
2003-05-30 19:56:46 +00:00
echo $1 | sed 's|^.*://.*/||g'
2002-08-09 18:03:48 +00:00
}
2003-02-27 08:26:02 +00:00
checkdeps() {
2003-11-25 02:02:36 +00:00
local missdep=""
2003-02-27 08:26:02 +00:00
local deplist=""
missdep=`pacman -T $*`
2003-05-30 19:56:46 +00:00
ret=$?
if [ "$ret" != "0" ]; then
if [ "$ret" = "127" ]; then
2003-12-21 01:34:32 +00:00
msg "Missing Dependencies:"
2003-05-30 19:56:46 +00:00
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
depname=`echo $dep | sed 's|=.*$||' | sed 's|>.*$||' | sed 's|<.*$||'`
deplist="$deplist $depname"
continue
fi
nl=1
done
msg ""
else
2003-12-21 01:34:32 +00:00
error "pacman returned a fatal error."
2003-05-30 19:56:46 +00:00
exit 1
fi
fi
2003-02-27 08:26:02 +00:00
echo $deplist
}
2003-11-25 02:02:36 +00:00
handledeps() {
local missingdeps=0
local deplist="$*"
local haveperm=0
if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
haveperm=1
fi
if [ "$deplist" != "" -a $haveperm -eq 1 ]; then
if [ "$DEP_BIN" = "1" ]; then
# install missing deps from binary packages (using pacman -S)
2003-12-21 01:34:32 +00:00
msg "Installing missing dependencies..."
2003-11-25 02:02:36 +00:00
pacman -D $deplist
if [ "$?" = "127" ]; then
2003-12-21 01:34:32 +00:00
error "Failed to install missing dependencies."
2003-11-25 02:02:36 +00:00
exit 1
fi
# TODO: check deps again to make sure they were resolved
elif [ "$DEP_SRC" = "1" ]; then
# install missing deps by building them from source.
# we look for each package name in $ABSROOT and build it.
if [ "$ABSROOT" = "" ]; then
2003-12-21 01:34:32 +00:00
error "The ABSROOT environment variable is not defined."
2003-11-25 02:02:36 +00:00
exit 1
fi
# TODO: handle version comparators (eg, glibc>=2.2.5)
2003-12-21 01:34:32 +00:00
msg "Building missing dependencies..."
2003-11-25 02:02:36 +00:00
for dep in $deplist; do
candidates=`find $ABSROOT -type d -name "$dep"`
if [ "$candidates" = "" ]; then
2003-12-21 01:34:32 +00:00
error "Could not find \"$dep\" under $ABSROOT"
2003-11-25 02:02:36 +00:00
exit 1
fi
success=0
for pkgdir in $candidates; do
if [ -f $pkgdir/PKGBUILD ]; then
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
2003-12-21 01:34:32 +00:00
error "Failed to build \"$dep\""
2003-11-25 02:02:36 +00:00
exit 1
fi
done
# TODO: check deps again to make sure they were resolved
else
missingdeps=1
fi
elif [ "$deplist" != "" -a $haveperm -eq 0 ]; then
if [ "$DEP_SRC" = "1" -o "$DEP_BIN" = "1" ]; then
2003-12-21 01:34:32 +00:00
warning "Cannot auto-install missing dependencies as a normal user!"
plain "Run makepkg as root to resolve dependencies automatically."
2003-11-25 02:02:36 +00:00
fi
missingdeps=1
fi
return $missingdeps
}
2003-02-27 08:26:02 +00:00
2003-04-11 16:58:50 +00:00
usage() {
2003-05-30 19:56:46 +00:00
echo "makepkg version $myver"
echo "usage: $0 [options]"
echo "options:"
2003-09-03 02:09:29 +00:00
echo " -b, --builddeps Build missing dependencies from source"
2003-05-30 19:56:46 +00: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"
2004-01-04 17:53:32 +00:00
echo " -e, --noextract Do not extract source files (use existing src/ dir)"
2003-05-30 19:56:46 +00:00
echo " -f, --force Overwrite existing package"
2003-09-03 02:09:29 +00:00
echo " -g, --genmd5 Generate MD5sums for source files"
2003-05-30 19:56:46 +00:00
echo " -h, --help This help"
2003-09-03 02:09:29 +00:00
echo " -i, --install Install package after successful build"
2003-12-21 01:34:32 +00:00
echo " -m, --nocolor Disable colorized output messages"
2003-09-03 02:09:29 +00:00
echo " -n, --nostrip Do not strip binaries/libraries"
echo " -p <buildscript> Use an alternate build script (instead of PKGBUILD)"
2003-11-25 02:02:36 +00:00
echo " -r, --rmdeps Remove installed dependencies after a successful build"
2003-09-03 02:09:29 +00:00
echo " -s, --syncdeps Install missing dependencies with pacman"
echo " -w <destdir> Write package to <destdir> instead of the working dir"
2003-05-30 19:56:46 +00:00
echo
echo " if -p is not specified, makepkg will look for a PKGBUILD"
echo " file in the current directory."
echo
2003-04-11 16:58:50 +00:00
}
2002-08-09 18:03:48 +00:00
2003-11-25 02:02:36 +00:00
2003-02-27 08:26:02 +00:00
# Options
2002-08-09 18:03:48 +00:00
CLEANUP=0
2003-03-17 19:36:48 +00:00
CLEANCACHE=0
2002-08-09 18:03:48 +00:00
INSTALL=0
2003-09-03 02:09:29 +00:00
GENMD5=0
2003-02-27 08:26:02 +00:00
DEP_BIN=0
DEP_SRC=0
NODEPS=0
FORCE=0
2004-01-04 17:53:32 +00:00
NOEXTRACT=0
2003-09-03 02:09:29 +00:00
NOSTRIP=0
2003-11-25 02:02:36 +00:00
RMDEPS=0
2002-09-16 05:22:13 +00:00
BUILDSCRIPT="./PKGBUILD"
2002-08-09 18:03:48 +00:00
2003-09-15 04:58:02 +00:00
ARGLIST=$@
2003-04-11 16:58:50 +00:00
while [ "$#" -ne "0" ]; do
2003-05-30 19:56:46 +00:00
case $1 in
2003-11-25 02:02:36 +00:00
--clean) CLEANUP=1 ;;
2003-05-30 19:56:46 +00:00
--cleancache) CLEANCACHE=1 ;;
2003-11-25 02:02:36 +00:00
--syncdeps) DEP_BIN=1 ;;
--builddeps) DEP_SRC=1 ;;
--nodeps) NODEPS=1 ;;
2004-01-04 17:53:32 +00:00
--noextract) NOEXTRACT=1 ;;
2003-11-25 02:02:36 +00:00
--install) INSTALL=1 ;;
--force) FORCE=1 ;;
--nostrip) NOSTRIP=1 ;;
2003-12-21 01:34:32 +00:00
--nocolor) USE_COLOR="n" ;;
2003-11-25 02:02:36 +00:00
--genmd5) GENMD5=1 ;;
--rmdeps) RMDEPS=1 ;;
2003-09-03 02:09:29 +00:00
--help)
usage
exit 0
;;
2003-05-30 19:56:46 +00:00
--*)
usage
exit 1
;;
-*)
2004-01-04 17:53:32 +00:00
while getopts "cCsbdehifgmnrp:w:-" opt; do
2003-05-30 19:56:46 +00:00
case $opt in
c) CLEANUP=1 ;;
C) CLEANCACHE=1 ;;
s) DEP_BIN=1 ;;
b) DEP_SRC=1 ;;
d) NODEPS=1 ;;
2004-01-04 17:53:32 +00:00
e) NOEXTRACT=1 ;;
2003-05-30 19:56:46 +00:00
i) INSTALL=1 ;;
2003-09-03 02:09:29 +00:00
g) GENMD5=1 ;;
2003-05-30 19:56:46 +00:00
f) FORCE=1 ;;
2003-12-21 01:34:32 +00:00
m) USE_COLOR="n" ;;
2003-09-03 02:09:29 +00:00
n) NOSTRIP=1 ;;
2003-05-30 19:56:46 +00:00
w) PKGDEST=$OPTARG ;;
p) BUILDSCRIPT=$OPTARG ;;
2003-11-25 02:02:36 +00:00
r) RMDEPS=1 ;;
2003-09-03 02:09:29 +00:00
h)
usage
exit 0
;;
2003-05-30 19:56:46 +00:00
-)
OPTIND=0
break
;;
*)
usage
exit 1
;;
esac
done
;;
*)
true
;;
esac
shift
2002-09-16 05:22:13 +00:00
done
2002-08-09 18:03:48 +00:00
2003-11-25 02:02:36 +00:00
# convert a (possibly) relative path to absolute
2004-04-29 19:43:18 +00:00
cd $PKGDEST 2>/dev/null
if [ $? -ne 0 ]; then
error "Package destination directory does not exist or permission denied."
exit 1
fi
2003-11-25 02:02:36 +00:00
PKGDEST=`pwd`
cd -
2003-03-17 19:36:48 +00:00
if [ "$CLEANCACHE" = "1" ]; then
2003-09-03 02:09:29 +00:00
if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
2003-12-21 01:34:32 +00:00
msg "Cleaning up source files from the cache."
2003-09-03 02:09:29 +00:00
rm -rf /var/cache/pacman/src/*
exit 0
else
2003-12-21 01:34:32 +00:00
error "You must be root to clean the cache."
2003-09-03 02:09:29 +00:00
exit 1
fi
2003-03-17 19:36:48 +00:00
fi
2004-04-30 03:37:13 +00:00
unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums force
2003-11-25 02:02:36 +00:00
unset replaces depends conflicts backup source install build makedepends
2002-08-09 18:03:48 +00:00
umask 0022
if [ ! -f $BUILDSCRIPT ]; then
2003-12-21 01:34:32 +00:00
error "$BUILDSCRIPT does not exist."
2003-05-30 19:56:46 +00:00
exit 1
2002-08-09 18:03:48 +00:00
fi
source $BUILDSCRIPT
# check for no-no's
if [ `echo $pkgver | grep '-'` ]; then
2003-12-21 01:34:32 +00:00
error "pkgver is not allowed to contain hyphens."
2003-05-30 19:56:46 +00:00
exit 1
2002-08-09 18:03:48 +00:00
fi
if [ `echo $pkgrel | grep '-'` ]; then
2003-12-21 01:34:32 +00:00
error "pkgrel is not allowed to contain hyphens."
2003-05-30 19:56:46 +00:00
exit 1
2002-08-09 18:03:48 +00:00
fi
2003-09-03 02:09:29 +00:00
if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz -a "$FORCE" = "0" -a "$GENMD5" = "0" ]; then
2003-09-15 04:58:02 +00:00
if [ "$INSTALL" = "1" ]; then
2003-12-21 01:34:32 +00:00
warning "a package has already been built, installing existing package."
2003-09-15 04:58:02 +00:00
pacman --upgrade $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz
exit $?
else
2003-12-21 01:34:32 +00:00
error "a package has already been built. (use -f to overwrite)"
2003-09-15 04:58:02 +00:00
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
if [ "`id -u`" != "0" ]; then
if [ "$USE_FAKEROOT" = "y" -o "$USE_FAKEROOT" = "Y" ]; then
if [ `type -p fakeroot` ]; then
2003-12-21 01:34:32 +00:00
msg "Entering fakeroot environment"
2003-09-15 04:58:02 +00:00
fakeroot -- $0 -F $ARGLIST
exit $?
else
2003-12-21 01:34:32 +00:00
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 ""
2003-09-15 04:58:02 +00:00
sleep 1
fi
else
2003-12-21 01:34:32 +00:00
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 ""
2003-09-15 04:58:02 +00:00
sleep 1
fi
2003-02-27 08:26:02 +00:00
fi
2003-12-21 01:34:32 +00:00
msg "Making package: $pkgname (`date`)"
2003-09-03 02:09:29 +00:00
2003-11-25 02:02:36 +00:00
unset deplist makedeplist
2003-02-27 08:26:02 +00:00
if [ `type -p pacman` -a "$NODEPS" = "0" ]; then
2003-12-21 01:34:32 +00:00
msg "Checking Runtime Dependencies..."
2003-02-27 08:26:02 +00:00
deplist=`checkdeps ${depends[@]}`
2003-11-25 02:02:36 +00:00
handledeps $deplist
if [ $? -gt 0 ]; then
exit 1
fi
2003-12-21 01:34:32 +00:00
msg "Checking Buildtime Dependencies..."
2003-11-25 02:02:36 +00:00
makedeplist=`checkdeps ${makedepends[@]}`
handledeps $makedeplist
if [ $? -gt 0 ]; then
exit 1
2003-05-30 19:56:46 +00:00
fi
2003-02-27 08:26:02 +00:00
elif [ "$NODEPS" = "1" ]; then
2003-12-21 01:34:32 +00:00
warning "skipping dependency checks."
2002-08-09 18:03:48 +00:00
else
2003-12-21 01:34:32 +00:00
warning "pacman was not found in PATH. skipping dependency checks."
2002-08-09 18:03:48 +00:00
fi
2003-02-27 08:26:02 +00:00
cd $startdir
2002-08-09 18:03:48 +00:00
2003-09-15 04:58:02 +00:00
# retrieve sources
2003-12-21 01:34:32 +00:00
msg "Retrieving Sources..."
2002-08-09 18:03:48 +00:00
mkdir -p src
cd $startdir/src
for netfile in ${source[@]}; do
2003-05-30 19:56:46 +00:00
file=`strip_url $netfile`
if [ -f ../$file ]; then
2003-12-21 01:34:32 +00:00
msg " Found $file in build dir"
2003-05-30 19:56:46 +00:00
cp ../$file .
elif [ -f /var/cache/pacman/src/$file ]; then
2003-12-21 01:34:32 +00:00
msg " Using local copy of $file"
2003-05-30 19:56:46 +00:00
cp /var/cache/pacman/src/$file .
else
# check for a download utility
if [ -z "$FTPAGENT" ]; then
2003-12-21 01:34:32 +00:00
error "FTPAGENT is not configured. Check the /etc/makepkg.conf file."
msg "Aborting..."
2003-05-30 19:56:46 +00:00
exit 1
fi
ftpclient=`echo $FTPAGENT | awk {'print $1'}`
if [ ! -x $ftpclient ]; then
2003-12-21 01:34:32 +00:00
error "ftpclient `basename $ftpclient` is not installed."
msg "Aborting..."
2003-05-30 19:56:46 +00:00
exit 1
fi
proto=`echo $netfile | sed 's|://.*||'`
if [ "$proto" != "ftp" -a "$proto" != "http" ]; then
2003-12-21 01:34:32 +00:00
error "$netfile was not found in the build directory and is not a proper URL."
msg "Aborting..."
2003-05-30 19:56:46 +00:00
exit 1
fi
2003-12-21 01:34:32 +00:00
msg " Downloading $file"
2003-05-30 19:56:46 +00:00
$FTPAGENT $netfile 2>&1
if [ ! -f $file ]; then
2003-12-21 01:34:32 +00:00
error "Failed to download $file"
msg "Aborting..."
2003-05-30 19:56:46 +00:00
exit 1
fi
2003-09-03 02:09:29 +00:00
if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
mkdir -p /var/cache/pacman/src && cp $file /var/cache/pacman/src
else
cp $file ..
fi
2003-05-30 19:56:46 +00:00
fi
2003-09-15 04:58:02 +00:00
done
if [ "$GENMD5" = "0" ]; then
2004-01-04 17:53:32 +00:00
if [ "$NOEXTRACT" = "1" ]; then
warning "Skipping source extraction -- using existing src/ tree"
else
# MD5 validation
if [ ${#md5sums[@]} -ne ${#source[@]} ]; then
warning "MD5sums are missing or incomplete. Cannot verify source integrity."
#sleep 1
elif [ `type -p md5sum` ]; then
msg "Validating source files with MD5sums"
errors=0
idx=0
for netfile in ${source[@]}; do
file=`strip_url $netfile`
echo -n " $file ... " >&2
echo "${md5sums[$idx]} $file" | md5sum -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 "The md5sum program is missing. Cannot verify source files!"
sleep 1
fi
# extract sources
msg "Extracting Sources..."
2003-09-15 04:58:02 +00:00
for netfile in ${source[@]}; do
file=`strip_url $netfile`
unset cmd
case $file in
*.tar.gz|*.tar.Z|*.tgz)
2004-01-04 17:53:32 +00:00
cmd="tar --use-compress-program=gzip -xf $file" ;;
2003-09-15 04:58:02 +00:00
*.tar.bz2)
2004-01-04 17:53:32 +00:00
cmd="tar --use-compress-program=bzip2 -xf $file" ;;
2003-09-15 04:58:02 +00:00
*.tar)
2004-01-04 17:53:32 +00:00
cmd="tar -xf $file" ;;
2003-09-15 04:58:02 +00:00
*.zip)
2004-01-04 17:53:32 +00:00
cmd="unzip -qqo $file" ;;
2003-09-15 04:58:02 +00:00
*.gz)
2004-01-04 17:53:32 +00:00
cmd="gunzip $file" ;;
2003-09-15 04:58:02 +00:00
*.bz2)
2004-01-04 17:53:32 +00:00
cmd="bunzip2 $file" ;;
2003-09-15 04:58:02 +00:00
esac
if [ "$cmd" != "" ]; then
2003-12-21 01:34:32 +00:00
msg " $cmd"
2003-09-15 04:58:02 +00:00
$cmd
if [ $? -ne 0 ]; then
2003-12-21 01:34:32 +00:00
error "Failed to extract $file"
msg "Aborting..."
2003-09-15 04:58:02 +00:00
exit 1
fi
fi
2004-01-04 17:53:32 +00:00
done
fi
2003-09-15 04:58:02 +00:00
else
# generate md5 hashes
2003-09-03 02:09:29 +00:00
if [ ! `type -p md5sum` ]; then
2003-12-21 01:34:32 +00:00
error "Cannot find the md5sum program."
2003-09-03 02:09:29 +00:00
exit 1
fi
2003-12-21 01:34:32 +00:00
msg "Generating MD5sums for source files"
plain ""
2003-09-03 02:09:29 +00:00
ct=0
2003-12-21 01:34:32 +00:00
newline=0
2003-09-03 02:09:29 +00:00
numsrc=${#source[@]}
for netfile in ${source[@]}; do
file=`strip_url $netfile`
sum=`md5sum $file | cut -d' ' -f 1`
if [ $ct -eq 0 ]; then
echo -n "md5sums=("
else
2003-12-21 01:34:32 +00:00
if [ $newline -eq 0 ]; then
echo -n " "
fi
2003-09-03 02:09:29 +00:00
fi
echo -n "'$sum'"
ct=$(($ct+1))
if [ $ct -eq $numsrc ]; then
echo ')'
else
2003-12-21 01:34:32 +00:00
if [ $newline -eq 1 ]; then
echo '\'
newline=0
else
echo -n ' '
newline=1
fi
2003-09-03 02:09:29 +00:00
fi
done
2003-12-21 01:34:32 +00:00
plain ""
2003-09-03 02:09:29 +00:00
exit 0
fi
if [ "`id -u`" = "0" ]; then
# chown all source files to root.root
chown -R root.root $startdir/src
fi
2002-08-09 18:03:48 +00:00
# check for existing pkg directory
if [ -d $startdir/pkg ]; then
2004-01-04 17:53:32 +00:00
msg "Removing existing pkg/ directory..."
2003-05-30 19:56:46 +00:00
rm -rf $startdir/pkg
2002-08-09 18:03:48 +00:00
fi
mkdir -p $startdir/pkg
# build
2003-12-21 01:34:32 +00:00
msg "Starting build()..."
2002-08-09 18:03:48 +00:00
build 2>&1
if [ $? -gt 0 ]; then
2003-12-21 01:34:32 +00:00
error "Build Failed. Aborting..."
2003-05-30 19:56:46 +00:00
exit 2
2002-08-09 18:03:48 +00:00
fi
2003-02-27 08:26:02 +00:00
# remove info/doc files
cd $startdir
rm -rf pkg/usr/info pkg/usr/share/info
rm -rf pkg/usr/doc pkg/usr/share/doc
# move /usr/share/man files to /usr/man
if [ -d pkg/usr/share/man ]; then
2003-05-30 19:56:46 +00:00
mkdir -p pkg/usr/man
cp -a pkg/usr/share/man/* pkg/usr/man/
rm -rf pkg/usr/share/man
fi
# remove /usr/share directory if empty
if [ -d pkg/usr/share ]; then
if [ -z "`ls -1 pkg/usr/share`" ]; then
rm -r pkg/usr/share
fi
2003-02-27 08:26:02 +00:00
fi
# compress man pages
2004-02-07 20:37:00 +00:00
msg "Compressing man pages..."
for i in `find pkg/{usr{,/local},opt/*}/man -type f 2>/dev/null`; do
ext=${i##*.}
fn=${i##*/}
if [ "$ext" != "gz" ]; then
# update symlinks to this manpage
for ln in `find pkg/{usr{,/local},opt/*}/man -lname "$fn" 2>/dev/null`; do
rm -f $ln
ln -sf ${fn}.gz ${ln}.gz
done
# compress the original
gzip -9 $i
fi
done
2003-02-27 08:26:02 +00:00
cd $startdir
2003-09-03 02:09:29 +00:00
# strip binaries
if [ "$NOSTRIP" = "0" ]; then
2003-12-21 01:34:32 +00:00
msg "Stripping debugging symbols from libraries..."
2004-02-07 20:37:00 +00:00
find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \
| grep -v "No such file" | grep -v "format not recognized"
2003-12-21 01:34:32 +00:00
msg "Stripping symbols from binaries..."
2004-02-07 20:37:00 +00:00
find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip '{}' \; 2>&1 \
| grep -v "No such file" | grep -v "format not recognized"
2003-09-03 02:09:29 +00:00
fi
2003-02-27 08:26:02 +00:00
2002-08-09 18:03:48 +00:00
# get some package meta info
2003-11-25 02:02:36 +00:00
builddate=`LC_ALL= ; LANG= ; date -u "+%a %b %e %H:%M:%S %Y"`
2002-08-09 18:03:48 +00:00
if [ "$PACKAGER" != "" ]; then
2003-05-30 19:56:46 +00:00
packager="$PACKAGER"
2002-08-09 18:03:48 +00:00
else
2003-05-30 19:56:46 +00:00
packager="Arch Linux (http://www.archlinux.org)"
2002-08-09 18:03:48 +00:00
fi
size=`du -cb $startdir/pkg | tail -1 | awk '{print $1}'`
# write the .PKGINFO file
2003-12-21 01:34:32 +00:00
msg "Generating .PKGINFO file..."
2002-08-09 18:03:48 +00:00
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
2003-05-30 19:56:46 +00:00
echo "url = $url" >>.PKGINFO
2004-04-15 05:05:54 +00:00
echo "license = $license" >>.PKGINFO
2002-08-09 18:03:48 +00:00
echo "builddate = $builddate" >>.PKGINFO
echo "packager = $packager" >>.PKGINFO
echo "size = $size" >>.PKGINFO
2003-09-03 02:09:29 +00: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
2002-08-09 18:03:48 +00:00
done
2003-09-03 02:09:29 +00:00
for it in "${provides[@]}"; do
echo "provides = $it" >>.PKGINFO
2002-08-09 18:03:48 +00:00
done
2003-09-03 02:09:29 +00:00
for it in "${backup[@]}"; do
echo "backup = $it" >>.PKGINFO
2002-08-09 18:03:48 +00:00
done
# check for an install script
if [ "$install" != "" ]; then
2003-12-21 01:34:32 +00:00
msg "Copying install script..."
2003-05-30 19:56:46 +00:00
cp $startdir/$install $startdir/pkg/.INSTALL
2002-08-09 18:03:48 +00:00
fi
2003-05-30 19:56:46 +00:00
# build a filelist
2003-12-21 01:34:32 +00:00
msg "Generating .FILELIST file..."
2003-05-30 19:56:46 +00:00
cd $startdir/pkg
2003-09-15 04:58:02 +00:00
tar cvf /dev/null * | sort >.FILELIST
2003-05-30 19:56:46 +00:00
2002-08-09 18:03:48 +00:00
# tar it up
2003-12-21 01:34:32 +00:00
msg "Compressing package..."
2002-08-09 18:03:48 +00:00
cd $startdir/pkg
2003-05-30 19:56:46 +00:00
if [ -f $startdir/pkg/.INSTALL ]; then
cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel.pkg.tar.gz .PKGINFO .FILELIST .INSTALL *"
2002-08-09 18:03:48 +00:00
else
2003-05-30 19:56:46 +00:00
cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel.pkg.tar.gz .PKGINFO .FILELIST *"
2002-08-09 18:03:48 +00:00
fi
2003-09-03 02:09:29 +00:00
$cmd | sort >../filelist
2002-08-09 18:03:48 +00:00
cd $startdir
if [ "$CLEANUP" = "1" ]; then
2003-12-21 01:34:32 +00:00
msg "Cleaning up..."
2003-05-30 19:56:46 +00:00
rm -rf src pkg filelist
2002-08-09 18:03:48 +00:00
fi
2003-11-25 02:02:36 +00:00
if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
2003-12-21 01:34:32 +00:00
msg "Removing installed dependencies..."
2003-11-25 02:02:36 +00:00
pacman -R $makedeplist $deplist
fi
2003-12-21 01:34:32 +00:00
msg "Finished making: $pkgname (`date`)"
2002-08-09 18:03:48 +00:00
2003-11-25 02:02:36 +00:00
if [ "$INSTALL" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
2003-12-21 01:34:32 +00:00
msg "Running pacman --upgrade..."
2003-09-15 04:58:02 +00:00
pacman --upgrade $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz
exit $?
2002-08-09 18:03:48 +00:00
fi
exit 0