summaryrefslogtreecommitdiff
path: root/md/writeup/openwrt_dependency_graph_drawing.md
blob: 49a5b800fb6aafce515b4dd05373ba9da640d3ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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:

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