xbps-src: improve bulk_sortdeps().

./xbps-src sort-dependencies $(./xbps-src show-build-deps xbps)

0.202s vs 0.514s
This commit is contained in:
Juan RP 2019-07-04 11:00:13 +02:00 committed by Jürgen Buchmüller
parent ba4c05aa00
commit 3b73edbaa5
1 changed files with 18 additions and 13 deletions

View File

@ -1,24 +1,29 @@
# vim: set ts=4 sw=4 et:
bulk_sortdeps() {
local _pkgs _pkg pkgs pkg found f x tmpf
local pkgs="$@"
local pkg _pkg
local NPROCS=$(($(nproc)*2))
local NRUNNING=0
pkgs="$@"
tmpf=$(mktemp) || exit 1
# Now make the real dependency graph of all pkgs to build.
# Perform a topological sort of all pkgs but only with build dependencies
# that are found in previous step.
# Perform a topological sort of all build dependencies.
if [ $NRUNNING -eq $NPROCS ]; then
NRUNNING=0
wait
fi
for pkg in ${pkgs}; do
_pkgs="$(./xbps-src show-build-deps $pkg 2>/dev/null)"
found=0
for x in ${_pkgs}; do
for f in ${pkgs}; do
[[ $f == $x ]] && found=1 && echo "${pkg} ${f}" >> $tmpf
# async/parallel execution
(
for _pkg in $(./xbps-src show-build-deps $pkg 2>/dev/null); do
echo "$pkg $_pkg" >> $tmpf
done
done
[[ $found -eq 0 ]] && echo "${pkg} ${pkg}" >> $tmpf
echo "$pkg $pkg" >> $tmpf
) &
done
wait
tsort $tmpf|tac
rm -f $tmpf
}
@ -30,7 +35,7 @@ bulk_build() {
export XBPS_ARCH=${XBPS_TARGET_MACHINE}
fi
if ! command -v xbps-checkvers &>/dev/null; then
msg_error "xbps-src: cannot find xbps-checkvers(8) command!\n"
msg_error "xbps-src: cannot find xbps-checkvers(1) command!\n"
fi
bulk_sortdeps "$(xbps-checkvers -f '%n' ${1} --distdir=$XBPS_DISTDIR)"