pkg_subgraph_deps: support for dependency type, regression tests, doc
This commit is contained in:
parent
a5cbc1cf98
commit
cc76d2d43f
3 changed files with 98 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: pkg_subgraph_deps.1,v 1.3 2011/12/28 09:32:57 cheusov Exp $
|
||||
.\" $NetBSD: pkg_subgraph_deps.1,v 1.4 2011/12/29 14:54:57 cheusov Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2010 by Aleksey Cheusov (cheusov@tut.by)
|
||||
.\" Absolutely no warranty.
|
||||
|
@ -24,7 +24,12 @@ takes a dependency graph of packages on input and outputs subgraph
|
|||
.B pkg_subgraph_deps
|
||||
takes a dependency graph of packages on input and outputs a subgraph
|
||||
consisting of dependent (by default) packages, that is packages that depend
|
||||
on listed ones directly or indirectly. Sample of input is below
|
||||
on listed ones directly or indirectly. The dependency graph is represented
|
||||
as a list or graph edges (one per line) or isolated nodes (one per line).
|
||||
Graph edge consists of package pair with optional dependency type (first token).
|
||||
By default the dependency type is output if given on input.
|
||||
.EXAMPLE
|
||||
Example of input graph
|
||||
.VB
|
||||
|
||||
jpeg emacs
|
||||
|
@ -39,6 +44,24 @@ on listed ones directly or indirectly. Sample of input is below
|
|||
libjudy
|
||||
runawk
|
||||
|
||||
.VE
|
||||
.EXAMPLE
|
||||
Example of input graph
|
||||
.VB
|
||||
|
||||
DEPENDS lang/runawk parallel/paexec
|
||||
BUILD_DEPENDS devel/mk-configure parallel/paexec
|
||||
BUILD_DEPENDS sysutils/checkperms lang/runawk
|
||||
BUILD_DEPENDS sysutils/checkperms devel/libmaa
|
||||
DEPENDS devel/libmaa parallel/paexec
|
||||
BUILD_DEPENDS devel/mk-configure lang/runawk
|
||||
BUILD_DEPENDS sysutils/checkperms devel/libtool-base
|
||||
BUILD_DEPENDS lang/f2c devel/libtool-base
|
||||
BUILD_DEPENDS sysutils/checkperms devel/mk-configure
|
||||
BUILD_DEPENDS sysutils/checkperms parallel/paexec
|
||||
BUILD_DEPENDS devel/libtool-base devel/libmaa
|
||||
BUILD_DEPENDS sysutils/checkperms lang/f2c
|
||||
|
||||
.VE
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
|
|
|
@ -97,13 +97,34 @@ NF == 1 || (NF == 2 && $1 == $2) {
|
|||
next
|
||||
}
|
||||
|
||||
NF == 2 {
|
||||
if (opt_deps)
|
||||
edge [$2, ++count [$2]] = $1
|
||||
else
|
||||
edge [$1, ++count [$1]] = $2
|
||||
NF == 3 {
|
||||
dep_type = $1
|
||||
$1 = $2
|
||||
$2 = $3
|
||||
NF = 2
|
||||
}
|
||||
|
||||
nodes [$1] = nodes [$2] = 1
|
||||
NF == 2 {
|
||||
if (opt_deps){
|
||||
from = $2
|
||||
to = $1
|
||||
}else{
|
||||
from = $1
|
||||
to = $2
|
||||
}
|
||||
|
||||
if (dep_type)
|
||||
edge_types [from, to] = edge_types [from, to] " " dep_type
|
||||
dep_type = ""
|
||||
|
||||
if (edge_set [from, to]++)
|
||||
next
|
||||
|
||||
edge [from, ++count [from]] = to
|
||||
|
||||
nodes [from] = nodes [to] = 1
|
||||
|
||||
# print "!", dep_type, from, to
|
||||
next
|
||||
}
|
||||
|
||||
|
@ -128,7 +149,21 @@ function rec (pkg, i,to){
|
|||
}
|
||||
}
|
||||
|
||||
function print_edge (from, to, ok){
|
||||
function do_print_edge (type, from, to, v){
|
||||
if (opt_deps){
|
||||
# swap from and to
|
||||
v = to
|
||||
to = from
|
||||
from = v
|
||||
}
|
||||
|
||||
if (type)
|
||||
print type, from, to
|
||||
else
|
||||
print from, to
|
||||
}
|
||||
|
||||
function print_edge (from, to, ok,arr,i){
|
||||
# print "?", from, to
|
||||
if (opt_1 && opt_invert){
|
||||
ok = !((from SUBSEP to) in result_edge)
|
||||
|
@ -141,16 +176,23 @@ function print_edge (from, to, ok){
|
|||
}
|
||||
|
||||
if (ok){
|
||||
if (opt_deps)
|
||||
print to, from
|
||||
else
|
||||
print from, to
|
||||
# print "ft:", from, to
|
||||
if (!((from SUBSEP to) in edge_types)){
|
||||
do_print_edge("", from, to)
|
||||
}else{
|
||||
split(edge_types [from, to], arr)
|
||||
for (i in arr){
|
||||
do_print_edge(arr [i], from, to)
|
||||
}
|
||||
}
|
||||
|
||||
printed [from] = printed [to] = 1
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
delete edge_set
|
||||
|
||||
for (i in list){
|
||||
rec(i)
|
||||
result [i] = 1
|
||||
|
|
|
@ -215,3 +215,23 @@ head -n1 |
|
|||
cmp 'pkg_subgraph_deps #9' \
|
||||
'error: assertion failed: pkg_subgraph_deps: -xv1 is not allowed!
|
||||
'
|
||||
|
||||
pkg_subgraph_deps -r -f src_pkgs2.txt src_deps2.txt |
|
||||
sort |
|
||||
cmp 'pkg_subgraph_deps #10' \
|
||||
'BUILD_DEPENDS devel/gmake textproc/dict-server
|
||||
BUILD_DEPENDS devel/libtool-base devel/libmaa
|
||||
BUILD_DEPENDS devel/libtool-base textproc/dict-server
|
||||
BUILD_DEPENDS devel/libtool-base wip/libuxre
|
||||
BUILD_DEPENDS lang/perl5 textproc/dict-mueller7
|
||||
BUILD_DEPENDS sysutils/coreutils textproc/dict-mueller7
|
||||
BUILD_DEPENDS textproc/dict-server textproc/dict-mueller7
|
||||
BUILD_DEPENDS wip/heirloom-libcommon wip/libuxre
|
||||
DEPENDS devel/libmaa textproc/dict-server
|
||||
DEPENDS lang/f2c devel/libtool-base
|
||||
DEPENDS textproc/dict-server textproc/dict-mueller7
|
||||
DEPENDS wip/heirloom-common wip/heirloom-doc
|
||||
DEPENDS wip/heirloom-doc wip/heirloom-libcommon
|
||||
textproc/dictem
|
||||
wip/runawk
|
||||
'
|
||||
|
|
Loading…
Reference in a new issue