Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/delete-packages54
1 files changed, 52 insertions, 2 deletions
diff --git a/bin/delete-packages b/bin/delete-packages
index 8c515c2..cf151fa 100755
--- a/bin/delete-packages
+++ b/bin/delete-packages
@@ -21,8 +21,12 @@ usage() {
>&2 echo ' delete obsolete binary packages.'
>&2 echo ''
>&2 echo 'possible options:'
+ >&2 echo ' -b|--build-support $package-list:'
+ >&2 echo ' Only delete the matching packages from [build-support].'
+ >&2 echo ' conflicts -f; only accepted once'
>&2 echo ' -f|--force $id:'
>&2 echo ' Only delete the selected packages - but delete in any case.'
+ >&2 echo ' conflicts -b'
>&2 echo ' -h|--help:'
>&2 echo ' Show this help and exit.'
>&2 echo ' -i|--ignore-insanity:'
@@ -35,7 +39,8 @@ usage() {
}
eval set -- "$(
- getopt -o f:hinw \
+ getopt -o b:f:hinw \
+ --long build-support: \
--long force: \
--long help \
--long ignore-insanity \
@@ -46,6 +51,7 @@ eval set -- "$(
)"
block_flag='-n'
+build_support=''
force_ids=''
ignore_insanity=false
no_action=false
@@ -53,6 +59,14 @@ no_action=false
while true
do
case "$1" in
+ -b|--build-support)
+ if [ -n "${build_support}" ]; then
+ >&2 printf 'Option given multiple times: %s\n' "$1"
+ usage
+ fi
+ shift
+ build_support="$1"
+ ;;
-f|--force)
shift
force_ids="${force_ids} $1"
@@ -81,6 +95,12 @@ do
shift
done
+if [ -n "${build_support}" ] && \
+ [ -n "${force_ids}" ]; then
+ >&2 echo 'Conflicting flags: -b & -f.'
+ usage
+fi
+
if [ -s "${work_dir}/build-master-sanity" ]; then
>&2 echo 'Build master is not sane.'
if ! ${ignore_insanity}; then
@@ -131,6 +151,23 @@ export TMPDIR="${tmp_dir}"
s/$/")),/
$ s/,$/;/
'
+ elif [ -n "${build_support}" ]; then
+ printf ' SELECT DISTINCT `binary_packages_in_repositories`.`id`'
+ printf ' FROM `binary_packages_in_repositories`'
+ mysql_join_binary_packages_in_repositories_binary_packages
+ mysql_join_binary_packages_in_repositories_repositories
+ mysql_join_binary_packages_architectures
+ mysql_join_repositories_architectures '' 'r_a'
+ printf ' WHERE `repositories`.`name`="build-support"'
+ printf ' AND CONCAT(`r_a`.`name`," ",'
+ mysql_package_name_query
+ printf ') IN ('
+ base64_encode_each < "${build_support}" | \
+ sed '
+ s/^/from_base64("/
+ s/$/"),/
+ $ s/,$/);/
+ '
else
printf ' SELECT DISTINCT `binary_packages_in_repositories`.`id`'
printf ' FROM `binary_packages_in_repositories`'
@@ -314,7 +351,20 @@ fi
printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `bpir_to_delete`;\n' \
"${tmp_dir}/package-in-repository-ids"
- printf 'UPDATE `binary_packages_in_repositories` '
+ printf 'DELETE `binary_packages_in_repositories`'
+ printf ' FROM `binary_packages_in_repositories`'
+ printf ' JOIN `bpir_to_delete` ON `bpir_to_delete`.`id`=`binary_packages_in_repositories`.`id`'
+ mysql_join_binary_packages_in_repositories_repositories
+ printf ' WHERE `repositories`.`name`="build-support";\n'
+
+ printf 'DELETE `binary_packages`'
+ printf ' 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'
+
+ printf 'UPDATE `binary_packages_in_repositories`'
printf ' JOIN `bpir_to_delete` ON `bpir_to_delete`.`id`=`binary_packages_in_repositories`.`id`'
# shellcheck disable=SC2154
printf ' SET `binary_packages_in_repositories`.`repository`=%s;\n' \