pkg-stats 11 KB

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