Improve "depends" awk statement, part deux

This commit is contained in:
Steven Penny 2014-05-21 21:23:28 -05:00
parent d124c46078
commit e0f31ae249
1 changed files with 13 additions and 17 deletions

30
apt-cyg
View File

@ -277,27 +277,23 @@ case "$command" in
do do
awk ' awk '
$1 == "@" { $1 == "@" {
k = $2 pkg = $2
} }
$1 == "requires:" { $1 == "requires:" {
a[k] = $0 for (i=2; i<=NF; i++)
reqs[pkg][$i]
} }
END { END {
p[1] = query prtPkg(query)
d[query] = 0 }
while (length(p)) { function prtPkg(pkg) {
key = p[length(p)] if (seen[pkg]++) return
depth = d[key] printf "%*s%s\n", indent, "", pkg
delete p[length(p)] indent++
if (s[key]++) continue if (pkg in reqs)
printf "%*s%s\n", depth, "", key for (req in reqs[pkg])
split(a[key], r) prtPkg(req)
delete r[1] indent--
for (req in r) {
p[length(p) + 1] = r[req]
d[r[req]] = depth + 1
}
}
} }
' query="$pkg" setup.ini ' query="$pkg" setup.ini
done done