Tools for building 32-bit archlinux packages from archlinux.org's official, 64-bit tested PKGBUILDs et al.

build-master-status 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. #!/bin/sh
  2. # report about status of build master
  3. # shellcheck disable=SC2119,SC2120
  4. # shellcheck source=../lib/load-configuration
  5. . "${0%/*}/../lib/load-configuration"
  6. tmp_dir=$(mktemp -d 'tmp.build-master-status.XXXXXXXXXX' --tmpdir)
  7. trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT
  8. # do not block if locked
  9. exec 9> "${status_lock_file}"
  10. if ! verbose_flock -n 9; then
  11. >&2 echo 'Saving status skipped, cannot acquire lock.'
  12. exit
  13. fi
  14. # update todos
  15. find "${base_dir}/bin/" "${base_dir}/conf/" "${base_dir}/lib/" -type f \
  16. -exec grep -nHF '' '{}' \; | \
  17. sed 's,^'"$(str_to_regex "${base_dir}")"'/,,' | \
  18. sed -n '
  19. /^[^:]\+:[0-9]\+:\s*#\s*TODO:/ {
  20. :a
  21. $! {
  22. N
  23. s/\n[^:[:space:]]\+:[0-9]\+:\s*\([^#[:space:]].*\)\?$//
  24. Ta
  25. }
  26. s/\n[^:[:space:]]\+:[0-9]\+:\s*#\s*/\\\\n/g
  27. s/^\([^:]\+\):\([0-9]\+\):\s*#\s*TODO:\s*/\1\t\2\t/
  28. p
  29. }
  30. ' > "${tmp_dir}/todos"
  31. if [ -s "${tmp_dir}/todos" ]; then
  32. # shellcheck disable=SC2016
  33. {
  34. printf 'SHOW CREATE TABLE `todos`' | \
  35. mysql_run_query 'unimportant' | \
  36. sed '
  37. 1s/^\S\+\s\+CREATE TABLE `todos` /CREATE TEMPORARY TABLE `td` /
  38. s/ NOT NULL AUTO_INCREMENT/ NULL/
  39. s/PRIMARY KEY/INDEX/
  40. '
  41. printf ';\n'
  42. printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `td` (`file`,`line`,`description`);\n' \
  43. "${tmp_dir}/todos"
  44. for matches in 'file line description' 'file description' 'file line' 'description'; do
  45. printf 'UPDATE `td`'
  46. printf ' JOIN `todos`'
  47. for match in ${matches}; do
  48. printf ' AND `td`.`%s`=`todos`.`%s`' \
  49. "${match}" "${match}"
  50. done | \
  51. sed 's/^ AND / ON /'
  52. printf ' SET `td`.`id`=`todos`.`id`'
  53. printf ' WHERE `td`.`id` IS NULL;\n'
  54. done
  55. printf 'UPDATE `todos`'
  56. printf ' JOIN `td`'
  57. printf ' ON `todos`.`id`=`td`.`id`'
  58. printf ',`todos`.`%s`=`td`.`%s`' \
  59. 'file' 'file' \
  60. 'line' 'line' \
  61. 'description' 'description' | \
  62. sed 's/^,/ SET /'
  63. printf ';\n'
  64. printf 'INSERT IGNORE INTO `todos` (`file`,`line`,`description`)'
  65. printf ' SELECT `td`.`file`,`td`.`line`,`td`.`description`'
  66. printf ' FROM `td`'
  67. printf ' WHERE `td`.`id` IS NULL;\n'
  68. printf 'DELETE FROM `todos`'
  69. printf ' WHERE NOT EXISTS ('
  70. printf 'SELECT 1'
  71. printf ' FROM `td`'
  72. printf ' AND `td`.`%s`=`todos`.`%s`' \
  73. 'file' 'file' \
  74. 'line' 'line' \
  75. 'description' 'description' | \
  76. sed 's/^ AND / WHERE /'
  77. printf ');\n'
  78. printf 'DROP TEMPORARY TABLE `td`;\n'
  79. printf 'DELETE FROM `todo_links`'
  80. printf ' WHERE NOT EXISTS ('
  81. printf 'SELECT 1'
  82. printf ' FROM `todos` '
  83. printf 'WHERE `todos`.`id`=`todo_links`.`depending_on`'
  84. printf ') OR NOT EXISTS ('
  85. printf 'SELECT 1'
  86. printf ' FROM `todos` '
  87. printf 'WHERE `todos`.`id`=`todo_links`.`dependent`'
  88. printf ');\n'
  89. } | \
  90. mysql_run_query 'unimportant'
  91. fi
  92. rm -f "${tmp_dir}/todos"
  93. if [ ! -s "${work_dir}/build-master-sanity" ]; then
  94. # shellcheck disable=SC2016
  95. {
  96. printf 'INSERT IGNORE INTO `statistics` ('
  97. printf '`%s`,' \
  98. 'pending_tasks_count' \
  99. 'pending_packages_count' \
  100. 'broken_tasks_count' \
  101. 'dependency_loops_count' \
  102. 'dependency_looped_tasks_count' \
  103. 'locked_tasks_count' \
  104. 'blocked_tasks_count' \
  105. 'next_tasks_count' \
  106. 'stable_packages_count' \
  107. 'staging_packages_count' \
  108. 'testing_packages_count' \
  109. 'tested_packages_count' \
  110. 'architecture' | \
  111. sed 's/,$//'
  112. printf ') SELECT '
  113. printf '`ba_q`.`%s`,' \
  114. 'pending_tasks_count' \
  115. 'pending_packages_count' \
  116. 'broken_tasks_count' \
  117. 'dependency_loops_count' \
  118. 'dependency_looped_tasks_count' \
  119. 'locked_tasks_count' \
  120. 'blocked_tasks_count' \
  121. 'next_tasks_count'
  122. printf '`bp_q`.`%s`,' \
  123. 'stable_packages_count' \
  124. 'staging_packages_count' \
  125. 'testing_packages_count' \
  126. 'tested_packages_count'
  127. printf '`architectures`.`id`'
  128. printf ' FROM `architectures`'
  129. printf ' LEFT JOIN ('
  130. printf 'SELECT'
  131. printf ' COUNT('
  132. printf 'DISTINCT `build_assignments`.`id`'
  133. printf ') AS `pending_tasks_count`,'
  134. printf ' COUNT('
  135. printf 'DISTINCT `binary_packages`.`id`'
  136. printf ') AS `pending_packages_count`,'
  137. printf ' COUNT('
  138. printf 'DISTINCT IF('
  139. printf '`build_assignments`.`is_broken`,'
  140. printf '`build_assignments`.`id`,'
  141. printf 'NULL'
  142. printf ')'
  143. printf ') AS `broken_tasks_count`,'
  144. printf ' COUNT('
  145. printf 'DISTINCT `build_dependency_loops`.`loop`'
  146. printf ') AS `dependency_loops_count`,'
  147. printf ' COUNT('
  148. printf 'DISTINCT `build_dependency_loops`.`build_assignment`'
  149. printf ') AS `dependency_looped_tasks_count`,'
  150. printf ' COUNT('
  151. printf 'DISTINCT `build_slaves`.`currently_building`'
  152. printf ') AS `locked_tasks_count`,'
  153. printf ' COUNT('
  154. printf 'DISTINCT IF('
  155. printf '`build_assignments`.`is_blocked` IS NULL,'
  156. printf 'NULL,'
  157. printf '`build_assignments`.`id`'
  158. printf ')'
  159. printf ') AS `blocked_tasks_count`,'
  160. printf ' COUNT('
  161. printf 'DISTINCT IF('
  162. mysql_query_has_pending_dependencies \
  163. "$(
  164. # shellcheck disable=SC2154
  165. printf 'IF(`build_assignments`.`architecture`=%s,%s,`build_assignments`.`architecture`)' \
  166. "${architecture_ids__any}" \
  167. "${architecture_ids__i686}"
  168. )" \
  169. '`build_assignments`.`id`'
  170. printf ','
  171. printf 'NULL,'
  172. printf '`build_assignments`.`id`'
  173. printf ')'
  174. printf ') AS `next_tasks_count`,'
  175. printf ' `build_assignments`.`architecture`'
  176. printf ' FROM `build_assignments`'
  177. mysql_join_build_assignments_binary_packages
  178. mysql_join_binary_packages_binary_packages_in_repositories
  179. mysql_join_binary_packages_in_repositories_repositories
  180. printf ' JOIN ('
  181. printf 'SELECT `binary_packages`.`build_assignment`'
  182. printf ' FROM `binary_packages`'
  183. mysql_join_binary_packages_binary_packages_in_repositories
  184. printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \
  185. "${repository_ids__any_build_list}"
  186. printf ' GROUP BY `binary_packages`.`build_assignment`'
  187. printf ') AS `bp_subq`'
  188. printf ' ON `bp_subq`.`build_assignment`=`build_assignments`.`id`'
  189. printf ' LEFT'
  190. mysql_join_build_assignments_build_slaves
  191. printf ' LEFT'
  192. mysql_join_build_assignments_build_dependency_loops
  193. printf ' GROUP BY `build_assignments`.`architecture`'
  194. printf ') AS `ba_q`'
  195. printf ' ON `ba_q`.`architecture`=`architectures`.`id`'
  196. printf ' LEFT JOIN ('
  197. printf 'SELECT'
  198. printf ' SUM('
  199. printf 'IF('
  200. # shellcheck disable=SC2154
  201. printf '`repositories`.`stability`=%s,' \
  202. "${repository_stability_ids__stable}"
  203. printf '1,0'
  204. printf ')'
  205. printf ') AS `stable_packages_count`,'
  206. printf ' SUM('
  207. printf 'IF('
  208. # shellcheck disable=SC2154
  209. printf '`repositories`.`stability`=%s,' \
  210. "${repository_stability_ids__staging}"
  211. printf '1,0'
  212. printf ')'
  213. printf ') AS `staging_packages_count`,'
  214. printf ' SUM('
  215. printf 'IF('
  216. # shellcheck disable=SC2154
  217. printf '`repositories`.`stability`=%s' \
  218. "${repository_stability_ids__testing}"
  219. printf ' AND NOT `binary_packages`.`is_tested`,'
  220. printf '1,0'
  221. printf ')'
  222. printf ') AS `testing_packages_count`,'
  223. printf ' SUM('
  224. printf 'IF('
  225. printf '`repositories`.`stability`=%s' \
  226. "${repository_stability_ids__testing}"
  227. printf ' AND `binary_packages`.`is_tested`,'
  228. printf '1,0'
  229. printf ')'
  230. printf ') AS `tested_packages_count`,'
  231. printf ' `repositories`.`architecture`'
  232. printf ' FROM `binary_packages`'
  233. mysql_join_binary_packages_binary_packages_in_repositories
  234. mysql_join_binary_packages_in_repositories_repositories
  235. printf ' GROUP BY `repositories`.`architecture`'
  236. printf ') AS `bp_q`'
  237. printf ' ON `bp_q`.`architecture`=`architectures`.`id`;\n'
  238. } | \
  239. mysql_run_query 'unimportant'
  240. fi
  241. # update count of blocked packages
  242. update_blocked_packages_count