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

build-master-status 8.4KB

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