scripts/makepkg.in: Clean up.

* Move create_xdelta() outside of fakeroot run.
	* Clean up dep check functions.
	* Clean up extract_sources().

Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Andrew Fyfe 2007-06-02 17:41:15 +01:00 committed by Dan McGee
parent 508d5cb3a3
commit 3b1e67628e

View file

@ -231,9 +231,9 @@ handledeps() {
[ $# -eq 0 ] && return $R_DEPS_SATISFIED [ $# -eq 0 ] && return $R_DEPS_SATISFIED
local deplist="$*" local deplist="$*"
local striplist dep depstrip local dep depstrip striplist
for dep in $deplist; do for dep in $deplist; do
depstrip="$(echo $dep | sed -e 's|=.*$||' -e 's|>.&$||' -e 's|<.*$||')" depstrip="$(echo $dep | sed -e 's|=.*$||' -e 's|>.*$||' -e 's|<.*$||')"
striplist="$striplist $depstrip" striplist="$striplist $depstrip"
done done
@ -303,11 +303,16 @@ handledeps() {
} }
resolve_deps() { resolve_deps() {
# $pkgdeps is a GLOBAL variable, used by remove_deps()
local R_DEPS_SATISFIED=0 local R_DEPS_SATISFIED=0
local R_DEPS_MISSING=0 local R_DEPS_MISSING=1
deplist="$(check_deps $*)" local deplist="$(check_deps $*)"
[ "$deplist" = "" ] && return $R_DEPS_SATISFIED if [ "$deplist" = "" ]; then
return $R_DEPS_SATISFIED
else
pkgdeps="$pkgdeps $deplist"
fi
if handledeps $deplist; then if handledeps $deplist; then
# check deps again to make sure they were resolved # check deps again to make sure they were resolved
@ -328,24 +333,21 @@ resolve_deps() {
# fix flyspray bug #5923 # fix flyspray bug #5923
remove_deps() { remove_deps() {
# $pkgdeps is a GLOBAL variable, set by resolve_deps()
[ "$RMDEPS" = "0" ] && return [ "$RMDEPS" = "0" ] && return
[ "$pkgdeps" = "" ] && return
# runtimedeps and buildtimedeps are set when resolving deps local dep depstrip deplist
local deplist="$runtimedeps $buildtimedeps" for dep in $pkgdeps; do
depstrip=$(echo $dep | sed -e 's|=.*$||' -e 's|>.*$||' -e 's|<.*$||')
[ "$deplist" = "" ] && return deplist="$deplist $depstrip"
local striplist dep depstrip
for dep in $deplist; do
depstrip="$(echo $dep | sed -e 's|=.*$||' -e 's|>.&$||' -e 's|<.*$||')"
striplist="$striplist $depstrip"
done done
msg "Removing installed dependencies..." msg "Removing installed dependencies..."
if [ "$ASROOT" = "0" ]; then if [ "$ASROOT" = "0" ]; then
sudo pacman $PACMAN_OPTS -Rs $striplist sudo pacman $PACMAN_OPTS -Rs $deplist
else else
pacman $PACMAN_OPTS -Rs $striplist pacman $PACMAN_OPTS -Rs $deplist
fi fi
} }
@ -508,18 +510,21 @@ extract_sources() {
cmd="gunzip -d -f $file" ;; cmd="gunzip -d -f $file" ;;
*application/x-bzip*) *application/x-bzip*)
cmd="bunzip2 -f $file" ;; cmd="bunzip2 -f $file" ;;
*)
# Don't know what to use to extract this file,
# skip to the next file
continue;;
esac esac
if [ "$cmd" != "" ]; then local ret=0
msg2 "$cmd" msg2 "$cmd"
$cmd $cmd || ret=$?
if [ $? -ne 0 ]; then if [ $ret -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
if [ "$unziphack" != "1" -o $? -ne 1 ]; then if [ $unziphack -ne 1 -o $ret -ne 1 ]; then
error "$(gettext "Failed to extract %s")" "$file" error "$(gettext "Failed to extract %s")" "$file"
msg "$(gettext "Aborting...")" msg "$(gettext "Aborting...")"
exit 1 exit 1
fi
fi fi
fi fi
done done
@ -746,8 +751,6 @@ create_package() {
error "$(gettext "Failed to create package file.")" error "$(gettext "Failed to create package file.")"
exit 1 # TODO: error code exit 1 # TODO: error code
fi fi
create_xdelta "$pkg_file"
} }
create_xdelta() { create_xdelta() {
@ -1177,27 +1180,14 @@ if [ "$NODEPS" = "1" -o "$GENINTEG" = "1" -o "$NOBUILD" = "1" -o "$REPKG" = "1"
fi fi
# skip printing a warning message for the others: geninteg, nobuild, repkg # skip printing a warning message for the others: geninteg, nobuild, repkg
elif [ $(type -p pacman) ]; then elif [ $(type -p pacman) ]; then
unset pkgdeps # Set by resolve_deps() and used by remove_deps()
deperr=0 deperr=0
# these two variables are needed later by remove_deps
unset runtimedeps buildtimedeps
msg "$(gettext "Checking Runtime Dependencies...")" msg "$(gettext "Checking Runtime Dependencies...")"
resolve_deps ${depends[@]} resolve_deps ${depends[@]} || deperr=1
ret=$?
# deplist is a global variable set by resolve_deps
runtimedeps="$deplist"
if [ "$ret" != "0" ]; then
deperr=1
fi
msg "$(gettext "Checking Buildtime Dependencies...")" msg "$(gettext "Checking Buildtime Dependencies...")"
resolve_deps ${makedepends[@]} resolve_deps ${makedepends[@]} || deperr=1
ret=$?
# deplist is a global variable set by resolve_deps
buildtimedeps="$deplist"
if [ "$ret" != "0" ]; then
deperr=1
fi
if [ $deperr -eq 1 ]; then if [ $deperr -eq 1 ]; then
error "$(gettext "could not resolve all dependencies.")" error "$(gettext "could not resolve all dependencies.")"
@ -1258,6 +1248,8 @@ else
[ $ret -ne 0 ] && exit $ret [ $ret -ne 0 ] && exit $ret
unset ret unset ret
fi fi
create_xdelta "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
fi fi
cd "$startdir" cd "$startdir"