From 766546736f961d1bf12fc74a65584f1c75ebb1f6 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 19 Feb 2021 09:54:04 +0100 Subject: bin/db-update: -e|--everything new --- bin/db-update | 59 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/db-update b/bin/db-update index 4424c26..9fbc544 100755 --- a/bin/db-update +++ b/bin/db-update @@ -27,6 +27,9 @@ usage() { >&2 echo ' move possible packages from staging to testing.' >&2 echo '' >&2 echo 'possible options:' + >&2 echo ' -e|--everything $arch/$repo:' + >&2 echo ' Force movement of every package in the given repo and' + >&2 echo ' move nothing else.' >&2 echo ' -f|--force $arch/$repo/$pkgname:' >&2 echo ' Force movement of given package and move nothing else.' >&2 echo ' -h|--help:' @@ -56,7 +59,8 @@ usage() { } eval set -- "$( - getopt -o f:hino:pw \ + getopt -o e:f:hino:pw \ + --long everything: \ --long force: \ --long help \ --long ignore-insanity \ @@ -73,6 +77,7 @@ ignore_insanity=false no_action_flag='' progressive=false force_pkgs='' +force_every_pkgs='' only='' while true @@ -86,6 +91,14 @@ do printf '\n%s' "${force_pkgs}" ) ;; + -e|--everything) + shift + force_every_pkgs=$( + printf '%s' "$1" | \ + base64 -w0 + printf '\n%s' "${force_every_pkgs}" + ) + ;; -h|--help) usage 0 ;; @@ -135,6 +148,18 @@ if ${progressive} && \ usage fi +if ${progressive} && \ + [ -n "${force_every_pkgs}" ]; then + >&2 echo 'db-update: conflicting arguments' + usage +fi + +if [ -n "${force_pkgs}" ] && \ + [ -n "${force_every_pkgs}" ]; then + >&2 echo 'db-update: conflicting arguments' + usage +fi + if [ -s "${work_dir}/build-master-sanity" ]; then >&2 echo 'Build master is not sane.' if ! ${ignore_insanity}; then @@ -295,7 +320,8 @@ mysql_query_update_replaced_bpir() { # are for the same architecture if we joined them via # repository_moves, because only repositories with the same # architectures should be listed there. - if [ -n "${force_pkgs}" ]; then + if [ -n "${force_pkgs}" ] || \ + [ -n "${force_every_pkgs}" ]; then printf 'DROP TEMPORARY TABLE IF EXISTS `%s_bpir`;\n' \ 'moveable' 'replaced' printf 'CREATE TEMPORARY TABLE `replaced_bpir` (`id` BIGINT, `replaced_by` BIGINT, UNIQUE KEY (`id`));\n' @@ -312,15 +338,26 @@ mysql_query_update_replaced_bpir() { printf ' ON `binary_packages`.`build_assignment`=`f_bp`.`build_assignment`' mysql_join_binary_packages_binary_packages_in_repositories 'f_bp' 'f_bpir' printf ' AND `f_bpir`.`repository`=`repositories`.`id`' - printf ' WHERE CONCAT(' - printf '`architectures`.`name`,"/",' - printf '`repositories`.`name`,"/",' - printf '`f_bp`.`pkgname`' - printf ') IN (' - # shellcheck disable=SC2086 - printf 'from_base64("%s"),' \ - ${force_pkgs} | \ - sed 's/,$/);\n/' + if [ -n "${force_pkgs}" ]; then + printf ' WHERE CONCAT(' + printf '`architectures`.`name`,"/",' + printf '`repositories`.`name`,"/",' + printf '`f_bp`.`pkgname`' + printf ') IN (' + # shellcheck disable=SC2086 + printf 'from_base64("%s"),' \ + ${force_pkgs} | \ + sed 's/,$/);\n/' + else + printf ' WHERE CONCAT(' + printf '`architectures`.`name`,"/",' + printf '`repositories`.`name`' + printf ') IN (' + # shellcheck disable=SC2086 + printf 'from_base64("%s"),' \ + ${force_every_pkgs} | \ + sed 's/,$/);\n/' + fi printf 'DELETE `moveable_bpir`' printf ' FROM `moveable_bpir`' printf ' JOIN `binary_packages_in_repositories`' -- cgit v1.2.3-70-g09d2