pkg-stats 6.6 KB

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