summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/mysql-functions172
1 files changed, 83 insertions, 89 deletions
diff --git a/lib/mysql-functions b/lib/mysql-functions
index c605c8b..c249a5f 100755
--- a/lib/mysql-functions
+++ b/lib/mysql-functions
@@ -708,97 +708,91 @@ mysql_sanity_check() {
# mysql_find_build_assignment_loops
# recreate the `build_dependency_loops` table
mysql_find_build_assignment_loops() {
- new_loops=$(
- {
- printf 'SELECT DISTINCT `architectures`.`id`'
- printf ' FROM `architectures`'
- printf ' WHERE `architectures`.`id`!=%s;\n' \
- "${architecture_ids__any}"
- } | \
- mysql_run_query | \
- while read -r arch_id; do
- {
- printf 'SELECT DISTINCT'
- printf ' `ncy_ba`.`id`,'
- printf '`nt_ba`.`id`'
- printf ' FROM `dependencies`'
- mysql_join_dependencies_dependency_types
- mysql_join_dependencies_install_target_providers_with_versions
- mysql_join_install_target_providers_binary_packages '' 'ncy_bp'
- mysql_join_dependencies_binary_packages '' 'nt_bp'
- for which in 'ncy' 'nt'; do
- mysql_join_binary_packages_binary_packages_in_repositories "${which}"'_bp' "${which}"'_bpir'
- mysql_join_binary_packages_build_assignments "${which}"'_bp' "${which}"'_ba'
- printf ' JOIN `architecture_compatibilities` AS `%s_ac`' \
- "${which}"
- printf ' ON `%s_ac`.`built_for`=`%s_ba`.`architecture`' \
- "${which}" "${which}"
- printf ' AND `%s_ac`.`runs_on`=%s' \
- "${which}" "${arch_id}"
- printf ' AND `%s_ac`.`fully_compatible`' \
- "${which}"
- done
- printf ' WHERE `nt_bpir`.`repository`=%s' \
- "${repository_ids__any_build_list}"
- printf ' AND `ncy_bpir`.`repository`=%s' \
- "${repository_ids__any_build_list}"
- printf ' AND `dependency_types`.`relevant_for_building`'
- printf ' AND ('
- printf '`dependency_types`.`relevant_for_binary_packages`'
- printf ' OR NOT EXISTS ('
- printf 'SELECT 1 FROM `binary_packages_in_repositories` AS `subst_bpir`'
- mysql_join_binary_packages_in_repositories_repositories 'subst_bpir' 'subst_r'
- printf ' AND `subst_r`.`is_on_master_mirror`'
- mysql_join_binary_packages_in_repositories_binary_packages 'subst_bpir' 'subst_bp'
- mysql_join_binary_packages_build_assignments 'subst_bp' 'subst_ba'
- printf ' JOIN `architecture_compatibilities` AS `subst_ac`'
- printf ' ON `subst_ac`.`built_for`=`subst_ba`.`architecture`'
- printf ' AND `subst_ac`.`runs_on`=%s' \
- "${arch_id}"
- printf ' AND `subst_ac`.`fully_compatible`'
- mysql_join_binary_packages_in_repositories_install_target_providers 'subst_bpir' 'subst_itp'
- mysql_join_install_target_providers_versions 'subst_itp' 'subst_itp_v'
- printf ' WHERE `subst_itp`.`install_target`=`dependencies`.`depending_on`'
- printf ' AND '
- mysql_query_ordering_correct \
- '`dependencies_versions`.`order`' \
- '`subst_itp_v`.`order`' \
- '`dependencies`.`version_relation`'
- printf ')'
- printf ');\n'
- } | \
- mysql_run_query | \
- tr '\t' ' ' | \
- tsort 2>&1 >/dev/null | \
- sed 's/^tsort:\s*//'
- done | \
- {
- loop=0
- while read -r id; do
- if [ "x${id}" = 'x-: input contains a loop:' ]; then
- loop=$((loop+1))
- continue
- fi
- if ! printf '%s' "${id}" | tr '\n' ' ' | grep -q '^[0-9]\+$'; then
- >&2 printf 'ERROR: non-numeric id "%s"\n' "${id}"
- continue
- fi
- printf '(%s,%s),\n' "${loop}" "${id}"
- done | \
- sed '
- 1~20 i INSERT INTO `build_dependency_loops` (`loop`,`build_assignment`) VALUES ''
- 0~20 s/,$/;/
- $ s/,$/;/
- '
- }
- )
{
- printf 'DELETE FROM `build_dependency_loops`;\n'
- if [ -n "${new_loops}" ]; then
- printf 'INSERT INTO `build_dependency_loops` (`loop`,`build_assignment`) VALUES %s;\n' \
- "${new_loops}"
- fi
+ printf 'SELECT DISTINCT `architectures`.`id`'
+ printf ' FROM `architectures`'
+ printf ' WHERE `architectures`.`id`!=%s;\n' \
+ "${architecture_ids__any}"
} | \
+ mysql_run_query | \
+ while read -r arch_id; do
+ {
+ printf 'SELECT DISTINCT'
+ printf ' `ncy_ba`.`id`,'
+ printf '`nt_ba`.`id`'
+ printf ' FROM `dependencies`'
+ mysql_join_dependencies_dependency_types
+ mysql_join_dependencies_install_target_providers_with_versions
+ mysql_join_install_target_providers_binary_packages '' 'ncy_bp'
+ mysql_join_dependencies_binary_packages '' 'nt_bp'
+ for which in 'ncy' 'nt'; do
+ mysql_join_binary_packages_binary_packages_in_repositories "${which}"'_bp' "${which}"'_bpir'
+ mysql_join_binary_packages_build_assignments "${which}"'_bp' "${which}"'_ba'
+ printf ' JOIN `architecture_compatibilities` AS `%s_ac`' \
+ "${which}"
+ printf ' ON `%s_ac`.`built_for`=`%s_ba`.`architecture`' \
+ "${which}" "${which}"
+ printf ' AND `%s_ac`.`runs_on`=%s' \
+ "${which}" "${arch_id}"
+ printf ' AND `%s_ac`.`fully_compatible`' \
+ "${which}"
+ done
+ printf ' WHERE `nt_bpir`.`repository`=%s' \
+ "${repository_ids__any_build_list}"
+ printf ' AND `ncy_bpir`.`repository`=%s' \
+ "${repository_ids__any_build_list}"
+ printf ' AND `dependency_types`.`relevant_for_building`'
+ printf ' AND ('
+ printf '`dependency_types`.`relevant_for_binary_packages`'
+ printf ' OR NOT EXISTS ('
+ printf 'SELECT 1 FROM `binary_packages_in_repositories` AS `subst_bpir`'
+ mysql_join_binary_packages_in_repositories_repositories 'subst_bpir' 'subst_r'
+ printf ' AND `subst_r`.`is_on_master_mirror`'
+ mysql_join_binary_packages_in_repositories_binary_packages 'subst_bpir' 'subst_bp'
+ mysql_join_binary_packages_build_assignments 'subst_bp' 'subst_ba'
+ printf ' JOIN `architecture_compatibilities` AS `subst_ac`'
+ printf ' ON `subst_ac`.`built_for`=`subst_ba`.`architecture`'
+ printf ' AND `subst_ac`.`runs_on`=%s' \
+ "${arch_id}"
+ printf ' AND `subst_ac`.`fully_compatible`'
+ mysql_join_binary_packages_in_repositories_install_target_providers 'subst_bpir' 'subst_itp'
+ mysql_join_install_target_providers_versions 'subst_itp' 'subst_itp_v'
+ printf ' WHERE `subst_itp`.`install_target`=`dependencies`.`depending_on`'
+ printf ' AND '
+ mysql_query_ordering_correct \
+ '`dependencies_versions`.`order`' \
+ '`subst_itp_v`.`order`' \
+ '`dependencies`.`version_relation`'
+ printf ')'
+ printf ');\n'
+ } | \
+ mysql_run_query | \
+ tr '\t' ' ' | \
+ tsort 2>&1 >/dev/null | \
+ sed 's/^tsort:\s*//'
+ done | \
+ {
+ loop=0
+ while read -r id; do
+ if [ "x${id}" = 'x-: input contains a loop:' ]; then
+ loop=$((loop+1))
+ continue
+ fi
+ if ! printf '%s' "${id}" | tr '\n' ' ' | grep -q '^[0-9]\+$'; then
+ >&2 printf 'ERROR: non-numeric id "%s"\n' "${id}"
+ continue
+ fi
+ printf '(%s,%s),\n' "${loop}" "${id}"
+ done | \
+ sed '
+ 1~20 i INSERT INTO `build_dependency_loops` (`loop`,`build_assignment`) VALUES ''
+ 0~20 s/,$/;/
+ $ s/,$/;/
+ '
+ } | \
+ sed '
+ 1 i DELETE FROM `build_dependency_loops`;
+ ' | \
mysql_run_query
}