pkg-stats 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. </style>
  37. </head>
  38. <a href=\"#results\">Results</a><br/>
  39. <table>
  40. <tr>
  41. <td rowspan=\"2\">Id</td>
  42. <td rowspan=\"2\">Package</td>
  43. <td colspan=\"2\" class=\"centered\">AUTOTARGETS</td>
  44. <td colspan=\"2\" class=\"centered\">GENTARGETS</td>
  45. <td colspan=\"2\" class=\"centered\">manual</td>
  46. <td rowspan=\"2\" class=\"centered\">Actions</td>
  47. </tr>
  48. <tr>
  49. <td class=\"centered\">host</td>
  50. <td class=\"centered\">target</td>
  51. <td class=\"centered\">host</td>
  52. <td class=\"centered\">target</td>
  53. <td class=\"centered\">host</td>
  54. <td class=\"centered\">target</td>
  55. </tr>"
  56. convert_to_generic_target=0
  57. convert_to_generic_host=0
  58. convert_to_autotools=0
  59. cnt=1
  60. for i in $(find package/ -name '*.mk') ; do
  61. if test $i = "package/mtd/mtd.mk" -o \
  62. $i = "package/java/java.mk" -o \
  63. $i = "package/database/database.mk" -o \
  64. $i = "package/editors/editors.mk" -o \
  65. $i = "package/games/games.mk" -o \
  66. $i = "package/multimedia/multimedia" -o \
  67. $i = "package/customize/customize.mk" -o \
  68. $i = "package/gnuconfig/gnuconfig.mk" -o \
  69. $i = "package/x11r7/x11r7.mk" ; then
  70. echo "skipping $i" 1>&2
  71. continue
  72. fi
  73. found=0
  74. echo "<tr>"
  75. echo "<td>$cnt</td>"
  76. cnt=$((cnt+1))
  77. echo "<td>$i</td>"
  78. is_auto_host=0
  79. is_auto_target=0
  80. is_pkg_target=0
  81. is_pkg_host=0
  82. is_manual_target=0
  83. is_manual_host=0
  84. echo "<td class=\"centered\">"
  85. if grep -E "\(call AUTOTARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then
  86. is_auto_host=1
  87. echo "<b>YES</b>"
  88. else
  89. echo "NO"
  90. fi
  91. echo "<td class=\"centered\">"
  92. if grep -E "\(call AUTOTARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then
  93. found=1
  94. is_auto_target=1
  95. echo "<b>YES</b>"
  96. else
  97. echo "NO"
  98. fi
  99. echo "</td>"
  100. echo "<td class=\"centered\">"
  101. if grep -E "\(call GENTARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then
  102. found=1
  103. is_pkg_host=1
  104. echo "<b>YES</b>"
  105. else
  106. echo "NO"
  107. fi
  108. echo "</td>"
  109. echo "<td class=\"centered\">"
  110. if grep -E "\(call GENTARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then
  111. found=1
  112. is_pkg_target=1
  113. echo "<b>YES</b>"
  114. else
  115. echo "NO"
  116. fi
  117. echo "</td>"
  118. pkg=$(basename $i)
  119. pkg=${pkg%.mk}
  120. echo "<td class=\"centered\">"
  121. if grep "^host-$pkg:" $i > /dev/null ; then
  122. found=1
  123. is_manual_host=1
  124. echo "<b>YES</b>"
  125. else
  126. echo "NO"
  127. fi
  128. echo "</td>"
  129. echo "<td class=\"centered\">"
  130. if grep "^$pkg:" $i > /dev/null ; then
  131. found=1
  132. is_manual_target=1
  133. echo "<b>YES</b>"
  134. else
  135. echo "NO"
  136. fi
  137. echo "</td>"
  138. echo "<td>"
  139. echo "<ul>"
  140. if [ $is_manual_target -eq 1 ]; then
  141. echo "<li>convert to generic target</li>"
  142. convert_to_generic_target=$((convert_to_generic_target+1))
  143. fi
  144. if [ $is_manual_host -eq 1 ]; then
  145. echo "<li>convert to generic host</li>"
  146. convert_to_generic_host=$((convert_to_generic_host+1))
  147. fi
  148. if grep "\./configure" $i > /dev/null ; then
  149. if [ $is_manual_host -ne 1 ] ; then
  150. echo "<li>convert package to autotools ?</li>"
  151. convert_to_autotools=$((convert_to_autotools+1))
  152. fi
  153. fi
  154. if [ $found -eq 0 ] ; then
  155. echo "<li>look manually</li>"
  156. fi
  157. echo "</ul>"
  158. echo "</td>"
  159. echo "</tr>"
  160. done
  161. echo "</table>"
  162. echo "<table>"
  163. echo "<tr>"
  164. echo "<td>Packages to convert to generic target</td>"
  165. echo "<td>$convert_to_generic_target</td>"
  166. echo "</tr>"
  167. echo "<tr>"
  168. echo "<td>Packages to convert to generic host</td>"
  169. echo "<td>$convert_to_generic_host</td>"
  170. echo "</tr>"
  171. echo "<tr>"
  172. echo "<td>Packages to convert to autotools</td>"
  173. echo "<td>$convert_to_autotools</td>"
  174. echo "</tr>"
  175. echo "<tr>"
  176. echo "<td>TOTAL</td>"
  177. echo "<td>$cnt</td>"
  178. echo "</tr>"
  179. echo "</table>"