diff options
author | dbj <dbj@pkgsrc.org> | 2009-01-05 02:37:05 +0000 |
---|---|---|
committer | dbj <dbj@pkgsrc.org> | 2009-01-05 02:37:05 +0000 |
commit | 06b5331c6d1a60aae3814c7f90b5d278b55d1e22 (patch) | |
tree | d4cd1e3ef9b0f62a633e8abaefb6fdb11c426eb9 /mk | |
parent | 150d47c21802cf65275533ba48bb94914fbbc7c5 (diff) | |
download | pkgsrc-06b5331c6d1a60aae3814c7f90b5d278b55d1e22.tar.gz |
this script was not visiting packages in the proper order when subpackages
had common dependencies. This change hopefully fixes that.
Diffstat (limited to 'mk')
-rwxr-xr-x | mk/scripts/depends-depth-first.awk | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/mk/scripts/depends-depth-first.awk b/mk/scripts/depends-depth-first.awk index ff82427e2cd..1021b5484fc 100755 --- a/mk/scripts/depends-depth-first.awk +++ b/mk/scripts/depends-depth-first.awk @@ -1,6 +1,6 @@ #!/usr/bin/awk -f # -# $NetBSD: depends-depth-first.awk,v 1.5 2006/01/21 22:16:13 jlam Exp $ +# $NetBSD: depends-depth-first.awk,v 1.6 2009/01/05 02:37:05 dbj Exp $ # # Copyright (c) 2006 The NetBSD Foundation, Inc. # All rights reserved. @@ -187,47 +187,56 @@ function main( cmd, depends_pkgpath, dir, pkgpath) { # # Push the given package directories onto the stack. while (ARGC >= ARGSTART) { + ARGC--; cmd = TEST " -d " PKGSRCDIR "/" ARGV[ARGC] if (system(cmd) == 0) { if (do_root == 0) { root[ARGV[ARGC]] = ARGV[ARGC] } - push(dir_stack, ARGV[ARGC]) + if (status[ARGV[ARGC]] == "") { + push(dir_stack, ARGV[ARGC]) + } } - } - # Depth-first traversal of dependency graph. - while (!empty(dir_stack)) { - pkgpath = top(dir_stack) - if (status[pkgpath] == "walked") { - if (walk_order == "postfix") { + # Depth-first traversal of dependency graph. + while (!empty(dir_stack)) { + pkgpath = top(dir_stack) + + if (status[pkgpath] != "") { + if (walk_order == "postfix" && status[pkgpath] != "visited") { + status[pkgpath] = "visited" + visit(pkgpath) + } + pop(dir_stack) + continue + } + + status[pkgpath] = "walked" + + if (walk_order == "prefix" && status[pkgpath] != "visited") { + status[pkgpath] = "visited" visit(pkgpath) } - pop(dir_stack) - continue - } - status[pkgpath] = "walked" - if (walk_order == "prefix") { - visit(pkgpath) - } - # Grab the "depends_type" dependencies of the current - # package and push them onto the stack. We use the - # "show-depends-pkgpaths" target to fetch this information. - # - dir = PKGSRCDIR "/" pkgpath - cmd = "if " TEST " -d " dir "; then cd " dir " && " MAKE " show-depends-pkgpaths DEPENDS_TYPE=\"" depends_type "\"; fi" - while (cmd | getline depends_pkgpath) { - if (status[depends_pkgpath] == "") { - status[depends_pkgpath] = "pushed" - push(tmp_stack, depends_pkgpath) + # Grab the "depends_type" dependencies of the current + # package and push them onto the stack. We use the + # "show-depends-pkgpaths" target to fetch this information. + # + dir = PKGSRCDIR "/" pkgpath + cmd = "if " TEST " -d " dir "; then cd " dir " && " MAKE " show-depends-pkgpaths DEPENDS_TYPE=\"" depends_type "\"; fi" + while (cmd | getline depends_pkgpath) { + if (status[depends_pkgpath] == "") { + push(tmp_stack, depends_pkgpath) + } + } + close(cmd) + # This isn't really necessary, but does preserve child traversal + # order as presented by show-depends-pkgpaths + while (!empty(tmp_stack)) { + push(dir_stack, top(tmp_stack)) + pop(tmp_stack) } - } - close(cmd) - while (!empty(tmp_stack)) { - push(dir_stack, top(tmp_stack)) - pop(tmp_stack) } } exit 0 @@ -261,7 +270,7 @@ function visit(pkgpath, cmd, dir) { # top(stack) # push(stack, element) # pop(stack) -# The well-known functions associated with a LIFO. +# The well-known functions associated with a STACK. # ###################################################################### function empty(stack) { |