Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=ebe166f705ba005f89947d7f48182a597fad8a4c

commit ebe166f705ba005f89947d7f48182a597fad8a4c
Author: Michel Hermier <[email protected]>
Date:   Thu Mar 13 09:09:31 2014 +0100

makepkg: Make makepkg() call return instead of exit.

diff --git a/scripts/makepkg b/scripts/makepkg
index 61252f5..c6da137 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -1149,7 +1149,7 @@ makepkg() {

if in_array "$1" "${!_makepkg_commands[@]}"; then
"${_makepkg_commands[$1]}" "${@:2}"
-               exit $?
+               return $?
fi
while [ $# -gt 0 ]; do
_options_consumed=1
@@ -1183,7 +1183,7 @@ makepkg() {
--gzip)       COMPRESS_PROGRAM="gzip" ;;
-h|--help)
makepkg_usage
-                       exit 0
+                       return 0
;;
# assigned options
-A)
@@ -1256,20 +1256,20 @@ fi
# check for COMPRESS_PROGRAM program to be in the path
if [ -z "`which $COMPRESS_PROGRAM 2>/dev/null`" ]; then
error "Cannot find compress program ($COMPRESS_PROGRAM) in PATH"
-       exit 1
+       return 1
fi

# check for sudo
if [ "$DEP_SUDO" = "1" -a ! "`type -p sudo`" ]; then
error "Cannot find the sudo binary! Is sudo installed?"
-       exit 1
+       return 1
fi

# convert a (possibly) relative path to absolute
cd $PKGDEST 2>/dev/null
if [ $? -ne 0 ]; then
error "Package destination directory does not exist or permission denied."
-       exit 1
+       return 1
fi
PKGDEST=`pwd`
cd $OLDPWD
@@ -1281,7 +1281,7 @@ fi
if [ ! -z "$CLEANCCACHE" ]; then
export CCACHE_DIR=$CCACHE_BASEDIR/$CLEANCCACHE
ccache -C
-       exit 0
+       return 0
fi

if [ "$INCHROOT" = "1" ]; then
@@ -1312,10 +1312,10 @@ if [ $CLEANCACHE -ge 1 ]; then
error "Failed to umount some bind mounts, can't remove the chroot."
fi
fi
-               exit 0
+               return 0
else
error "You must be root to clean the cache."
-               exit 1
+               return 1
fi
fi

@@ -1332,20 +1332,20 @@ if [ ! -z "$DOWNLOAD" -a "$INFAKEROOT" != "1" ]; then
# find the package
if ! $PACMAN -Si $DOWNLOAD >/dev/null 2>&1; then
error "Package \"$DOWNLOAD\" was not found."
-               exit 1
+               return 1
fi

# check for a download utility
if [ -z "$FTPAGENT" ]; then
error "FTPAGENT is not configured. Check the /etc/makepkg.conf file."
msg "Aborting..."
-               exit 1
+               return 1
fi
ftpclient=`$ECHO $FTPAGENT | awk {'print $1'}`
if [ ! -x $ftpclient ]; then
error "ftpclient `basename $ftpclient` is not installed."
msg "Aborting..."
-               exit 1
+               return 1
fi

confs=`cat /etc/pacman-g2.conf |grep ^Include|sed 's/.* = \(.*\)/\1/'`
@@ -1365,7 +1365,7 @@ if [ ! -z "$DOWNLOAD" -a "$INFAKEROOT" != "1" ]; then
if [ ! -f $file ]; then
error "Failed to download $file"
msg "Aborting..."
-               exit 1
+               return 1
fi
junk=`$ECHO $dir|sed 
"s|^.*://\(.*\)/frugalware-$arch|\1/$quickdl|"`/source/$cat/$DOWNLOAD/
mv $junk* ./
@@ -1380,21 +1380,21 @@ if [ "$PACKAGER" != "" ]; then
packager="$PACKAGER"
else
error "Please make sure that you edit /etc/makepkg.conf and set the PACKAGER= 
variable"
-       exit 1
+       return 1
fi
if [ -z "$PKG_EXT" ]; then
error "Please make sure that you edit /etc/makepkg.conf and set the PKG_EXT= 
variable"
-       exit 1
+       return 1
fi
if [ ! -f $BUILDSCRIPT ]; then
error "$BUILDSCRIPT does not exist."
-       exit 1
+       return 1
fi

source ./$BUILDSCRIPT

if ! makepkg_validate; then
-       exit 1
+       return 1
fi

if [ "`type -p fblint`" ]; then
@@ -1421,7 +1421,7 @@ fi

if [ ! -e "$install" -a ! -e "$startdir/$install" -a ! "`check_option 
GENSCRIPTLET`" ]; then
error "Missing install scriptlet. If this is intentional, add 'genscriptlet' to 
options()."
-       exit 1
+       return 1
fi

if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.$PKG_EXT -a "$FORCE" = 
"0" -a "$GENSHA1" = "0" ]; then
@@ -1430,7 +1430,7 @@ if [ -f 
$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.$PKG_EXT -a "$FORCE" =
install_pkg
else
error "a package has already been built.  (use -f to overwrite)"
-               exit 1
+               return 1
fi
fi

@@ -1469,11 +1469,11 @@ unset LC_ALL LANG
if [ "$CHROOT" = "1" -a "$INCHROOT" != "1" ]; then
if [ "`id -u`" != 0 ]; then
error "Building in a chroot as an unprivileged user is not possible."
-               exit 1
+               return 1
fi
if [ "$CHROOTDIR" = "" ]; then
error "The CHROOTDIR environment variable is not defined."
-               exit 1
+               return 1
fi
CHROOTDIR="$CHROOTDIR/$TREE"

@@ -1507,7 +1507,7 @@ if [ "$CHROOT" = "1" -a "$INCHROOT" != "1" ]; then
error "Failed to build chroot environment."
chroot_umount
chroot_unlock
-                       exit 1
+                       return 1
fi
cat $_F_makepkg_pacconf > $CHROOTDIR/etc/pacman-g2.conf
# later runs use 'chroot pacman-g2' instead of
@@ -1525,7 +1525,7 @@ if [ "$CHROOT" = "1" -a "$INCHROOT" != "1" ]; then
error "Failed to update chroot environment."
chroot_umount
chroot_unlock
-                       exit 1
+                       return 1
fi
fi
# why is this necessary?
@@ -1557,7 +1557,7 @@ if [ "$CHROOT" = "1" -a "$INCHROOT" != "1" ]; then
if [ "$?" != "0" ]; then
error "An error occurred while attempting to copy config files to chroot."
chroot_umount
-               exit 1
+               return 1
fi
# to make Finclude work
[ -d $CHROOTDIR/var/tmp/fst/include/ ] || mkdir -p 
$CHROOTDIR/var/tmp/fst/include/
@@ -1637,7 +1637,7 @@ if [ "$CHROOT" = "1" -a "$INCHROOT" != "1" ]; then

chroot_umount
chroot_unlock
-       exit $ret
+       return $ret
fi

# Enter the fakeroot environment if necessary.  This will call the makepkg 
script again
@@ -1651,7 +1651,7 @@ if [ "`id -u`" != "0" ]; then
else
fakeroot -- $0 -F --inchroot $ARGLIST
fi
-                       exit $?
+                       return $?
else
warning "Fakeroot is not installed.  Building as an unprivileged user"
plain "will result in non-root ownership of the packaged files."
@@ -1677,25 +1677,25 @@ if [ `type -p $PACMAN` -a "$NODEPS" = "0" ]; then
makedeplist=`checkdeps ${makedepends[@]}`
handledeps $makedeplist
if [ $? -gt 0 ]; then
-               exit 1
+               return 1
fi
# check deps again to make sure they were resolved
deplist=`checkdeps ${makedepends[@]}`
if [ ! -z "$deplist" ]; then
error "Failed to install missing buildtime dependencies."
-               exit 1
+               return 1
fi
msg "Checking Runtime Dependencies..."
deplist=`checkdeps ${depends[@]}`
handledeps $deplist
if [ $? -gt 0 ]; then
-               exit 1
+               return 1
fi
# check deps again to make sure they were resolved
deplist=`checkdeps ${depends[@]}`
if [ ! -z "$deplist" ]; then
error "Failed to install missing dependencies."
-               exit 1
+               return 1
fi
elif [ "$NODEPS" = "1" ]; then
warning "skipping dependency checks."
@@ -1721,12 +1721,12 @@ if [ "$NOUP2DATE" = "0" ]; then
if [ -z "$up2date" ]; then
$ECHO "   FAILED" >&2
error "There was no output!"
-                       exit 1
+                       return 1
else
if [ "$pkgver" != "$up2date" ]; then
$ECHO "   FAILED" >&2
error "Upstream version differs! ($pkgver != $up2date)"
-                       exit 1
+                       return 1
else
$ECHO "   Passed" >&2
fi
@@ -1782,7 +1782,7 @@ for netfile in "${source[@]}" "${signatures[@]}"; do
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
+                       return 1
fi
# try to download the file from the cache server
if [ -n "$RSYNCAGENT" -a -n "$CACHEURL" ]; then
@@ -1793,7 +1793,7 @@ for netfile in "${source[@]}" "${signatures[@]}"; do
if [ ! -f "$file" ]; then
error "Failed to download $file from cache while it is there"
msg "Aborting..."
-                                       exit 1
+                                       return 1
fi
fi
fi
@@ -1804,7 +1804,7 @@ for netfile in "${source[@]}" "${signatures[@]}"; do
if [ ! -f "$file" ]; then
error "Failed to download $file"
msg "Aborting..."
-                               exit 1
+                               return 1
fi
fi
if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
@@ -1840,7 +1840,7 @@ if [ "$GENSHA1" = "0" ]; then
done
if [ $errors -gt 0 ]; then
error "One or more files did not pass the validity check!"
-                                       exit 1
+                                       return 1
fi
else
warning "The sha1sum program is missing.  Cannot verify source files!"
@@ -1891,7 +1891,7 @@ if [ "$GENSHA1" = "0" ]; then
done
if [ $errors -gt 0 ]; then
error "One or more files did not pass the validity check!"
-                                       exit 1
+                                       return 1
fi
else
warning "The gpg program is missing.  Cannot verify source files!"
@@ -1913,7 +1913,7 @@ else
if [ "$GENSHA1" = "1" ]; then
if [ ! `type -p sha1sum` ]; then
error "Cannot find the sha1sum program."
-                       exit 1
+                       return 1
fi
msg "Generating SHA1sums for source files"
plain ""
@@ -1945,7 +1945,7 @@ else
cd ${startdir}
if [ "`grep -c sha1sums= ${BUILDSCRIPT}`" -gt 1 ]; then
error "${BUILDSCRIPT} contain more than one sha1sums, please update manually"
-                               exit 1
+                               return 1
fi
if grep -q sha1sums= ${BUILDSCRIPT}; then
msg "Updating \$sha1sums() in the $BUILDSCRIPT."
@@ -1961,7 +1961,7 @@ else
warning "Initial \$sha1sums() array does not exist, Aborting..."
fi
fi
-               exit 0
+               return 0
fi
fi

@@ -1983,7 +1983,7 @@ done

if [ "$NOBUILD" = "1" ]; then
msg "Sources are ready."
-       exit 0
+       return 0
fi

# use distcc if requested
@@ -2015,7 +2015,7 @@ if [ "$NOCCACHE" = "0" -a -d /usr/lib/ccache/bin -a ! 
"`check_option NOCCACHE`"
error "You installed ccache but you are not in the ccache group."
plain "Either add yourserlf to the ccache group or"
plain "use the -B option to disable ccache support."
-                       exit 1
+                       return 1
else
warning "The fst user is not in the ccache group, ccache will be disabled."
fi
@@ -2072,13 +2072,13 @@ for hook in "${_P_makepkg_prebuild_hooks[@]}" 
makepkg_timed_build "${_P_makepkg_
"$hook"
if [ $? -ne 0 ]; then
error "Build Failed.  Aborting..."
-               exit 2
+               return 2
fi
done

if [ -n "`find . -name "*|*"`" ]; then
error "Filenames in a package must not contain pipes!"
-       exit 2
+       return 2
fi

cd $startdir
@@ -2164,9 +2164,8 @@ msg "Finished making: $pkgname  (`date`)"

install_pkg

-exit 0
+       return 0
}

makepkg "$@"
exit $?
-
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to