2
1

pkg-stats 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. generic_packages=0
  68. manual_packages=0
  69. packages_with_licence=0
  70. packages_without_licence=0
  71. packages_with_license_files=0
  72. packages_without_license_files=0
  73. total_patch_count=0
  74. cnt=0
  75. for i in $(find boot/ linux/ package/ -name '*.mk' | sort) ; do
  76. if test \
  77. $i = "boot/common.mk" -o \
  78. $i = "linux/linux-ext-xenomai.mk" -o \
  79. $i = "linux/linux-ext-rtai.mk" -o \
  80. $i = "package/efl/efl.mk" -o \
  81. $i = "package/freescale-imx/freescale-imx.mk" -o \
  82. $i = "package/gcc/gcc.mk" -o \
  83. $i = "package/gstreamer/gstreamer.mk" -o \
  84. $i = "package/gstreamer1/gstreamer1.mk" -o \
  85. $i = "package/gtk2-themes/gtk2-themes.mk" -o \
  86. $i = "package/matchbox/matchbox.mk" -o \
  87. $i = "package/opengl/opengl.mk" -o \
  88. $i = "package/qt5/qt5.mk" -o \
  89. $i = "package/x11r7/x11r7.mk" -o \
  90. $i = "package/pkg-autotools.mk" -o \
  91. $i = "package/pkg-cmake.mk" -o \
  92. $i = "package/pkg-download.mk" -o \
  93. $i = "package/pkg-generic.mk" -o \
  94. $i = "package/pkg-utils.mk" ; then
  95. echo "skipping $i" 1>&2
  96. continue
  97. fi
  98. cnt=$((cnt+1))
  99. hashost=0
  100. hastarget=0
  101. infratype=""
  102. # Determine package infrastructure
  103. if grep -E "\(host-autotools-package\)" $i > /dev/null ; then
  104. infratype="autotools"
  105. hashost=1
  106. fi
  107. if grep -E "\(autotools-package\)" $i > /dev/null ; then
  108. infratype="autotools"
  109. hastarget=1
  110. fi
  111. if grep -E "\(host-generic-package\)" $i > /dev/null ; then
  112. infratype="generic"
  113. hashost=1
  114. fi
  115. if grep -E "\(generic-package\)" $i > /dev/null ; then
  116. infratype="generic"
  117. hastarget=1
  118. fi
  119. if grep -E "\(host-cmake-package\)" $i > /dev/null ; then
  120. infratype="cmake"
  121. hashost=1
  122. fi
  123. if grep -E "\(cmake-package\)" $i > /dev/null ; then
  124. infratype="cmake"
  125. hastarget=1
  126. fi
  127. pkg=$(basename $i)
  128. pkg=${pkg%.mk}
  129. pkgvariable=$(echo ${pkg} | tr "a-z-" "A-Z_")
  130. # Count packages per infrastructure
  131. if [ -z ${infratype} ] ; then
  132. infratype="manual"
  133. manual_packages=$(($manual_packages+1))
  134. elif [ ${infratype} = "autotools" ]; then
  135. autotools_packages=$(($autotools_packages+1))
  136. elif [ ${infratype} = "cmake" ]; then
  137. cmake_packages=$(($cmake_packages+1))
  138. elif [ ${infratype} = "generic" ]; then
  139. generic_packages=$(($generic_packages+1))
  140. fi
  141. if grep -qE "^${pkgvariable}_LICENSE[ ]*=" $i ; then
  142. packages_with_license=$(($packages_with_license+1))
  143. license=1
  144. else
  145. packages_without_license=$(($packages_without_license+1))
  146. license=0
  147. fi
  148. if grep -qE "^${pkgvariable}_LICENSE_FILES[ ]*=" $i ; then
  149. packages_with_license_files=$(($packages_with_license_files+1))
  150. license_files=1
  151. else
  152. packages_without_license_files=$(($packages_without_license_files+1))
  153. license_files=0
  154. fi
  155. echo "<tr>"
  156. echo "<td>$cnt</td>"
  157. echo "<td>$i</td>"
  158. package_dir=$(dirname $i)
  159. patch_count=$(find ${package_dir} -name '*.patch' | wc -l)
  160. total_patch_count=$(($total_patch_count+$patch_count))
  161. if test $patch_count -lt 1 ; then
  162. patch_count_class="nopatches"
  163. elif test $patch_count -lt 5 ; then
  164. patch_count_class="somepatches"
  165. else
  166. patch_count_class="lotsofpatches"
  167. fi
  168. echo "<td class=\"centered ${patch_count_class}\">"
  169. echo "<b>$patch_count</b>"
  170. echo "</td>"
  171. if [ ${infratype} = "manual" ] ; then
  172. echo "<td class=\"centered wrong\"><b>manual</b></td>"
  173. else
  174. echo "<td class=\"centered correct\">"
  175. echo "<b>${infratype}</b><br/>"
  176. if [ ${hashost} -eq 1 -a ${hastarget} -eq 1 ]; then
  177. echo "target + host"
  178. elif [ ${hashost} -eq 1 ]; then
  179. echo "host"
  180. else
  181. echo "target"
  182. fi
  183. echo "</td>"
  184. fi
  185. if [ ${license} -eq 0 ] ; then
  186. echo "<td class=\"centered wrong\">No</td>"
  187. else
  188. echo "<td class=\"centered correct\">Yes</td>"
  189. fi
  190. if [ ${license_files} -eq 0 ] ; then
  191. echo "<td class=\"centered wrong\">No</td>"
  192. else
  193. echo "<td class=\"centered correct\">Yes</td>"
  194. fi
  195. echo "</tr>"
  196. done
  197. echo "</table>"
  198. echo "<a id="results"></a>"
  199. echo "<table>"
  200. echo "<tr>"
  201. echo "<td>Packages using the <i>generic</i> infrastructure</td>"
  202. echo "<td>$generic_packages</td>"
  203. echo "</tr>"
  204. echo "<tr>"
  205. echo "<td>Packages using the <i>cmake</i> infrastructure</td>"
  206. echo "<td>$cmake_packages</td>"
  207. echo "</tr>"
  208. echo "<tr>"
  209. echo "<td>Packages using the <i>autotools</i> infrastructure</td>"
  210. echo "<td>$autotools_packages</td>"
  211. echo "</tr>"
  212. echo "<tr>"
  213. echo "<td>Packages not using any infrastructure</td>"
  214. echo "<td>$manual_packages</td>"
  215. echo "</tr>"
  216. echo "<tr>"
  217. echo "<td>Packages having license information</td>"
  218. echo "<td>$packages_with_license</td>"
  219. echo "</tr>"
  220. echo "<tr>"
  221. echo "<td>Packages not having licence information</td>"
  222. echo "<td>$packages_without_license</td>"
  223. echo "</tr>"
  224. echo "<tr>"
  225. echo "<td>Packages having license files information</td>"
  226. echo "<td>$packages_with_license_files</td>"
  227. echo "</tr>"
  228. echo "<tr>"
  229. echo "<td>Packages not having licence files information</td>"
  230. echo "<td>$packages_without_license_files</td>"
  231. echo "</tr>"
  232. echo "<tr>"
  233. echo "<td>Number of patches in all packages</td>"
  234. echo "<td>$total_patch_count</td>"
  235. echo "</tr>"
  236. echo "<tr>"
  237. echo "<td>TOTAL</td>"
  238. echo "<td>$cnt</td>"
  239. echo "</tr>"
  240. echo "</table>"
  241. echo "<hr/>"
  242. echo "<i>Updated on $(LANG=C date), Git commit $(git log master -n 1 --pretty=format:%H)</i>"
  243. echo "</body>"
  244. echo "</html>"