pkg-stats 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. #!/bin/bash
  2. # Copyright (C) 2009 by Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. # This script generates an HTML file that contains a report about all
  18. # Buildroot packages, their usage of the different package
  19. # infrastructure and possible cleanup actions
  20. #
  21. # Run the script from the Buildroot toplevel directory:
  22. #
  23. # ./support/scripts/pkg-stats > /tmp/pkg.html
  24. #
  25. echo "<head>
  26. <style type=\"text/css\">
  27. table {
  28. width: 100%;
  29. }
  30. td {
  31. border: 1px solid black;
  32. }
  33. td.centered {
  34. text-align: center;
  35. }
  36. td.wrong {
  37. background: #ff9a69;
  38. }
  39. td.correct {
  40. background: #d2ffc4;
  41. }
  42. td.nopatches {
  43. background: #d2ffc4;
  44. }
  45. td.somepatches {
  46. background: #ffd870;
  47. }
  48. td.lotsofpatches {
  49. background: #ff9a69;
  50. }
  51. </style>
  52. <title>Statistics of Buildroot packages</title>
  53. </head>
  54. <a href=\"#results\">Results</a><br/>
  55. <table>
  56. <tr>
  57. <td>Id</td>
  58. <td>Package</td>
  59. <td class=\"centered\">Patch count</td>
  60. <td class=\"centered\">Infrastructure</td>
  61. <td class=\"centered\">License</td>
  62. <td class=\"centered\">License files</td>
  63. </tr>
  64. "
  65. autotools_packages=0
  66. cmake_packages=0
  67. luarocks_package=0
  68. perl_packages=0
  69. python_packages=0
  70. virtual_packages=0
  71. generic_packages=0
  72. manual_packages=0
  73. packages_with_licence=0
  74. packages_without_licence=0
  75. packages_with_license_files=0
  76. packages_without_license_files=0
  77. total_patch_count=0
  78. cnt=0
  79. for i in $(find boot/ linux/ package/ -name '*.mk' | sort) ; do
  80. if test \
  81. $i = "boot/common.mk" -o \
  82. $i = "linux/linux-ext-xenomai.mk" -o \
  83. $i = "linux/linux-ext-rtai.mk" -o \
  84. $i = "package/efl/efl.mk" -o \
  85. $i = "package/freescale-imx/freescale-imx.mk" -o \
  86. $i = "package/gcc/gcc.mk" -o \
  87. $i = "package/gstreamer/gstreamer.mk" -o \
  88. $i = "package/gstreamer1/gstreamer1.mk" -o \
  89. $i = "package/gtk2-themes/gtk2-themes.mk" -o \
  90. $i = "package/matchbox/matchbox.mk" -o \
  91. $i = "package/opengl/opengl.mk" -o \
  92. $i = "package/qt5/qt5.mk" -o \
  93. $i = "package/x11r7/x11r7.mk" -o \
  94. $i = "package/pkg-autotools.mk" -o \
  95. $i = "package/pkg-cmake.mk" -o \
  96. $i = "package/pkg-luarocks.mk" -o \
  97. $i = "package/pkg-perl.mk" -o \
  98. $i = "package/pkg-python.mk" -o \
  99. $i = "package/pkg-virtual.mk" -o \
  100. $i = "package/pkg-download.mk" -o \
  101. $i = "package/pkg-generic.mk" -o \
  102. $i = "package/pkg-utils.mk" ; then
  103. echo "skipping $i" 1>&2
  104. continue
  105. fi
  106. cnt=$((cnt+1))
  107. hashost=0
  108. hastarget=0
  109. infratype=""
  110. # Determine package infrastructure
  111. if grep -E "\(host-autotools-package\)" $i > /dev/null ; then
  112. infratype="autotools"
  113. hashost=1
  114. fi
  115. if grep -E "\(autotools-package\)" $i > /dev/null ; then
  116. infratype="autotools"
  117. hastarget=1
  118. fi
  119. if grep -E "\(host-luarocks-package\)" $i > /dev/null ; then
  120. infratype="luarocks"
  121. hashost=1
  122. fi
  123. if grep -E "\(luarocks-package\)" $i > /dev/null ; then
  124. infratype="luarocks"
  125. hastarget=1
  126. fi
  127. if grep -E "\(host-perl-package\)" $i > /dev/null ; then
  128. infratype="perl"
  129. hashost=1
  130. fi
  131. if grep -E "\(perl-package\)" $i > /dev/null ; then
  132. infratype="perl"
  133. hastarget=1
  134. fi
  135. if grep -E "\(host-python-package\)" $i > /dev/null ; then
  136. infratype="python"
  137. hashost=1
  138. fi
  139. if grep -E "\(python-package\)" $i > /dev/null ; then
  140. infratype="python"
  141. hastarget=1
  142. fi
  143. if grep -E "\(host-virtual-package\)" $i > /dev/null ; then
  144. infratype="virtual"
  145. hashost=1
  146. fi
  147. if grep -E "\(virtual-package\)" $i > /dev/null ; then
  148. infratype="virtual"
  149. hastarget=1
  150. fi
  151. if grep -E "\(host-generic-package\)" $i > /dev/null ; then
  152. infratype="generic"
  153. hashost=1
  154. fi
  155. if grep -E "\(generic-package\)" $i > /dev/null ; then
  156. infratype="generic"
  157. hastarget=1
  158. fi
  159. if grep -E "\(host-cmake-package\)" $i > /dev/null ; then
  160. infratype="cmake"
  161. hashost=1
  162. fi
  163. if grep -E "\(cmake-package\)" $i > /dev/null ; then
  164. infratype="cmake"
  165. hastarget=1
  166. fi
  167. pkg=$(basename $i)
  168. pkg=${pkg%.mk}
  169. pkgvariable=$(echo ${pkg} | tr "a-z-" "A-Z_")
  170. # Count packages per infrastructure
  171. if [ -z ${infratype} ] ; then
  172. infratype="manual"
  173. manual_packages=$(($manual_packages+1))
  174. elif [ ${infratype} = "autotools" ]; then
  175. autotools_packages=$(($autotools_packages+1))
  176. elif [ ${infratype} = "cmake" ]; then
  177. cmake_packages=$(($cmake_packages+1))
  178. elif [ ${infratype} = "luarocks" ]; then
  179. luarocks_packages=$(($luarocks_packages+1))
  180. elif [ ${infratype} = "perl" ]; then
  181. perl_packages=$(($perl_packages+1))
  182. elif [ ${infratype} = "python" ]; then
  183. python_packages=$(($python_packages+1))
  184. elif [ ${infratype} = "virtual" ]; then
  185. virtual_packages=$(($virtual_packages+1))
  186. elif [ ${infratype} = "generic" ]; then
  187. generic_packages=$(($generic_packages+1))
  188. fi
  189. if grep -qE "^${pkgvariable}_LICENSE[ ]*=" $i ; then
  190. packages_with_license=$(($packages_with_license+1))
  191. license=1
  192. else
  193. packages_without_license=$(($packages_without_license+1))
  194. license=0
  195. fi
  196. if grep -qE "^${pkgvariable}_LICENSE_FILES[ ]*=" $i ; then
  197. packages_with_license_files=$(($packages_with_license_files+1))
  198. license_files=1
  199. else
  200. packages_without_license_files=$(($packages_without_license_files+1))
  201. license_files=0
  202. fi
  203. echo "<tr>"
  204. echo "<td>$cnt</td>"
  205. echo "<td>$i</td>"
  206. package_dir=$(dirname $i)
  207. patch_count=$(find ${package_dir} -name '*.patch' | wc -l)
  208. total_patch_count=$(($total_patch_count+$patch_count))
  209. if test $patch_count -lt 1 ; then
  210. patch_count_class="nopatches"
  211. elif test $patch_count -lt 5 ; then
  212. patch_count_class="somepatches"
  213. else
  214. patch_count_class="lotsofpatches"
  215. fi
  216. echo "<td class=\"centered ${patch_count_class}\">"
  217. echo "<b>$patch_count</b>"
  218. echo "</td>"
  219. if [ ${infratype} = "manual" ] ; then
  220. echo "<td class=\"centered wrong\"><b>manual</b></td>"
  221. else
  222. echo "<td class=\"centered correct\">"
  223. echo "<b>${infratype}</b><br/>"
  224. if [ ${hashost} -eq 1 -a ${hastarget} -eq 1 ]; then
  225. echo "target + host"
  226. elif [ ${hashost} -eq 1 ]; then
  227. echo "host"
  228. else
  229. echo "target"
  230. fi
  231. echo "</td>"
  232. fi
  233. if [ ${license} -eq 0 ] ; then
  234. echo "<td class=\"centered wrong\">No</td>"
  235. else
  236. echo "<td class=\"centered correct\">Yes</td>"
  237. fi
  238. if [ ${license_files} -eq 0 ] ; then
  239. echo "<td class=\"centered wrong\">No</td>"
  240. else
  241. echo "<td class=\"centered correct\">Yes</td>"
  242. fi
  243. echo "</tr>"
  244. done
  245. echo "</table>"
  246. echo "<a id="results"></a>"
  247. echo "<table>"
  248. echo "<tr>"
  249. echo "<td>Packages using the <i>generic</i> infrastructure</td>"
  250. echo "<td>$generic_packages</td>"
  251. echo "</tr>"
  252. echo "<tr>"
  253. echo "<td>Packages using the <i>cmake</i> infrastructure</td>"
  254. echo "<td>$cmake_packages</td>"
  255. echo "</tr>"
  256. echo "<tr>"
  257. echo "<td>Packages using the <i>autotools</i> infrastructure</td>"
  258. echo "<td>$autotools_packages</td>"
  259. echo "</tr>"
  260. echo "<tr>"
  261. echo "<td>Packages using the <i>luarocks</i> infrastructure</td>"
  262. echo "<td>$luarocks_packages</td>"
  263. echo "</tr>"
  264. echo "<tr>"
  265. echo "<td>Packages using the <i>perl</i> infrastructure</td>"
  266. echo "<td>$perl_packages</td>"
  267. echo "</tr>"
  268. echo "<tr>"
  269. echo "<td>Packages using the <i>python</i> infrastructure</td>"
  270. echo "<td>$python_packages</td>"
  271. echo "</tr>"
  272. echo "<tr>"
  273. echo "<td>Packages using the <i>virtual</i> infrastructure</td>"
  274. echo "<td>$virtual_packages</td>"
  275. echo "</tr>"
  276. echo "<tr>"
  277. echo "<td>Packages not using any infrastructure</td>"
  278. echo "<td>$manual_packages</td>"
  279. echo "</tr>"
  280. echo "<tr>"
  281. echo "<td>Packages having license information</td>"
  282. echo "<td>$packages_with_license</td>"
  283. echo "</tr>"
  284. echo "<tr>"
  285. echo "<td>Packages not having licence information</td>"
  286. echo "<td>$packages_without_license</td>"
  287. echo "</tr>"
  288. echo "<tr>"
  289. echo "<td>Packages having license files information</td>"
  290. echo "<td>$packages_with_license_files</td>"
  291. echo "</tr>"
  292. echo "<tr>"
  293. echo "<td>Packages not having licence files information</td>"
  294. echo "<td>$packages_without_license_files</td>"
  295. echo "</tr>"
  296. echo "<tr>"
  297. echo "<td>Number of patches in all packages</td>"
  298. echo "<td>$total_patch_count</td>"
  299. echo "</tr>"
  300. echo "<tr>"
  301. echo "<td>TOTAL</td>"
  302. echo "<td>$cnt</td>"
  303. echo "</tr>"
  304. echo "</table>"
  305. echo "<hr/>"
  306. echo "<i>Updated on $(LANG=C date), Git commit $(git log master -n 1 --pretty=format:%H)</i>"
  307. echo "</body>"
  308. echo "</html>"