[pacman-dev] makepkg script changes
Dan McGee
dpmcgee at gmail.com
Mon Dec 11 20:21:15 EST 2006
This is a relatively big patch with a few different things in it. As
always, take it or leave it.
* Addresses FS bugs 5223 and 5973, comments are in the patch noting
the start of these changes.
* Allows makepkg script to be usable again. I did notice that
integrity checks are not working at the moment, but I assume that is
known.
* Removed some duplicate lines of code (e.g. things that were moved
earlier in the script or outside of loops)
* Adds quotes around filename references to ensure we do not break the
script with weird filenames.
* Changes use of `` and $() to be a bit more consistent- `` are used
wherever possible.
* Removes /usr/share from man page compression search- they are
explicitly moved from this location ten lines before in the script so
there better not be anything there.
Dan
____________________
--- pacman-lib.orig/scripts/makepkg 2006-12-05 17:30:23.000000000 -0500
+++ pacman-lib/scripts/makepkg 2006-12-11 20:02:59.000000000 -0500
@@ -25,11 +25,12 @@
# USA.
#
-myver='2.9.8'
+myver='3.0.0'
startdir=`pwd`
PKGDEST=$startdir
# Options
+BUILDSCRIPT="./PKGBUILD"
CLEANUP=0
CLEANCACHE=0
DEP_BIN=0
@@ -187,18 +188,18 @@
if [ "$INFAKEROOT" = "1" ]; then
export FAKEROOTKEY=$FAKEROOTKEY2
unset FAKEROOTKEY2
- fi
+ fi
elif [ "$DEP_SRC" = "1" ]; then
# install missing deps by building them from source.
# we look for each package name in $SRCROOT and build it.
if [ "$SRCROOT" = "" ]; then
- error "Source root cannot be found - please make sure
it is specified in /etc/makepkg.conf"
+ error "Source root cannot be found - please make sure it is
specified in /etc/makepkg.conf"
exit 1
fi
# TODO: handle version comparators (eg, glibc>=2.2.5)
msg "Building missing dependencies..."
for dep in $deplist; do
- candidates=$(find $SRCROOT -type d -name "$dep")
+ candidates=`find $SRCROOT -type d -name "$dep"`
if [ "$candidates" = "" ]; then
error "Could not find \"$dep\" under $SRCROOT"
exit 1
@@ -266,12 +267,14 @@
echo " -k, --keepdocs Keep doc and info directories"
echo " -L, --log Log package build process"
echo " -m, --nocolor Disable colorized output messages"
- echo " -n, --nostrip Do not strip binaries/libraries"
+ echo " -n, --nostrip Do not strip symbols from binaries/libraries"
echo " -o, --nobuild Download and extract files only"
echo " -p <buildscript> Use an alternate build script (instead of
'$BUILDSCRIPT')"
echo " -r, --rmdeps Remove installed dependencies after a
successful build"
echo " -s, --syncdeps Install missing dependencies with pacman"
echo " -S, --sudosync Install missing dependencies with pacman and sudo"
+ # fix flyspray feature request #5223
+ echo " -t <sourcedir> Cache source files in <sourcedir>"
echo " -w <destdir> Write package to <destdir> instead of the
working dir"
echo
echo "These options can be passed to pacman:"
@@ -279,22 +282,19 @@
echo " --noconfirm Do not ask for confirmation when resolving
dependencies"
echo " --noprogressbar Do not show a progress bar when downloading files"
echo
- echo "If -p is not specified, makepkg will look for './$BUILDSCRIPT'"
+ echo "If -p is not specified, makepkg will look for '$BUILDSCRIPT'"
echo
}
ARGLIST=$@
-if [ -f /etc//makepkg.conf ]; then
+if [ -f /etc/makepkg.conf ]; then
source /etc/makepkg.conf
else
error "/etc/makepkg.conf not found. cannot continue"
exit 1
fi
-#Let's be courteous and support frugalware's extensions
-[ -e /usr/lib/frugalware/fwmakepkg ] && . /usr/lib/frugalware/fwmakepkg
-
while [ "$#" -ne "0" ]; do
case $1 in
# pacman
@@ -327,7 +327,7 @@
exit 1
;;
-*)
- while getopts "bBcCdefghij:Lmnop:rsSw:-" opt; do
+ while getopts "bBcCdefghij:kLmnop:rsSt:w:-" opt; do
case $opt in
b) DEP_SRC=1 ;;
B) USE_CCACHE=0 ;;
@@ -352,6 +352,7 @@
r) RMDEPS=1 ;;
s) DEP_BIN=1 ;;
S) DEP_SUDO=1 ;;
+ t) SRCDEST=$OPTARG ;;
w) PKGDEST=$OPTARG ;;
-)
OPTIND=0
@@ -387,13 +388,19 @@
cd $OLDPWD
if [ "$CLEANCACHE" = "1" ]; then
- if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
+ if [ -n "$SRCDEST" ]; then
msg "Cleaning up source files from the cache."
- rm -rf /var/cache/pacman/src/*
+ rm -rf $SRCDEST/*
exit 0
else
- error "You must be root to clean the cache."
- exit 1
+ if [ "`id -u`" = "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
+ fi
fi
fi
@@ -401,7 +408,6 @@
unset replaces depends conflicts backup source install build makedepends
unset options
-
# some applications (eg, blackbox) will not build with some languages
unset LC_ALL LANG
umask 0022
@@ -409,11 +415,6 @@
if [ ! -f $BUILDSCRIPT ]; then
error "$BUILDSCRIPT does not exist."
exit 1
-else
- #this is fun.... we'll unset
- for var in $(grep "=" $BUILDSCRIPT | sed "s|.*\(\<.*\>\)=.*|\1|g"); do
- unset $var
- done
fi
source $BUILDSCRIPT
@@ -427,16 +428,18 @@
error "pkgrel is not allowed to be empty."
exit 1
fi
-if [ $(echo $pkgver | grep '-') ]; then
+if [ `echo $pkgver | grep '-'` ]; then
error "pkgver is not allowed to contain hyphens."
exit 1
fi
-if [ $(echo $pkgrel | grep '-') ]; then
+if [ `echo $pkgrel | grep '-'` ]; then
error "pkgrel is not allowed to contain hyphens."
exit 1
fi
if ! in_array $CARCH ${arch[@]}; then
error "$pkgname is not available for the '$CARCH' architecture."
+ plain "Note that many packages may need a line added to their $BUILDSCRIPT"
+ plain "such as arch=('$CARCH')."
exit 1
fi
@@ -457,8 +460,6 @@
fi
fi
-# some applications (eg, blackbox) will not build with some languages
-unset LC_ALL LANG
# 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
@@ -488,7 +489,8 @@
msg "Making package: $pkgname $pkgver-$pkgrel (`date`)"
unset deplist makedeplist
-if [ `type -p pacman` -a "$NODEPS" = "0" ]; then
+# fix flyspray bug #5973
+if [ `type -p pacman` -a "$NODEPS" = "0" -a "$GENINTEG" = "0" -a
"$NOBUILD" = "0" ]; then
msg "Checking Runtime Dependencies..."
deplist=`checkdeps ${depends[@]}`
handledeps $deplist
@@ -507,7 +509,7 @@
if [ $? -gt 0 ]; then
exit 1
fi
-elif [ "$NODEPS" = "1" ]; then
+elif [ "$NODEPS" = "1" -o "$GENINTEG" = "1" -o "$NOBUILD" = "1" ]; then
warning "skipping dependency checks."
else
warning "pacman was not found in PATH. skipping dependency checks."
@@ -520,13 +522,16 @@
mkdir -p src
cd $startdir/src
for netfile in ${source[@]}; do
- file=`strip_url $netfile`
- if [ -f ../$file ]; then
+ file=`strip_url "$netfile"`
+ if [ -f "../$file" ]; then
msg " Found $file in build dir"
- cp ../$file .
- elif [ -f /var/cache/pacman/src/$file ]; then
- msg " Using local copy of $file"
- cp /var/cache/pacman/src/$file .
+ cp "../$file" .
+ elif [ -f "$SRCDEST/$file" ]; then
+ msg " Using cached copy of $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
# check for a download utility
if [ -z "$FTPAGENT" ]; then
@@ -540,35 +545,35 @@
msg "Aborting..."
exit 1
fi
- proto=`echo $netfile | sed 's|://.*||'`
+ proto=`echo "$netfile" | sed 's|://.*||'`
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
msg " Downloading $file"
- $FTPAGENT $netfile 2>&1
- if [ ! -f $file ]; then
+ $FTPAGENT "$netfile" 2>&1
+ if [ ! -f "$file" ]; then
error "Failed to download $file"
msg "Aborting..."
exit 1
fi
- if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
- mkdir -p /var/cache/pacman/src && cp $file /var/cache/pacman/src
+ if [ -n "$SRCDEST" ]; then
+ mkdir -p $SRCDEST && cp "$file" $SRCDEST
+ elif [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
+ mkdir -p /var/cache/pacman/src && cp "$file" /var/cache/pacman/src
else
- cp $file ..
+ cp "$file" ..
fi
fi
done
-
-
if [ "$NOEXTRACT" = "1" ]; then
warning "Skipping source extraction -- using existing src/ tree"
warning "Skipping source integrity checks -- using existing src/ tree"
else
for integ in ${INTEGRITY_CHECK[@]}; do
- integ="$(echo $integ | tr A-Z a-z)"
+ integ=`echo $integ | tr A-Z a-z`
case "$integ" in
md5) integrity_name="md5sum" ;;
sha1) integrity_name="sha1sum" ;;
@@ -577,12 +582,13 @@
sha512) integrity_name="sha512sum" ;;
*) error "Invalid integrity algorithm '$integ' specified"; exit 1;;
esac
- if [ ! $(type -p $integrity_name) ]; then
+ if [ ! `type -p $integrity_name` ]; then
error "Cannot find the $integrity_name program."
exit 1
fi
- if [ "$GENINTEG" = "1" ]; then
+ # Generate integrity checks
+ if [ "$GENINTEG" = "1" ]; then
msg "Generating ${integrity_name}s for source files"
plain ""
ct=0
@@ -590,7 +596,7 @@
numsrc=${#source[@]}
for netfile in "${source[@]}"; do
file=`strip_url "$netfile"`
- sum=$(eval "$integrity_name '$file' | cut -d' ' -f 1")
+ sum=`eval "$integrity_name '$file' | cut -d' ' -f 1"`
if [ $ct -eq 0 ]; then
echo -n "${integrity_name}s=("
else
@@ -607,7 +613,8 @@
done
plain ""
exit 0
- else #validation
+ # Validate integrity checks
+ else
integrity_sums=($(eval echo \${${integrity_name}s[@]}))
if [ ${#integrity_sums[@]} -eq ${#source[@]} ]; then
@@ -615,7 +622,7 @@
errors=0
idx=0
for netfile in "${source[@]}"; do
- file=$(strip_url "$netfile")
+ file=`strip_url "$netfile"`
echo -n " $file ... " >&2
echo "${integrity_sums[$idx]} $file" |
$integrity_name -c - >/dev/null 2>&1
if [ $? -ne 0 ]; then
@@ -723,9 +730,6 @@
mv "$BUILDLOG" "$BUILDLOG.$i"
fi
- echo $SHELLOPTS | grep errexit 2>&1 >/dev/null
- set_e=$?
-
#use 'errexit' to bail on syntax error
[ $set_e -eq 1 ] && set -e
build 2>&1 | tee "$BUILDLOG"
@@ -771,12 +775,12 @@
# compress man pages
msg "Compressing man pages..."
-find $startdir/pkg/{usr{,/local,/share},opt/*}/man -type f
2>/dev/null | while read i ; do
+find $startdir/pkg/{usr{,/local},opt/*}/man -type f 2>/dev/null |
while read i ; do
ext="${i##*.}"
fn="${i##*/}"
if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
# update symlinks to this manpage
- find $startdir/pkg/{usr{,/local,/share},opt/*}/man -lname "$fn" 2>
/dev/null | while read ln ; do
+ find $startdir/pkg/{usr{,/local},opt/*}/man -lname "$fn" 2>
/dev/null | while read ln ; do
rm -f "$ln"
ln -sf "${fn}.gz" "${ln}.gz"
done
--- pacman-lib.orig/etc/makepkg.conf.in 2006-11-16 20:40:22.000000000 -0500
+++ pacman-lib/etc/makepkg.conf.in 2006-12-11 20:09:54.000000000 -0500
@@ -61,8 +61,10 @@
# PACKAGE OUTPUT
#########################################################################
#
-#-- Destination: specify a fixed directory where all packages will be placed
+#-- Destination: specify a fixed directory where made packages will be placed
#PKGDEST=/home/packages
+#-- Source cache: specify a fixed directory where source files will be cached
+#SRCDEST=/home/source
#-- Packager: name/email of the person or organization building packages
#PACKAGER="John Doe <john at doe.com>"
More information about the pacman-dev
mailing list