pkg_subgraph_deps: new option -1 was added, more regression tests

This commit is contained in:
Aleksey Cheusov 2011-12-28 09:32:57 +00:00 committed by Thomas Klausner
parent 1eb986359d
commit 3967f22d52
3 changed files with 99 additions and 11 deletions

View file

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_subgraph_deps.1,v 1.2 2010/11/07 13:56:17 cheusov Exp $
.\" $NetBSD: pkg_subgraph_deps.1,v 1.3 2011/12/28 09:32:57 cheusov Exp $
.\"
.\" Copyright (c) 2010 by Aleksey Cheusov (cheusov@tut.by)
.\" Absolutely no warranty.
@ -65,6 +65,9 @@ Output only packages without information about dependencies between them.
.B "-v"
Invert condition.
.TP
.B "-1"
Only direct dependencies or dependent packages are output.
.TP
.B "-t"
Produce output compatible with
.B tsort(1)

View file

@ -1,6 +1,6 @@
#!/usr/bin/env runawk
# Copyright (c) 2010, Aleksey Cheusov <vle@gmx.net>
# Copyright (c) 2010-2011, Aleksey Cheusov <vle@gmx.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -45,6 +45,7 @@
# -v invert condition
# -n output nodes, not edges
# -t produce output compatible with tsort(1) command
# -1 output only direct dependent packages or dependencies
# Input graph is represented by list of edges and isolated nodes, e.g.
# devel/gmake textproc/dict-client
# devel/gmake textproc/dict-server
@ -70,6 +71,7 @@ BEGIN {
opt_invert = getarg("v")
opt_nodes = getarg("n")
opt_tsort = getarg("t")
opt_1 = getarg("1")
if (!fn && !pkgs){
print "-f or -p are mandatory!" > "/dev/stderr"
@ -113,14 +115,29 @@ function rec (pkg, i,to){
result [pkg] = 1
for (i=1; i <= count [pkg]; ++i){
to = edge [pkg, i]
rec(to)
# print "!", pkg, to
if (opt_1)
result_edge [pkg, to] = 0
else
rec(to)
result [to] = 1
}
}
function print_edge (from, to){
if ((from in result) && (to in result)){
print from, to
function print_edge (from, to, ok){
# print "?", from, to
ok = ((from in result) && (to in result))
if (ok && opt_1 && !opt_invert)
ok = ((from SUBSEP to) in result_edge)
if (ok){
if (opt_deps)
print to, from
else
print from, to
printed [from] = printed [to] = 1
}
}
@ -147,10 +164,7 @@ END {
for (i in edge){
from = substr(i, 1, index(i, SUBSEP)-1)
if (opt_deps)
print_edge(edge [i], from)
else
print_edge(from, edge [i])
print_edge(from, edge [i])
}
}

View file

@ -14,6 +14,16 @@ wip/runawk wip/paexec
wip/runawk wip/pkg_summary-utils
'
pkg_subgraph_deps -1 -f src_pkgs.txt src_deps.txt | sort |
cmp 'pkg_subgraph_deps #1.1' \
'textproc/dictem
wip/libuxre wip/heirloom-awk
wip/runawk wip/awk-pkgsrc-dewey
wip/runawk wip/distbb
wip/runawk wip/paexec
wip/runawk wip/pkg_summary-utils
'
pkg_subgraph_deps -f src_pkgs.txt -r src_deps.txt | sort |
cmp 'pkg_subgraph_deps #2' \
'devel/libtool-base wip/libuxre
@ -25,6 +35,14 @@ wip/heirloom-libcommon wip/libuxre
wip/runawk
'
pkg_subgraph_deps -1 -f src_pkgs.txt -r src_deps.txt | sort |
cmp 'pkg_subgraph_deps #2.1' \
'devel/libtool-base wip/libuxre
textproc/dictem
wip/heirloom-libcommon wip/libuxre
wip/runawk
'
pkg_subgraph_deps -x -f src_pkgs.txt src_deps.txt | sort |
cmp 'pkg_subgraph_deps #3' \
'wip/awk-pkgsrc-dewey wip/pkg_summary-utils
@ -35,6 +53,15 @@ wip/pkg_summary-utils wip/pkg_online-client
wip/pkg_summary-utils wip/pkg_online-server
'
pkg_subgraph_deps -x1 -f src_pkgs.txt src_deps.txt | sort |
cmp 'pkg_subgraph_deps #3.1' \
'wip/awk-pkgsrc-dewey
wip/distbb
wip/heirloom-awk
wip/paexec
wip/pkg_summary-utils
'
pkg_subgraph_deps -rx -fsrc_pkgs.txt src_deps.txt | sort |
cmp 'pkg_subgraph_deps #4' \
'lang/f2c devel/libtool-base
@ -42,6 +69,12 @@ wip/heirloom-common wip/heirloom-doc
wip/heirloom-doc wip/heirloom-libcommon
'
pkg_subgraph_deps -1rx -fsrc_pkgs.txt src_deps.txt | sort |
cmp 'pkg_subgraph_deps #4.1' \
'devel/libtool-base
wip/heirloom-libcommon
'
pkg_subgraph_deps -xv -f src_pkgs.txt src_deps.txt | sort |
cmp 'pkg_subgraph_deps #5' \
'devel/gmake textproc/dict-client
@ -103,6 +136,44 @@ wip/libuxre
wip/runawk
'
pkg_subgraph_deps -r -p'wip/pkg_online-client,wip/distbb' src_deps.txt | sort |
pkg_subgraph_deps -r -p'wip/pkg_online-client,wip/distbb' src_deps.txt |
sort |
cmp 'pkg_subgraph_deps #8' \
''
pkg_subgraph_deps -r -p'wip/pkg_online-client wip/distbb' src_deps.txt |
sort |
cmp 'pkg_subgraph_deps #8.1' \
'devel/gmake textproc/dict-client
devel/libmaa textproc/dict-client
devel/libmaa wip/paexec
devel/libtool-base devel/libmaa
devel/libtool-base textproc/dict-client
devel/pipestatus wip/distbb
devel/pipestatus wip/pkg_online-client
devel/pipestatus wip/pkg_summary-utils
lang/f2c devel/libtool-base
net/netcat wip/pkg_online-client
textproc/dict-client wip/pkg_online-client
wip/awk-pkgsrc-dewey wip/pkg_summary-utils
wip/paexec wip/distbb
wip/pkg_summary-utils wip/distbb
wip/pkg_summary-utils wip/pkg_online-client
wip/runawk wip/awk-pkgsrc-dewey
wip/runawk wip/distbb
wip/runawk wip/paexec
wip/runawk wip/pkg_summary-utils
'
pkg_subgraph_deps -r1 -p'wip/pkg_online-client wip/distbb' src_deps.txt |
sort |
cmp 'pkg_subgraph_deps #8.2' \
'devel/pipestatus wip/distbb
devel/pipestatus wip/pkg_online-client
net/netcat wip/pkg_online-client
textproc/dict-client wip/pkg_online-client
wip/paexec wip/distbb
wip/pkg_summary-utils wip/distbb
wip/pkg_summary-utils wip/pkg_online-client
wip/runawk wip/distbb
'