控制图
controlgraph是一个有向图,它可以被遍历以支持并行的debian包构建。
从具有有效debian打包的可用目录中,生成一个包含节点的目录(表示源包)和边的构建依赖关系的图。此图的反面可以通过广度优先搜索遍历,以按依赖顺序构建。
controlgraph是以线性或点格式返回要生成的目录的控制图的程序。
安装pip3 install controlgraph
库使用importsysfrompathlibimportPathimportcontrolgraphimportnetworkxasnx# get all directoriesdirs=[pforpinPath.cwd().iterdir()ifp.is_dir()]# get map of local binary packages to locally-available source build dependenciespkgs=controlgraph.parse_all_controlfiles(dirs)# generate build dependency graph from mapdep_graph=controlgraph.graph(pkgs)# print full dot graphnx.nx_pydot.write_dot(dep_graph,sys.stdout)# print linear order from depth-first searchprint(" ".join(list(nx.dfs_postorder_nodes(dep_graph))))
输出strict digraph {
"opx-nas-daemon";
"opx-common-utils";
"opx-cps";
"opx-logging";
"opx-nas-acl";
"opx-sdi-sys";
"opx-nas-daemon" -> "opx-common-utils";
"opx-nas-daemon" -> "opx-cps";
"opx-nas-daemon" -> "opx-logging";
"opx-nas-daemon" -> "opx-nas-acl";
"opx-common-utils" -> "opx-logging";
"opx-cps" -> "opx-common-utils";
"opx-cps" -> "opx-logging";
"opx-nas-acl" -> "opx-common-utils";
"opx-nas-acl" -> "opx-cps";
"opx-nas-acl" -> "opx-logging";
"opx-sdi-sys" -> "opx-common-utils";
"opx-sdi-sys" -> "opx-logging";
}
opx-logging opx-common-utils opx-cps opx-nas-acl opx-nas-daemon opx-sdi-sys
cli用法
当存在一个或多个目录时,运行controlgraph。$ for r in opx-nas-acl opx-nas-daemon opx-alarm opx-logging opx-common-utils;do
git clone "https://github.com/open-switch/$r"done
$ controlgraph
opx-alarm opx-logging opx-common-utils opx-nas-acl opx-nas-daemon
$ controlgraph --graph
strict digraph {"opx-alarm";"opx-nas-daemon";"opx-common-utils";"opx-logging";"opx-nas-acl";"opx-nas-daemon" -> "opx-common-utils";"opx-nas-daemon" -> "opx-logging";"opx-nas-daemon" -> "opx-nas-acl";"opx-common-utils" -> "opx-logging";"opx-nas-acl" -> "opx-common-utils";"opx-nas-acl" -> "opx-logging";}
欢迎加入QQ群-->: 979659372
推荐PyPI第三方库