From 85e1b4ef9f0da06b6bcb2a3c8e550fdd1bb8b794 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 13 Feb 2018 10:38:17 +0100 Subject: bin/get-package-updates: test_exclusion now cooperates with the database --- bin/get-package-updates | 57 ++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'bin/get-package-updates') diff --git a/bin/get-package-updates b/bin/get-package-updates index 533f14f..465f896 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -9,8 +9,6 @@ # TODO: Find out, why sometimes package updates are missed. -# TODO: test_exclusion does not yet cooperate with the database - # TODO: read information from database # TODO: correctly handle if pkgbase of a split package is renamed, e.g.: @@ -104,31 +102,36 @@ delete_package() { echo "$1" >> \ "${work_dir}/deletion-list.new" sed -i "/^$(str_to_regex "${1}") /d" "${work_dir}/build-list.new" - # shellcheck disable=SC2016 - { - # packages from the build-list/to-be-decided go straight to the deletion-list - printf 'UPDATE `binary_packages`' - printf ' JOIN `%s` ON `%s`.`id`=`binary_packages`.`%s`' \ - 'repositories' 'repositories' 'repository' \ - 'build_assignments' 'build_assignments' 'build_assignment' - printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ - 'package_sources' 'package_sources' 'build_assignments' 'package_source' - printf ' SET `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`="deletion-list")' - printf ' WHERE `repositories`.`name` in ("build-list","to-be-decided")' - printf ' AND `package_sources`.`pkgbase`=from_base64("%s");\n' \ - "$(printf '%s' "$1" | base64 -w0)" - # other packages are marked as `is_to_be_deleted` - printf 'UPDATE `binary_packages`' - printf ' JOIN `%s` ON `%s`.`id`=`binary_packages`.`%s`' \ - 'repositories' 'repositories' 'repository' \ - 'build_assignments' 'build_assignments' 'build_assignment' - printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ - 'package_sources' 'package_sources' 'build_assignments' 'package_source' - printf ' SET `binary_packages`.`is_to_be_deleted`=1' - printf ' WHERE `package_sources`.`pkgbase`=from_base64("%s");' \ - "$(printf '%s' "$1" | base64 -w0)" - } | \ - ${mysql_command} + # TODO: Once we want to rely on the database for test_exclusion, we + # need to run the command below unconditionally, but with some + # changes, so we can easily revert. + if [ -z "${test_exclusion}" ]; then + # shellcheck disable=SC2016 + { + # packages from the build-list/to-be-decided go straight to the deletion-list + printf 'UPDATE `binary_packages`' + printf ' JOIN `%s` ON `%s`.`id`=`binary_packages`.`%s`' \ + 'repositories' 'repositories' 'repository' \ + 'build_assignments' 'build_assignments' 'build_assignment' + printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ + 'package_sources' 'package_sources' 'build_assignments' 'package_source' + printf ' SET `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`="deletion-list")' + printf ' WHERE `repositories`.`name` in ("build-list","to-be-decided")' + printf ' AND `package_sources`.`pkgbase`=from_base64("%s");\n' \ + "$(printf '%s' "$1" | base64 -w0)" + # other packages are marked as `is_to_be_deleted` + printf 'UPDATE `binary_packages`' + printf ' JOIN `%s` ON `%s`.`id`=`binary_packages`.`%s`' \ + 'repositories' 'repositories' 'repository' \ + 'build_assignments' 'build_assignments' 'build_assignment' + printf ' JOIN `%s` ON `%s`.`id`=`%s`.`%s`' \ + 'package_sources' 'package_sources' 'build_assignments' 'package_source' + printf ' SET `binary_packages`.`is_to_be_deleted`=1' + printf ' WHERE `package_sources`.`pkgbase`=from_base64("%s");' \ + "$(printf '%s' "$1" | base64 -w0)" + } | \ + ${mysql_command} + fi } # create tmp_dir and trap -- cgit v1.2.3-70-g09d2