index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-07-05 15:29:41 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-07-05 15:29:41 +0200 |
commit | c2361c1a45e1c5c43141a4fa41d067d7130b61c0 (patch) | |
tree | badaf9e8b00c23e88e5df306c67d0dbc21f8cabe /bin | |
parent | 80209fad24182a1522e98f90fc94ceada5bf8594 (diff) |
-rwxr-xr-x | bin/why-dont-you | 262 |
diff --git a/bin/why-dont-you b/bin/why-dont-you index d795050..170ee81 100755 --- a/bin/why-dont-you +++ b/bin/why-dont-you @@ -217,7 +217,7 @@ case "${action}" in "${pkgname}" continue fi - # bpir="${infos%% *}" + bpir="${infos%% *}" infos="${infos#* }" if [ "${infos% *}" = '0' ]; then printf '"%s" is not tested.\n' \ @@ -231,131 +231,165 @@ case "${action}" in continue fi - # shellcheck disable=SC2016 - { - printf 'CREATE TEMPORARY TABLE `moveable_bpir` (`id` BIGINT, `to_repository` BIGINT, UNIQUE KEY `id`(`id`));\n' - printf 'CREATE TEMPORARY TABLE `replaceable_bpir` (`id` BIGINT, `replaced_by` BIGINT, UNIQUE KEY `id`(`id`));\n' - - for copy in '' '_copy'; do - printf 'CREATE TEMPORARY TABLE `knots%s` (' \ - "${copy}" - printf '`id` BIGINT NOT NULL AUTO_INCREMENT,' - printf ' `and` BIT,' - printf ' `content_id` BIGINT,' - printf ' `content_type` ENUM("bpir","it"),' - printf ' `reason_length` MEDIUMINT,' - printf ' UNIQUE KEY (`id`),' - printf ' UNIQUE KEY `content`(`content_id`,`content_type`));\n' - done - printf 'CREATE TEMPORARY TABLE `edges` (' + printf '%s %s\n' "${bpir}" "${pkgname}" >> \ + "${tmp_dir}/packages" + done + + if [ ! -s "${tmp_dir}/packages" ]; then + exit + fi + + # shellcheck disable=SC2016 + { + printf 'CREATE TEMPORARY TABLE `moveable_bpir` (`id` BIGINT, `to_repository` BIGINT, UNIQUE KEY `id`(`id`));\n' + printf 'CREATE TEMPORARY TABLE `replaceable_bpir` (`id` BIGINT, `replaced_by` BIGINT, UNIQUE KEY `id`(`id`));\n' + + for copy in '' '_copy'; do + printf 'CREATE TEMPORARY TABLE `knots%s` (' \ + "${copy}" + printf '`id` BIGINT NOT NULL AUTO_INCREMENT,' + printf ' `and` BIT,' + printf ' `content_id` BIGINT,' + printf ' `content_type` ENUM("bpir","it"),' + printf ' `reason_length` MEDIUMINT,' + printf ' `active` BIT,' + printf ' `relevant` BIT,' + printf ' UNIQUE KEY (`id`),' + printf ' UNIQUE KEY `content`(`content_id`,`content_type`));\n' + printf 'CREATE TEMPORARY TABLE `edges%s` (' \ + "${copy}" printf '`cause` BIGINT,' printf ' `impact` BIGINT,' printf ' `invert` BIT,' printf ' UNIQUE KEY `content` (`cause`,`impact`));\n' + done - printf 'INSERT IGNORE INTO `moveable_bpir` (`id`,`to_repository`)' - printf ' SELECT ' - printf '`binary_packages_in_repositories`.`id`,' - printf '`repository_moves`.`to_repository`' - printf ' FROM `binary_packages_in_repositories`' - mysql_join_binary_packages_in_repositories_repositories - mysql_join_binary_packages_in_repositories_binary_packages - mysql_join_binary_packages_build_assignments - mysql_join_build_assignments_package_sources - mysql_join_package_sources_upstream_repositories - mysql_join_upstream_repositories_repository_moves - printf ' AND `repository_moves`.`from_repository`=`repositories`.`id`' - printf ' WHERE `repositories`.`stability`=%s' \ - "${from_stability}" - printf ' AND %s' \ - "${test_filter}" - printf ' AND NOT `binary_packages`.`has_issues`;\n' - - printf 'INSERT IGNORE INTO `replaceable_bpir` (`id`,`replaced_by`)' - printf ' SELECT `binary_packages_in_repositories`.`id`,`r_bpir`.`id`' - printf ' FROM `moveable_bpir`' - printf ' JOIN `binary_packages_in_repositories` AS `r_bpir`' - printf ' ON `r_bpir`.`id`=`moveable_bpir`.`id`' - mysql_join_binary_packages_in_repositories_binary_packages 'r_bpir' 'r_bp' - printf ' JOIN `binary_packages`' - printf ' ON `binary_packages`.`pkgname`=`r_bp`.`pkgname`' - mysql_join_binary_packages_binary_packages_in_repositories - printf ' WHERE `binary_packages_in_repositories`.`repository`=`moveable_bpir`.`to_repository`;\n' - - # we generate a graph with bpir and it as knots - - printf 'INSERT INTO `knots` (`and`,`content_id`,`content_type`)' - printf ' SELECT 1,`moveable_bpir`.`id`,"bpir"' - printf ' FROM `moveable_bpir`;\n' - - printf 'INSERT INTO `knots` (`and`,`content_id`,`content_type`)' - printf ' SELECT 1,`binary_packages_in_repositories`.`id`,"bpir"' - printf ' FROM `binary_packages_in_repositories`' - mysql_join_binary_packages_in_repositories_repositories - printf ' WHERE `repositories`.`stability`=%s;\n' \ + printf 'INSERT IGNORE INTO `moveable_bpir` (`id`,`to_repository`)' + printf ' SELECT ' + printf '`binary_packages_in_repositories`.`id`,' + printf '`repository_moves`.`to_repository`' + printf ' FROM `binary_packages_in_repositories`' + mysql_join_binary_packages_in_repositories_repositories + mysql_join_binary_packages_in_repositories_binary_packages + mysql_join_binary_packages_build_assignments + mysql_join_build_assignments_package_sources + mysql_join_package_sources_upstream_repositories + mysql_join_upstream_repositories_repository_moves + printf ' AND `repository_moves`.`from_repository`=`repositories`.`id`' + printf ' WHERE `repositories`.`stability`=%s' \ + "${from_stability}" + printf ' AND %s' \ + "${test_filter}" + printf ' AND NOT `binary_packages`.`has_issues`;\n' + + printf 'INSERT IGNORE INTO `replaceable_bpir` (`id`,`replaced_by`)' + printf ' SELECT `binary_packages_in_repositories`.`id`,`r_bpir`.`id`' + printf ' FROM `moveable_bpir`' + printf ' JOIN `binary_packages_in_repositories` AS `r_bpir`' + printf ' ON `r_bpir`.`id`=`moveable_bpir`.`id`' + mysql_join_binary_packages_in_repositories_binary_packages 'r_bpir' 'r_bp' + printf ' JOIN `binary_packages`' + printf ' ON `binary_packages`.`pkgname`=`r_bp`.`pkgname`' + mysql_join_binary_packages_binary_packages_in_repositories + printf ' WHERE `binary_packages_in_repositories`.`repository`=`moveable_bpir`.`to_repository`;\n' + + # we generate a graph with bpir and it as knots + + printf 'INSERT INTO `knots` (`and`,`content_id`,`content_type`)' + printf ' SELECT 1,`moveable_bpir`.`id`,"bpir"' + printf ' FROM `moveable_bpir`;\n' + + printf 'INSERT INTO `knots` (`and`,`content_id`,`content_type`)' + printf ' SELECT 1,`binary_packages_in_repositories`.`id`,"bpir"' + printf ' FROM `binary_packages_in_repositories`' + mysql_join_binary_packages_in_repositories_repositories + mysql_join_binary_packages_in_repositories_binary_packages + printf ' JOIN `repository_stability_relations`' + printf ' ON `repository_stability_relations`.`less_stable`=%s' \ + "${to_stability}" + printf ' AND `repository_stability_relations`.`more_stable`=`repositories`.`stability`' + printf ' WHERE NOT EXISTS(' + printf 'SELECT 1' + printf ' FROM `binary_packages_in_repositories` AS `subst_bpir`' + mysql_join_binary_packages_in_repositories_repositories 'subst_bpir' 'subst_r' + printf ' JOIN `repository_stability_relations` AS `rsr_a`' + printf ' ON `rsr_a`.`less_stable`=%s' \ "${to_stability}" - - printf 'INSERT INTO `knots` (`and`,`content_id`,`content_type`)' - printf ' SELECT 0,`install_targets`.`id`,"it"' - printf ' FROM `install_targets`;\n' - - # create copy - printf 'INSERT INTO `knots_copy` SELECT * FROM `knots`;\n' - - # "available" bpir requires available install_target + printf ' AND `rsr_a`.`more_stable`=`subst_r`.`stability`' + printf ' JOIN `repository_stability_relations` AS `rsr_b`' + printf ' ON `rsr_b`.`less_stable`=`subst_r`.`stability`' + mysql_join_binary_packages_in_repositories_binary_packages 'subst_bpir' 'subst_bp' + printf ' WHERE `subst_bp`.`pkgname`=`binary_packages`.`pkgname`' + printf ' AND `subst_bpir`.`id`!=`binary_packages_in_repositories`.`id`' + printf ' AND `rsr_b`.`more_stable`=`repositories`.`stability`' + printf ');\n' + + printf 'INSERT INTO `knots` (`and`,`content_id`,`content_type`)' + printf ' SELECT 0,`install_targets`.`id`,"it"' + printf ' FROM `install_targets`;\n' + + # create copy + printf 'INSERT INTO `knots_copy` SELECT * FROM `knots`;\n' + + # "available" bpir requires available install_target + printf 'INSERT INTO `edges` (`cause`,`impact`,`invert`)' + printf ' SELECT DISTINCT `c`.`id`,`i`.`id`,0' + printf ' FROM `knots` AS `i`' + printf ' JOIN `binary_packages_in_repositories`' + printf ' ON `binary_packages_in_repositories`.`id`=`i`.`content_id`' + printf ' AND `i`.`content_type`="bpir"' + mysql_join_binary_packages_in_repositories_dependencies + mysql_join_dependencies_dependency_types + printf ' AND `dependency_types`.`relevant_for_binary_packages`' + printf ' JOIN `knots_copy` AS `c`' + printf ' ON `dependencies`.`depending_on`=`c`.`content_id`' + printf ' AND `c`.`content_type`="it";\n' + + # "available" install_target requires available bpir - but we + # only care about bpir being moved or being more stable than + # target stability + for what in 'moveable' 'there'; do printf 'INSERT INTO `edges` (`cause`,`impact`,`invert`)' printf ' SELECT DISTINCT `c`.`id`,`i`.`id`,0' - printf ' FROM `knots` AS `i`' + printf ' FROM `knots` AS `c`' printf ' JOIN `binary_packages_in_repositories`' - printf ' ON `binary_packages_in_repositories`.`id`=`i`.`content_id`' - printf ' AND `i`.`content_type`="bpir"' - mysql_join_binary_packages_in_repositories_dependencies - mysql_join_dependencies_dependency_types - printf ' AND `dependency_types`.`relevant_for_binary_packages`' - printf ' JOIN `knots_copy` AS `c`' - printf ' ON `dependencies`.`depending_on`=`c`.`content_id`' - printf ' AND `c`.`content_type`="it";\n' - - # "available" install_target requires available bpir - but we - # only care about bpir being replaced or moved - for bpir in 'moveable' 'replaceable'; do - printf 'INSERT INTO `edges` (`cause`,`impact`,`invert`)' - printf ' SELECT DISTINCT `c`.`id`,`i`.`id`,0' - printf ' FROM `knots` AS `c`' - printf ' JOIN `binary_packages_in_repositories`' - printf ' ON `binary_packages_in_repositories`.`id`=`c`.`content_id`' - printf ' AND `c`.`content_type`="bpir"' - printf ' JOIN `%s_bpir`' \ - "${bpir}" - printf ' ON `%s_bpir`.`id`=`binary_packages_in_repositories`.`id`' \ - "${bpir}" - mysql_join_binary_packages_in_repositories_install_target_providers - printf ' JOIN `knots_copy` AS `i`' - printf ' ON `install_target_providers`.`install_target`=`i`.`content_id`' - printf ' AND `i`.`content_type`="it";\n' - done - - # additionally, "available" moveable_bpir requires matching - # replaceable_bpir unavailable - printf 'INSERT INTO `edges` (`cause`,`impact`,`invert`)' - printf ' SELECT `c`.`id`,`i`.`id`,1' - printf ' FROM `replaceable_bpir`' - printf ' JOIN `knots` AS `c`' - printf ' ON `c`.`content_id`=`replaceable_bpir`.`id`' + printf ' ON `binary_packages_in_repositories`.`id`=`c`.`content_id`' printf ' AND `c`.`content_type`="bpir"' + if [ "${what}" = 'moveable' ]; then + printf ' JOIN `moveable_bpir`' + printf ' ON `moveable_bpir`.`id`=`binary_packages_in_repositories`.`id`' + else + mysql_join_binary_packages_in_repositories_repositories + printf ' JOIN `repository_stability_relations`' + printf ' ON `repository_stability_relations`.`more_stable`=`repositories`.`stability`' + printf ' AND `repository_stability_relations`.`less_stable`=%s' \ + "${to_stability}" + fi + mysql_join_binary_packages_in_repositories_install_target_providers printf ' JOIN `knots_copy` AS `i`' - printf ' ON `i`.`content_id`=`replaceable_bpir`.`replaced_by`' - printf ' AND `i`.`content_type`="bpir";\n' - - # TODO: set knot values and evaluate graph - printf 'SELECT COUNT(1) FROM `%s`;\n' knots knots_copy edges - } | \ - mysql_run_query + printf ' ON `install_target_providers`.`install_target`=`i`.`content_id`' + printf ' AND `i`.`content_type`="it";\n' + done - printf '"%s" might be %sd (but evaluation of that is not yet completely implemented!).\n' \ - "${pkgname}" \ - "${action}" - done + # additionally, "available" moveable_bpir requires matching + # replaceable_bpir unavailable + printf 'INSERT INTO `edges` (`cause`,`impact`,`invert`)' + printf ' SELECT `c`.`id`,`i`.`id`,1' + printf ' FROM `replaceable_bpir`' + printf ' JOIN `knots` AS `c`' + printf ' ON `c`.`content_id`=`replaceable_bpir`.`id`' + printf ' AND `c`.`content_type`="bpir"' + printf ' JOIN `knots_copy` AS `i`' + printf ' ON `i`.`content_id`=`replaceable_bpir`.`replaced_by`' + printf ' AND `i`.`content_type`="bpir";\n' + + while read -r bpir pkgname; do + printf 'CALL `find_the_culprit`(%s);\n' \ + "${bpir}" + done < \ + "${tmp_dir}/packages" + } | \ + mysql_run_query ;; |