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

get-package-updates 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. #!/bin/sh
  2. # check for packages that need to be built
  3. # shellcheck disable=SC2119,SC2120
  4. # shellcheck source=../lib/load-configuration
  5. . "${0%/*}/../lib/load-configuration"
  6. # TODO: Find out, why sometimes package updates are missed.
  7. # TODO: correctly handle if pkgbase of a split package is renamed, e.g.:
  8. # $a -> ($a,$b) ==> $b -> ($a,$b)
  9. # TODO: keep database clean in case of abort
  10. # TODO: maybe it's best to complain on irc if the generation of the meta
  11. # data from the PKGBUILD fails
  12. # shellcheck disable=SC2016
  13. usage() {
  14. >&2 echo ''
  15. >&2 echo 'get-package-updates: check for packages that need to be built,'
  16. >&2 echo ' and build a list in the proper build order'
  17. >&2 echo ''
  18. >&2 echo 'possible options:'
  19. >&2 echo ' -d|--date $datetime:'
  20. >&2 echo ' Pull latest commit before $datetime'
  21. >&2 echo ' (yyyy-mm-ddThh:mm:ss). Conflicts -n.'
  22. >&2 echo ' -h|--help: Show this help and exit.'
  23. >&2 echo ' -i|--ignore-insanity:'
  24. >&2 echo ' Do not abort when insane.'
  25. >&2 echo ' -n|--no-pull: Do not pull git repos, merely reorder build list.'
  26. >&2 echo ' Conflicts -d.'
  27. >&2 echo ' -r|--recent-modifications:'
  28. >&2 echo ' Use the latest commit for the modifications'
  29. >&2 echo ' git repository (e.g. ignore -d for it).'
  30. >&2 echo ' Requires -d.'
  31. >&2 echo ' -w|--wait: If necessary, wait for lock blocking.'
  32. [ -z "$1" ] && exit 1 || exit "$1"
  33. }
  34. eval set -- "$(
  35. getopt -o d:hinrw \
  36. --long date: \
  37. --long help \
  38. --long ignore-insanity \
  39. --long no-pull \
  40. --long recent-modifications \
  41. --long wait \
  42. -n "$(basename "$0")" -- "$@" || \
  43. echo usage
  44. )"
  45. block_flag='-n'
  46. date_time=''
  47. ignore_insanity=false
  48. pull=true
  49. recent_modifications=false
  50. while true
  51. do
  52. case "$1" in
  53. -d|--date)
  54. shift
  55. date_time="$1"
  56. ;;
  57. -h|--help)
  58. usage 0
  59. ;;
  60. -i|--ignore-insanity)
  61. ignore_insanity=true
  62. ;;
  63. -n|--no-pull)
  64. pull=false
  65. ;;
  66. -r|--recent-modifications)
  67. recent_modifications=true
  68. ;;
  69. -w|--wait)
  70. block_flag=''
  71. ;;
  72. --)
  73. shift
  74. break
  75. ;;
  76. *)
  77. >&2 echo 'Whoops, forgot to implement option "'"$1"'" internally.'
  78. exit 42
  79. ;;
  80. esac
  81. shift
  82. done
  83. if [ $# -ne 0 ]; then
  84. >&2 echo 'Too many arguments.'
  85. usage
  86. fi
  87. if [ -n "${date_time}" ] && ! ${pull}; then
  88. >&2 printf -- '-d and -n are mutually exclusive.\n'
  89. usage
  90. fi
  91. if ${recent_modifications} && [ -z "${date_time}" ]; then
  92. >&2 printf -- '-r requires -d.\n'
  93. usage
  94. fi
  95. if [ -s "${work_dir}/build-master-sanity" ]; then
  96. >&2 echo 'Build master is not sane.'
  97. if ! ${ignore_insanity}; then
  98. exit
  99. fi
  100. fi
  101. # delete_package arch package
  102. # mark $arch/$package for deletion
  103. delete_package() {
  104. # shellcheck disable=SC2016
  105. query_delete_packages=$(
  106. printf '`architectures` AS `d_a`'
  107. printf ' JOIN `architecture_compatibilities` AS `a_c`'
  108. printf ' ON `a_c`.`runs_on`=`d_a`.`id`'
  109. printf ' AND `d_a`.`name`=from_base64("%s")' \
  110. "$(printf '%s' "$1" | base64 -w0)"
  111. printf ' JOIN `build_assignments`'
  112. printf ' ON (`a_c`.`built_for`=`build_assignments`.`architecture`'
  113. # "any" references all architectures, but this is not represented
  114. # in `architecture_compatibilities`: If a package is not buildable
  115. # for "any", this means literally, that it is not buildable for
  116. # the _least_ architecture (e.g. it is not generic)
  117. printf ' OR `d_a`.`name`="any")'
  118. mysql_join_build_assignments_package_sources
  119. printf ' AND `package_sources`.`pkgbase`=from_base64("%s")' \
  120. "$(printf '%s' "$2" | base64 -w0)"
  121. mysql_join_build_assignments_binary_packages
  122. mysql_join_binary_packages_binary_packages_in_repositories
  123. )
  124. # shellcheck disable=SC2016
  125. {
  126. # packages from the build-list/to-be-decided go straight to the deletion-list
  127. # this happens in two steps, because we need to create one item per
  128. # target architecture
  129. printf 'INSERT IGNORE INTO `binary_packages_in_repositories` ('
  130. printf '`package`,'
  131. printf '`repository`,'
  132. printf '`last_moved`,'
  133. printf '`is_to_be_deleted`'
  134. printf ') SELECT'
  135. printf ' `binary_packages`.`id`,'
  136. printf '`d_r`.`id`,'
  137. printf 'NOW(),'
  138. printf '1'
  139. printf ' FROM'
  140. printf ' %s' "${query_delete_packages}"
  141. mysql_join_binary_packages_in_repositories_repositories
  142. # shellcheck disable=SC2154
  143. printf ' AND `repositories`.`stability` in (%s,%s)' \
  144. "${repository_stability_ids__unbuilt}" \
  145. "${repository_stability_ids__virtual}"
  146. mysql_join_build_assignments_architectures '' 'ba_a'
  147. printf ' JOIN `repositories` AS `d_r`'
  148. printf ' ON ('
  149. # arch-specific build_assignments must match exactly
  150. printf '`d_r`.`architecture`=`ba_a`.`id`'
  151. # "any" build_assignments build for all architectures
  152. printf ' OR `ba_a`.`name`="any"'
  153. printf ')'
  154. # shellcheck disable=SC2154
  155. printf ' AND `d_r`.`stability`=%s;\n' \
  156. "${repository_stability_ids__forbidden}"
  157. printf 'COMMIT;\n'
  158. printf 'DELETE `binary_packages_in_repositories`'
  159. printf ' FROM %s' "${query_delete_packages}"
  160. mysql_join_binary_packages_in_repositories_repositories
  161. # shellcheck disable=SC2154
  162. printf ' AND `repositories`.`stability` in (%s,%s);\n' \
  163. "${repository_stability_ids__unbuilt}" \
  164. "${repository_stability_ids__virtual}"
  165. printf 'COMMIT;\n'
  166. # other packages are marked as `is_to_be_deleted`
  167. printf 'UPDATE %s' "${query_delete_packages}"
  168. printf ' SET `binary_packages_in_repositories`.`is_to_be_deleted`=1;\n'
  169. } | \
  170. mysql_run_query
  171. }
  172. something_new=false
  173. for repo in ${repo_names}; do
  174. eval repo_path='"${repo_paths__'"${repo}"'}"'
  175. # Update git repositories (official packages, community packages and the repository of package customizations).
  176. if [ -d "${repo_path}/.git" ]; then
  177. git -C "${repo_path}" pull --ff-only
  178. else
  179. git -C "${repo_path}" fetch origin master:master
  180. fi || \
  181. true
  182. # read previous git revision numbers from database.
  183. # shellcheck disable=SC2016
  184. eval "old_repo_revisions__${repo}='$(
  185. {
  186. printf 'SELECT `git_repositories`.`head`'
  187. printf ' FROM `git_repositories`'
  188. printf ' WHERE `git_repositories`.`name`=from_base64("%s");\n' \
  189. "$(printf '%s' "${repo}" | base64 -w0)"
  190. } | \
  191. mysql_run_query
  192. )'"
  193. # determine new git revision
  194. if ${pull}; then
  195. if ${recent_modifications} && \
  196. [ "${repo}" = 'archlinux32' ] || \
  197. [ -z "${date_time}" ]; then
  198. eval "new_repo_revisions__${repo}='$(
  199. git -C "${repo_path}" rev-parse HEAD
  200. )'"
  201. else
  202. new_rev=$(
  203. git -C "${repo_path}" rev-list -n1 --until "${date_time}" HEAD
  204. )
  205. eval 'old_rev="${old_repo_revisions__'"${repo}"'}"'
  206. # do not go backwards in time
  207. # shellcheck disable=SC2154
  208. if ! git -C "${repo_path}" merge-base --is-ancestor "${old_rev}" "${new_rev}"; then
  209. new_rev="${old_rev}"
  210. fi
  211. eval "new_repo_revisions__${repo}='${new_rev}'"
  212. fi
  213. else
  214. eval 'new_repo_revisions__'"${repo}"'="${old_repo_revisions__'"${repo}"'}"'
  215. fi
  216. if ! eval '[ "${new_repo_revisions__'"${repo}"'}" = "${old_repo_revisions__'"${repo}"'}" ]'; then
  217. something_new=true
  218. fi
  219. done
  220. if ${pull} && \
  221. ! ${something_new}; then
  222. >&2 echo 'Nothing changed.'
  223. exit
  224. fi
  225. # Create a lock file for build list.
  226. exec 9> "${build_list_lock_file}"
  227. if ! verbose_flock ${block_flag} 9; then
  228. >&2 echo 'come back (shortly) later - I cannot lock build list.'
  229. exit
  230. fi
  231. exec 8> "${sanity_check_lock_file}"
  232. if ! verbose_flock -s ${block_flag} 8; then
  233. >&2 echo 'come back (shortly) later - sanity-check running.'
  234. exit
  235. fi
  236. cleanup() {
  237. mysql_cleanup
  238. rm -rf --one-file-system "${tmp_dir:?}"
  239. }
  240. tmp_dir=$(mktemp -d 'tmp.get-package-updates.XXXXXXXXXX' --tmpdir)
  241. trap cleanup EXIT
  242. # shellcheck disable=SC2119
  243. mysql_cleanup
  244. echo 'Check modified packages from the last update, and put them to the build list.'
  245. # Check modified packages from the last update, and put them to the build list.
  246. # If a package is updated, but already on the rebuild list, then just update the git revision number.
  247. # If a package is deleted, remove from the rebuild list, and add it to the deletion list.
  248. # If a new package is added, then ensure that it's not on the deletion list.
  249. # shellcheck disable=SC2016
  250. {
  251. printf 'SELECT DISTINCT'
  252. printf ' `package_sources`.`pkgbase`,'
  253. printf '`upstream_repositories`.`name`,'
  254. printf 'IF(`build_assignments`.`architecture`=%s,"any","x86_64")' \
  255. "${architecture_ids__any}"
  256. printf ' FROM `binary_packages`'
  257. mysql_join_binary_packages_binary_packages_in_repositories
  258. mysql_join_binary_packages_build_assignments
  259. mysql_join_build_assignments_package_sources
  260. mysql_join_package_sources_upstream_repositories
  261. printf ' WHERE `binary_packages_in_repositories`.`repository`=%s;\n' \
  262. "${repository_ids__any_build_list}"
  263. } | \
  264. mysql_run_query | \
  265. sed '
  266. s@^\(\S*\)\t\(\S*\)\t\(\S*\)$@s,^\\(.\\t\1/repos/\2-\3/\\)[^/]\\+$,\\1PKGBUILD,\ns,^\\(.\\t\2/\1/\\)[^/]\\+$,\\1PKGBUILD,@
  267. ' > \
  268. "${tmp_dir}/trigger-rebuild-on-any-file-sed-expression"
  269. {
  270. # trigger rebuild of packages removed from blacklist
  271. # shellcheck disable=SC2016
  272. {
  273. printf 'SELECT `package_sources`.`pkgbase`,`upstream_repositories`.`name`,`git_repositories`.`name`'
  274. printf ' FROM `package_sources`'
  275. mysql_join_package_sources_upstream_repositories
  276. mysql_join_upstream_repositories_git_repositories
  277. printf ' WHERE `package_sources`.`pkgbase` IN ('
  278. # shellcheck disable=SC2154
  279. git -C "${repo_paths__archlinux32}" diff --name-status "${old_repo_revisions__archlinux32}" "${new_repo_revisions__archlinux32}" -- 'blacklist' | \
  280. sed '
  281. s@^D\tblacklist/[^/]\+/[^/]\+/@@
  282. t
  283. d
  284. ' | \
  285. base64_encode_each | \
  286. sed '
  287. s/^/from_base64("/
  288. s/$/")/
  289. ' | \
  290. tr '\n' ','
  291. printf '"");\n'
  292. } | \
  293. mysql_run_query | \
  294. while read -r pkgbase repository git_repository; do
  295. printf 'A %s ' \
  296. "${pkgbase}"
  297. eval 'printf '"'"'%s'"'"' "${new_repo_revisions__'"${git_repository}"'}"'
  298. printf ' %s\n' \
  299. "${repository}"
  300. done
  301. # actual updates/removes
  302. for repo in ${repo_names}; do
  303. eval repo_path='"${repo_paths__'"${repo}"'}"'
  304. eval old_repo_revision='"${old_repo_revisions__'"${repo}"'}"'
  305. eval new_repo_revision='"${new_repo_revisions__'"${repo}"'}"'
  306. # if old revision unknown, mimic "git diff"-output
  307. # shellcheck disable=SC2154
  308. if [ "${old_repo_revision}" = "NONE" ]; then
  309. git -C "${repo_path}" archive --format=tar HEAD | \
  310. tar -t | \
  311. sed 's|^|A\t|'
  312. else
  313. git -C "${repo_path}" diff --no-renames --name-status "${old_repo_revision}" "${new_repo_revision}"
  314. fi | \
  315. # rename any file to "PKGBUILD" for packages on the build-list
  316. sed -f "${tmp_dir}/trigger-rebuild-on-any-file-sed-expression" | \
  317. # only track changes in PKGBUILDs
  318. grep '/PKGBUILD$' | \
  319. if [ "${repo}" = "archlinux32" ]; then
  320. # modify the directory structure from the modifiaction-repository
  321. # to the one of an original source repository
  322. # shellcheck disable=SC2016
  323. sed 's|^\(.\t\)\([^/]\+\)/\([^/]\+\)/\(.\+\)$|\2 \1\3/repos/\2-x86_64/\4|' | \
  324. while read -r pkg_repo rest; do
  325. repo=$(find_git_repository_to_package_repository "${pkg_repo}")
  326. eval 'printf '"'"'%s %s\n'"'" \
  327. "$(printf '"${new_repo_revisions__%s}"' "${repo}")" \
  328. "'${rest}'"
  329. done
  330. else
  331. sed "s|^|${new_repo_revision} |"
  332. fi | \
  333. grep '^\S\+ .\s[^/]\+/repos/[^/]\+/PKGBUILD$' | \
  334. # ignore i686
  335. grep -v -- '-i686/PKGBUILD$' | \
  336. # ignore staging and testing
  337. grep -v -- '[-/]\(staging\|testing\|unstable\)-[^/]\+/PKGBUILD$' | \
  338. sed 's|^\(\S\+\) \(.\)\t\([^/]\+\)/repos/\([^/]\+\)-[^/-]\+/PKGBUILD$|\2 \3 \1 \4|'
  339. done | \
  340. sort -u | \
  341. sed '
  342. s|^D\s|0 \0|
  343. t
  344. s|^[AM]\s|1 \0|
  345. t
  346. s|^|2 |
  347. ' | \
  348. sort -k1,1 | \
  349. sed 's|^[012] ||'
  350. } | \
  351. while read -r mode package git_revision repository; do
  352. if [ "${mode}" = 'D' ]; then
  353. # deleted PKGBUILD
  354. # shellcheck disable=SC2154
  355. git_revision="${new_repo_revisions__archlinux32}"
  356. found_package=false
  357. # we need to test archlinux32 last, because otherwise
  358. # find_package_repository_to_package might look in the wrong git
  359. # repository of a package w/o upstream
  360. for repository in ${repo_names} archlinux32; do
  361. eval 'repo_path="${repo_paths__'"${repository}"'}"'
  362. if [ "${repository}" = "archlinux32" ]; then
  363. if git -C "${repo_path}" archive "${new_repo_revisions__archlinux32}" 2> /dev/null | \
  364. tar -t 2> /dev/null | \
  365. grep -q "/$(str_to_regex "${package}")/PKGBUILD$"; then
  366. found_package=true
  367. fi
  368. else
  369. # shellcheck disable=SC2154
  370. if eval 'git -C "${repo_path}" archive "${new_repo_revisions__'"${repository}"'}" -- "${package}/repos" 2> /dev/null | ' \
  371. 'tar -t --wildcards "${package}/repos/*/PKGBUILD" 2> /dev/null | ' \
  372. 'cut -d/ -f3 | ' \
  373. 'grep -v '"'"'staging\|testing\|-unstable'"'"' | ' \
  374. 'grep -vq -- '"'"'-i686$'"'"; then
  375. eval 'git_revision="${new_repo_revisions__'"${repository}"'}"'
  376. found_package=true
  377. break
  378. fi
  379. fi
  380. done
  381. if ${found_package}; then
  382. mode='M'
  383. repository=$(
  384. find_package_repository_to_package "${package}" "${repository}" "${git_revision}"
  385. )
  386. else
  387. delete_package 'any' "${package}"
  388. continue
  389. fi
  390. fi
  391. if [ "${mode}" = 'A' ] || [ "${mode}" = 'M' ]; then
  392. # shellcheck disable=SC2016
  393. {
  394. # delete old build assignment and associated binary packages
  395. # which are not yet built or on the deletion list
  396. printf 'DELETE `build_assignments`,`binary_packages`,`binary_packages_in_repositories`'
  397. printf ' FROM `binary_packages`'
  398. mysql_join_binary_packages_build_assignments
  399. mysql_join_build_assignments_package_sources
  400. mysql_join_binary_packages_binary_packages_in_repositories
  401. mysql_join_binary_packages_in_repositories_repositories
  402. printf ' WHERE `package_sources`.`pkgbase`=from_base64("%s")' \
  403. "$(
  404. printf '%s' "${package}" | \
  405. base64 -w0
  406. )"
  407. # shellcheck disable=SC2154
  408. printf ' AND `repositories`.`stability` IN (%s,%s);\n' \
  409. "${repository_stability_ids__unbuilt}" \
  410. "${repository_stability_ids__forbidden}"
  411. # remove is-to-be-deleted marker from old binary packages
  412. printf 'UPDATE `binary_packages_in_repositories`'
  413. mysql_join_binary_packages_in_repositories_binary_packages
  414. mysql_join_binary_packages_build_assignments
  415. mysql_join_build_assignments_package_sources
  416. printf ' SET `binary_packages_in_repositories`.`is_to_be_deleted`=0'
  417. printf ' WHERE `package_sources`.`pkgbase`=from_base64("%s");\n' \
  418. "$(
  419. printf '%s' "${package}" | \
  420. base64 -w0
  421. )"
  422. } | \
  423. mysql_run_query
  424. printf '%s\n' "${package}" >> "${tmp_dir}/modified-packages"
  425. # shellcheck disable=SC2154
  426. printf '%s ' "${package}" "${git_revision}" "${new_repo_revisions__archlinux32}" "${repository}" >&2
  427. mysql_generate_package_metadata "${repository_ids__any_to_be_decided}" "${package}" "${git_revision}" "${new_repo_revisions__archlinux32}" "${repository}"
  428. printf '\n' >&2
  429. continue
  430. fi
  431. >&2 echo "unknown git diff mode '${mode}'"
  432. exit 1
  433. done
  434. if [ -s "${tmp_dir}/modified-packages" ] || ! ${pull}; then
  435. echo 'Delete black-listed packages.'
  436. if [ -s "${tmp_dir}/modified-packages" ]; then
  437. sort -u "${tmp_dir}/modified-packages" --output "${tmp_dir}/modified-packages"
  438. fi
  439. # extract black-listed packages
  440. git -C "${repo_paths__archlinux32}" archive "${new_repo_revisions__archlinux32}" -- 'blacklist' | \
  441. tar -t 'blacklist' | \
  442. sed '
  443. s@^blacklist/\([^/]\+\)/[^/]\+/\([^/]\+\)$@\1\t\2@
  444. t
  445. d
  446. ' | \
  447. sort -u | \
  448. if [ -s "${tmp_dir}/modified-packages" ]; then
  449. sort -k2,2 | \
  450. join -1 1 -2 2 -o 2.1,2.2 "${tmp_dir}/modified-packages" -
  451. sed '
  452. /^lib32-/ s/^/any /
  453. t
  454. d
  455. ' "${tmp_dir}/modified-packages"
  456. else
  457. cat
  458. fi | \
  459. sort -u | \
  460. while read -r arch pkgbase; do
  461. delete_package "${arch}" "${pkgbase}"
  462. done
  463. fi
  464. echo 'Done - mark decisions as final.'
  465. # shellcheck disable=SC2016
  466. {
  467. # save blacklist into database
  468. printf 'CREATE TEMPORARY TABLE `blacklist` (`arch` VARCHAR(16), `pkgbase` VARCHAR(64), `reason` TEXT);\n'
  469. git -C "${repo_paths__archlinux32}" archive "${new_repo_revisions__archlinux32}" -- 'blacklist' | \
  470. tar -x --to-command 'sed "s@^@$TAR_FILENAME @"' 'blacklist' | \
  471. sed '
  472. s@^blacklist/\([^/[:space:]]\+\)/\S\+/\([^/[:space:]]\+\) @\1 \2 @
  473. t
  474. d
  475. ' | \
  476. while read -r arch pkgbase reason; do
  477. printf '(from_base64("%s"),from_base64("%s"),from_base64("%s")),\n' \
  478. "$(printf '%s' "${arch}" | base64 -w0)" \
  479. "$(printf '%s' "${pkgbase}" | base64 -w0)" \
  480. "$(printf '%s' "${reason}" | base64 -w0)"
  481. done | \
  482. sed '
  483. 1 i INSERT IGNORE INTO `blacklist` (`arch`,`pkgbase`,`reason`) VALUES
  484. $ s/,$/;/
  485. '
  486. printf 'UPDATE `build_assignments`'
  487. printf ' SET `build_assignments`.`is_black_listed`=NULL;\n'
  488. printf 'UPDATE `blacklist`'
  489. printf ' JOIN `architectures`'
  490. printf ' ON `architectures`.`name`=`blacklist`.`arch`'
  491. printf ' JOIN `package_sources`'
  492. printf ' ON `blacklist`.`pkgbase`=`package_sources`.`pkgbase`'
  493. mysql_join_package_sources_build_assignments
  494. printf ' JOIN `architecture_compatibilities`'
  495. printf ' ON `build_assignments`.`architecture`=`architecture_compatibilities`.`built_for`'
  496. printf ' AND ('
  497. printf '`architectures`.`id`=`architecture_compatibilities`.`runs_on`'
  498. # shellcheck disable=SC2154
  499. printf ' OR `architectures`.`id`=%s' \
  500. "${architecture_ids__any}"
  501. printf ')'
  502. printf ' SET `build_assignments`.`is_black_listed`=`blacklist`.`reason`;\n'
  503. printf 'DROP TEMPORARY TABLE `blacklist`;\n'
  504. printf 'COMMIT;\n'
  505. # update hashes of repositories in mysql database
  506. for repo in ${repo_names}; do
  507. printf 'UPDATE `git_repositories`'
  508. printf ' SET `git_repositories`.`head`=from_base64("%s")' \
  509. "$(eval 'printf '"'"'%s'"'"' "${new_repo_revisions__'"${repo}"'}" | base64 -w0')"
  510. printf ' WHERE `git_repositories`.`name`=from_base64("%s");\n' \
  511. "$(printf '%s' "${repo}" | base64 -w0)"
  512. done
  513. # move binary_packages from "to-be-decided" to "build-list"
  514. printf 'UPDATE `binary_packages_in_repositories`'
  515. mysql_join_binary_packages_in_repositories_binary_packages
  516. printf ' SET `binary_packages_in_repositories`.`repository`=%s' \
  517. "${repository_ids__any_build_list}"
  518. printf ' WHERE `binary_packages_in_repositories`.`repository`=%s;\n' \
  519. "${repository_ids__any_to_be_decided}"
  520. } | \
  521. mysql_run_query
  522. echo 'Aftermath - sort versions.'
  523. mysql_sort_versions
  524. echo 'Aftermath - find assignment loops.'
  525. # update loop list in database (beware, the packages are expected to be in "build-list",
  526. # not "to-be-decided", so we need to run this after moving the packages from "to-be-decided" to the "build-list".
  527. mysql_find_build_assignment_loops
  528. echo 'Aftermath - remove duplicate binary_packages.'
  529. # remove duplicate binary_packages from "build-list"
  530. mysql_query_remove_old_binary_packages_from_build_list | \
  531. mysql_run_query 'unimportant'