pkg-stats 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. #!/usr/bin/env 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. <td class=\"centered\">Hash file</td>
  64. </tr>
  65. "
  66. autotools_packages=0
  67. cmake_packages=0
  68. kconfig_packages=0
  69. luarocks_package=0
  70. perl_packages=0
  71. python_packages=0
  72. rebar_packages=0
  73. virtual_packages=0
  74. generic_packages=0
  75. manual_packages=0
  76. packages_with_licence=0
  77. packages_without_licence=0
  78. packages_with_license_files=0
  79. packages_without_license_files=0
  80. packages_with_hash_file=0
  81. packages_without_hash_file=0
  82. total_patch_count=0
  83. cnt=0
  84. for i in $(find boot/ linux/ package/ -name '*.mk' | sort) ; do
  85. if test \
  86. $i = "boot/common.mk" -o \
  87. $i = "linux/linux-ext-ev3dev-linux-drivers.mk" -o \
  88. $i = "linux/linux-ext-fbtft.mk" -o \
  89. $i = "linux/linux-ext-xenomai.mk" -o \
  90. $i = "linux/linux-ext-rtai.mk" -o \
  91. $i = "package/freescale-imx/freescale-imx.mk" -o \
  92. $i = "package/gcc/gcc.mk" -o \
  93. $i = "package/gstreamer/gstreamer.mk" -o \
  94. $i = "package/gstreamer1/gstreamer1.mk" -o \
  95. $i = "package/gtk2-themes/gtk2-themes.mk" -o \
  96. $i = "package/matchbox/matchbox.mk" -o \
  97. $i = "package/opengl/opengl.mk" -o \
  98. $i = "package/qt5/qt5.mk" -o \
  99. $i = "package/x11r7/x11r7.mk" -o \
  100. $i = "package/doc-asciidoc.mk" -o \
  101. $i = "package/pkg-autotools.mk" -o \
  102. $i = "package/pkg-cmake.mk" -o \
  103. $i = "package/pkg-kconfig.mk" -o \
  104. $i = "package/pkg-luarocks.mk" -o \
  105. $i = "package/pkg-perl.mk" -o \
  106. $i = "package/pkg-python.mk" -o \
  107. $i = "package/pkg-rebar.mk" -o \
  108. $i = "package/pkg-virtual.mk" -o \
  109. $i = "package/pkg-download.mk" -o \
  110. $i = "package/pkg-generic.mk" -o \
  111. $i = "package/pkg-utils.mk" ; then
  112. echo "skipping $i" 1>&2
  113. continue
  114. fi
  115. cnt=$((cnt+1))
  116. hashost=0
  117. hastarget=0
  118. infratype=""
  119. # Determine package infrastructure
  120. if grep -E "\(host-autotools-package\)" $i > /dev/null ; then
  121. infratype="autotools"
  122. hashost=1
  123. fi
  124. if grep -E "\(autotools-package\)" $i > /dev/null ; then
  125. infratype="autotools"
  126. hastarget=1
  127. fi
  128. if grep -E "\(kconfig-package\)" $i > /dev/null ; then
  129. infratype="kconfig"
  130. hastarget=1
  131. fi
  132. if grep -E "\(host-luarocks-package\)" $i > /dev/null ; then
  133. infratype="luarocks"
  134. hashost=1
  135. fi
  136. if grep -E "\(luarocks-package\)" $i > /dev/null ; then
  137. infratype="luarocks"
  138. hastarget=1
  139. fi
  140. if grep -E "\(host-perl-package\)" $i > /dev/null ; then
  141. infratype="perl"
  142. hashost=1
  143. fi
  144. if grep -E "\(perl-package\)" $i > /dev/null ; then
  145. infratype="perl"
  146. hastarget=1
  147. fi
  148. if grep -E "\(host-python-package\)" $i > /dev/null ; then
  149. infratype="python"
  150. hashost=1
  151. fi
  152. if grep -E "\(python-package\)" $i > /dev/null ; then
  153. infratype="python"
  154. hastarget=1
  155. fi
  156. if grep -E "\(host-rebar-package\)" $i > /dev/null ; then
  157. infratype="rebar"
  158. hashost=1
  159. fi
  160. if grep -E "\(rebar-package\)" $i > /dev/null ; then
  161. infratype="rebar"
  162. hastarget=1
  163. fi
  164. if grep -E "\(host-virtual-package\)" $i > /dev/null ; then
  165. infratype="virtual"
  166. hashost=1
  167. fi
  168. if grep -E "\(virtual-package\)" $i > /dev/null ; then
  169. infratype="virtual"
  170. hastarget=1
  171. fi
  172. if grep -E "\(host-generic-package\)" $i > /dev/null ; then
  173. infratype="generic"
  174. hashost=1
  175. fi
  176. if grep -E "\(generic-package\)" $i > /dev/null ; then
  177. infratype="generic"
  178. hastarget=1
  179. fi
  180. if grep -E "\(host-cmake-package\)" $i > /dev/null ; then
  181. infratype="cmake"
  182. hashost=1
  183. fi
  184. if grep -E "\(cmake-package\)" $i > /dev/null ; then
  185. infratype="cmake"
  186. hastarget=1
  187. fi
  188. pkg=$(basename $i)
  189. dir=$(dirname $i)
  190. pkg=${pkg%.mk}
  191. pkgvariable=$(echo ${pkg} | tr "a-z-" "A-Z_")
  192. # Count packages per infrastructure
  193. if [ -z ${infratype} ] ; then
  194. infratype="manual"
  195. manual_packages=$(($manual_packages+1))
  196. elif [ ${infratype} = "autotools" ]; then
  197. autotools_packages=$(($autotools_packages+1))
  198. elif [ ${infratype} = "cmake" ]; then
  199. cmake_packages=$(($cmake_packages+1))
  200. elif [ ${infratype} = "kconfig" ]; then
  201. kconfig_packages=$(($kconfig_packages+1))
  202. elif [ ${infratype} = "luarocks" ]; then
  203. luarocks_packages=$(($luarocks_packages+1))
  204. elif [ ${infratype} = "perl" ]; then
  205. perl_packages=$(($perl_packages+1))
  206. elif [ ${infratype} = "python" ]; then
  207. python_packages=$(($python_packages+1))
  208. elif [ ${infratype} = "rebar" ]; then
  209. rebar_packages=$(($rebar_packages+1))
  210. elif [ ${infratype} = "virtual" ]; then
  211. virtual_packages=$(($virtual_packages+1))
  212. elif [ ${infratype} = "generic" ]; then
  213. generic_packages=$(($generic_packages+1))
  214. fi
  215. if grep -qE "^${pkgvariable}_LICENSE[ ]*=" $i ; then
  216. packages_with_license=$(($packages_with_license+1))
  217. license=1
  218. else
  219. packages_without_license=$(($packages_without_license+1))
  220. license=0
  221. fi
  222. if grep -qE "^${pkgvariable}_LICENSE_FILES[ ]*=" $i ; then
  223. packages_with_license_files=$(($packages_with_license_files+1))
  224. license_files=1
  225. else
  226. packages_without_license_files=$(($packages_without_license_files+1))
  227. license_files=0
  228. fi
  229. if test -f ${dir}/${pkg}.hash; then
  230. packages_with_hash_file=$(($packages_with_hash_file+1))
  231. hash_file=1
  232. else
  233. packages_without_hash_file=$(($packages_without_hash_file+1))
  234. hash_file=0
  235. fi
  236. echo "<tr>"
  237. echo "<td>$cnt</td>"
  238. echo "<td>$i</td>"
  239. package_dir=$(dirname $i)
  240. patch_count=$(find ${package_dir} -name '*.patch' | wc -l)
  241. total_patch_count=$(($total_patch_count+$patch_count))
  242. if test $patch_count -lt 1 ; then
  243. patch_count_class="nopatches"
  244. elif test $patch_count -lt 5 ; then
  245. patch_count_class="somepatches"
  246. else
  247. patch_count_class="lotsofpatches"
  248. fi
  249. echo "<td class=\"centered ${patch_count_class}\">"
  250. echo "<b>$patch_count</b>"
  251. echo "</td>"
  252. if [ ${infratype} = "manual" ] ; then
  253. echo "<td class=\"centered wrong\"><b>manual</b></td>"
  254. else
  255. echo "<td class=\"centered correct\">"
  256. echo "<b>${infratype}</b><br/>"
  257. if [ ${hashost} -eq 1 -a ${hastarget} -eq 1 ]; then
  258. echo "target + host"
  259. elif [ ${hashost} -eq 1 ]; then
  260. echo "host"
  261. else
  262. echo "target"
  263. fi
  264. echo "</td>"
  265. fi
  266. if [ ${license} -eq 0 ] ; then
  267. echo "<td class=\"centered wrong\">No</td>"
  268. else
  269. echo "<td class=\"centered correct\">Yes</td>"
  270. fi
  271. if [ ${license_files} -eq 0 ] ; then
  272. echo "<td class=\"centered wrong\">No</td>"
  273. else
  274. echo "<td class=\"centered correct\">Yes</td>"
  275. fi
  276. if [ ${hash_file} -eq 0 ] ; then
  277. echo "<td class=\"centered wrong\">No</td>"
  278. else
  279. echo "<td class=\"centered correct\">Yes</td>"
  280. fi
  281. echo "</tr>"
  282. done
  283. echo "</table>"
  284. echo "<a id="results"></a>"
  285. echo "<table>"
  286. echo "<tr>"
  287. echo "<td>Packages using the <i>generic</i> infrastructure</td>"
  288. echo "<td>$generic_packages</td>"
  289. echo "</tr>"
  290. echo "<tr>"
  291. echo "<td>Packages using the <i>cmake</i> infrastructure</td>"
  292. echo "<td>$cmake_packages</td>"
  293. echo "</tr>"
  294. echo "<tr>"
  295. echo "<td>Packages using the <i>autotools</i> infrastructure</td>"
  296. echo "<td>$autotools_packages</td>"
  297. echo "</tr>"
  298. echo "<tr>"
  299. echo "<td>Packages using the <i>luarocks</i> infrastructure</td>"
  300. echo "<td>$luarocks_packages</td>"
  301. echo "</tr>"
  302. echo "<tr>"
  303. echo "<td>Packages using the <i>kconfig</i> infrastructure</td>"
  304. echo "<td>$kconfig_packages</td>"
  305. echo "</tr>"
  306. echo "<tr>"
  307. echo "<td>Packages using the <i>perl</i> infrastructure</td>"
  308. echo "<td>$perl_packages</td>"
  309. echo "</tr>"
  310. echo "<tr>"
  311. echo "<td>Packages using the <i>python</i> infrastructure</td>"
  312. echo "<td>$python_packages</td>"
  313. echo "</tr>"
  314. echo "<tr>"
  315. echo "<td>Packages using the <i>rebar</i> infrastructure</td>"
  316. echo "<td>$rebar_packages</td>"
  317. echo "</tr>"
  318. echo "<tr>"
  319. echo "<td>Packages using the <i>virtual</i> infrastructure</td>"
  320. echo "<td>$virtual_packages</td>"
  321. echo "</tr>"
  322. echo "<tr>"
  323. echo "<td>Packages not using any infrastructure</td>"
  324. echo "<td>$manual_packages</td>"
  325. echo "</tr>"
  326. echo "<tr>"
  327. echo "<td>Packages having license information</td>"
  328. echo "<td>$packages_with_license</td>"
  329. echo "</tr>"
  330. echo "<tr>"
  331. echo "<td>Packages not having licence information</td>"
  332. echo "<td>$packages_without_license</td>"
  333. echo "</tr>"
  334. echo "<tr>"
  335. echo "<td>Packages having license files information</td>"
  336. echo "<td>$packages_with_license_files</td>"
  337. echo "</tr>"
  338. echo "<tr>"
  339. echo "<td>Packages not having licence files information</td>"
  340. echo "<td>$packages_without_license_files</td>"
  341. echo "</tr>"
  342. echo "<tr>"
  343. echo "<td>Packages having hash file</td>"
  344. echo "<td>$packages_with_hash_file</td>"
  345. echo "</tr>"
  346. echo "<tr>"
  347. echo "<td>Packages not having hash file</td>"
  348. echo "<td>$packages_without_hash_file</td>"
  349. echo "</tr>"
  350. echo "<tr>"
  351. echo "<td>Number of patches in all packages</td>"
  352. echo "<td>$total_patch_count</td>"
  353. echo "</tr>"
  354. echo "<tr>"
  355. echo "<td>TOTAL</td>"
  356. echo "<td>$cnt</td>"
  357. echo "</tr>"
  358. echo "</table>"
  359. echo "<hr/>"
  360. echo "<i>Updated on $(LANG=C date), Git commit $(git log master -n 1 --pretty=format:%H)</i>"
  361. echo "</body>"
  362. echo "</html>"