From d19ef9704c085af8ff9a4fb37bad447963dfadfc Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 21 Oct 2019 20:18:34 +0200 Subject: [PATCH] xbps-src: revert to previous bulk_sortdeps code This should restore sort-dependencies behavior back to its former behavior of not including all of the build dependencies not in the input list in its listing. --- common/xbps-src/shutils/bulk.sh | 60 +++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh index ed5c4ce192d..e5f3443c010 100644 --- a/common/xbps-src/shutils/bulk.sh +++ b/common/xbps-src/shutils/bulk.sh @@ -1,28 +1,54 @@ # vim: set ts=4 sw=4 et: +bulk_getlink() { + local p="${1##*/}" + local target="$(readlink $XBPS_SRCPKGDIR/$p)" + + if [ $? -eq 0 -a -n "$target" ]; then + p=$target + fi + echo $p +} + bulk_sortdeps() { - local pkgs="$@" - local pkg _pkg - local NPROCS=$(($(nproc)*2)) - local NRUNNING=0 + local _pkgs _pkg pkgs pkg found f x tmpf - tmpf=$(mktemp) || exit 1 + _pkgs="$@" + # Iterate over the list and make sure that only real pkgs are + # added to our pkglist. + for pkg in ${_pkgs}; do + found=0 + f=$(bulk_getlink $pkg) + for x in ${pkgs}; do + if [ "$x" = "${f}" ]; then + found=1 + break + fi + done + if [ $found -eq 0 ]; then + pkgs+="${f} " + fi + done - # Perform a topological sort of all *direct* build dependencies. + 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. for pkg in ${pkgs}; do - if [ $NRUNNING -eq $NPROCS ]; then - NRUNNING=0 - wait - fi - NRUNNING=$((NRUNNING+1)) - ( - for _pkg in $(./xbps-src show-build-deps $pkg 2>/dev/null); do - echo "$pkg $_pkg" >> $tmpf + _pkgs="$(./xbps-src show-build-deps $pkg 2>/dev/null)" + found=0 + for x in ${_pkgs}; do + _pkg=$(bulk_getlink $x) + for f in ${pkgs}; do + if [ "${f}" != "${_pkg}" ]; then + continue + fi + found=1 + echo "${pkg} ${f}" >> $tmpf done - echo "$pkg $pkg" >> $tmpf - ) & + done + [ $found -eq 0 ] && echo "${pkg} ${pkg}" >> $tmpf done - wait tsort $tmpf|tac rm -f $tmpf }