diff options
-rwxr-xr-x | lib/common-functions | 14 | ||||
-rwxr-xr-x | lib/mysql-functions | 20 |
2 files changed, 21 insertions, 13 deletions
diff --git a/lib/common-functions b/lib/common-functions index cb39509..921a7b3 100755 --- a/lib/common-functions +++ b/lib/common-functions @@ -218,19 +218,7 @@ remove_old_package_versions() { "${tmp_dir}/db-removes" printf 'DELETE `binary_packages_in_repositories` FROM `binary_packages_in_repositories`' printf ' JOIN `del` ON `binary_packages_in_repositories`.`id`=`del`.`id`;\n' - printf 'SELECT CONCAT("pool/",' - mysql_package_name_query - printf ') FROM `binary_packages`' - mysql_join_binary_packages_architectures - printf ' WHERE NOT EXISTS (' - printf 'SELECT 1 FROM `binary_packages_in_repositories`' - printf ' WHERE `binary_packages_in_repositories`.`package`=`binary_packages`.`id`' - printf ');\n' - printf 'DELETE `binary_packages` FROM `binary_packages`' - printf ' WHERE NOT EXISTS (' - printf 'SELECT 1 FROM `binary_packages_in_repositories`' - printf ' WHERE `binary_packages_in_repositories`.`package`=`binary_packages`.`id`' - printf ');\n' + mysql_query_and_delete_unneeded_binary_packages } | \ mysql_run_query | \ sort -u >> \ diff --git a/lib/mysql-functions b/lib/mysql-functions index 2670c9b..6ff541c 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -1040,6 +1040,7 @@ for link in \ 'gpg_keys:owner:persons' \ \ 'install_target_providers:package:binary_packages' \ + 'install_target_providers:package package:binary_packages_in_repositories' \ 'install_target_providers:install_target:install_targets' \ 'install_target_providers:install_target depending_on:dependencies' \ \ @@ -1104,3 +1105,22 @@ mysql_retrieve_static_information() { mysql_run_query )" } + +# mysql_query_and_delete_unneeded_binary_packages +# print a query which lists and deletes binary_packages which are not +# linked from binary_packages_in_repositories +mysql_query_and_delete_unneeded_binary_packages() { + printf 'SELECT CONCAT("pool/",' + mysql_package_name_query + printf ') FROM `binary_packages`' + mysql_join_binary_packages_architectures + printf ' WHERE NOT EXISTS (' + printf 'SELECT 1 FROM `binary_packages_in_repositories`' + printf ' WHERE `binary_packages_in_repositories`.`package`=`binary_packages`.`id`' + printf ');\n' + printf 'DELETE `binary_packages` FROM `binary_packages`' + printf ' WHERE NOT EXISTS (' + printf 'SELECT 1 FROM `binary_packages_in_repositories`' + printf ' WHERE `binary_packages_in_repositories`.`package`=`binary_packages`.`id`' + printf ');\n' +} |