python-treq: bump to version 16.12.0
[buildroot-gz.git] / support / scripts / pkg-stats
blob421fa5cf5d0ff6d02730edeb888f697abc661847
1 #!/usr/bin/env bash
3 # Copyright (C) 2009 by Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # This script generates an HTML file that contains a report about all
20 # Buildroot packages, their usage of the different package
21 # infrastructure and possible cleanup actions
23 # Run the script from the Buildroot toplevel directory:
25 # ./support/scripts/pkg-stats > /tmp/pkg.html
28 echo "<head>
29 <style type=\"text/css\">
30 table {
31 width: 100%;
33 td {
34 border: 1px solid black;
36 td.centered {
37 text-align: center;
39 td.wrong {
40 background: #ff9a69;
42 td.correct {
43 background: #d2ffc4;
45 td.nopatches {
46 background: #d2ffc4;
49 td.somepatches {
50 background: #ffd870;
53 td.lotsofpatches {
54 background: #ff9a69;
56 </style>
57 <title>Statistics of Buildroot packages</title>
58 </head>
60 <a href=\"#results\">Results</a><br/>
62 <table>
63 <tr>
64 <td>Id</td>
65 <td>Package</td>
66 <td class=\"centered\">Patch count</td>
67 <td class=\"centered\">Infrastructure</td>
68 <td class=\"centered\">License</td>
69 <td class=\"centered\">License files</td>
70 <td class=\"centered\">Hash file</td>
71 </tr>
74 autotools_packages=0
75 cmake_packages=0
76 kconfig_packages=0
77 luarocks_package=0
78 perl_packages=0
79 python_packages=0
80 rebar_packages=0
81 virtual_packages=0
82 generic_packages=0
83 manual_packages=0
84 packages_with_licence=0
85 packages_without_licence=0
86 packages_with_license_files=0
87 packages_without_license_files=0
88 packages_with_hash_file=0
89 packages_without_hash_file=0
90 total_patch_count=0
91 cnt=0
93 for i in $(find boot/ linux/ package/ -name '*.mk' | sort) ; do
95 if test \
96 $i = "boot/common.mk" -o \
97 $i = "linux/linux-ext-ev3dev-linux-drivers.mk" -o \
98 $i = "linux/linux-ext-fbtft.mk" -o \
99 $i = "linux/linux-ext-xenomai.mk" -o \
100 $i = "linux/linux-ext-rtai.mk" -o \
101 $i = "package/freescale-imx/freescale-imx.mk" -o \
102 $i = "package/gcc/gcc.mk" -o \
103 $i = "package/gstreamer/gstreamer.mk" -o \
104 $i = "package/gstreamer1/gstreamer1.mk" -o \
105 $i = "package/gtk2-themes/gtk2-themes.mk" -o \
106 $i = "package/matchbox/matchbox.mk" -o \
107 $i = "package/opengl/opengl.mk" -o \
108 $i = "package/qt5/qt5.mk" -o \
109 $i = "package/x11r7/x11r7.mk" -o \
110 $i = "package/doc-asciidoc.mk" -o \
111 $i = "package/pkg-autotools.mk" -o \
112 $i = "package/pkg-cmake.mk" -o \
113 $i = "package/pkg-kconfig.mk" -o \
114 $i = "package/pkg-luarocks.mk" -o \
115 $i = "package/pkg-perl.mk" -o \
116 $i = "package/pkg-python.mk" -o \
117 $i = "package/pkg-rebar.mk" -o \
118 $i = "package/pkg-virtual.mk" -o \
119 $i = "package/pkg-download.mk" -o \
120 $i = "package/pkg-generic.mk" -o \
121 $i = "package/pkg-utils.mk" ; then
122 echo "skipping $i" 1>&2
123 continue
126 cnt=$((cnt+1))
128 hashost=0
129 hastarget=0
130 infratype=""
132 # Determine package infrastructure
133 if grep -E "\(host-autotools-package\)" $i > /dev/null ; then
134 infratype="autotools"
135 hashost=1
138 if grep -E "\(autotools-package\)" $i > /dev/null ; then
139 infratype="autotools"
140 hastarget=1
143 if grep -E "\(kconfig-package\)" $i > /dev/null ; then
144 infratype="kconfig"
145 hastarget=1
148 if grep -E "\(host-luarocks-package\)" $i > /dev/null ; then
149 infratype="luarocks"
150 hashost=1
153 if grep -E "\(luarocks-package\)" $i > /dev/null ; then
154 infratype="luarocks"
155 hastarget=1
158 if grep -E "\(host-perl-package\)" $i > /dev/null ; then
159 infratype="perl"
160 hashost=1
163 if grep -E "\(perl-package\)" $i > /dev/null ; then
164 infratype="perl"
165 hastarget=1
168 if grep -E "\(host-python-package\)" $i > /dev/null ; then
169 infratype="python"
170 hashost=1
173 if grep -E "\(python-package\)" $i > /dev/null ; then
174 infratype="python"
175 hastarget=1
178 if grep -E "\(host-rebar-package\)" $i > /dev/null ; then
179 infratype="rebar"
180 hashost=1
183 if grep -E "\(rebar-package\)" $i > /dev/null ; then
184 infratype="rebar"
185 hastarget=1
188 if grep -E "\(host-virtual-package\)" $i > /dev/null ; then
189 infratype="virtual"
190 hashost=1
193 if grep -E "\(virtual-package\)" $i > /dev/null ; then
194 infratype="virtual"
195 hastarget=1
198 if grep -E "\(host-generic-package\)" $i > /dev/null ; then
199 infratype="generic"
200 hashost=1
203 if grep -E "\(generic-package\)" $i > /dev/null ; then
204 infratype="generic"
205 hastarget=1
208 if grep -E "\(host-cmake-package\)" $i > /dev/null ; then
209 infratype="cmake"
210 hashost=1
213 if grep -E "\(cmake-package\)" $i > /dev/null ; then
214 infratype="cmake"
215 hastarget=1
218 pkg=$(basename $i)
219 dir=$(dirname $i)
220 pkg=${pkg%.mk}
221 pkgvariable=$(echo ${pkg} | tr "a-z-" "A-Z_")
224 # Count packages per infrastructure
225 if [ -z ${infratype} ] ; then
226 infratype="manual"
227 manual_packages=$(($manual_packages+1))
228 elif [ ${infratype} = "autotools" ]; then
229 autotools_packages=$(($autotools_packages+1))
230 elif [ ${infratype} = "cmake" ]; then
231 cmake_packages=$(($cmake_packages+1))
232 elif [ ${infratype} = "kconfig" ]; then
233 kconfig_packages=$(($kconfig_packages+1))
234 elif [ ${infratype} = "luarocks" ]; then
235 luarocks_packages=$(($luarocks_packages+1))
236 elif [ ${infratype} = "perl" ]; then
237 perl_packages=$(($perl_packages+1))
238 elif [ ${infratype} = "python" ]; then
239 python_packages=$(($python_packages+1))
240 elif [ ${infratype} = "rebar" ]; then
241 rebar_packages=$(($rebar_packages+1))
242 elif [ ${infratype} = "virtual" ]; then
243 virtual_packages=$(($virtual_packages+1))
244 elif [ ${infratype} = "generic" ]; then
245 generic_packages=$(($generic_packages+1))
248 if grep -qE "^${pkgvariable}_LICENSE[ ]*=" $i ; then
249 packages_with_license=$(($packages_with_license+1))
250 license=1
251 else
252 packages_without_license=$(($packages_without_license+1))
253 license=0
256 if grep -qE "^${pkgvariable}_LICENSE_FILES[ ]*=" $i ; then
257 packages_with_license_files=$(($packages_with_license_files+1))
258 license_files=1
259 else
260 packages_without_license_files=$(($packages_without_license_files+1))
261 license_files=0
264 if test -f ${dir}/${pkg}.hash; then
265 packages_with_hash_file=$(($packages_with_hash_file+1))
266 hash_file=1
267 else
268 packages_without_hash_file=$(($packages_without_hash_file+1))
269 hash_file=0
272 echo "<tr>"
274 echo "<td>$cnt</td>"
275 echo "<td>$i</td>"
277 package_dir=$(dirname $i)
278 patch_count=$(find ${package_dir} -name '*.patch' | wc -l)
279 total_patch_count=$(($total_patch_count+$patch_count))
281 if test $patch_count -lt 1 ; then
282 patch_count_class="nopatches"
283 elif test $patch_count -lt 5 ; then
284 patch_count_class="somepatches"
285 else
286 patch_count_class="lotsofpatches"
289 echo "<td class=\"centered ${patch_count_class}\">"
290 echo "<b>$patch_count</b>"
291 echo "</td>"
293 if [ ${infratype} = "manual" ] ; then
294 echo "<td class=\"centered wrong\"><b>manual</b></td>"
295 else
296 echo "<td class=\"centered correct\">"
297 echo "<b>${infratype}</b><br/>"
298 if [ ${hashost} -eq 1 -a ${hastarget} -eq 1 ]; then
299 echo "target + host"
300 elif [ ${hashost} -eq 1 ]; then
301 echo "host"
302 else
303 echo "target"
305 echo "</td>"
308 if [ ${license} -eq 0 ] ; then
309 echo "<td class=\"centered wrong\">No</td>"
310 else
311 echo "<td class=\"centered correct\">Yes</td>"
314 if [ ${license_files} -eq 0 ] ; then
315 echo "<td class=\"centered wrong\">No</td>"
316 else
317 echo "<td class=\"centered correct\">Yes</td>"
320 if [ ${hash_file} -eq 0 ] ; then
321 echo "<td class=\"centered wrong\">No</td>"
322 else
323 echo "<td class=\"centered correct\">Yes</td>"
326 echo "</tr>"
328 done
329 echo "</table>"
331 echo "<a id="results"></a>"
332 echo "<table>"
333 echo "<tr>"
334 echo "<td>Packages using the <i>generic</i> infrastructure</td>"
335 echo "<td>$generic_packages</td>"
336 echo "</tr>"
337 echo "<tr>"
338 echo "<td>Packages using the <i>cmake</i> infrastructure</td>"
339 echo "<td>$cmake_packages</td>"
340 echo "</tr>"
341 echo "<tr>"
342 echo "<td>Packages using the <i>autotools</i> infrastructure</td>"
343 echo "<td>$autotools_packages</td>"
344 echo "</tr>"
345 echo "<tr>"
346 echo "<td>Packages using the <i>luarocks</i> infrastructure</td>"
347 echo "<td>$luarocks_packages</td>"
348 echo "</tr>"
349 echo "<tr>"
350 echo "<td>Packages using the <i>kconfig</i> infrastructure</td>"
351 echo "<td>$kconfig_packages</td>"
352 echo "</tr>"
353 echo "<tr>"
354 echo "<td>Packages using the <i>perl</i> infrastructure</td>"
355 echo "<td>$perl_packages</td>"
356 echo "</tr>"
357 echo "<tr>"
358 echo "<td>Packages using the <i>python</i> infrastructure</td>"
359 echo "<td>$python_packages</td>"
360 echo "</tr>"
361 echo "<tr>"
362 echo "<td>Packages using the <i>rebar</i> infrastructure</td>"
363 echo "<td>$rebar_packages</td>"
364 echo "</tr>"
365 echo "<tr>"
366 echo "<td>Packages using the <i>virtual</i> infrastructure</td>"
367 echo "<td>$virtual_packages</td>"
368 echo "</tr>"
369 echo "<tr>"
370 echo "<td>Packages not using any infrastructure</td>"
371 echo "<td>$manual_packages</td>"
372 echo "</tr>"
373 echo "<tr>"
374 echo "<td>Packages having license information</td>"
375 echo "<td>$packages_with_license</td>"
376 echo "</tr>"
377 echo "<tr>"
378 echo "<td>Packages not having licence information</td>"
379 echo "<td>$packages_without_license</td>"
380 echo "</tr>"
381 echo "<tr>"
382 echo "<td>Packages having license files information</td>"
383 echo "<td>$packages_with_license_files</td>"
384 echo "</tr>"
385 echo "<tr>"
386 echo "<td>Packages not having licence files information</td>"
387 echo "<td>$packages_without_license_files</td>"
388 echo "</tr>"
389 echo "<tr>"
390 echo "<td>Packages having hash file</td>"
391 echo "<td>$packages_with_hash_file</td>"
392 echo "</tr>"
393 echo "<tr>"
394 echo "<td>Packages not having hash file</td>"
395 echo "<td>$packages_without_hash_file</td>"
396 echo "</tr>"
397 echo "<tr>"
398 echo "<td>Number of patches in all packages</td>"
399 echo "<td>$total_patch_count</td>"
400 echo "</tr>"
401 echo "<tr>"
402 echo "<td>TOTAL</td>"
403 echo "<td>$cnt</td>"
404 echo "</tr>"
405 echo "</table>"
407 echo "<hr/>"
408 echo "<i>Updated on $(LANG=C date), Git commit $(git log master -n 1 --pretty=format:%H)</i>"
409 echo "</body>"
410 echo "</html>"