dtc: update legal info
[buildroot-gz.git] / support / scripts / pkg-stats
blobcc3bef452c4ae326db96f9f73d25ca82f213ea84
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-fbtft.mk" -o \
98 $i = "linux/linux-ext-xenomai.mk" -o \
99 $i = "linux/linux-ext-rtai.mk" -o \
100 $i = "package/freescale-imx/freescale-imx.mk" -o \
101 $i = "package/gcc/gcc.mk" -o \
102 $i = "package/gstreamer/gstreamer.mk" -o \
103 $i = "package/gstreamer1/gstreamer1.mk" -o \
104 $i = "package/gtk2-themes/gtk2-themes.mk" -o \
105 $i = "package/matchbox/matchbox.mk" -o \
106 $i = "package/opengl/opengl.mk" -o \
107 $i = "package/qt5/qt5.mk" -o \
108 $i = "package/x11r7/x11r7.mk" -o \
109 $i = "package/doc-asciidoc.mk" -o \
110 $i = "package/pkg-autotools.mk" -o \
111 $i = "package/pkg-cmake.mk" -o \
112 $i = "package/pkg-kconfig.mk" -o \
113 $i = "package/pkg-luarocks.mk" -o \
114 $i = "package/pkg-perl.mk" -o \
115 $i = "package/pkg-python.mk" -o \
116 $i = "package/pkg-rebar.mk" -o \
117 $i = "package/pkg-virtual.mk" -o \
118 $i = "package/pkg-download.mk" -o \
119 $i = "package/pkg-generic.mk" -o \
120 $i = "package/pkg-utils.mk" ; then
121 echo "skipping $i" 1>&2
122 continue
125 cnt=$((cnt+1))
127 hashost=0
128 hastarget=0
129 infratype=""
131 # Determine package infrastructure
132 if grep -E "\(host-autotools-package\)" $i > /dev/null ; then
133 infratype="autotools"
134 hashost=1
137 if grep -E "\(autotools-package\)" $i > /dev/null ; then
138 infratype="autotools"
139 hastarget=1
142 if grep -E "\(kconfig-package\)" $i > /dev/null ; then
143 infratype="kconfig"
144 hastarget=1
147 if grep -E "\(host-luarocks-package\)" $i > /dev/null ; then
148 infratype="luarocks"
149 hashost=1
152 if grep -E "\(luarocks-package\)" $i > /dev/null ; then
153 infratype="luarocks"
154 hastarget=1
157 if grep -E "\(host-perl-package\)" $i > /dev/null ; then
158 infratype="perl"
159 hashost=1
162 if grep -E "\(perl-package\)" $i > /dev/null ; then
163 infratype="perl"
164 hastarget=1
167 if grep -E "\(host-python-package\)" $i > /dev/null ; then
168 infratype="python"
169 hashost=1
172 if grep -E "\(python-package\)" $i > /dev/null ; then
173 infratype="python"
174 hastarget=1
177 if grep -E "\(host-rebar-package\)" $i > /dev/null ; then
178 infratype="rebar"
179 hashost=1
182 if grep -E "\(rebar-package\)" $i > /dev/null ; then
183 infratype="rebar"
184 hastarget=1
187 if grep -E "\(host-virtual-package\)" $i > /dev/null ; then
188 infratype="virtual"
189 hashost=1
192 if grep -E "\(virtual-package\)" $i > /dev/null ; then
193 infratype="virtual"
194 hastarget=1
197 if grep -E "\(host-generic-package\)" $i > /dev/null ; then
198 infratype="generic"
199 hashost=1
202 if grep -E "\(generic-package\)" $i > /dev/null ; then
203 infratype="generic"
204 hastarget=1
207 if grep -E "\(host-cmake-package\)" $i > /dev/null ; then
208 infratype="cmake"
209 hashost=1
212 if grep -E "\(cmake-package\)" $i > /dev/null ; then
213 infratype="cmake"
214 hastarget=1
217 pkg=$(basename $i)
218 dir=$(dirname $i)
219 pkg=${pkg%.mk}
220 pkgvariable=$(echo ${pkg} | tr "a-z-" "A-Z_")
223 # Count packages per infrastructure
224 if [ -z ${infratype} ] ; then
225 infratype="manual"
226 manual_packages=$(($manual_packages+1))
227 elif [ ${infratype} = "autotools" ]; then
228 autotools_packages=$(($autotools_packages+1))
229 elif [ ${infratype} = "cmake" ]; then
230 cmake_packages=$(($cmake_packages+1))
231 elif [ ${infratype} = "kconfig" ]; then
232 kconfig_packages=$(($kconfig_packages+1))
233 elif [ ${infratype} = "luarocks" ]; then
234 luarocks_packages=$(($luarocks_packages+1))
235 elif [ ${infratype} = "perl" ]; then
236 perl_packages=$(($perl_packages+1))
237 elif [ ${infratype} = "python" ]; then
238 python_packages=$(($python_packages+1))
239 elif [ ${infratype} = "rebar" ]; then
240 rebar_packages=$(($rebar_packages+1))
241 elif [ ${infratype} = "virtual" ]; then
242 virtual_packages=$(($virtual_packages+1))
243 elif [ ${infratype} = "generic" ]; then
244 generic_packages=$(($generic_packages+1))
247 if grep -qE "^${pkgvariable}_LICENSE[ ]*=" $i ; then
248 packages_with_license=$(($packages_with_license+1))
249 license=1
250 else
251 packages_without_license=$(($packages_without_license+1))
252 license=0
255 if grep -qE "^${pkgvariable}_LICENSE_FILES[ ]*=" $i ; then
256 packages_with_license_files=$(($packages_with_license_files+1))
257 license_files=1
258 else
259 packages_without_license_files=$(($packages_without_license_files+1))
260 license_files=0
263 if test -f ${dir}/${pkg}.hash; then
264 packages_with_hash_file=$(($packages_with_hash_file+1))
265 hash_file=1
266 else
267 packages_without_hash_file=$(($packages_without_hash_file+1))
268 hash_file=0
271 echo "<tr>"
273 echo "<td>$cnt</td>"
274 echo "<td>$i</td>"
276 package_dir=$(dirname $i)
277 patch_count=$(find ${package_dir} -name '*.patch' | wc -l)
278 total_patch_count=$(($total_patch_count+$patch_count))
280 if test $patch_count -lt 1 ; then
281 patch_count_class="nopatches"
282 elif test $patch_count -lt 5 ; then
283 patch_count_class="somepatches"
284 else
285 patch_count_class="lotsofpatches"
288 echo "<td class=\"centered ${patch_count_class}\">"
289 echo "<b>$patch_count</b>"
290 echo "</td>"
292 if [ ${infratype} = "manual" ] ; then
293 echo "<td class=\"centered wrong\"><b>manual</b></td>"
294 else
295 echo "<td class=\"centered correct\">"
296 echo "<b>${infratype}</b><br/>"
297 if [ ${hashost} -eq 1 -a ${hastarget} -eq 1 ]; then
298 echo "target + host"
299 elif [ ${hashost} -eq 1 ]; then
300 echo "host"
301 else
302 echo "target"
304 echo "</td>"
307 if [ ${license} -eq 0 ] ; then
308 echo "<td class=\"centered wrong\">No</td>"
309 else
310 echo "<td class=\"centered correct\">Yes</td>"
313 if [ ${license_files} -eq 0 ] ; then
314 echo "<td class=\"centered wrong\">No</td>"
315 else
316 echo "<td class=\"centered correct\">Yes</td>"
319 if [ ${hash_file} -eq 0 ] ; then
320 echo "<td class=\"centered wrong\">No</td>"
321 else
322 echo "<td class=\"centered correct\">Yes</td>"
325 echo "</tr>"
327 done
328 echo "</table>"
330 echo "<a id="results"></a>"
331 echo "<table>"
332 echo "<tr>"
333 echo "<td>Packages using the <i>generic</i> infrastructure</td>"
334 echo "<td>$generic_packages</td>"
335 echo "</tr>"
336 echo "<tr>"
337 echo "<td>Packages using the <i>cmake</i> infrastructure</td>"
338 echo "<td>$cmake_packages</td>"
339 echo "</tr>"
340 echo "<tr>"
341 echo "<td>Packages using the <i>autotools</i> infrastructure</td>"
342 echo "<td>$autotools_packages</td>"
343 echo "</tr>"
344 echo "<tr>"
345 echo "<td>Packages using the <i>luarocks</i> infrastructure</td>"
346 echo "<td>$luarocks_packages</td>"
347 echo "</tr>"
348 echo "<tr>"
349 echo "<td>Packages using the <i>kconfig</i> infrastructure</td>"
350 echo "<td>$kconfig_packages</td>"
351 echo "</tr>"
352 echo "<tr>"
353 echo "<td>Packages using the <i>perl</i> infrastructure</td>"
354 echo "<td>$perl_packages</td>"
355 echo "</tr>"
356 echo "<tr>"
357 echo "<td>Packages using the <i>python</i> infrastructure</td>"
358 echo "<td>$python_packages</td>"
359 echo "</tr>"
360 echo "<tr>"
361 echo "<td>Packages using the <i>rebar</i> infrastructure</td>"
362 echo "<td>$rebar_packages</td>"
363 echo "</tr>"
364 echo "<tr>"
365 echo "<td>Packages using the <i>virtual</i> infrastructure</td>"
366 echo "<td>$virtual_packages</td>"
367 echo "</tr>"
368 echo "<tr>"
369 echo "<td>Packages not using any infrastructure</td>"
370 echo "<td>$manual_packages</td>"
371 echo "</tr>"
372 echo "<tr>"
373 echo "<td>Packages having license information</td>"
374 echo "<td>$packages_with_license</td>"
375 echo "</tr>"
376 echo "<tr>"
377 echo "<td>Packages not having licence information</td>"
378 echo "<td>$packages_without_license</td>"
379 echo "</tr>"
380 echo "<tr>"
381 echo "<td>Packages having license files information</td>"
382 echo "<td>$packages_with_license_files</td>"
383 echo "</tr>"
384 echo "<tr>"
385 echo "<td>Packages not having licence files information</td>"
386 echo "<td>$packages_without_license_files</td>"
387 echo "</tr>"
388 echo "<tr>"
389 echo "<td>Packages having hash file</td>"
390 echo "<td>$packages_with_hash_file</td>"
391 echo "</tr>"
392 echo "<tr>"
393 echo "<td>Packages not having hash file</td>"
394 echo "<td>$packages_without_hash_file</td>"
395 echo "</tr>"
396 echo "<tr>"
397 echo "<td>Number of patches in all packages</td>"
398 echo "<td>$total_patch_count</td>"
399 echo "</tr>"
400 echo "<tr>"
401 echo "<td>TOTAL</td>"
402 echo "<td>$cnt</td>"
403 echo "</tr>"
404 echo "</table>"
406 echo "<hr/>"
407 echo "<i>Updated on $(LANG=C date), Git commit $(git log master -n 1 --pretty=format:%H)</i>"
408 echo "</body>"
409 echo "</html>"