summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-06-12 14:30:02 +0200
committerErich Eckner <git@eckner.net>2018-06-12 14:30:02 +0200
commit7076434dfbf8e1c11db92bf44695cbc2b5c2564b (patch)
treecec2045fe1b14cb1044e89284459abc5fcc46bf9
parent083fccdcd313c6fab61ad204c8f3bbc0183bc20c (diff)
downloadbuilder-7076434dfbf8e1c11db92bf44695cbc2b5c2564b.tar.xz
bin/db-update: do not remove db entries with "-n"
-rwxr-xr-xbin/db-update41
1 files changed, 22 insertions, 19 deletions
diff --git a/bin/db-update b/bin/db-update
index 1b72805..7d5af50 100755
--- a/bin/db-update
+++ b/bin/db-update
@@ -370,25 +370,28 @@ for source_stability in \
s,^\(\S\+\) \(\S\+\) \(\S\+\)$,\2/\3/\1,
' "${tmp_dir}/rm"
- # shellcheck disable=SC2016
- {
- printf 'CREATE TEMPORARY TABLE `replaced_bpir` (`id` BIGINT, UNIQUE KEY (`id`));\n'
- printf 'CREATE TEMPORARY TABLE `moved_bpir` (`id` BIGINT, `new_repository` MEDIUMINT, UNIQUE KEY (`id`));\n'
- printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `%s` COLUMNS TERMINATED BY " ";\n' \
- "${tmp_dir}/mv.id" 'moved_bpir' \
- "${tmp_dir}/rm.id" 'replaced_bpir'
- printf 'DELETE `binary_packages_in_repositories` FROM `binary_packages_in_repositories`'
- printf ' JOIN `replaced_bpir` ON `binary_packages_in_repositories`.`id`=`replaced_bpir`.`id`;\n'
- mysql_query_and_delete_unneeded_binary_packages
- printf 'UPDATE `binary_packages_in_repositories`'
- printf ' JOIN `moved_bpir` ON `binary_packages_in_repositories`.`id`=`moved_bpir`.`id`'
- printf ' SET `binary_packages_in_repositories`.`repository`=`moved_bpir`.`new_repository`,'
- printf '`binary_packages_in_repositories`.`last_moved`=NOW()'
- printf ' WHERE `binary_packages_in_repositories`.`repository`!=`moved_bpir`.`new_repository`;\n'
- } | \
- mysql_run_query | \
- sort -u >> \
- "${tmp_dir}/rm"
+ # somewhat inaccurate
+ if ! ${no_action}; then
+ # shellcheck disable=SC2016
+ {
+ printf 'CREATE TEMPORARY TABLE `replaced_bpir` (`id` BIGINT, UNIQUE KEY (`id`));\n'
+ printf 'CREATE TEMPORARY TABLE `moved_bpir` (`id` BIGINT, `new_repository` MEDIUMINT, UNIQUE KEY (`id`));\n'
+ printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `%s` COLUMNS TERMINATED BY " ";\n' \
+ "${tmp_dir}/mv.id" 'moved_bpir' \
+ "${tmp_dir}/rm.id" 'replaced_bpir'
+ printf 'DELETE `binary_packages_in_repositories` FROM `binary_packages_in_repositories`'
+ printf ' JOIN `replaced_bpir` ON `binary_packages_in_repositories`.`id`=`replaced_bpir`.`id`;\n'
+ mysql_query_and_delete_unneeded_binary_packages
+ printf 'UPDATE `binary_packages_in_repositories`'
+ printf ' JOIN `moved_bpir` ON `binary_packages_in_repositories`.`id`=`moved_bpir`.`id`'
+ printf ' SET `binary_packages_in_repositories`.`repository`=`moved_bpir`.`new_repository`,'
+ printf '`binary_packages_in_repositories`.`last_moved`=NOW()'
+ printf ' WHERE `binary_packages_in_repositories`.`repository`!=`moved_bpir`.`new_repository`;\n'
+ } | \
+ mysql_run_query | \
+ sort -u >> \
+ "${tmp_dir}/rm"
+ fi
# move the packages remotely via sftp
{