summaryrefslogblamecommitdiffstats
path: root/md/writeup/openwrt_dependency_graph_drawing.md
blob: f36e4187aacec48d00b27421210852d4fd066dce (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                                        
     















                                                                     
       








                      
     






                                                               
       





                                      
     
















                                                                       
       



























                                                                                                                                                                           
title:OpenWRT dependency graph drawing
keywords:openwrt

# 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:

```sh
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

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


To use type

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


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

```text
deptree.dot
```

now convert dot file to pdf, psd, png:


```sh
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:

```text
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
<a href=/img/openwrt_dependency_graph_drawing/graph1.png width="250"><img src="/img/openwrt_dependency_graph_drawing/graph1.png" style="width:40%" alt="nprove router"></a>

<a href=/img/openwrt_dependency_graph_drawing/graph1.png width="250"><img src="/img/openwrt_dependency_graph_drawing/graph1.png" style="width:40%" alt="nprove router"></a>