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
29 <style type=\"text/css\">
34 border: 1px solid black;
57 <title>Statistics of Buildroot packages</title>
60 <a href=\"#results\">Results</a><br/>
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>
81 packages_with_licence
=0
82 packages_without_licence
=0
83 packages_with_license_files
=0
84 packages_without_license_files
=0
88 for i
in $
(find boot
/ linux
/ package
/ -name '*.mk' |
sort) ; do
91 $i = "boot/common.mk" -o \
92 $i = "linux/linux-ext-xenomai.mk" -o \
93 $i = "linux/linux-ext-rtai.mk" -o \
94 $i = "package/efl/efl.mk" -o \
95 $i = "package/freescale-imx/freescale-imx.mk" -o \
96 $i = "package/gcc/gcc.mk" -o \
97 $i = "package/gstreamer/gstreamer.mk" -o \
98 $i = "package/gstreamer1/gstreamer1.mk" -o \
99 $i = "package/gtk2-themes/gtk2-themes.mk" -o \
100 $i = "package/matchbox/matchbox.mk" -o \
101 $i = "package/opengl/opengl.mk" -o \
102 $i = "package/qt5/qt5.mk" -o \
103 $i = "package/x11r7/x11r7.mk" -o \
104 $i = "package/pkg-autotools.mk" -o \
105 $i = "package/pkg-cmake.mk" -o \
106 $i = "package/pkg-luarocks.mk" -o \
107 $i = "package/pkg-perl.mk" -o \
108 $i = "package/pkg-python.mk" -o \
109 $i = "package/pkg-virtual.mk" -o \
110 $i = "package/pkg-download.mk" -o \
111 $i = "package/pkg-generic.mk" -o \
112 $i = "package/pkg-utils.mk" ; then
113 echo "skipping $i" 1>&2
123 # Determine package infrastructure
124 if grep -E "\(host-autotools-package\)" $i > /dev
/null
; then
125 infratype
="autotools"
129 if grep -E "\(autotools-package\)" $i > /dev
/null
; then
130 infratype
="autotools"
134 if grep -E "\(host-luarocks-package\)" $i > /dev
/null
; then
139 if grep -E "\(luarocks-package\)" $i > /dev
/null
; then
144 if grep -E "\(host-perl-package\)" $i > /dev
/null
; then
149 if grep -E "\(perl-package\)" $i > /dev
/null
; then
154 if grep -E "\(host-python-package\)" $i > /dev
/null
; then
159 if grep -E "\(python-package\)" $i > /dev
/null
; then
163 if grep -E "\(host-virtual-package\)" $i > /dev
/null
; then
168 if grep -E "\(virtual-package\)" $i > /dev
/null
; then
173 if grep -E "\(host-generic-package\)" $i > /dev
/null
; then
178 if grep -E "\(generic-package\)" $i > /dev
/null
; then
183 if grep -E "\(host-cmake-package\)" $i > /dev
/null
; then
188 if grep -E "\(cmake-package\)" $i > /dev
/null
; then
195 pkgvariable
=$
(echo ${pkg} |
tr "a-z-" "A-Z_")
198 # Count packages per infrastructure
199 if [ -z ${infratype} ] ; then
201 manual_packages
=$
(($manual_packages+1))
202 elif [ ${infratype} = "autotools" ]; then
203 autotools_packages
=$
(($autotools_packages+1))
204 elif [ ${infratype} = "cmake" ]; then
205 cmake_packages
=$
(($cmake_packages+1))
206 elif [ ${infratype} = "luarocks" ]; then
207 luarocks_packages
=$
(($luarocks_packages+1))
208 elif [ ${infratype} = "perl" ]; then
209 perl_packages
=$
(($perl_packages+1))
210 elif [ ${infratype} = "python" ]; then
211 python_packages
=$
(($python_packages+1))
212 elif [ ${infratype} = "virtual" ]; then
213 virtual_packages
=$
(($virtual_packages+1))
214 elif [ ${infratype} = "generic" ]; then
215 generic_packages
=$
(($generic_packages+1))
218 if grep -qE "^${pkgvariable}_LICENSE[ ]*=" $i ; then
219 packages_with_license
=$
(($packages_with_license+1))
222 packages_without_license
=$
(($packages_without_license+1))
226 if grep -qE "^${pkgvariable}_LICENSE_FILES[ ]*=" $i ; then
227 packages_with_license_files
=$
(($packages_with_license_files+1))
230 packages_without_license_files
=$
(($packages_without_license_files+1))
239 package_dir
=$
(dirname $i)
240 patch_count
=$
(find ${package_dir} -name '*.patch' |
wc -l)
241 total_patch_count
=$
(($total_patch_count+$patch_count))
243 if test $patch_count -lt 1 ; then
244 patch_count_class
="nopatches"
245 elif test $patch_count -lt 5 ; then
246 patch_count_class
="somepatches"
248 patch_count_class
="lotsofpatches"
251 echo "<td class=\"centered ${patch_count_class}\">"
252 echo "<b>$patch_count</b>"
255 if [ ${infratype} = "manual" ] ; then
256 echo "<td class=\"centered wrong\"><b>manual</b></td>"
258 echo "<td class=\"centered correct\">"
259 echo "<b>${infratype}</b><br/>"
260 if [ ${hashost} -eq 1 -a ${hastarget} -eq 1 ]; then
262 elif [ ${hashost} -eq 1 ]; then
270 if [ ${license} -eq 0 ] ; then
271 echo "<td class=\"centered wrong\">No</td>"
273 echo "<td class=\"centered correct\">Yes</td>"
276 if [ ${license_files} -eq 0 ] ; then
277 echo "<td class=\"centered wrong\">No</td>"
279 echo "<td class=\"centered correct\">Yes</td>"
287 echo "<a id="results
"></a>"
290 echo "<td>Packages using the <i>generic</i> infrastructure</td>"
291 echo "<td>$generic_packages</td>"
294 echo "<td>Packages using the <i>cmake</i> infrastructure</td>"
295 echo "<td>$cmake_packages</td>"
298 echo "<td>Packages using the <i>autotools</i> infrastructure</td>"
299 echo "<td>$autotools_packages</td>"
302 echo "<td>Packages using the <i>luarocks</i> infrastructure</td>"
303 echo "<td>$luarocks_packages</td>"
306 echo "<td>Packages using the <i>perl</i> infrastructure</td>"
307 echo "<td>$perl_packages</td>"
310 echo "<td>Packages using the <i>python</i> infrastructure</td>"
311 echo "<td>$python_packages</td>"
314 echo "<td>Packages using the <i>virtual</i> infrastructure</td>"
315 echo "<td>$virtual_packages</td>"
318 echo "<td>Packages not using any infrastructure</td>"
319 echo "<td>$manual_packages</td>"
322 echo "<td>Packages having license information</td>"
323 echo "<td>$packages_with_license</td>"
326 echo "<td>Packages not having licence information</td>"
327 echo "<td>$packages_without_license</td>"
330 echo "<td>Packages having license files information</td>"
331 echo "<td>$packages_with_license_files</td>"
334 echo "<td>Packages not having licence files information</td>"
335 echo "<td>$packages_without_license_files</td>"
338 echo "<td>Number of patches in all packages</td>"
339 echo "<td>$total_patch_count</td>"
342 echo "<td>TOTAL</td>"
348 echo "<i>Updated on $(LANG=C date), Git commit $(git log master -n 1 --pretty=format:%H)</i>"