Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/bootstrap-mysql
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bootstrap-mysql')
-rwxr-xr-xbin/bootstrap-mysql72
1 files changed, 63 insertions, 9 deletions
diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql
index 822d995..35f5398 100755
--- a/bin/bootstrap-mysql
+++ b/bin/bootstrap-mysql
@@ -367,6 +367,25 @@ if [ ! "$1" = 'slim' ]; then
printf 'CREATE TEMPORARY TABLE `moveable_binary_packages%s` (`id` BIGINT, `to_repository` MEDIUMINT, UNIQUE KEY (`id`));\n' \
"${copy}"
done
+ printf 'DROP TEMPORARY TABLE IF EXISTS `package_blobs`;\n'
+ printf 'CREATE TEMPORARY TABLE `package_blobs` (`ps_a` BIGINT, `ps_b` BIGINT, UNIQUE KEY `content` (`ps_a`,`ps_b`));\n'
+ # all packages being vaguely relevant enter `package_blobs`, because
+ # they might block any other package from moving
+ printf 'INSERT IGNORE INTO `package_blobs` (`ps_a`,`ps_b`)'
+ printf ' SELECT `a_ps`.`id`,`b_ps`.`id`'
+ printf ' FROM `package_sources` AS `a_ps`'
+ printf ' JOIN `package_sources` AS `b_ps`'
+ printf ' ON UNIX_TIMESTAMP(`a_ps`.`commit_time`) - UNIX_TIMESTAMP(`b_ps`.`commit_time`) BETWEEN -10 AND 10'
+ mysql_join_package_sources_build_assignments 'a_ps' 'a_ba'
+ mysql_join_package_sources_build_assignments 'b_ps' 'b_ba'
+ mysql_join_build_assignments_binary_packages 'a_ba' 'a_bp'
+ mysql_join_build_assignments_binary_packages 'b_ba' 'b_bp'
+ mysql_join_binary_packages_repositories 'a_bp' 'a_r'
+ mysql_join_binary_packages_repositories 'b_bp' 'b_r'
+ mysql_join_repositories_repository_stabilities 'a_r' 'a_rs'
+ mysql_join_repositories_repository_stabilities 'b_r' 'b_rs'
+ printf ' WHERE `a_rs`.`name` = `from_stability`'
+ printf ' AND `b_rs`.`name` = `from_stability`;\n'
# these packages are considered for moving:
printf 'INSERT IGNORE INTO `moveable_binary_packages` (`id`,`to_repository`)'
printf ' SELECT `binary_packages`.`id`,`repository_moves`.`to_repository`'
@@ -408,6 +427,8 @@ if [ ! "$1" = 'slim' ]; then
# now we delete all unreplaceable and unmoveable packages from the respective
# list until no further changes are required
printf 'REPEAT\n'
+ printf 'SET row_count_saved = 0;\n'
+
# create copies of our temporary tables *yuck*
for table in 'replaced' 'moveable'; do
for copy in '' '2'; do
@@ -433,23 +454,23 @@ if [ ! "$1" = 'slim' ]; then
printf ' AND `dependency_types`.`relevant_for_binary_packages`'
# ... by a not-deleted, "more stable" package already in place or ...
printf ' WHERE NOT EXISTS ('
- printf 'SELECT * FROM `install_target_providers`'
+ printf 'SELECT 1 FROM `install_target_providers`'
mysql_join_install_target_providers_binary_packages '' 'prov_bp'
mysql_join_binary_packages_repositories 'prov_bp' 'prov_r'
printf ' JOIN `repository_stability_relations` ON `prov_r`.`stability`=`repository_stability_relations`.`more_stable`'
printf ' WHERE `install_target_providers`.`install_target`=`dependencies`.`depending_on`'
printf ' AND `target_repositories`.`stability`=`repository_stability_relations`.`less_stable`'
printf ' AND NOT EXISTS ('
- printf 'SELECT * FROM `replaced_binary_packages_copy`'
+ printf 'SELECT 1 FROM `replaced_binary_packages_copy`'
printf ' WHERE `replaced_binary_packages_copy`.`id`=`prov_bp`.`id`'
printf ')'
# ... by a moved package
printf ') AND NOT EXISTS ('
- printf 'SELECT * FROM `install_target_providers`'
+ printf 'SELECT 1 FROM `install_target_providers`'
printf ' JOIN `moveable_binary_packages_copy` ON `moveable_binary_packages_copy`.`id`=`install_target_providers`.`package`'
printf ' WHERE `install_target_providers`.`install_target`=`dependencies`.`depending_on`'
printf ');\n'
- printf 'SET @row_count_saved = ROW_COUNT();\n'
+ printf 'SET row_count_saved = row_count_saved + ROW_COUNT();\n'
# refresh copies of our temporary tables *yuck*
for table in 'replaced' 'moveable'; do
@@ -485,7 +506,7 @@ if [ ! "$1" = 'slim' ]; then
mysql_join_install_target_providers_dependencies
printf ' AND NOT EXISTS ('
# dependencies of replaced packages don't matter
- printf 'SELECT * FROM `replaced_binary_packages_copy`'
+ printf 'SELECT 1 FROM `replaced_binary_packages_copy`'
printf ' WHERE `replaced_binary_packages_copy`.`id`=`dependencies`.`dependent`'
printf ')'
mysql_join_dependencies_dependency_types
@@ -502,7 +523,7 @@ if [ ! "$1" = 'slim' ]; then
# a) ^
printf ' WHERE NOT EXISTS ('
# no moved package ...
- printf 'SELECT *'
+ printf 'SELECT 1'
printf ' FROM `moveable_binary_packages_copy`'
mysql_join_binary_packages_install_target_providers 'moveable_binary_packages_copy' 'subst_itp'
# ... provides the same
@@ -510,7 +531,7 @@ if [ ! "$1" = 'slim' ]; then
# b) 1) ^
printf ') AND NOT EXISTS ('
# no current package ...
- printf 'SELECT *'
+ printf 'SELECT 1'
printf ' FROM `binary_packages` AS `subst_bp`'
mysql_join_binary_packages_install_target_providers 'subst_bp' 'subst_itp'
# ... in a repository ...
@@ -522,14 +543,47 @@ if [ ! "$1" = 'slim' ]; then
printf ' WHERE `subst_rr`.`less_stable`=`repl_r`.`stability`'
printf ' AND NOT EXISTS ('
# ... and which is not replaced ...
- printf 'SELECT * FROM `replaced_binary_packages_copy2`'
+ printf 'SELECT 1 FROM `replaced_binary_packages_copy2`'
printf ' WHERE `replaced_binary_packages_copy2`.`id`=`subst_bp`.`id`'
printf ')'
# ... and provides the same
printf ' AND `subst_itp`.`install_target`=`install_target_providers`.`install_target`'
# b) 2) ^
printf ');\n'
- printf 'UNTIL row_count_saved=0 AND ROW_COUNT()=0\n'
+ printf 'SET row_count_saved = row_count_saved + ROW_COUNT();\n'
+
+ # refresh copies of our temporary tables *yuck*
+ for table in 'replaced' 'moveable'; do
+ for copy in '' '2'; do
+ if [ "${table}" = 'moveable' ] && \
+ [ "${copy}" = '2' ]; then
+ continue
+ fi
+ printf 'DELETE FROM `%s_binary_packages_copy%s`;\n' "${table}" "${copy}"
+ printf 'INSERT IGNORE INTO `%s_binary_packages_copy%s`' "${table}" "${copy}"
+ printf ' SELECT `%s_binary_packages`.*' "${table}"
+ printf ' FROM `%s_binary_packages`;\n' "${table}"
+ done
+ done
+
+ printf 'DELETE `replaced_binary_packages`,`moveable_binary_packages` FROM `replaced_binary_packages`'
+ printf ' RIGHT JOIN `moveable_binary_packages`'
+ printf ' ON `replaced_binary_packages`.`replaced_by`=`moveable_binary_packages`.`id`'
+ printf ' JOIN `binary_packages`'
+ printf ' ON `binary_packages`.`id`=`moveable_binary_packages`.`id`'
+ mysql_join_binary_packages_build_assignments
+ printf ' JOIN `package_blobs`'
+ printf ' ON `build_assignments`.`package_source`=`package_blobs`.`ps_a`'
+ printf ' JOIN `build_assignments` AS `bl_ba`'
+ printf ' ON `bl_ba`.`package_source`=`package_blobs`.`ps_b`'
+ mysql_join_build_assignments_binary_packages 'bl_ba' 'bl_bp'
+ printf ' WHERE NOT EXISTS ('
+ printf 'SELECT 1 FROM `moveable_binary_packages_copy`'
+ printf ' WHERE `moveable_binary_packages_copy`.`id`=`bl_bp`.`id`'
+ printf ');\n'
+ printf 'SET row_count_saved = row_count_saved + ROW_COUNT();\n'
+
+ printf 'UNTIL row_count_saved=0\n'
printf 'END REPEAT;\n'
for table in 'moveable' 'replaced'; do
for copy in '' '2'; do