Cleaned up dependencies check functions in makepkg
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
80237630af
commit
85fbf528bb
1 changed files with 93 additions and 103 deletions
|
@ -239,141 +239,131 @@ checkdeps() {
|
||||||
}
|
}
|
||||||
|
|
||||||
handledeps() {
|
handledeps() {
|
||||||
local missingdeps=0
|
local R_DEPS_SATISFIED=0
|
||||||
local deplist="$*"
|
local R_DEPS_MISSING=1
|
||||||
local depstrip=""
|
|
||||||
local striplist=""
|
|
||||||
local haveperm=0
|
|
||||||
if [ "$EUID" = "0" -o "$SUDO" = 1 ]; then
|
|
||||||
haveperm=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
[ $# -eq 0 ] && return $R_DEPS_SATISFIED
|
||||||
|
|
||||||
|
local deplist="$*"
|
||||||
|
local striplist dep depstrip
|
||||||
for dep in $deplist; do
|
for dep in $deplist; do
|
||||||
depstrip=$(echo $dep | sed 's|=.*$||' | sed 's|>.*$||' | sed 's|<.*$||')
|
depstrip="$(echo $dep | sed -e 's|=.*$||' -e 's|>.&$||' -e 's|<.*$||')"
|
||||||
striplist="$striplist $depstrip"
|
striplist="$striplist $depstrip"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$deplist" != "" -a $haveperm -eq 1 ]; then
|
if [ "$DEP_SRC" = "0" -a "$DEP_BIN" = "0" ]; then
|
||||||
if [ "$DEP_BIN" = "1" -a "$SUDO" = "1" ]; then
|
return $R_DEPS_MISSING
|
||||||
# install missing deps from binary packages (using pacman -S and sudo)
|
elif [ "$SUDO" = 0 -a $EUID -gt 0 ]; then
|
||||||
msg "$(gettext "Installing missing dependencies...")"
|
warning "$(gettext "Cannot auto-install missing dependencies as a normal user without sudo!")"
|
||||||
sudo pacman $PACMAN_OPTS -S $striplist
|
plain "$(gettext "Run makepkg as root or with -S to resolve dependencies automatically.")"
|
||||||
if [ $? -eq 1 ]; then
|
return $R_DEPS_MISSING
|
||||||
error "$(gettext "Pacman failed to install missing dependencies.")"
|
fi
|
||||||
exit 1
|
|
||||||
|
if [ "$DEP_BIN" = "1" ]; then
|
||||||
|
# install missing deps from binary packages (using pacman -S)
|
||||||
|
msg "$(gettext "Installing missing dependencies...")"
|
||||||
|
local ret=0
|
||||||
|
|
||||||
|
if [ "$SUDO" = 1 ]; then
|
||||||
|
sudo pacman $PACMAN_OPTS -S $striplist || ret=$?
|
||||||
|
else
|
||||||
|
pacman $PACMAN_OPTS -S $striplist || ret=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $ret -ne 0 ]; then
|
||||||
|
error "$(gettext "Pacman failed to install missing dependencies.")"
|
||||||
|
exit 1 # TODO: error code
|
||||||
|
fi
|
||||||
|
elif [ "$DEP_SRC" = "1" ]; then
|
||||||
|
msg "$(gettext "Building missing dependencies...")"
|
||||||
|
|
||||||
|
# install missing deps by building them from source.
|
||||||
|
# we look for each package name in $SRCROOT and build it.
|
||||||
|
if [ "$SRCROOT" = "" ]; then
|
||||||
|
error "$(gettext "Source root cannot be found - please make sure it is specified in makepkg.conf")"
|
||||||
|
exit 1 # TODO: error code
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: handle version comparators (eg, glibc>=2.2.5)
|
||||||
|
for dep in $striplist; do
|
||||||
|
local candidates="$(find "$SRCROOT" -type d -name "$dep")"
|
||||||
|
if [ "$candidates" = "" ]; then
|
||||||
|
error "$(gettext "Could not find '%s' under %s")" "$dep" "$SRCROOT"
|
||||||
|
exit 1 # TODO: error code
|
||||||
fi
|
fi
|
||||||
elif [ "$DEP_BIN" = "1" ]; then
|
|
||||||
# install missing deps from binary packages (using pacman -S)
|
local makepkg_opts='-i -c -b'
|
||||||
msg "$(gettext "Installing missing dependencies...")"
|
[ "$RMDEPS" = "1" ] && makepkg_opts="$makepkg_opts -r"
|
||||||
pacman $PACMAN_OPTS -S $striplist
|
local ret packagedir
|
||||||
if [ $? -eq 1 ]; then
|
for packagedir in $candidates; do
|
||||||
error "$(gettext "Pacman failed to install missing dependencies.")"
|
if [ -f "$packagedir/$BUILDSCRIPT" ]; then
|
||||||
exit 1
|
cd "$packagedir"
|
||||||
fi
|
ret=0
|
||||||
elif [ "$DEP_SRC" = "1" ]; then
|
PKGDEST="$PKGDEST" makepkg $makepkg_opts || ret=$?
|
||||||
# install missing deps by building them from source.
|
[ $ret -eq 0 ] && continue 2
|
||||||
# we look for each package name in $SRCROOT and build it.
|
|
||||||
if [ "$SRCROOT" = "" ]; then
|
|
||||||
error "$(gettext "Source root cannot be found - ensure it is specified in makepkg.conf.")"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# TODO: handle version comparators (eg, glibc>=2.2.5)
|
|
||||||
msg "$(gettext "Building missing dependencies...")"
|
|
||||||
for dep in $striplist; do
|
|
||||||
candidates=$(find $SRCROOT -type d -name "$dep")
|
|
||||||
if [ "$candidates" = "" ]; then
|
|
||||||
error "$(gettext "Could not find \"%s\" under %s")" "$dep" "$SRCROOT"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
success=0
|
|
||||||
for packagedir in $candidates; do
|
|
||||||
if [ -f "$packagedir/$BUILDSCRIPT" ]; then
|
|
||||||
cd "$packagedir"
|
|
||||||
if [ "$RMDEPS" = "1" ]; then
|
|
||||||
PKGDEST="$PKGDEST" makepkg -i -c -b -r
|
|
||||||
else
|
|
||||||
PKGDEST="$PKGDEST" makepkg -i -c -b
|
|
||||||
fi
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
success=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ "$success" = "0" ]; then
|
|
||||||
error "$(gettext "Failed to build \"%s\"")" "$dep"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
|
||||||
missingdeps=1
|
error "$(gettext "Failed to build '%s'")" "$dep"
|
||||||
fi
|
exit 1 # TODO: error code
|
||||||
elif [ "$deplist" != "" -a $haveperm -eq 0 ]; then
|
done
|
||||||
if [ "$DEP_SRC" = "1" -o "$DEP_BIN" = "1" ]; then
|
|
||||||
warning "$(gettext "Cannot auto-install missing dependencies as a normal user without sudo!")"
|
|
||||||
plain "$(gettext "Run makepkg as root or with -S to resolve dependencies automatically.")"
|
|
||||||
fi
|
|
||||||
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
|
local script
|
||||||
do
|
for script in /etc/profile.d/*.sh; do
|
||||||
if [ -x $i ]; then
|
if [ -x $script ]; then
|
||||||
. $i &>/dev/null
|
source $script &>/dev/null
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
return $missingdeps
|
return $R_DEPS_SATISFIED
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvedeps() {
|
resolvedeps() {
|
||||||
deplist=""
|
local R_DEPS_SATISFIED=0
|
||||||
newdeplist=""
|
local R_DEPS_MISSING=0
|
||||||
|
|
||||||
deplist=$(checkdeps $*)
|
deplist="$(checkdeps $*)"
|
||||||
if [ -n "${deplist}" ]; then
|
[ "$deplist" = "" ] && return $R_DEPS_SATISFIED
|
||||||
handledeps $deplist
|
|
||||||
if [ $? -eq 0 ]; then
|
if handledeps $deplist; then
|
||||||
# check deps again to make sure they were resolved
|
# check deps again to make sure they were resolved
|
||||||
newdeplist=$(checkdeps $*)
|
deplist="$(checkdeps $*)"
|
||||||
if [ -n "${newdeplist}" ]; then
|
[ "$deplist" = "" ] && return $R_DEPS_SATISFIED
|
||||||
error "$(gettext "Failed to install all missing dependencies.")"
|
elif [ "$DEP_BIN" = "1" -o "$DEP_SRC" = "1" ]; then
|
||||||
fi
|
error "$(gettext "Failed to install all missing dependencies.")"
|
||||||
else
|
|
||||||
newdeplist="$deplist"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if new dep list is not empty, print the list
|
msg "$(gettext "Missing Dependencies:")"
|
||||||
if [ -n "${newdeplist}" ]; then
|
local dep
|
||||||
msg "$(gettext "Missing Dependencies:")"
|
for dep in $deplist; do
|
||||||
for dep in ${newdeplist}; do
|
msg2 "$dep"
|
||||||
msg2 "${dep}"
|
done
|
||||||
done
|
|
||||||
return 1
|
return $R_DEPS_MISSING
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# fix flyspray bug #5923
|
# fix flyspray bug #5923
|
||||||
removedeps() {
|
removedeps() {
|
||||||
|
[ "$RMDEPS" = "0" ] && return
|
||||||
|
[ "$SUDO" = "0" -a $EUID -gt 0 ] && return
|
||||||
|
|
||||||
# runtimedeps and buildtimedeps are set when resolving deps
|
# runtimedeps and buildtimedeps are set when resolving deps
|
||||||
local deplist="$runtimedeps $buildtimedeps"
|
local deplist="$runtimedeps $buildtimedeps"
|
||||||
local depstrip=""
|
|
||||||
local striplist=""
|
|
||||||
|
|
||||||
|
[ "$deplist" = "" ] && return
|
||||||
|
|
||||||
|
local striplist dep depstrip
|
||||||
for dep in $deplist; do
|
for dep in $deplist; do
|
||||||
depstrip=$(echo $dep | sed 's|=.*$||' | sed 's|>.*$||' | sed 's|<.*$||')
|
depstrip="$(echo $dep | sed -e 's|=.*$||' -e 's|>.&$||' -e 's|<.*$||')"
|
||||||
striplist="$striplist $depstrip"
|
striplist="$striplist $depstrip"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$RMDEPS" = "1" -a "$SUDO" = "1" -a -n "$deplist" ]; then
|
msg "Removing installed dependencies..."
|
||||||
msg "$(gettext "Removing installed dependencies...")"
|
if [ "$SUDO" = "1" ]; then
|
||||||
sudo pacman $PACMAN_OPTS -Rs $striplist
|
sudo pacman $PACMAN_OPTS -Rs $striplist
|
||||||
elif [ "$RMDEPS" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" -a -n "$deplist" ]; then
|
else
|
||||||
msg "$(gettext "Removing installed dependencies...")"
|
|
||||||
pacman $PACMAN_OPTS -Rs $striplist
|
pacman $PACMAN_OPTS -Rs $striplist
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue