[pacman-dev] [PATCH] fix in_array (usage) and code cleanup
Jürgen Hötzel
juergen at hoetzel.info
Thu Dec 21 15:33:39 EST 2006
Hi,
the use of in_array in line 444 is invalid:
bash-3.2$ makepkg-cvs
/home/juergen/archlinux/pacman-lib/scripts/makepkg: line 444: [: too many
arguments
Helper function like in_array should not use global variables. I also
did some code cleanup (the temp. file "filelist" was not even used). Less
Code. Better Code.
patch enclosed.
Jürgen
-------------- next part --------------
Index: scripts/makepkg
===================================================================
RCS file: /home/cvs-pacman/pacman-lib/scripts/makepkg,v
retrieving revision 1.25
diff -u -p -r1.25 makepkg
--- scripts/makepkg 21 Dec 2006 20:03:41 -0000 1.25
+++ scripts/makepkg 21 Dec 2006 20:32:09 -0000
@@ -120,7 +120,7 @@ check_option() {
}
in_array() {
- needle=$1
+ local needle=$1
shift 1
[ -z "$1" ] && return 1
for i in $*; do
@@ -441,7 +441,7 @@ if [ $(echo $pkgrel | grep '-') ]; then
error "pkgrel is not allowed to contain hyphens."
exit 1
fi
-if [ ! in_array $CARCH ${arch[@]} ]; then
+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')."
@@ -884,22 +884,15 @@ tar cvf /dev/null * | sort >.FILELIST
# tar it up
msg "Compressing package..."
cd $startdir/pkg
-if [ -f $startdir/pkg/.INSTALL ]; then
- cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT} .PKGINFO .FILELIST .INSTALL *"
-else
- cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT} .PKGINFO .FILELIST *"
-fi
-$cmd | sort >../filelist
-
-if [ ${PIPESTATUS[0]} -gt 0 ]; then
- error "Failed to create package file."
- exit ${PIPESTATUS[0]}
+if ! tar czf $PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT} .PKGINFO .FILELIST ${install:+.INSTALL} *; then
+ error "Failed to create package file."
+ exit 1
fi
cd $startdir
if [ "$CLEANUP" = "1" ]; then
msg "Cleaning up..."
- rm -rf src pkg filelist
+ rm -rf src pkg
rm -rf ${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*
fi
More information about the pacman-dev
mailing list