From 2a4617fd25cf56e2d81d90c0c2aff81bfd9e9823 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 12 Mar 2018 13:50:24 +0100 Subject: bin/delete-packages: repair deletion of packages on the mirror --- bin/delete-packages | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/bin/delete-packages b/bin/delete-packages index 258e441..8a4ea4a 100755 --- a/bin/delete-packages +++ b/bin/delete-packages @@ -129,6 +129,14 @@ trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT mysql_join_binary_packages_repositories printf ';\n' + printf ' SELECT "package-file",`repositories`.`name`,' + mysql_package_name_query + printf ' FROM `to_deletes`' + printf ' JOIN `binary_packages` ON `to_deletes`.`id`=`binary_packages`.`id`' + mysql_join_binary_packages_repositories + mysql_join_binary_packages_architectures + printf ';\n' + printf ' SELECT "package-id",`to_deletes`.`id`' printf ' FROM `to_deletes`' printf ';\n' @@ -146,6 +154,15 @@ trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT w '"${tmp_dir}"'/packages d } + /^package-file /{ + s/^\S\+ // + s, ,/, + s/$/.pkg.tar.xz/ + w '"${tmp_dir}"'/package-files + s/$/.sig/ + w '"${tmp_dir}"'/package-files + d + } /^package-id /{ s/^\S\+ // w '"${tmp_dir}"'/package-ids @@ -196,22 +213,21 @@ done < \ printf 'CREATE TEMPORARY TABLE `to_deletes` (`id` BIGINT, UNIQUE KEY (`id`));\n' printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `to_deletes`;\n' \ "${tmp_dir}/package-ids" - printf 'DELETE `binary_packages` FROM `binary_packages` ' + + printf 'UPDATE `binary_packages` ' printf ' JOIN `to_deletes` ON `to_deletes`.`id`=`binary_packages`.`id`' mysql_join_binary_packages_repositories mysql_join_binary_packages_architectures - printf ';\n' + printf ' SET `repository`=(' + printf 'SELECT `repositories`.`id`' + printf ' FROM `repositories`' + printf ' WHERE `repositories`.`name`="deletion-list"' + printf ');\n' } | \ mysql_run_query -tr ' ' '/' < \ - "${tmp_dir}/packages" | \ - sed ' - p - s/$/.sig/ - ' | \ - sed ' - s,^,rm "i686/, - s,$,", - ' | \ +sed ' + s,^,rm "i686/, + s,$,", +' "${tmp_dir}/package-files" | \ ${master_mirror_sftp_command} -- cgit v1.2.3-70-g09d2