From eb16aede0f1d7c1c35f552181879fe794ebe7087 Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 25 Oct 2021 22:03:22 +0000 Subject: _tsort: fix implementation FossilOrigin-Name: 0f8ddafd39ca827197f99011564d0b4de9a62dce151e12914a7da9385ac3e369 --- src/cpt-lib.in | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cpt-lib.in b/src/cpt-lib.in index 32ce2e1..1280765 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -76,6 +76,10 @@ colors_enabled() { esac } +_dep_append() { + dep_graph=$(printf '%s\n%s %s\n' "$dep_graph" "$@" ;) +} + _tsort() { # Return a linear reverse topological sort of the piped input, so we # generate a proper build order. Returns 1 if a dependency cycle occurs. @@ -884,6 +888,7 @@ pkg_depends() { # listed first and then the parents in reverse order. contains "$pkgs" "$1" || { pkgs="$pkgs $1 " + [ "$2" = raw ] && _dep_append "$1" "$1" while read -r dep type || [ "$dep" ]; do # Skip comments and empty lines. [ "${dep##\#*}" ] || continue @@ -898,14 +903,12 @@ pkg_depends() { # Filter out non-explicit, already installed dependencies if called # from 'pkg_build()'. - [ "$pkg_build" ] && (pkg_list "$1" >/dev/null) && continue + [ "$pkg_build" ] && (pkg_list "$dep" >/dev/null) && continue if [ "$2" = explicit ] || [ "$3" ]; then - dep_graph="$dep_graph - $dep $dep" + _dep_append "$dep" "$dep" else - dep_graph="$dep_graph - $1 $dep" + _dep_append "$1" "$dep" fi # Recurse through the dependencies of the child packages. Forward @@ -932,7 +935,7 @@ pkg_order() { order=; redro=; deps= for pkg do case $pkg in - *.tar.*) deps="$deps $pkg " ;; + *.tar.*) _dep_append "$pkg" "$pkg" ;; *) pkg_depends "$pkg" raw esac done pkg_depends_commit -- cgit v1.2.3