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

get-package-updates 19KB

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