打印封装的依赖关系树 [英] Print package dependency tree

查看:160
本文介绍了打印封装的依赖关系树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用这个文件,我想打印一个
软件包的依赖关系树,给定一个单一的基础包。例如,拿
bash包

@庆典
#几行删除
要求:coreutils的libintl8 libncursesw10 libreadline7 _Update-INFO-DIR cygwin的

我想找到般所需的输出
包,部分例如

 庆典
庆典的coreutils
庆典的coreutils libattr1
庆典的coreutils libattr1 libintl8
庆典的coreutils libattr1 libintl8 libiconv2
庆典的coreutils libattr1 libintl8 _autorebase
庆典的coreutils libattr1 libintl8 _autorebase底垫
庆典的coreutils libattr1 libintl8 _autorebase变基冲刺
庆典的coreutils libattr1 libintl8 _autorebase变基冲刺的cygwin
庆典的coreutils libattr1 libintl8 _autorebase变基冲刺cygwin的基础cygwin的

我有这样的命令,但它不会递归

#!AWK -f
$ 1 ==@{
  PKG = $ 16
}
$ 1 ==要求:{
  对于(i = 2; I< = NF;我++)
    请求数[PKG] [I-1] = $我
}
结束 {
  查询=庆典
  对(在请求数[查询] PKG){
    打印请求数[查询] [PKG]
  }
}


解决方案

#!的/ usr /斌/的awk -f
@include加盟
$ 1 ==@{
  助攻= $ 16
}
$ 1 ==要求:{
  对于(Z = 2; z,其中= NF; Z ++)
    请求数[助攻] [Z-1] = $ž
}
结束 {
  PRPG(庆典)
}
功能smartmatch(小,大,价值){
  对于(每个大)
    值[大[每]
  在值返回小
}
功能PRPG(FPG){
  如果(smartmatch(FPG,SPATH))回报
  SPATH [长度(SPATH)+1] = FPG
  打印已加入(SPATH,1,长度(SPATH))
  如果(IsArray的(请求数[FPG))
    对于(每个请求数[FPG])
      PRPG(请求数[FPG] [每])
  删除SPATH [长度(SPATH)
}

Using this file, I would like to print a tree of package dependencies, given a single base package. For example, take the Bash package

@ bash
# few lines removed
requires: coreutils libintl8 libncursesw10 libreadline7 _update-info-dir cygwin

I would like find-like output of the required packages, partial example

bash
bash coreutils
bash coreutils libattr1
bash coreutils libattr1 libintl8
bash coreutils libattr1 libintl8 libiconv2
bash coreutils libattr1 libintl8 _autorebase
bash coreutils libattr1 libintl8 _autorebase rebase
bash coreutils libattr1 libintl8 _autorebase rebase dash
bash coreutils libattr1 libintl8 _autorebase rebase dash cygwin
bash coreutils libattr1 libintl8 _autorebase rebase dash cygwin base-cygwin

I have this command but it does not recurse

#!awk -f
$1 == "@" {
  pkg = $2
}
$1 == "requires:" {
  for (i=2; i<=NF; i++)
    reqs[pkg][i-1] = $i
}
END {
  query = "bash"
  for (pkg in reqs[query]) {
    print reqs[query][pkg]
  }
}

解决方案

#!/usr/bin/awk -f
@include "join"
$1 == "@" {
  apg = $2
}
$1 == "requires:" {
  for (z=2; z<=NF; z++)
    reqs[apg][z-1] = $z
}
END {
  prpg("bash")
}
function smartmatch(small, large,    values) {
  for (each in large)
    values[large[each]]
  return small in values
}
function prpg(fpg) {
  if (smartmatch(fpg, spath)) return
  spath[length(spath)+1] = fpg
  print join(spath, 1, length(spath))
  if (isarray(reqs[fpg]))
    for (each in reqs[fpg])
      prpg(reqs[fpg][each])
  delete spath[length(spath)]
}

Source

这篇关于打印封装的依赖关系树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆