OpenWRT dependency graph drawing

Here is script that show package compiled package dependencies of OpenWrt packages. Script reads compiled packages dependencies and generates GraphViz files and draws graph of all packaged dependencies. This graph can be used to see how to remove unesesseray dependencies. Practicaly this script was used to see how overall all system is designed and if there is some circular dependencies. After there where removed unnesesarry dependencies generated graph was used to see overall system design.

.ipk files are tar.gz archives and can be renamed as .tar.gz and opened with GUI or in terminal:

tar -xvf package.ipg

Structure of ipkg files is:

debian-binary - version
\data.tar.gz - here is all rootfs data files
\control.tar.gz
control - package info here is dependencies and package name.

Here tree based on OpenWRT git commit of 24 May 2013

How to use script, first parametr of script is directory where is all OpenWrt package files usualy it is under

openwrt-trunk/
    bin/
        platform-name/
            packages/

To use type

deptree.py system-path/openwrt-trunk/bin/platform-name/packages

Output files comes in same directory where script where lunched generated file name is:

deptree.dot

now convert dot file to pdf, psd, png:

dot -Tps $(NAME).dot -o graph1.ps
dot -Tpdf $(NAME).dot -o graph1.pdf
dot -Tpng $(NAME).dot -o graph1.png

All OpenWRT was default selected for default platform there is about ~152 of them the generated totaly 325 dependencies image

There where removed only one level deep dependencies there was 185 of then after first level deep dependencies where removed generated image is little bit cleaner

Rules with dependecies where removed:

if (A depends on [B,C] and B depends on [C])    and
    there is (edges A->B->C and A->C) then 
        dependency C can be removed from A

TODO:

add more sophisticated graph algorith add to remove more dependencies

Links

https://openwrt.org/
http://www.python.org/
http://www.graphviz.org/
http://en.wikipedia.org/wiki/Dependency_graph

Downloads

openwrt_dep_tree.tar.gz - 2KiB - http://archive.main.lv/files/writeup/openwrt_dependency_graph_drawing/openwrt_dep_tree.tar.gz

Images

nprove router

nprove router