pkg-stats 6.7 KB

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