Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/why-dont-you
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-02-26 13:47:49 +0100
committerErich Eckner <git@eckner.net>2020-02-26 13:47:49 +0100
commit634286e569949aa0d32b1c282377f4ee997ea087 (patch)
tree73ac49d6c9f365eb952096d0dd1b00e8042b72a9 /bin/why-dont-you
parente4d15e3848eb16803e462ed0050978efde4939c0 (diff)
bin/why-dont-you: stabilize|unstage: works, but is less comprehensive than before (e.g. does not work recursively)
Diffstat (limited to 'bin/why-dont-you')
-rwxr-xr-xbin/why-dont-you353
1 files changed, 128 insertions, 225 deletions
diff --git a/bin/why-dont-you b/bin/why-dont-you
index 63b96e9..06edacb 100755
--- a/bin/why-dont-you
+++ b/bin/why-dont-you
@@ -203,72 +203,58 @@ case "${action}" in
if [ "${action}" = 'stabilize' ]; then
# shellcheck disable=SC2154
from_stability=${repository_stability_ids__testing}
- # shellcheck disable=SC2154
- to_stability=${repository_stability_ids__stable}
# shellcheck disable=SC2016
test_filter='`binary_packages`.`is_tested`'
else
# shellcheck disable=SC2154
from_stability=${repository_stability_ids__staging}
- # shellcheck disable=SC2154
- to_stability=${repository_stability_ids__testing}
test_filter='1'
fi
for pkgname in "$@"; do
- infos=$(
- # shellcheck disable=SC2016
- {
- printf 'SELECT'
- printf ' `binary_packages_in_repositories`.`id`,'
- printf ' IF(%s,1,0),' "${test_filter}"
- printf ' IF(`binary_packages`.`has_issues`,1,0)'
- printf ' FROM `binary_packages_in_repositories`'
- mysql_join_binary_packages_in_repositories_repositories
- mysql_join_repositories_architectures
- mysql_join_binary_packages_in_repositories_binary_packages
- printf ' WHERE `repositories`.`stability`=%s' \
- "${from_stability}"
- printf ' AND ('
- printf '`binary_packages`.`pkgname`=from_base64("%s")' \
- "$(
- printf '%s' "${pkgname}" | \
- base64 -w0
- )"
- printf 'OR CONCAT('
- printf '`architectures`.`name`,"/",'
- printf '`binary_packages`.`pkgname`'
- printf ')=from_base64("%s")' \
- "$(
- printf '%s' "${pkgname}" | \
- base64 -w0
- )"
- printf ');\n'
- } | \
- mysql_run_query 'unimportant' | \
- tr '\t' ' '
- )
- if [ -z "${infos}" ]; then
- printf 'Cannot find "%s"\n' \
- "${pkgname}"
- continue
- fi
- bpir="${infos%% *}"
- infos="${infos#* }"
- if [ "${infos% *}" = '0' ]; then
- printf '"%s" is not tested.\n' \
- "${pkgname}"
- continue
- fi
- infos="${infos#* }"
- if [ "${infos}" = '1' ]; then
- printf 'There are unresolved bugs reported against "%s".\n' \
- "${pkgname}"
- continue
- fi
-
- printf '%s %s\n' "${bpir}" "${pkgname}" >> \
- "${tmp_dir}/packages"
+ # shellcheck disable=SC2016
+ {
+ printf 'SELECT'
+ printf ' `binary_packages_in_repositories`.`id`,'
+ printf ' IF(%s,1,0),' "${test_filter}"
+ printf ' IF(`binary_packages`.`has_issues`,1,0)'
+ printf ' FROM `binary_packages_in_repositories`'
+ mysql_join_binary_packages_in_repositories_repositories
+ mysql_join_repositories_architectures
+ mysql_join_binary_packages_in_repositories_binary_packages
+ printf ' WHERE `repositories`.`stability`=%s' \
+ "${from_stability}"
+ printf ' AND ('
+ printf '`binary_packages`.`pkgname`=from_base64("%s")' \
+ "$(
+ printf '%s' "${pkgname}" | \
+ base64 -w0
+ )"
+ printf 'OR CONCAT('
+ printf '`architectures`.`name`,"/",'
+ printf '`binary_packages`.`pkgname`'
+ printf ')=from_base64("%s")' \
+ "$(
+ printf '%s' "${pkgname}" | \
+ base64 -w0
+ )"
+ printf ');\n'
+ } \
+ | mysql_run_query 'unimportant' \
+ | while read -r bpir tested issues; do
+ if [ "${tested}" = '0' ]; then
+ printf '"%s" is not tested.\n' \
+ "${pkgname}"
+ continue
+ fi
+ if [ "${issues}" = '1' ]; then
+ printf 'There are unresolved bugs reported against "%s".\n' \
+ "${pkgname}"
+ continue
+ fi
+ printf '%s\n' "${bpir}" \
+ >> "${tmp_dir}/packages"
+ done
done
if [ ! -s "${tmp_dir}/packages" ]; then
@@ -277,177 +263,94 @@ case "${action}" in
# 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 `r_bpir`.`id`,`m_bpir`.`id`'
- printf ' FROM `moveable_bpir`'
- printf ' JOIN `binary_packages_in_repositories` AS `m_bpir`'
- printf ' ON `m_bpir`.`id`=`moveable_bpir`.`id`'
- mysql_join_binary_packages_in_repositories_binary_packages 'm_bpir' 'm_bp'
- printf ' JOIN `binary_packages` AS `r_bp`'
- printf ' ON `r_bp`.`pkgname`=`m_bp`.`pkgname`'
- mysql_join_binary_packages_binary_packages_in_repositories 'r_bp' 'r_bpir'
- mysql_join_binary_packages_in_repositories_repositories 'r_bpir' 'r_r'
- printf ' JOIN `repositories` AS `m_r`'
- printf ' ON `m_r`.`id`=`moveable_bpir`.`to_repository`'
- printf ' AND `m_r`.`architecture`=`r_r`.`architecture`'
- printf ' JOIN `repository_stability_relations` AS `rsr`'
- printf ' ON `rsr`.`more_stable`=`r_r`.`stability`'
- printf ' AND `rsr`.`less_stable`=`m_r`.`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'
- mysql_join_binary_packages_in_repositories_binary_packages 'subst_bpir' 'subst_bp'
- printf ' JOIN `repository_stability_relations` AS `rsr_a`'
- printf ' ON `rsr_a`.`more_stable`=`subst_r`.`stability`'
- printf ' JOIN `repository_stability_relations` AS `rsr_b`'
- printf ' ON `rsr_b`.`less_stable`=`subst_r`.`stability`'
- printf ' WHERE `subst_bp`.`pkgname`=`r_bp`.`pkgname`'
- printf ' AND `subst_bp`.`id`=`r_bp`.`id`'
- printf ' AND `rsr_a`.`less_stable`=`m_r`.`stability`'
- printf ' AND `rsr_b`.`more_stable`=`r_r`.`stability`'
+ printf 'CREATE TEMPORARY TABLE `bpirs` ('
+ printf '`id` BIGINT,'
+ printf 'UNIQUE KEY `id`(`id`)'
printf ');\n'
+ printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `bpirs`;\n' \
+ "${tmp_dir}/packages"
- # 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 ' 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`'
- printf ' SELECT *'
- printf ' 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 `c`'
+ printf 'SELECT CONCAT('
+ printf '"\\"",'
+ printf '`sub_q`.`label`,'
+ printf '"\\" depends on ",'
+ printf 'GROUP_CONCAT('
+ printf 'CONCAT('
+ printf '"\\"",'
+ printf '`sub_q`.`dependency`,'
+ printf '"\\""'
+ printf ')'
+ printf '),'
+ printf '" which must be moved simultanously"'
+ printf ') FROM ('
+ printf 'SELECT DISTINCT '
+ printf 'CONCAT(`architectures`.`name`,"/",`itp_bp`.`pkgname`) AS `dependency`,'
+ printf '`bpirs`.`id`,'
+ printf 'CONCAT(`architectures`.`name`,"/",`binary_packages`.`pkgname`) AS `label`'
+ printf ' FROM `bpirs`'
printf ' JOIN `binary_packages_in_repositories`'
- 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 `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 ' 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 'unimportant'
+ printf ' ON `binary_packages_in_repositories`.`id`=`bpirs`.`id`'
+ mysql_join_binary_packages_in_repositories_repositories
+ mysql_join_repositories_architectures
+ mysql_join_binary_packages_in_repositories_binary_packages
+ mysql_join_binary_packages_dependencies
+ 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 '' 'itp_bp'
+ mysql_join_binary_packages_binary_packages_in_repositories 'itp_bp' 'itp_bpir'
+ mysql_join_binary_packages_in_repositories_repositories 'itp_bpir' 'itp_r'
+ printf ' AND `itp_r`.`architecture`=`repositories`.`architecture`'
+ printf ' JOIN `repository_stability_relations`'
+ printf ' ON `repository_stability_relations`.`more_stable`=`repositories`.`stability`'
+ printf ' AND `repository_stability_relations`.`less_stable`=`itp_r`.`stability`'
+ printf ') AS `sub_q`'
+ printf ' GROUP BY `sub_q`.`id`;\n'
+
+ printf 'SELECT CONCAT('
+ printf '"\\"",'
+ printf '`sub_q`.`label`,'
+ printf '"\\" replaces dependencies of ",'
+ printf 'GROUP_CONCAT('
+ printf 'CONCAT('
+ printf '"\\"",'
+ printf '`sub_q`.`dependent`,'
+ printf '"\\""'
+ printf ')'
+ printf '),'
+ printf '"\\" which must be replaced simulatanously"'
+ printf ') FROM ('
+ printf 'SELECT DISTINCT '
+ printf 'CONCAT(`architectures`.`name`,"/",`d_bp`.`pkgname`) AS `dependent`,'
+ printf '`bpirs`.`id`,'
+ printf 'CONCAT(`architectures`.`name`,"/",`binary_packages`.`pkgname`) AS `label`'
+ printf ' FROM `bpirs`'
+ printf ' JOIN `binary_packages_in_repositories`'
+ printf ' ON `binary_packages_in_repositories`.`id`=`bpirs`.`id`'
+ mysql_join_binary_packages_in_repositories_repositories
+ mysql_join_repositories_architectures
+ mysql_join_binary_packages_in_repositories_binary_packages
+ printf ' JOIN `binary_packages` AS `r_bp`'
+ printf ' ON `binary_packages`.`pkgname`=`r_bp`.`pkgname`'
+ mysql_join_binary_packages_binary_packages_in_repositories 'r_bp' 'r_bpir'
+ printf ' JOIN `repository_moves`'
+ printf ' ON `repository_moves`.`from_repository`=`repositories`.`id`'
+ printf ' AND `repository_moves`.`to_repository`=`r_bpir`.`repository`'
+ mysql_join_binary_packages_install_target_providers 'r_bp' 'r_itp'
+ mysql_join_install_target_providers_dependencies_with_versions 'r_itp'
+ mysql_join_dependencies_dependency_types
+ printf ' AND `dependency_types`.`relevant_for_binary_packages`'
+ mysql_join_dependencies_binary_packages '' 'd_bp'
+ mysql_join_binary_packages_binary_packages_in_repositories 'd_bp' 'd_bpir'
+ mysql_join_binary_packages_in_repositories_repositories 'd_bpir' 'd_r'
+ printf ' AND `d_r`.`architecture`=`repositories`.`architecture`'
+ printf ' JOIN `repository_stability_relations`'
+ printf ' ON `repository_stability_relations`.`more_stable`=`d_r`.`stability`'
+ printf ' AND `repository_stability_relations`.`less_stable`=`repositories`.`stability`'
+ printf ') AS `sub_q`'
+ printf ' GROUP BY `sub_q`.`id`;\n'
+ } \
+ | mysql_run_query 'unimportant'
;;