From 9bc50bd0b7bbda05b2c9da3130d722e2210fb26d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 8 May 2018 11:30:22 +0200 Subject: lib/common-functions: rewrite remove_old_package_versions to use db and take package id as parameter --- bin/copy-to-build-support | 14 +++++++------- bin/return-assignment | 30 +++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/copy-to-build-support b/bin/copy-to-build-support index bd4412a..2de852a 100755 --- a/bin/copy-to-build-support +++ b/bin/copy-to-build-support @@ -109,8 +109,8 @@ sed -n ' repository="${id#* }" id="${id%% *}" - printf '%s\n' "${package}" >> \ - "${tmp_dir}/packages" + printf '%s\n' "${id}" >> \ + "${tmp_dir}/package-ids" for suffix in '' '.sig'; do printf 'ln "i686/%s/%s%s" "i686/build-support/%s%s"\n' \ "${repository}" \ @@ -180,14 +180,14 @@ if [ -s "${tmp_dir}/mysql-command" ]; then "${tmp_dir}/mysql-command" fi -if [ -s "${tmp_dir}/packages" ]; then - while read -r package; do - remove_old_package_versions 'i686' 'build-support' "${package}" +if [ -s "${tmp_dir}/package-ids" ]; then + while read -r package_id; do + remove_old_package_versions "${package_id}" done < \ - "${tmp_dir}/packages" + "${tmp_dir}/package-ids" fi if [ -w "$1" ]; then - cat "${tmp_dir}/packages" > \ + cat "${tmp_dir}/package-ids" > \ "$1" fi diff --git a/bin/return-assignment b/bin/return-assignment index 1b5e991..28b01e7 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -576,6 +576,30 @@ trigger_mirror_refreshs } | \ mysql_run_query -for package in ${packages}; do - remove_old_package_versions 'i686' "${destination}" "${package}" -done +# shellcheck disable=SC2016 +{ + printf 'SELECT' + printf ' `binary_packages`.`id`' + printf ' FROM `binary_packages`' + mysql_join_binary_packages_architectures + mysql_join_binary_packages_repositories + printf ' WHERE ' + mysql_package_name_query + printf ' IN (' + # shellcheck disable=SC2086 + printf '%s\n' ${packages} | \ + base64_encode_each | \ + sed ' + s/^/from_base64("/ + s/$/"),/ + ' + printf '"") AND `repositories`.`name`=from_base64("%s");\n' \ + "$( + printf '%s' "${destination}" | \ + base64 -w0 + )" +} | \ + mysql_run_query | \ + while read -r package_id; do + remove_old_package_versions "${package_id}" + done -- cgit v1.2.3-54-g00ecf