summaryrefslogtreecommitdiff
path: root/support/scripts/pkg-stats
blob: 3e89bd14b8d955bc158500bd2f580e73b067ff47 (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/bin/bash

# Copyright (C) 2009 by Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

# This script generates an HTML file that contains a report about all
# Buildroot packages, their usage of the different package
# infrastructure and possible cleanup actions
#
# Run the script from the Buildroot toplevel directory:
#
#  ./scripts/pkg-stats > /tmp/pkg.html
#

echo "<head>
<style type=\"text/css\">
table {
  width: 100%;
}
td {
  border: 1px solid black;
}
td.centered {
  text-align: center;
}
tr.wrong td {
  background: #ff9a69;
}
tr.correct td {
  background: #d2ffc4;
}
</style>
</head>

<a href=\"#results\">Results</a><br/>

<table>
<tr>
<td rowspan=\"2\">Id</td>
<td rowspan=\"2\">Package</td>
<td>Patch count</td>
<td colspan=\"2\" class=\"centered\">AUTOTARGETS</td>
<td colspan=\"2\" class=\"centered\">GENTARGETS</td>
<td colspan=\"2\" class=\"centered\">CMAKETARGETS</td>
<td colspan=\"2\" class=\"centered\">manual</td>
<td rowspan=\"2\" class=\"centered\">Actions</td>
</tr>
<tr>
<td class=\"centered\">host</td>
<td class=\"centered\">target</td>
<td class=\"centered\">host</td>
<td class=\"centered\">target</td>
<td class=\"centered\">host</td>
<td class=\"centered\">target</td>
<td class=\"centered\">host</td>
<td class=\"centered\">target</td>
</tr>"

convert_to_generic_target=0
convert_to_generic_host=0
convert_to_autotools=0
total_patch_count=0
cnt=0
for i in $(find package/ -name '*.mk') ; do

    if test \
	$i = "package/java/java.mk" -o \
	$i = "package/games/games.mk" -o \
	$i = "package/multimedia/multimedia.mk" -o \
	$i = "package/customize/customize.mk" -o \
	$i = "package/matchbox/matchbox.mk" -o \
	$i = "package/x11r7/x11r7.mk" ; then
	echo "skipping $i" 1>&2
	continue
    fi

    cnt=$((cnt+1))

    is_auto_host=0
    is_auto_target=0
    is_cmake_host=0
    is_cmake_target=0
    is_pkg_target=0
    is_pkg_host=0
    is_manual_target=0
    is_manual_host=0

    if grep -E "\(call AUTOTARGETS,host\)" $i > /dev/null ; then
	is_auto_host=1
    fi

    if grep -E "\(call AUTOTARGETS\)" $i > /dev/null ; then
	is_auto_target=1
    fi

    if grep -E "\(call GENTARGETS,host\)" $i > /dev/null ; then
	is_pkg_host=1
    fi

    if grep -E "\(call GENTARGETS\)" $i > /dev/null ; then
	is_pkg_target=1
    fi

    if grep -E "\(call CMAKETARGETS,host\)" $i > /dev/null ; then
	is_cmake_host=1
    fi

    if grep -E "\(call CMAKETARGETS\)" $i > /dev/null ; then
	is_cmake_target=1
    fi

    pkg=$(basename $i)
    pkg=${pkg%.mk}

    if grep "^host-$pkg:" $i > /dev/null ; then
	is_manual_host=1
    fi

    if test $is_pkg_target -eq 0 -a $is_auto_target -eq 0 -a $is_cmake_target -eq 0; then
	is_manual_target=1
    fi

    tasks=""

    if [ $is_manual_target -eq 1 ] ; then
	if grep "/configure" $i > /dev/null ; then
	    tasks=$tasks"<li>convert package to autotools ?</li>"
	    convert_to_target_autotools=$((convert_to_target_autotools+1))
	else
	    tasks=$tasks"<li>convert to generic target</li>"
	    convert_to_generic_target=$((convert_to_generic_target+1))
	fi
    fi

    if [ $is_manual_host -eq 1 ]; then
	if grep "/configure" $i > /dev/null ; then
	    tasks=$tasks"<li>convert package to autotools ?</li>"
	    convert_to_host_autotools=$((convert_to_host_autotools+1))
	else
	    tasks=$tasks"<li>convert to generic host</li>"
	    convert_to_generic_host=$((convert_to_generic_host+1))
	fi
    fi

    if test -n "$tasks" ; then
	echo "<tr class=\"wrong\">"
    else
	echo "<tr class=\"correct\">"
    fi

    echo "<td>$cnt</td>"
    echo "<td>$i</td>"

    package_dir=$(dirname $i)
    patch_count=$(find ${package_dir} -name '*.patch' | wc -l)
    total_patch_count=$(($total_patch_count+$patch_count))

    if test $patch_count -lt 1 ; then
	patch_count_color="#00ff00"
    elif test $patch_count -lt 5 ; then
	patch_count_color="#ffc600"
    else
	patch_count_color="#ff0000"
    fi

    echo "<td class=\"centered\" style=\"color: $patch_count_color; font-weight: bold;\">"
    echo $patch_count
    echo "</td>"

    echo "<td class=\"centered\">"
    if [ $is_auto_host -eq 1 ] ; then
	echo "<b>YES</b>"
    else
	echo "NO"
    fi
    echo "</td>"

    echo "<td class=\"centered\">"
    if [ $is_auto_target -eq 1 ] ; then
	echo "<b>YES</b>"
    else
	echo "NO"
    fi
    echo "</td>"

    echo "<td class=\"centered\">"
    if [ $is_pkg_host -eq 1 ] ; then
	echo "<b>YES</b>"
    else
	echo "NO"
    fi
    echo "</td>"

    echo "<td class=\"centered\">"
    if [ $is_pkg_target -eq 1 ] ; then
	echo "<b>YES</b>"
    else
	echo "NO"
    fi
    echo "</td>"

    echo "<td class=\"centered\">"
    if [ $is_cmake_host -eq 1 ] ; then
	echo "<b>YES</b>"
    else
	echo "NO"
    fi
    echo "</td>"

    echo "<td class=\"centered\">"
    if [ $is_cmake_target -eq 1 ] ; then
	echo "<b>YES</b>"
    else
	echo "NO"
    fi
    echo "</td>"

    echo "<td class=\"centered\">"
    if [ $is_manual_host -eq 1 ] ; then
	echo "<b>YES</b>"
    else
	echo "NO"
    fi
    echo "</td>"

    echo "<td class=\"centered\">"
    if [ $is_manual_target -eq 1 ] ; then
	echo "<b>YES</b>"
    else
	echo "NO"
    fi
    echo "</td>"

    echo "<td>"
    echo "<ul>"
    echo $tasks
    echo "</ul>"
    echo "</td>"

    echo "</tr>"

done
echo "</table>"

echo "<table>"
echo "<tr>"
echo "<td>Packages to convert to generic target</td>"
echo "<td>$convert_to_generic_target</td>"
echo "</tr>"
echo "<tr>"
echo "<td>Packages to convert to generic host</td>"
echo "<td>$convert_to_generic_host</td>"
echo "</tr>"
echo "<tr>"
echo "<td>Packages to convert to target autotools</td>"
echo "<td>$convert_to_target_autotools</td>"
echo "</tr>"
echo "<tr>"
echo "<td>Packages to convert to host autotools</td>"
echo "<td>$convert_to_host_autotools</td>"
echo "</tr>"
echo "<tr>"
echo "<td>Number of patches in all packages</td>"
echo "<td>$total_patch_count</td>"
echo "</tr>"
echo "<tr>"
echo "<td>TOTAL</td>"
echo "<td>$cnt</td>"
echo "</tr>"
echo "</table>"