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:
parent
ba4c05aa00
commit
3b73edbaa5
1 changed files with 18 additions and 13 deletions
|
@ -1,24 +1,29 @@
|
||||||
# vim: set ts=4 sw=4 et:
|
# vim: set ts=4 sw=4 et:
|
||||||
|
|
||||||
bulk_sortdeps() {
|
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
|
tmpf=$(mktemp) || exit 1
|
||||||
|
|
||||||
# Now make the real dependency graph of all pkgs to build.
|
# Perform a topological sort of all build dependencies.
|
||||||
# Perform a topological sort of all pkgs but only with build dependencies
|
if [ $NRUNNING -eq $NPROCS ]; then
|
||||||
# that are found in previous step.
|
NRUNNING=0
|
||||||
|
wait
|
||||||
|
fi
|
||||||
|
|
||||||
for pkg in ${pkgs}; do
|
for pkg in ${pkgs}; do
|
||||||
_pkgs="$(./xbps-src show-build-deps $pkg 2>/dev/null)"
|
# async/parallel execution
|
||||||
found=0
|
(
|
||||||
for x in ${_pkgs}; do
|
for _pkg in $(./xbps-src show-build-deps $pkg 2>/dev/null); do
|
||||||
for f in ${pkgs}; do
|
echo "$pkg $_pkg" >> $tmpf
|
||||||
[[ $f == $x ]] && found=1 && echo "${pkg} ${f}" >> $tmpf
|
|
||||||
done
|
done
|
||||||
done
|
echo "$pkg $pkg" >> $tmpf
|
||||||
[[ $found -eq 0 ]] && echo "${pkg} ${pkg}" >> $tmpf
|
) &
|
||||||
done
|
done
|
||||||
|
wait
|
||||||
tsort $tmpf|tac
|
tsort $tmpf|tac
|
||||||
rm -f $tmpf
|
rm -f $tmpf
|
||||||
}
|
}
|
||||||
|
@ -30,7 +35,7 @@ bulk_build() {
|
||||||
export XBPS_ARCH=${XBPS_TARGET_MACHINE}
|
export XBPS_ARCH=${XBPS_TARGET_MACHINE}
|
||||||
fi
|
fi
|
||||||
if ! command -v xbps-checkvers &>/dev/null; then
|
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
|
fi
|
||||||
|
|
||||||
bulk_sortdeps "$(xbps-checkvers -f '%n' ${1} --distdir=$XBPS_DISTDIR)"
|
bulk_sortdeps "$(xbps-checkvers -f '%n' ${1} --distdir=$XBPS_DISTDIR)"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue