index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-09-19 08:08:26 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-09-19 08:08:26 +0200 |
commit | c3102a56ef285aee187a7f4350db1fdea23e1e42 (patch) | |
tree | b60a0963625e2a0eac4a495376805f809e1583b6 /lib/mysql-functions | |
parent | 2845a46d435e80abd65c85e6059789f6bfe170ea (diff) |
-rwxr-xr-x | lib/mysql-functions | 165 |
diff --git a/lib/mysql-functions b/lib/mysql-functions index c249a5f..51ca894 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -708,92 +708,91 @@ mysql_sanity_check() { # mysql_find_build_assignment_loops # recreate the `build_dependency_loops` table mysql_find_build_assignment_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 | \ + ( # new shell is intentional + tmp_file=$(mktemp "tmp.mysql-functions.mysql_find_build_assignment_loops.XXXXXXXXXX") + trap 'rm "${tmp_file}"' EXIT { - 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}" + 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 | \ - sed ' - 1~20 i INSERT INTO `build_dependency_loops` (`loop`,`build_assignment`) VALUES '' - 0~20 s/,$/;/ - $ s/,$/;/ - ' + awk ' + BEGIN { + i=0 + }; + /^-: input contains a loop:$/ { + i=i+1 + }; + !/^-: input contains a loop:$/ { + print i "\t" $1 + } + ' > \ + "${tmp_file}" + { + printf 'DELETE FROM `build_dependency_loops`;\n' + printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `build_assignments_loops` (`loop`,`build_assignment`);\n' \ + "${tmp_file}" } | \ - sed ' - 1 i DELETE FROM `build_dependency_loops`; - ' | \ - mysql_run_query + mysql_run_query + ) } # mysql_cleanup [dry] |