pkg-stats 6.8 KB

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