pkg-stats 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. tr.wrong td {
  37. background: #ff9a69;
  38. }
  39. tr.correct td {
  40. background: #d2ffc4;
  41. }
  42. </style>
  43. </head>
  44. <a href=\"#results\">Results</a><br/>
  45. <table>
  46. <tr>
  47. <td rowspan=\"2\">Id</td>
  48. <td rowspan=\"2\">Package</td>
  49. <td rowspan=\"2\">Patch count</td>
  50. <td colspan=\"2\" class=\"centered\">AUTOTARGETS</td>
  51. <td colspan=\"2\" class=\"centered\">GENTARGETS</td>
  52. <td colspan=\"2\" class=\"centered\">CMAKETARGETS</td>
  53. <td colspan=\"2\" class=\"centered\">manual</td>
  54. <td rowspan=\"2\" class=\"centered\">Actions</td>
  55. </tr>
  56. <tr>
  57. <td class=\"centered\">host</td>
  58. <td class=\"centered\">target</td>
  59. <td class=\"centered\">host</td>
  60. <td class=\"centered\">target</td>
  61. <td class=\"centered\">host</td>
  62. <td class=\"centered\">target</td>
  63. <td class=\"centered\">host</td>
  64. <td class=\"centered\">target</td>
  65. </tr>"
  66. convert_to_generic_target=0
  67. convert_to_generic_host=0
  68. convert_to_target_autotools=0
  69. convert_to_host_autotools=0
  70. total_patch_count=0
  71. cnt=0
  72. for i in $(find package/ -name '*.mk') ; do
  73. if test \
  74. $i = "package/efl/efl.mk" -o \
  75. $i = "package/games/games.mk" -o \
  76. $i = "package/gtk2-themes/gtk2-themes.mk" -o \
  77. $i = "package/multimedia/multimedia.mk" -o \
  78. $i = "package/customize/customize.mk" -o \
  79. $i = "package/matchbox/matchbox.mk" -o \
  80. $i = "package/x11r7/x11r7.mk" ; then
  81. echo "skipping $i" 1>&2
  82. continue
  83. fi
  84. cnt=$((cnt+1))
  85. is_auto_host=0
  86. is_auto_target=0
  87. is_cmake_host=0
  88. is_cmake_target=0
  89. is_pkg_target=0
  90. is_pkg_host=0
  91. is_manual_target=0
  92. is_manual_host=0
  93. if grep -E "\(call AUTOTARGETS,host\)" $i > /dev/null ; then
  94. is_auto_host=1
  95. fi
  96. if grep -E "\(call AUTOTARGETS\)" $i > /dev/null ; then
  97. is_auto_target=1
  98. fi
  99. if grep -E "\(call GENTARGETS,host\)" $i > /dev/null ; then
  100. is_pkg_host=1
  101. fi
  102. if grep -E "\(call GENTARGETS\)" $i > /dev/null ; then
  103. is_pkg_target=1
  104. fi
  105. if grep -E "\(call CMAKETARGETS,host\)" $i > /dev/null ; then
  106. is_cmake_host=1
  107. fi
  108. if grep -E "\(call CMAKETARGETS\)" $i > /dev/null ; then
  109. is_cmake_target=1
  110. fi
  111. pkg=$(basename $i)
  112. pkg=${pkg%.mk}
  113. if grep "^host-$pkg:" $i > /dev/null ; then
  114. is_manual_host=1
  115. fi
  116. if test $is_pkg_target -eq 0 -a $is_auto_target -eq 0 -a $is_cmake_target -eq 0; then
  117. is_manual_target=1
  118. fi
  119. tasks=""
  120. if [ $is_manual_target -eq 1 ] ; then
  121. if grep "/configure" $i > /dev/null ; then
  122. tasks=$tasks"<li>convert package to autotools ?</li>"
  123. convert_to_target_autotools=$((convert_to_target_autotools+1))
  124. else
  125. tasks=$tasks"<li>convert to generic target</li>"
  126. convert_to_generic_target=$((convert_to_generic_target+1))
  127. fi
  128. fi
  129. if [ $is_manual_host -eq 1 ]; then
  130. if grep "/configure" $i > /dev/null ; then
  131. tasks=$tasks"<li>convert package to autotools ?</li>"
  132. convert_to_host_autotools=$((convert_to_host_autotools+1))
  133. else
  134. tasks=$tasks"<li>convert to generic host</li>"
  135. convert_to_generic_host=$((convert_to_generic_host+1))
  136. fi
  137. fi
  138. if test -n "$tasks" ; then
  139. echo "<tr class=\"wrong\">"
  140. else
  141. echo "<tr class=\"correct\">"
  142. fi
  143. echo "<td>$cnt</td>"
  144. echo "<td>$i</td>"
  145. package_dir=$(dirname $i)
  146. patch_count=$(find ${package_dir} -name '*.patch' | wc -l)
  147. total_patch_count=$(($total_patch_count+$patch_count))
  148. if test $patch_count -lt 1 ; then
  149. patch_count_color="#00ff00"
  150. elif test $patch_count -lt 5 ; then
  151. patch_count_color="#ffc600"
  152. else
  153. patch_count_color="#ff0000"
  154. fi
  155. echo "<td class=\"centered\" style=\"color: $patch_count_color; font-weight: bold;\">"
  156. echo $patch_count
  157. echo "</td>"
  158. echo "<td class=\"centered\">"
  159. if [ $is_auto_host -eq 1 ] ; then
  160. echo "<b>YES</b>"
  161. else
  162. echo "NO"
  163. fi
  164. echo "</td>"
  165. echo "<td class=\"centered\">"
  166. if [ $is_auto_target -eq 1 ] ; then
  167. echo "<b>YES</b>"
  168. else
  169. echo "NO"
  170. fi
  171. echo "</td>"
  172. echo "<td class=\"centered\">"
  173. if [ $is_pkg_host -eq 1 ] ; then
  174. echo "<b>YES</b>"
  175. else
  176. echo "NO"
  177. fi
  178. echo "</td>"
  179. echo "<td class=\"centered\">"
  180. if [ $is_pkg_target -eq 1 ] ; then
  181. echo "<b>YES</b>"
  182. else
  183. echo "NO"
  184. fi
  185. echo "</td>"
  186. echo "<td class=\"centered\">"
  187. if [ $is_cmake_host -eq 1 ] ; then
  188. echo "<b>YES</b>"
  189. else
  190. echo "NO"
  191. fi
  192. echo "</td>"
  193. echo "<td class=\"centered\">"
  194. if [ $is_cmake_target -eq 1 ] ; then
  195. echo "<b>YES</b>"
  196. else
  197. echo "NO"
  198. fi
  199. echo "</td>"
  200. echo "<td class=\"centered\">"
  201. if [ $is_manual_host -eq 1 ] ; then
  202. echo "<b>YES</b>"
  203. else
  204. echo "NO"
  205. fi
  206. echo "</td>"
  207. echo "<td class=\"centered\">"
  208. if [ $is_manual_target -eq 1 ] ; then
  209. echo "<b>YES</b>"
  210. else
  211. echo "NO"
  212. fi
  213. echo "</td>"
  214. echo "<td>"
  215. echo "<ul>"
  216. echo $tasks
  217. echo "</ul>"
  218. echo "</td>"
  219. echo "</tr>"
  220. done
  221. echo "</table>"
  222. echo "<table>"
  223. echo "<tr>"
  224. echo "<td>Packages to convert to generic target</td>"
  225. echo "<td>$convert_to_generic_target</td>"
  226. echo "</tr>"
  227. echo "<tr>"
  228. echo "<td>Packages to convert to generic host</td>"
  229. echo "<td>$convert_to_generic_host</td>"
  230. echo "</tr>"
  231. echo "<tr>"
  232. echo "<td>Packages to convert to target autotools</td>"
  233. echo "<td>$convert_to_target_autotools</td>"
  234. echo "</tr>"
  235. echo "<tr>"
  236. echo "<td>Packages to convert to host autotools</td>"
  237. echo "<td>$convert_to_host_autotools</td>"
  238. echo "</tr>"
  239. echo "<tr>"
  240. echo "<td>Number of patches in all packages</td>"
  241. echo "<td>$total_patch_count</td>"
  242. echo "</tr>"
  243. echo "<tr>"
  244. echo "<td>TOTAL</td>"
  245. echo "<td>$cnt</td>"
  246. echo "</tr>"
  247. echo "</table>"