Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-05-04 10:04:33 +0200
committerErich Eckner <git@eckner.net>2019-05-04 10:04:33 +0200
commita45ffd7e5311c62c42bffd27d492746f6433e57a (patch)
treef736a0b8eb1c046ffc684f86141aa7511d9400dd
parentb1166c7aa420a659199b79a1478d2226b4badd96 (diff)
bin/prioritize-build-list: when -d given: run until no more priorities change
-rwxr-xr-xbin/prioritize-build-list142
1 files changed, 78 insertions, 64 deletions
diff --git a/bin/prioritize-build-list b/bin/prioritize-build-list
index e9ffeae..f3f178d 100755
--- a/bin/prioritize-build-list
+++ b/bin/prioritize-build-list
@@ -76,69 +76,83 @@ verbose_flock -s ${wait_for_lock} 9
exec 8> "${build_list_lock_file}"
verbose_flock ${wait_for_lock} 8
-# shellcheck disable=SC2016
-{
- printf 'UPDATE `build_assignments`'
- mysql_join_build_assignments_package_sources
- mysql_join_build_assignments_binary_packages
- mysql_join_binary_packages_binary_packages_in_repositories
- printf ' SET `build_assignments`.`priority`=('
- printf 'SELECT COALESCE(MAX(`all_priorities`.`priority`),0)+1'
- printf ' FROM ('
- printf 'SELECT `others`.`priority`'
- printf ' FROM `build_assignments` AS `others`'
- printf ') AS `all_priorities`'
- printf ')'
- printf ' WHERE ('
- tr '[:space:]' '\n' < "$1" | \
- base64_encode_each | \
- sed '
- s/^/`package_sources`.`pkgbase` REGEXP from_base64("/
- s/$/") OR /
- '
- printf '0) AND `binary_packages_in_repositories`.`repository`=%s;\n' \
- "${repository_ids__any_build_list}"
- printf 'SELECT row_count();\n'
- if ${dependencies}; then
+updated_rows=$(
+ # shellcheck disable=SC2016
+ {
printf 'UPDATE `build_assignments`'
- printf ' JOIN ('
- printf 'SELECT'
- printf ' `s_ba`.`id` AS `build_assignment`,'
- printf 'MAX(`g_ba`.`priority`) AS `priority`'
- printf ' FROM `build_assignments` AS `g_ba`'
- mysql_join_build_assignments_binary_packages 'g_ba' 'g_bp'
- mysql_join_binary_packages_binary_packages_in_repositories 'g_bp' 'g_bpir'
- printf ' AND `g_bpir`.`repository`=%s' \
- "${repository_ids__any_build_list}"
- mysql_join_binary_packages_dependencies 'g_bp'
- mysql_join_dependencies_dependency_types
- printf ' AND `dependency_types`.`relevant_for_binary_packages`'
- mysql_join_dependencies_install_target_providers_with_versions
- mysql_join_install_target_providers_binary_packages '' 's_bp'
- mysql_join_binary_packages_binary_packages_in_repositories 's_bp' 's_bpir'
- printf ' AND `s_bpir`.`repository`=%s' \
- "${repository_ids__any_build_list}"
- printf ' JOIN `architecture_compatibilities` AS `ac_a`'
- printf ' ON `ac_a`.`fully_compatible`'
- printf ' AND `ac_a`.`built_for`=`g_bp`.`architecture`'
- printf ' JOIN `architecture_compatibilities` AS `ac_b`'
- printf ' ON `ac_b`.`fully_compatible`'
- printf ' AND `ac_b`.`built_for`=`s_bp`.`architecture`'
- printf ' AND `ac_a`.`runs_on`=`ac_b`.`runs_on`'
- mysql_join_binary_packages_build_assignments 's_bp' 's_ba'
- printf ' GROUP BY `s_ba`.`id`'
- printf ') AS `sub_q`'
- printf ' ON `sub_q`.`build_assignment`=`build_assignments`.`id`'
- printf ' SET `build_assignments`.`priority`=`sub_q`.`priority`'
- printf ' WHERE `build_assignments`.`priority`<`sub_q`.`priority`'
- printf ';\n'
+ mysql_join_build_assignments_package_sources
+ mysql_join_build_assignments_binary_packages
+ mysql_join_binary_packages_binary_packages_in_repositories
+ printf ' SET `build_assignments`.`priority`=('
+ printf 'SELECT COALESCE(MAX(`all_priorities`.`priority`),0)+1'
+ printf ' FROM ('
+ printf 'SELECT `others`.`priority`'
+ printf ' FROM `build_assignments` AS `others`'
+ printf ') AS `all_priorities`'
+ printf ')'
+ printf ' WHERE ('
+ tr '[:space:]' '\n' < "$1" | \
+ base64_encode_each | \
+ sed '
+ s/^/`package_sources`.`pkgbase` REGEXP from_base64("/
+ s/$/") OR /
+ '
+ printf '0) AND `binary_packages_in_repositories`.`repository`=%s;\n' \
+ "${repository_ids__any_build_list}"
printf 'SELECT row_count();\n'
- fi
-} | \
- mysql_run_query | \
- if [ -w "$1" ] && \
- [ ! -p "$1" ]; then
- cat > "$1"
- else
- cat >&2
- fi
+ } | \
+ mysql_run_query
+)
+
+if ${dependencies}; then
+ new_updated_rows="${updated_rows}"
+ updated_rows=0
+ while [ ${new_updated_rows} -ne 0 ]; do
+ updated_rows=$((updated_rows+new_updated_rows))
+ new_updated_rows=$(
+ {
+ printf 'UPDATE `build_assignments`'
+ printf ' JOIN ('
+ printf 'SELECT'
+ printf ' `s_ba`.`id` AS `build_assignment`,'
+ printf 'MAX(`g_ba`.`priority`) AS `priority`'
+ printf ' FROM `build_assignments` AS `g_ba`'
+ mysql_join_build_assignments_binary_packages 'g_ba' 'g_bp'
+ mysql_join_binary_packages_binary_packages_in_repositories 'g_bp' 'g_bpir'
+ printf ' AND `g_bpir`.`repository`=%s' \
+ "${repository_ids__any_build_list}"
+ mysql_join_binary_packages_dependencies 'g_bp'
+ mysql_join_dependencies_dependency_types
+ printf ' AND `dependency_types`.`relevant_for_binary_packages`'
+ mysql_join_dependencies_install_target_providers_with_versions
+ mysql_join_install_target_providers_binary_packages '' 's_bp'
+ mysql_join_binary_packages_binary_packages_in_repositories 's_bp' 's_bpir'
+ printf ' AND `s_bpir`.`repository`=%s' \
+ "${repository_ids__any_build_list}"
+ printf ' JOIN `architecture_compatibilities` AS `ac_a`'
+ printf ' ON `ac_a`.`fully_compatible`'
+ printf ' AND `ac_a`.`built_for`=`g_bp`.`architecture`'
+ printf ' JOIN `architecture_compatibilities` AS `ac_b`'
+ printf ' ON `ac_b`.`fully_compatible`'
+ printf ' AND `ac_b`.`built_for`=`s_bp`.`architecture`'
+ printf ' AND `ac_a`.`runs_on`=`ac_b`.`runs_on`'
+ mysql_join_binary_packages_build_assignments 's_bp' 's_ba'
+ printf ' GROUP BY `s_ba`.`id`'
+ printf ') AS `sub_q`'
+ printf ' ON `sub_q`.`build_assignment`=`build_assignments`.`id`'
+ printf ' SET `build_assignments`.`priority`=`sub_q`.`priority`'
+ printf ' WHERE `build_assignments`.`priority`<`sub_q`.`priority`'
+ printf ';\n'
+ printf 'SELECT row_count();\n'
+ } | \
+ mysql_run_query
+ )
+ done
+fi
+
+if [ -w "$1" ] && \
+ [ ! -p "$1" ]; then
+ printf '%s\n' "${updated_rows}" >"$1"
+else
+ printf '%s\n' "${updated_rows}" >&2
+fi