pkg-stats 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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 colspan=\"2\" class=\"centered\">AUTOTARGETS</td>
  50. <td colspan=\"2\" class=\"centered\">GENTARGETS</td>
  51. <td colspan=\"2\" class=\"centered\">manual</td>
  52. <td rowspan=\"2\" class=\"centered\">Actions</td>
  53. </tr>
  54. <tr>
  55. <td class=\"centered\">host</td>
  56. <td class=\"centered\">target</td>
  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. </tr>"
  62. convert_to_generic_target=0
  63. convert_to_generic_host=0
  64. convert_to_autotools=0
  65. cnt=1
  66. for i in $(find package/ -name '*.mk') ; do
  67. if test $i = "package/mtd/mtd.mk" -o \
  68. $i = "package/java/java.mk" -o \
  69. $i = "package/database/database.mk" -o \
  70. $i = "package/editors/editors.mk" -o \
  71. $i = "package/games/games.mk" -o \
  72. $i = "package/multimedia/multimedia.mk" -o \
  73. $i = "package/customize/customize.mk" -o \
  74. $i = "package/gnuconfig/gnuconfig.mk" -o \
  75. $i = "package/x11r7/x11r7.mk" ; then
  76. echo "skipping $i" 1>&2
  77. continue
  78. fi
  79. cnt=$((cnt+1))
  80. is_auto_host=0
  81. is_auto_target=0
  82. is_pkg_target=0
  83. is_pkg_host=0
  84. is_manual_target=0
  85. is_manual_host=0
  86. if grep -E "\(call AUTOTARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then
  87. is_auto_host=1
  88. fi
  89. if grep -E "\(call AUTOTARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then
  90. is_auto_target=1
  91. fi
  92. if grep -E "\(call GENTARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then
  93. is_pkg_host=1
  94. fi
  95. if grep -E "\(call GENTARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then
  96. is_pkg_target=1
  97. fi
  98. pkg=$(basename $i)
  99. pkg=${pkg%.mk}
  100. if grep "^host-$pkg:" $i > /dev/null ; then
  101. is_manual_host=1
  102. fi
  103. if test $is_pkg_target -eq 0 -a $is_auto_target -eq 0 ; then
  104. is_manual_target=1
  105. fi
  106. tasks=""
  107. if [ $is_manual_target -eq 1 ] ; then
  108. if grep "/configure" $i > /dev/null ; then
  109. tasks=$tasks"<li>convert package to autotools ?</li>"
  110. convert_to_target_autotools=$((convert_to_target_autotools+1))
  111. else
  112. tasks=$tasks"<li>convert to generic target</li>"
  113. convert_to_generic_target=$((convert_to_generic_target+1))
  114. fi
  115. fi
  116. if [ $is_manual_host -eq 1 ]; then
  117. if grep "/configure" $i > /dev/null ; then
  118. tasks=$tasks"<li>convert package to autotools ?</li>"
  119. convert_to_host_autotools=$((convert_to_host_autotools+1))
  120. else
  121. tasks=$tasks"<li>convert to generic host</li>"
  122. convert_to_generic_host=$((convert_to_generic_host+1))
  123. fi
  124. fi
  125. if test -n "$tasks" ; then
  126. echo "<tr class=\"wrong\">"
  127. else
  128. echo "<tr class=\"correct\">"
  129. fi
  130. echo "<td>$cnt</td>"
  131. echo "<td>$i</td>"
  132. echo "<td class=\"centered\">"
  133. if [ $is_auto_host -eq 1 ] ; then
  134. echo "<b>YES</b>"
  135. else
  136. echo "NO"
  137. fi
  138. echo "</td>"
  139. echo "<td class=\"centered\">"
  140. if [ $is_auto_target -eq 1 ] ; then
  141. echo "<b>YES</b>"
  142. else
  143. echo "NO"
  144. fi
  145. echo "</td>"
  146. echo "<td class=\"centered\">"
  147. if [ $is_pkg_host -eq 1 ] ; then
  148. echo "<b>YES</b>"
  149. else
  150. echo "NO"
  151. fi
  152. echo "</td>"
  153. echo "<td class=\"centered\">"
  154. if [ $is_pkg_target -eq 1 ] ; then
  155. echo "<b>YES</b>"
  156. else
  157. echo "NO"
  158. fi
  159. echo "</td>"
  160. echo "<td class=\"centered\">"
  161. if [ $is_manual_host -eq 1 ] ; then
  162. echo "<b>YES</b>"
  163. else
  164. echo "NO"
  165. fi
  166. echo "</td>"
  167. echo "<td class=\"centered\">"
  168. if [ $is_manual_target -eq 1 ] ; then
  169. echo "<b>YES</b>"
  170. else
  171. echo "NO"
  172. fi
  173. echo "</td>"
  174. echo "<td>"
  175. echo "<ul>"
  176. echo $tasks
  177. echo "</ul>"
  178. echo "</td>"
  179. echo "</tr>"
  180. done
  181. echo "</table>"
  182. echo "<table>"
  183. echo "<tr>"
  184. echo "<td>Packages to convert to generic target</td>"
  185. echo "<td>$convert_to_generic_target</td>"
  186. echo "</tr>"
  187. echo "<tr>"
  188. echo "<td>Packages to convert to generic host</td>"
  189. echo "<td>$convert_to_generic_host</td>"
  190. echo "</tr>"
  191. echo "<tr>"
  192. echo "<td>Packages to convert to target autotools</td>"
  193. echo "<td>$convert_to_target_autotools</td>"
  194. echo "</tr>"
  195. echo "<tr>"
  196. echo "<td>Packages to convert to host autotools</td>"
  197. echo "<td>$convert_to_host_autotools</td>"
  198. echo "</tr>"
  199. echo "<tr>"
  200. echo "<td>TOTAL</td>"
  201. echo "<td>$cnt</td>"
  202. echo "</tr>"
  203. echo "</table>"