* Dan McGee <dpmcgee@gmail.com>

DOC_DIRS variable for documentation removal
   repackage option
   structure cleanup
   some option removal (--keepdocs, --nostrip)
   output fixes (msg and msg2)

* Jrgen Htzel <juergen@hoetzel.info>
   user-specific makepkg.conf (~/.makepkg.conf)
This commit is contained in:
Aaron Griffin 2006-12-21 17:42:58 +00:00
parent 1bdf36f419
commit 42a6acf739
2 changed files with 128 additions and 132 deletions

View file

@ -57,6 +57,8 @@ NOLIBTOOL=0
NOEMPTYDIRS=0 NOEMPTYDIRS=0
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5) INTEGRITY_CHECK=(md5)
+#-- Info and doc directories to be removed
DOC_DIRS=(usr/{,share/}{info,doc} opt/gnome/{,share/}{info,doc,gtk-doc})
######################################################################### #########################################################################

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
# makepkg # makepkg - make packages compatable for use with pacman
# #
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
# Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> # Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
@ -44,19 +44,21 @@ DEP_SUDO=0
FORCE=0 FORCE=0
GENINTEG=0 GENINTEG=0
INSTALL=0 INSTALL=0
DOWNLOAD=""
NOBUILD=0 NOBUILD=0
NODEPS=0 NODEPS=0
NOEXTRACT=0 NOEXTRACT=0
RMDEPS=0 RMDEPS=0
REPKG=0
LOGGING=0 LOGGING=0
PACMAN_OPTS= PACMAN_OPTS=
INFAKEROOT= #determine if we are running with fakeroot
if [ "$1" = "-F" ]; then if [ "$1" = "-F" ]; then
INFAKEROOT=1 INFAKEROOT=1
shift shift
else
INFAKEROOT=0
fi fi
### SUBROUTINES ### ### SUBROUTINES ###
@ -68,6 +70,7 @@ plain() {
echo " $1" >&2 echo " $1" >&2
fi fi
} }
msg() { msg() {
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then 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 echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2
@ -91,6 +94,7 @@ warning() {
echo "==> WARNING: $1" >&2 echo "==> WARNING: $1" >&2
fi fi
} }
error() { error() {
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then 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 echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2
@ -239,6 +243,7 @@ handledeps() {
fi fi
missingdeps=1 missingdeps=1
fi fi
# rerun any additional sh scripts found in /etc/profile.d/ # rerun any additional sh scripts found in /etc/profile.d/
for i in /etc/profile.d/*.sh for i in /etc/profile.d/*.sh
do do
@ -246,8 +251,6 @@ handledeps() {
. $i &>/dev/null . $i &>/dev/null
fi fi
done done
# some applications (eg, blackbox) will not build with some languages
unset LC_ALL LANG
return $missingdeps return $missingdeps
} }
@ -269,18 +272,15 @@ usage() {
echo " -h, --help This help" echo " -h, --help This help"
echo " -i, --install Install package after successful build" echo " -i, --install Install package after successful build"
echo " -j <jobs> Set MAKEFLAGS to \"-j<jobs>\" before building" echo " -j <jobs> Set MAKEFLAGS to \"-j<jobs>\" before building"
echo " -k, --keepdocs Keep doc and info directories"
echo " -L, --log Log package build process" echo " -L, --log Log package build process"
echo " -m, --nocolor Disable colorized output messages" echo " -m, --nocolor Disable colorized output messages"
echo " -n, --nostrip Do not strip symbols from binaries/libraries"
echo " -o, --nobuild Download and extract files only" echo " -o, --nobuild Download and extract files only"
echo " -p <buildscript> Use an alternate build script (instead of '$BUILDSCRIPT')" echo " -p <buildscript> Use an alternate build script (instead of '$BUILDSCRIPT')"
echo " -r, --rmdeps Remove installed dependencies after a successful build" echo " -r, --rmdeps Remove installed dependencies after a successful build"
# fix flyspray feature request #2978
echo " -R, --repackage Repackage contents of <startdir>/pkg without building"
echo " -s, --syncdeps Install missing dependencies with pacman" echo " -s, --syncdeps Install missing dependencies with pacman"
echo " -S, --sudosync Install missing dependencies with pacman and sudo" echo " -S, --sudosync Install missing dependencies with pacman and sudo"
# fix flyspray feature request #5223 - Dan McGee <dpmcgee@gmail.com>
echo " -t <sourcedir> Cache source files in <sourcedir>"
echo " -w <destdir> Write package to <destdir> instead of the working dir"
echo echo
echo "These options can be passed to pacman:" echo "These options can be passed to pacman:"
echo echo
@ -300,8 +300,10 @@ else
exit 1 exit 1
fi fi
#Let's be courteous and support frugalware's extensions #Source user-specific makepkg.conf overrides
[ -e /usr/lib/frugalware/fwmakepkg ] && . /usr/lib/frugalware/fwmakepkg if [ -f ~/.makepkg.conf ]; then
source ~/.makepkg.conf
fi
while [ "$#" -ne "0" ]; do while [ "$#" -ne "0" ]; do
case $1 in case $1 in
@ -319,12 +321,11 @@ while [ "$#" -ne "0" ]; do
--noextract) NOEXTRACT=1 ;; --noextract) NOEXTRACT=1 ;;
--install) INSTALL=1 ;; --install) INSTALL=1 ;;
--force) FORCE=1 ;; --force) FORCE=1 ;;
--keepdocs) KEEPDOCS=1 ;;
--nostrip) NOSTRIP=1 ;;
--nobuild) NOBUILD=1 ;; --nobuild) NOBUILD=1 ;;
--nocolor) USE_COLOR="n" ;; --nocolor) USE_COLOR="n" ;;
--geninteg) GENINTEG=1 ;; --geninteg) GENINTEG=1 ;;
--rmdeps) RMDEPS=1 ;; --rmdeps) RMDEPS=1 ;;
--repackage) REPKG=1 ;;
--log) LOGGING=1 ;; --log) LOGGING=1 ;;
--help) --help)
usage usage
@ -335,7 +336,7 @@ while [ "$#" -ne "0" ]; do
exit 1 exit 1
;; ;;
-*) -*)
while getopts "bBcCdefghij:kLmnop:rsSt:w:-" opt; do while getopts "bBcCdefghij:Lmop:rRsS-" opt; do
case $opt in case $opt in
b) DEP_SRC=1 ;; b) DEP_SRC=1 ;;
B) USE_CCACHE=0 ;; B) USE_CCACHE=0 ;;
@ -346,30 +347,27 @@ while [ "$#" -ne "0" ]; do
f) FORCE=1 ;; f) FORCE=1 ;;
g) GENINTEG=1 ;; g) GENINTEG=1 ;;
h) h)
usage usage
exit 0 exit 0
;; ;;
i) INSTALL=1 ;; i) INSTALL=1 ;;
j) export MAKEFLAGS="-j$OPTARG" ;; j) export MAKEFLAGS="-j$OPTARG" ;;
k) KEEPDOCS=1 ;;
L) LOGGING=1 ;; L) LOGGING=1 ;;
m) USE_COLOR="n" ;; m) USE_COLOR="n" ;;
n) NOSTRIP=1 ;;
o) NOBUILD=1 ;; o) NOBUILD=1 ;;
p) BUILDSCRIPT=$OPTARG ;; p) BUILDSCRIPT=$OPTARG ;;
r) RMDEPS=1 ;; r) RMDEPS=1 ;;
R) REPKG=1 ;;
s) DEP_BIN=1 ;; s) DEP_BIN=1 ;;
S) DEP_SUDO=1 ;; S) DEP_SUDO=1 ;;
t) SRCDEST=$OPTARG ;;
w) PKGDEST=$OPTARG ;;
-) -)
OPTIND=0 OPTIND=0
break break
;; ;;
*) *)
usage usage
exit 1 exit 1
;; ;;
esac esac
done done
;; ;;
@ -386,6 +384,7 @@ if [ "$DEP_SUDO" = "1" -a ! "$(type -p sudo)" ]; then
exit 1 exit 1
fi fi
# TODO: is this necessary?
# convert a (possibly) relative path to absolute # convert a (possibly) relative path to absolute
cd $PKGDEST 2>/dev/null cd $PKGDEST 2>/dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -396,20 +395,19 @@ PKGDEST=$(pwd)
cd $OLDPWD cd $OLDPWD
if [ "$CLEANCACHE" = "1" ]; then if [ "$CLEANCACHE" = "1" ]; then
#fix flyspray feature request #5223
if [ -n "$SRCDEST" ]; then if [ -n "$SRCDEST" ]; then
msg "Cleaning up source files from the cache." msg "Cleaning up source files from the cache."
rm -rf /var/cache/pacman/src/* rm -rf "$SRCDEST"/*
rm -rf "${SRCDEST}"/* if [ $? -ne 0 ]; then
exit 0 error "Problem removing files; you may not have correct permissions in $SRCDEST"
else
if [ "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
msg "Cleaning up source files from the cache."
rm -rf /var/cache/pacman/src/*
exit 0
else
error "You must be root to clean the cache."
exit 1 exit 1
else
exit 0
fi fi
else
error "Source destination must be defined in makepkg.conf."
exit 1
fi fi
fi fi
@ -452,7 +450,7 @@ if [ $(echo $pkgrel | grep '-') ]; then
error "pkgrel is not allowed to contain hyphens." error "pkgrel is not allowed to contain hyphens."
exit 1 exit 1
fi fi
if ! in_array $CARCH ${arch[@]}; then if [ ! in_array $CARCH ${arch[@]}]; then
error "$pkgname is not available for the '$CARCH' architecture." error "$pkgname is not available for the '$CARCH' architecture."
plain "Note that many packages may need a line added to their $BUILDSCRIPT" plain "Note that many packages may need a line added to their $BUILDSCRIPT"
plain "such as arch=('$CARCH')." plain "such as arch=('$CARCH')."
@ -504,7 +502,7 @@ fi
msg "Making package: $pkgname $pkgver-$pkgrel ($(date))" msg "Making package: $pkgname $pkgver-$pkgrel ($(date))"
unset deplist makedeplist unset deplist makedeplist
# fix flyspray bug #5973 - Dan McGee <dpmcgee@gmail.com> # fix flyspray bug #5973
if [ $(type -p pacman) -a "$NODEPS" = "0" -a "$GENINTEG" = "0" -a "$NOBUILD" = "0" ]; then if [ $(type -p pacman) -a "$NODEPS" = "0" -a "$GENINTEG" = "0" -a "$NOBUILD" = "0" ]; then
msg "Checking Runtime Dependencies..." msg "Checking Runtime Dependencies..."
deplist=$(checkdeps ${depends[@]}) deplist=$(checkdeps ${depends[@]})
@ -524,7 +522,9 @@ if [ $(type -p pacman) -a "$NODEPS" = "0" -a "$GENINTEG" = "0" -a "$NOBUILD" = "
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
exit 1 exit 1
fi fi
elif [ "$NODEPS" = "1" -o "$GENINTEG" = "1" -o "$NOBUILD" = "1" ]; then elif [ "$GENINTEG" = "1" -o "$NOBUILD" = "1" ]; then
msg "skipping dependency checks."
elif [ "$NODEPS" = "1" ]; then
warning "skipping dependency checks." warning "skipping dependency checks."
else else
warning "pacman was not found in PATH. skipping dependency checks." warning "pacman was not found in PATH. skipping dependency checks."
@ -537,16 +537,13 @@ msg "Retrieving Sources..."
mkdir -p src mkdir -p src
cd $startdir/src cd $startdir/src
for netfile in ${source[@]}; do for netfile in ${source[@]}; do
file=$(strip_url $netfile) file=$(strip_url "$netfile")
if [ -f "../$file" ]; then if [ -f "../$file" ]; then
msg " Found $file in build dir" msg2 "Found $file in build dir"
cp "../$file" . cp "../$file" .
elif [ -f "$SRCDEST/$file" ]; then elif [ -f "$SRCDEST/$file" ]; then
msg " Using cached copy of $file" msg2 "Using cached copy of $file"
cp "$SRCDEST$file" . cp "$SRCDEST/$file" .
elif [ -f "/var/cache/pacman/src/$file" ]; then
msg " Using cached copy of $file"
cp "/var/cache/pacman/src/$file" .
else else
# check for a download utility # check for a download utility
if [ -z "$FTPAGENT" ]; then if [ -z "$FTPAGENT" ]; then
@ -566,33 +563,29 @@ for netfile in ${source[@]}; do
msg "Aborting..." msg "Aborting..."
exit 1 exit 1
fi fi
msg " Downloading $file" msg2 "Downloading $file"
$FTPAGENT "$netfile" 2>&1 $FTPAGENT "$netfile" 2>&1
# fix flyspray bug #3289 # fix flyspray bug #3289
ftpret=$? ftpret=$?
if [ $ftpret -gt 0 ]; then if [ $ftpret -gt 0 ]; then
error "Failure while downloading $file" error "Failure while downloading $file"
msg "Aborting..." msg "Aborting..."
rm "$file" #rm "$file"
exit 1
exit 1 exit 1
fi fi
if [ "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then if [ -n "$SRCDEST" ]; then
mkdir -p /var/cache/pacman/src && cp $file /var/cache/pacman/src mkdir -p $SRCDEST && cp "$file" $SRCDEST
if [ -n "$SRCDEST" ]; then if [ $? -ne 0 ]; then
mkdir -p $SRCDEST && cp "$file" $SRCDEST warning "You do not have correct permissions to cache source in $SRCDEST"
elif [ "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
mkdir -p /var/cache/pacman/src && cp "$file" /var/cache/pacman/src
else
cp "$file" .. cp "$file" ..
fi fi
else
cp "$file" ..
fi fi
fi fi
done done
if [ "$NOEXTRACT" = "1" -o "$REPKG" ]; then
if [ "$NOEXTRACT" = "1" ]; then
warning "Skipping source integrity checks -- using existing src/ tree" warning "Skipping source integrity checks -- using existing src/ tree"
else else
for integ in ${INTEGRITY_CHECK[@]}; do for integ in ${INTEGRITY_CHECK[@]}; do
@ -635,7 +628,7 @@ else
fi fi
done done
plain "" plain ""
#Validate integrity checks #Validate integrity checks
else else
integrity_sums=($(eval echo \${${integrity_name}s[@]})) integrity_sums=($(eval echo \${${integrity_name}s[@]}))
@ -671,8 +664,8 @@ else
fi fi
#Extract sources #Extract sources
if [ "$NOEXTRACT" = "1" ]; then if [ "$NOEXTRACT" = "1" -o "$REPKG" = "1" ]; then
warning "Skipping source extraction -- using existing src/ tree" warning "Skipping source extraction -- using existing src/ tree"
else else
msg "Extracting Sources..." msg "Extracting Sources..."
for netfile in "${source[@]}"; do for netfile in "${source[@]}"; do
@ -699,7 +692,7 @@ else
cmd="bunzip2 -f $file" ;; cmd="bunzip2 -f $file" ;;
esac esac
if [ "$cmd" != "" ]; then if [ "$cmd" != "" ]; then
msg " $cmd" msg2 "$cmd"
$cmd $cmd
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# unzip will return a 1 as a warning, it is not an error # unzip will return a 1 as a warning, it is not an error
@ -713,81 +706,82 @@ else
done done
fi fi
if [ "$EUID" = "0" ]; then if [ "$REPKG" = "0" ]; then
# chown all source files to root.root if [ "$EUID" = "0" ]; then
chown -R root.root $startdir/src # chown all source files to root.root
fi chown -R root.root $startdir/src
# check for existing pkg directory
if [ -d $startdir/pkg ]; then
msg "Removing existing pkg/ directory..."
rm -rf $startdir/pkg
fi
mkdir -p $startdir/pkg
if [ "$NOBUILD" = "1" ]; then
msg "Sources are ready."
exit 0
fi
# use distcc if requested
if [ "$USE_DISTCC" = "y" ]; then
[ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
fi
# use ccache if it's available
if [ "$USE_CCACHE" = "1" ]; then
[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
fi
# build
msg "Starting build()..."
#check for "exit on syntax error" shell option
echo $SHELLOPTS | grep errexit 2>&1 >/dev/null
set_e=$?
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 fi
#use 'errexit' to bail on syntax error # check for existing pkg directory
[ $set_e -eq 1 ] && set -e if [ -d $startdir/pkg ]; then
build 2>&1 | tee "$BUILDLOG" msg "Removing existing pkg/ directory..."
[ $set_e -eq 1 ] && set +e rm -rf $startdir/pkg
if [ ${PIPESTATUS[0]} -gt 0 ]; then
error "Build Failed. Aborting..."
exit 2
fi fi
else mkdir -p $startdir/pkg
#use 'errexit' to bail on syntax error
[ $set_e -eq 1 ] && set -e if [ "$NOBUILD" = "1" ]; then
build 2>&1 msg "Sources are ready."
[ $set_e -eq 1 ] && set +e exit 0
if [ $? -gt 0 ]; then fi
error "Build Failed. Aborting..."
exit 2 # use distcc if requested
if [ "$USE_DISTCC" = "y" ]; then
[ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
fi
# use ccache if it's available
if [ "$USE_CCACHE" = "1" ]; then
[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
fi
# build
msg "Starting build()..."
#check for "exit on syntax error" shell option
echo $SHELLOPTS | grep errexit 2>&1 >/dev/null
set_e=$?
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
#use 'errexit' to bail on syntax error
[ $set_e -eq 1 ] && set -e
build 2>&1 | tee "$BUILDLOG"
[ $set_e -eq 1 ] && set +e
if [ ${PIPESTATUS[0]} -gt 0 ]; then
error "Build Failed. Aborting..."
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..."
exit 2
fi
fi fi
fi fi
if [ ! "$(check_option KEEPDOCS)" -a "$KEEPDOCS" = "0" ]; then if [ ! "$(check_option KEEPDOCS)" -a "$KEEPDOCS" = "0" ]; then
# remove info/doc files # remove info/doc files
msg "Removing info/doc files..." msg "Removing info/doc files..."
cd $startdir cd $startdir/pkg
rm -rf pkg/usr/info pkg/usr/share/info #fix flyspray bug #5021
rm -rf pkg/usr/doc pkg/usr/share/doc rm -rf ${DOC_DIRS[@]}
rm -rf pkg/{usr,opt/gnome}/share/gtk-doc
fi fi
# move /usr/share/man files to /usr/man # move /usr/share/man files to /usr/man
@ -816,7 +810,7 @@ done
cd $startdir cd $startdir
# strip binaries # strip binaries
if [ ! "$(check_option NOSTRIP)" -a "$NOSTRIP" = "0" ]; then if [ ! "$(check_option NOSTRIP)" -a "$NOSTIP" = "0" ]; then
msg "Stripping debugging symbols from libraries..." msg "Stripping debugging symbols from libraries..."
find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \ find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \ -exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \