get_missing_deps is extremely slow
the implementation:
get_missing_deps() {
local cmd="$APK info --quiet --installed $1"
shift
while [ "$1" ]; do
local cp=${1#\!}
if [ $cp != $1 ]; then
if $cmd $cp; then
error "Conflicting package installed: $cp"
return 1
fi
elif ! $cmd $1; then
echo $1
fi
shift
done
}
calls apk info ..
for every single thing listed in the dependency list. however, i'm not sure what the point of this check is at all.
for one- the conflict check is pointless. passing a !
dep to apk when adding the dependencies will also fail on conflict. all that adds is printing 'conflicting package installed'- but this would already be clear from an apk add
command in itself too.
for the other, only adding things that are 'missing' also seems weird- just adding the full list is always fine?
this is then used in
# build and install dependencies
builddeps() {
local pkg= i= BUILD_BASE=
[ -n "$nodeps" ] && return 0
msg "Analyzing dependencies..."
case "$BOOTSTRAP" in
no*) BUILD_BASE="";;
*) if cross_creating || cross_compiling; then
BUILD_BASE="build-base-$CTARGET_ARCH"
else
BUILD_BASE="build-base"
fi
esac
calcdeps "$BUILD_BASE"
# shall ccache be added?
[ -n "$USE_CCACHE" ] && builddeps="$builddeps ccache"
# find which deps are missing
local mbd mhd missing
mbd=$(get_missing_deps "" $builddeps) || return 1
mhd=$(get_missing_deps "--root $CBUILDROOT --arch $CTARGET_ARCH" $hostdeps) || return 1
missing=$(echo $mbd $mhd)
if [ -z "$install_deps" ]; then
# if we dont have any missing deps we are done now
[ -z "$missing" ] && return 0
error "Missing dependencies (use -r to autoinstall them): $missing"
return 1
fi
uninstall_after=".makedepends-$pkgname $uninstall_after"
# make a --simulate run first to detect missing deps
# apk-tools --virtual is no goot at reporting those.
deps "--quiet --simulate" || return 1
deps || return 1
}
which actually calls this more than once.
was there something this specifically had to do a long time ago? i feel like it would be much simpler (and, more importantly, faster, by not taking 10 seconds on a large makedepends list on slower hardware in the checks) to just add the dep list unconditionally, or, only do these checks when -r
is not passed (so something might be missing, and check for it, but with -r
we're adding it, so just add it without the check).
since i don't know the history, i wrote this out here instead of patching it.