summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/bootstrap-mysql56
-rw-r--r--misc/database-layout.dump53
2 files changed, 76 insertions, 33 deletions
diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql
index 07e5f7d..81d5c82 100755
--- a/bin/bootstrap-mysql
+++ b/bin/bootstrap-mysql
@@ -96,6 +96,7 @@ fi
# no open issues
printf ' AND NOT `binary_packages`.`has_issues`'
printf ';\n'
+
# these packages are considered for being replaced:
# for each moved package
printf 'INSERT IGNORE INTO `replaced_bpir` (`id`,`replaced_by`)'
@@ -103,30 +104,51 @@ fi
printf ' FROM `moveable_bpir`'
printf ' JOIN `binary_packages_in_repositories` AS `m_bpir` ON `m_bpir`.`id`=`moveable_bpir`.`id`'
mysql_join_binary_packages_in_repositories_binary_packages 'm_bpir' 'm_bp'
- mysql_join_binary_packages_in_repositories_repositories 'm_bpir' 'm_from_r'
# in all repositories more stable than its target repository
printf ' JOIN `repositories` AS `m_to_r` ON `moveable_bpir`.`to_repository`=`m_to_r`.`id`'
- printf ' JOIN `repository_stability_relations` AS `rsr_a`'
- printf ' ON `rsr_a`.`less_stable`=`m_to_r`.`stability`'
+ printf ' JOIN `repository_stability_relations` AS `rsr`'
+ printf ' ON `rsr`.`less_stable`=`m_to_r`.`stability`'
printf ' JOIN `repositories` AS `r_r`'
- printf ' ON `rsr_a`.`more_stable`=`r_r`.`stability`'
+ printf ' ON `rsr`.`more_stable`=`r_r`.`stability`'
printf ' AND `r_r`.`architecture`=`m_to_r`.`architecture`'
mysql_join_repositories_binary_packages_in_repositories 'r_r' 'r_bpir'
mysql_join_binary_packages_in_repositories_binary_packages 'r_bpir' 'r_bp'
# all packages with identical names
- printf ' AND `r_bp`.`pkgname`=`m_bp`.`pkgname`'
- # but only the least stable of equally named packages is considered
- printf ' WHERE NOT EXISTS ('
- printf 'SELECT 1'
- printf ' FROM `binary_packages_in_repositories` AS `sup_bpir`'
- mysql_join_binary_packages_in_repositories_binary_packages 'sup_bpir' 'sup_bp'
- mysql_join_binary_packages_in_repositories_repositories 'sup_bpir' 'sup_r'
- printf ' JOIN `repository_stability_relations` AS `rsr_b`'
- printf ' ON `rsr_b`.`less_stable`=`sup_r`.`stability`'
- printf ' WHERE `sup_bp`.`pkgname`=`m_bp`.`pkgname`'
- printf ' AND `sup_r`.`architecture`=`m_to_r`.`architecture`'
- printf ' AND `rsr_b`.`more_stable`=`r_r`.`stability`'
- printf ');\n'
+ printf ' AND `r_bp`.`pkgname`=`m_bp`.`pkgname`;\n'
+
+ # create 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_bpir_copy%s`;\n' "${table}" "${copy}"
+ printf 'INSERT IGNORE INTO `%s_bpir_copy%s`' "${table}" "${copy}"
+ printf ' SELECT `%s_bpir`.*' "${table}"
+ printf ' FROM `%s_bpir`;\n' "${table}"
+ done
+ done
+
+ # only the least stable of equally named to-be-replaced packages is
+ # kept
+ printf 'DELETE `replaced_bpir` FROM `replaced_bpir`'
+ printf ' JOIN `binary_packages_in_repositories` AS `not_r_bpir`'
+ printf ' ON `not_r_bpir`.`id`=`replaced_bpir`.`id`'
+ mysql_join_binary_packages_in_repositories_binary_packages 'not_r_bpir' 'not_r_bp'
+ mysql_join_binary_packages_in_repositories_repositories 'not_r_bpir' 'not_r_r'
+ printf ' JOIN `binary_packages` AS `r_bp`'
+ printf ' ON `r_bp`.`pkgname`=`not_r_bp`.`pkgname`'
+ printf ' AND `r_bp`.`id`!=`not_r_bp`.`id`'
+ mysql_join_binary_packages_binary_packages_in_repositories 'r_bp' 'r_bpir'
+ printf ' JOIN `replaced_bpir_copy`'
+ printf ' ON `r_bpir`.`id`=`replaced_bpir_copy`.`id`'
+ mysql_join_binary_packages_in_repositories_repositories 'r_bpir' 'r_r'
+ printf ' AND `not_r_r`.`architecture`=`r_r`.`architecture`'
+ printf ' JOIN `repository_stability_relations` AS `rsr`'
+ printf ' ON `rsr`.`less_stable`=`r_r`.`stability`'
+ printf ' AND `rsr`.`more_stable`=`not_r_r`.`stability`;\n'
+
# now we delete all unreplaceable and unmoveable packages from the respective
# list until no further changes are required
printf 'REPEAT\n'
diff --git a/misc/database-layout.dump b/misc/database-layout.dump
index c1d8dd1..aa43e3c 100644
--- a/misc/database-layout.dump
+++ b/misc/database-layout.dump
@@ -97,28 +97,49 @@ INSERT IGNORE INTO `replaced_bpir` (`id`,`replaced_by`)
ON `m_bpir`.`id`=`moveable_bpir`.`id`
JOIN `binary_packages` AS `m_bp`
ON `m_bpir`.`package`=`m_bp`.`id`
- JOIN `repositories` AS `m_from_r`
- ON `m_bpir`.`repository`=`m_from_r`.`id`
JOIN `repositories` AS `m_to_r`
ON `moveable_bpir`.`to_repository`=`m_to_r`.`id`
- JOIN `repository_stability_relations` AS `rsr_a`
- ON `rsr_a`.`less_stable`=`m_to_r`.`stability`
+ JOIN `repository_stability_relations` AS `rsr`
+ ON `rsr`.`less_stable`=`m_to_r`.`stability`
JOIN `repositories` AS `r_r`
- ON `rsr_a`.`more_stable`=`r_r`.`stability` AND `r_r`.`architecture`=`m_to_r`.`architecture`
+ ON `rsr`.`more_stable`=`r_r`.`stability` AND `r_r`.`architecture`=`m_to_r`.`architecture`
JOIN `binary_packages_in_repositories` AS `r_bpir`
ON `r_r`.`id`=`r_bpir`.`repository`
JOIN `binary_packages` AS `r_bp`
- ON `r_bpir`.`package`=`r_bp`.`id` AND `r_bp`.`pkgname`=`m_bp`.`pkgname`
- WHERE NOT EXISTS (
-SELECT 1
- FROM `binary_packages_in_repositories` AS `sup_bpir`
- JOIN `binary_packages` AS `sup_bp`
- ON `sup_bpir`.`package`=`sup_bp`.`id`
- JOIN `repositories` AS `sup_r`
- ON `sup_bpir`.`repository`=`sup_r`.`id`
- JOIN `repository_stability_relations` AS `rsr_b`
- ON `rsr_b`.`less_stable`=`sup_r`.`stability`
- WHERE `sup_bp`.`pkgname`=`m_bp`.`pkgname` AND `sup_r`.`architecture`=`m_to_r`.`architecture` AND `rsr_b`.`more_stable`=`r_r`.`stability`);
+ ON `r_bpir`.`package`=`r_bp`.`id` AND `r_bp`.`pkgname`=`m_bp`.`pkgname`;
+DELETE
+ FROM `replaced_bpir_copy`;
+INSERT IGNORE INTO `replaced_bpir_copy`
+ SELECT `replaced_bpir`.*
+ FROM `replaced_bpir`;
+DELETE
+ FROM `replaced_bpir_copy2`;
+INSERT IGNORE INTO `replaced_bpir_copy2`
+ SELECT `replaced_bpir`.*
+ FROM `replaced_bpir`;
+DELETE
+ FROM `moveable_bpir_copy`;
+INSERT IGNORE INTO `moveable_bpir_copy`
+ SELECT `moveable_bpir`.*
+ FROM `moveable_bpir`;
+DELETE `replaced_bpir`
+ FROM `replaced_bpir`
+ JOIN `binary_packages_in_repositories` AS `not_r_bpir`
+ ON `not_r_bpir`.`id`=`replaced_bpir`.`id`
+ JOIN `binary_packages` AS `not_r_bp`
+ ON `not_r_bpir`.`package`=`not_r_bp`.`id`
+ JOIN `repositories` AS `not_r_r`
+ ON `not_r_bpir`.`repository`=`not_r_r`.`id`
+ JOIN `binary_packages` AS `r_bp`
+ ON `r_bp`.`pkgname`=`not_r_bp`.`pkgname` AND `r_bp`.`id`!=`not_r_bp`.`id`
+ JOIN `binary_packages_in_repositories` AS `r_bpir`
+ ON `r_bp`.`id`=`r_bpir`.`package`
+ JOIN `replaced_bpir_copy`
+ ON `r_bpir`.`id`=`replaced_bpir_copy`.`id`
+ JOIN `repositories` AS `r_r`
+ ON `r_bpir`.`repository`=`r_r`.`id` AND `not_r_r`.`architecture`=`r_r`.`architecture`
+ JOIN `repository_stability_relations` AS `rsr`
+ ON `rsr`.`less_stable`=`r_r`.`stability` AND `rsr`.`more_stable`=`not_r_r`.`stability`;
REPEAT
SET row_count_saved = 0;
DELETE