aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-10-25 22:03:22 +0000
committermerakor <cem@ckyln.com>2021-10-25 22:03:22 +0000
commiteb16aede0f1d7c1c35f552181879fe794ebe7087 (patch)
treeec8cdcc0fee7e239ffca9b6099de9710e578a96a
parent667a5f7be3e01b0ccbb56098e37cf4153b2b3121 (diff)
downloadcpt-eb16aede0f1d7c1c35f552181879fe794ebe7087.tar.gz
_tsort: fix implementation
FossilOrigin-Name: 0f8ddafd39ca827197f99011564d0b4de9a62dce151e12914a7da9385ac3e369
-rw-r--r--src/cpt-lib.in15
1 files 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