summaryrefslogtreecommitdiff
path: root/bin/bootstrap-mysql
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bootstrap-mysql')
-rwxr-xr-xbin/bootstrap-mysql56
1 files changed, 39 insertions, 17 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'