Commit 495dac7f authored by Timo Teräs's avatar Timo Teräs

abuild: unify dependency installation and removal code

this fixes cross deps such as "CHOST=armhf abuild deps"
to work properly.

if makedepends is not defined the following default
will be used (as that's the definition cross-build
aware apkbuilds use):
  makedepends="$makedepends_build $makedepends_host"
parent a01d11d9
...@@ -79,12 +79,7 @@ cleanup() { ...@@ -79,12 +79,7 @@ cleanup() {
deps) deps)
if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then
msg "Uninstalling dependencies..." msg "Uninstalling dependencies..."
$SUDO_APK del --quiet $apk_opt_wait $uninstall_after undeps
if cross_compiling; then
$SUDO_APK del --root "$CBUILDROOT" \
--no-scripts --quiet $apk_opt_wait \
$uninstall_after
fi
fi fi
;; ;;
esac esac
...@@ -1758,33 +1753,41 @@ trace_makedepends() { ...@@ -1758,33 +1753,41 @@ trace_makedepends() {
' '
} }
# build and install dependencies calcdeps() {
builddeps() { builddeps=
local pkg= i= missing= hostdeps=
local hostdeps= builddeps= installed_hostdeps= installed_builddeps=
[ -n "$nodeps" ] && return 0
msg "Analyzing dependencies..."
# add depends unless it is a subpackage or package itself
if cross_compiling && [ -n "$makedepends_build" -o -n "$makedepends_host" ]; then if cross_compiling && [ -n "$makedepends_build" -o -n "$makedepends_host" ]; then
builddeps="$makedepends_build" for i in $1 $makedepends_build; do
for i in $BUILD_BASE; do list_has $i $hostdeps && continue
[ "$pkgname" = "${i%%[<>=]*}" ] && continue builddeps="$builddeps $i"
subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i"
done done
for i in $depends $makedepends_host; do for i in $depends $makedepends_host; do
[ "$pkgname" = "${i%%[<>=]*}" ] && continue [ "$pkgname" = "${i%%[<>=]*}" ] && continue
list_has $i $hostdeps && continue
subpackages_has ${i%%[<>=]*} || hostdeps="$hostdeps $i" subpackages_has ${i%%[<>=]*} || hostdeps="$hostdeps $i"
done done
else else
for i in $BUILD_BASE $depends $makedepends; do [ -z "$makedepends" ] && makedepends="$makedepends_build $makedepends_host"
for i in $1 $depends $makedepends; do
[ "$pkgname" = "${i%%[<>=]*}" ] && continue [ "$pkgname" = "${i%%[<>=]*}" ] && continue
list_has $i $builddeps && continue
subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i" subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i"
done done
fi fi
}
# build and install dependencies
builddeps() {
local pkg= i= missing=
local installed_hostdeps= installed_builddeps=
[ -n "$nodeps" ] && return 0
msg "Analyzing dependencies..."
calcdeps "$BUILD_BASE"
installed_builddeps=$($APK info --installed $builddeps) installed_builddeps=$($APK info --installed $builddeps)
[ -n "$hostdeps" ] && installed_hostdeps=$($APK info --root "$CBUILDROOT" --installed $hostdeps) [ -n "$CBUILDROOT" -a -n "$hostdeps" ] && installed_hostdeps=$($APK info --root "$CBUILDROOT" --installed $hostdeps)
# find which deps are missing # find which deps are missing
for i in $builddeps; do for i in $builddeps; do
...@@ -1819,27 +1822,17 @@ builddeps() { ...@@ -1819,27 +1822,17 @@ builddeps() {
if [ -n "$install_deps" ] && [ -z "$recursive" ]; then if [ -n "$install_deps" ] && [ -z "$recursive" ]; then
# make a --simulate run first to detect missing deps # make a --simulate run first to detect missing deps
# apk-tools --virtual is no goot at reporting those. # apk-tools --virtual is no goot at reporting those.
$SUDO_APK add --repository "$REPODEST/$repo" $apk_opt_wait \ deps "--quiet --simulate" || return 1
--simulate --quiet $builddeps || return 1 deps || return 1
if cross_compiling; then
$SUDO_APK add --root "$CBUILDROOT" --repository "$REPODEST/$repo" $apk_opt_wait \
--simulate --quiet $hostdeps || return 1
fi
$SUDO_APK add --repository "$REPODEST/$repo" $apk_opt_wait \
--virtual .makedepends-$pkgname $builddeps || return 1
if cross_compiling; then
$SUDO_APK add --root "$CBUILDROOT" --repository "$REPODEST/$repo" $apk_opt_wait \
--no-scripts --virtual .makedepends-$pkgname $hostdeps || return 1
fi
return 0 return 0
fi fi
[ -z "$recursive" ] && return 1
if [ -n "$CBUILDROOT" ]; then if [ -n "$CBUILDROOT" ]; then
error "Recursive rebuilding is not supported when cross compiling." error "Recursive rebuilding (-R) is not supported when cross compiling."
return 1 return 1
fi fi
[ -z "$recursive" ] && return 1
# find dependencies that are installed but missing in repo. # find dependencies that are installed but missing in repo.
for i in $builddeps; do for i in $builddeps; do
...@@ -2012,22 +2005,28 @@ install_has() { ...@@ -2012,22 +2005,28 @@ install_has() {
} }
deps() { deps() {
local builddeps= i [ -z "$hostdeps" -a -z "$builddeps" ] && calcdeps
for i in $depends $makedepends; do
[ "$pkgname" = "${i%%[<>=]*}" ] && continue local _quiet="$1"
subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i" [ -z "$_quiet" ] && msg "Installing for build:$builddeps"
done $SUDO_APK add $_quiet $apk_opt_wait --repository "$REPODEST/$repo" \
$SUDO_APK add $apk_opt_wait --repository "$REPODEST/$repo" \
--virtual .makedepends-$pkgname \ --virtual .makedepends-$pkgname \
$builddeps $builddeps
if [ -n "$CBUILDROOT" ]; then
[ -z "$_quiet" ] && msg "Installing for host:$hostdeps"
$SUDO_APK add $_quiet --root "$CBUILDROOT" --repository "$REPODEST/$repo" $apk_opt_wait \
--no-scripts --virtual .makedepends-$pkgname $hostdeps || return 1
fi
} }
undeps (){ undeps() {
$SUDO_APK del $apk_opt_wait .makedepends-$pkgname local _quiet="$@"
if cross_compiling; then $SUDO_APK del $_quiet $apk_opt_wait .makedepends-$pkgname
$SUDO_APK del --root "$CBUILDROOT" $apk_opt_wait \ if [ -n "$CBUILDROOT" ]; then
$SUDO_APK del $_quiet --root "$CBUILDROOT" $apk_opt_wait \
--no-scripts .makedepends-$pkgname --no-scripts .makedepends-$pkgname
fi fi
return 0
} }
# compat # compat
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment