index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
-rwxr-xr-x | bin/delete-packages | 84 |
diff --git a/bin/delete-packages b/bin/delete-packages index 75fdc8e..a0e6596 100755 --- a/bin/delete-packages +++ b/bin/delete-packages @@ -25,6 +25,7 @@ usage() { >&2 echo ' delete obsolete binary packages.' >&2 echo '' >&2 echo 'possible options:' + >&2 echo ' -f|--force $id: Only delete the selected packages - but delete in any case.' >&2 echo ' -h|--help: Show this help and exit.' >&2 echo ' -n|--no-action: Only print what would be deleted.' >&2 echo ' -w|--wait: If necessary, wait for lock blocking.' @@ -32,7 +33,8 @@ usage() { } eval set -- "$( - getopt -o hnw \ + getopt -o f:hnw \ + --long force: \ --long help \ --long no-action \ --long wait \ @@ -41,11 +43,16 @@ eval set -- "$( )" block_flag='-n' +force_ids='' no_action=false while true do case "$1" in + -f|--force) + shift + force_ids="${force_ids} $1" + ;; -h|--help) usage 0 ;; @@ -107,41 +114,48 @@ export TMPDIR="${tmp_dir}" { printf 'CREATE TEMPORARY TABLE `to_deletes` (`id` BIGINT, UNIQUE KEY (`id`));\n' printf 'INSERT IGNORE INTO `to_deletes`' - printf ' SELECT DISTINCT `binary_packages`.`id`' - printf ' FROM `binary_packages`' - mysql_join_binary_packages_binary_packages_in_repositories - mysql_join_binary_packages_in_repositories_repositories - printf ' LEFT' # should not be necessary, but is formally more correct - mysql_join_binary_packages_install_target_providers - printf ' WHERE `binary_packages_in_repositories`.`is_to_be_deleted`' - printf ' AND `repositories`.`is_on_master_mirror`' - printf ' AND NOT EXISTS (' - # no packages depending on that one exist - printf 'SELECT 1 FROM `dependencies`' - mysql_join_dependencies_dependency_types - printf ' AND `dependency_types`.`relevant_for_binary_packages`' - mysql_join_dependencies_binary_packages '' 'd_bp' - mysql_join_binary_packages_binary_packages_in_repositories 'd_bp' 'd_bpir' - # deliberately break dependencies of deletion-list packages - printf ' AND NOT `d_bpir`.`is_to_be_deleted`' - mysql_join_binary_packages_in_repositories_repositories 'd_bpir' 'd_r' - mysql_join_repositories_repository_stabilities 'd_r' 'd_rs' - # this is deliberately less restrict than `d_r`.`is_on_master_mirror` - printf ' AND `d_rs`.`name` NOT IN ("forbidden","virtual")' - printf ' WHERE `install_target_providers`.`install_target`=`dependencies`.`depending_on`' + if [ -n "${force_ids}" ]; then + printf ' VALUES ' + # shellcheck disable=SC2086 + printf '(%s),' ${force_ids} | \ + sed 's/,$/;\n/' + else + printf ' SELECT DISTINCT `binary_packages`.`id`' + printf ' FROM `binary_packages`' + mysql_join_binary_packages_binary_packages_in_repositories + mysql_join_binary_packages_in_repositories_repositories + printf ' LEFT' # should not be necessary, but is formally more correct + mysql_join_binary_packages_install_target_providers + printf ' WHERE `binary_packages_in_repositories`.`is_to_be_deleted`' + printf ' AND `repositories`.`is_on_master_mirror`' printf ' AND NOT EXISTS (' - printf 'SELECT 1 FROM `binary_packages` AS `s_bp`' - mysql_join_binary_packages_binary_packages_in_repositories 's_bp' 's_bpir' - printf ' AND NOT `s_bpir`.`is_to_be_deleted`' - mysql_join_binary_packages_install_target_providers 's_bp' 's_itp' - mysql_join_binary_packages_in_repositories_repositories 's_bpir' 's_r' - printf ' AND `s_r`.`is_on_master_mirror`' - printf ' JOIN `repository_stability_relations`' - printf ' ON `repository_stability_relations`.`more_stable`=`s_r`.`stability`' - printf ' WHERE `s_itp`.`install_target`=`install_target_providers`.`install_target`' - printf ' AND `repository_stability_relations`.`less_stable`=`d_r`.`stability`' - printf ')' - printf ');\n' + # no packages depending on that one exist + printf 'SELECT 1 FROM `dependencies`' + mysql_join_dependencies_dependency_types + printf ' AND `dependency_types`.`relevant_for_binary_packages`' + mysql_join_dependencies_binary_packages '' 'd_bp' + mysql_join_binary_packages_binary_packages_in_repositories 'd_bp' 'd_bpir' + # deliberately break dependencies of deletion-list packages + printf ' AND NOT `d_bpir`.`is_to_be_deleted`' + mysql_join_binary_packages_in_repositories_repositories 'd_bpir' 'd_r' + mysql_join_repositories_repository_stabilities 'd_r' 'd_rs' + # this is deliberately less restrict than `d_r`.`is_on_master_mirror` + printf ' AND `d_rs`.`name` NOT IN ("forbidden","virtual")' + printf ' WHERE `install_target_providers`.`install_target`=`dependencies`.`depending_on`' + printf ' AND NOT EXISTS (' + printf 'SELECT 1 FROM `binary_packages` AS `s_bp`' + mysql_join_binary_packages_binary_packages_in_repositories 's_bp' 's_bpir' + printf ' AND NOT `s_bpir`.`is_to_be_deleted`' + mysql_join_binary_packages_install_target_providers 's_bp' 's_itp' + mysql_join_binary_packages_in_repositories_repositories 's_bpir' 's_r' + printf ' AND `s_r`.`is_on_master_mirror`' + printf ' JOIN `repository_stability_relations`' + printf ' ON `repository_stability_relations`.`more_stable`=`s_r`.`stability`' + printf ' WHERE `s_itp`.`install_target`=`install_target_providers`.`install_target`' + printf ' AND `repository_stability_relations`.`less_stable`=`d_r`.`stability`' + printf ')' + printf ');\n' + fi printf 'SELECT DISTINCT "repo",`repositories`.`name`' printf ' FROM `to_deletes`' |