diff options
Diffstat (limited to 'bin/db-update')
-rwxr-xr-x | bin/db-update | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/bin/db-update b/bin/db-update index 59badd4..88c567d 100755 --- a/bin/db-update +++ b/bin/db-update @@ -52,13 +52,16 @@ usage() { >&2 echo ' Move forward any package which replaces no package whose' >&2 echo ' dependencies are all available somewhere.' >&2 echo ' Note, that this _may_ move _less_ packages.' + >&2 echo ' -s|--stuck:' + >&2 echo ' Force movement of every package, that is stuck for too' + >&2 echo ' long, and move nothing else.' >&2 echo ' -w|--wait:' >&2 echo ' If necessary, wait for lock blocking.' [ -z "$1" ] && exit 1 || exit "$1" } eval set -- "$( - getopt -o ef:hino:pw \ + getopt -o ef:hino:psw \ --long everything \ --long force: \ --long help \ @@ -66,6 +69,7 @@ eval set -- "$( --long no-action \ --long only: \ --long progressive \ + --long stuck \ --long wait \ -n "$(basename "$0")" -- "$@" || \ echo usage @@ -77,6 +81,7 @@ no_action_flag='' progressive=false force_pkgs='' force_every_pkg=false +force_stuck_pkgs=false only='' while true @@ -116,6 +121,9 @@ do >&2 echo 'Do not use this option, it is currently broken.' exit 42 ;; + -s|--stuck) + force_stuck_pkgs=true + ;; -w|--wait) block_flag='' ;; @@ -143,6 +151,8 @@ ${progressive} \ && number_of_force_flags=$((number_of_force_flags+1)) ${force_every_pkg} \ && number_of_force_flags=$((number_of_force_flags+1)) +${force_stuck_pkgs} \ +&& number_of_force_flags=$((number_of_force_flags+1)) if [ ${number_of_force_flags} -gt 1 ]; then >&2 echo 'db-update: conflicting arguments' @@ -171,7 +181,7 @@ if [ -n "${only}" ]; then printf 's@^!%s\\(/.\\+\\)\\?$@' \ "${arch}" for arch2 in i486 i686 pentium4; do - if [ "${arch}" == "${arch2}" ]; then + if [ "${arch}" = "${arch2}" ]; then continue fi printf '%s\\1\\n' \ @@ -310,7 +320,8 @@ mysql_query_update_replaced_bpir() { # repository_moves, because only repositories with the same # architectures should be listed there. if [ -n "${force_pkgs}" ] || \ - ${force_every_pkg}; then + ${force_every_pkg} || \ + ${force_stuck_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' @@ -321,6 +332,10 @@ mysql_query_update_replaced_bpir() { printf ' FROM `binary_packages_in_repositories`' mysql_join_binary_packages_in_repositories_repositories printf ' AND `repositories`.`is_on_master_mirror`' + printf ' AND `repositories`.`stability`=%s' \ + "${source_stability_id}" + printf ' AND `repositories`.`architecture`=%s' \ + "${arch_id}" mysql_join_repositories_architectures mysql_join_binary_packages_in_repositories_binary_packages printf ' JOIN `binary_packages` AS `f_bp`' @@ -337,19 +352,26 @@ mysql_query_update_replaced_bpir() { printf 'from_base64("%s"),' \ ${force_pkgs} | \ sed 's/,$/);\n/' + elif ${force_stuck_pkgs}; then + printf ' WHERE `binary_packages_in_repositories`.`last_moved` < DATE_SUB(NOW(),INTERVAL ' + # shellcheck disable=SC2154 + case "${source_stability_id}" in + "${repository_stability_ids__testing}") + printf '%s.5' "$((max_testing_duration+2))" + ;; + "${repository_stability_ids__staging}") + printf '2.5' + ;; + *) + >&2 printf 'unknown source stability id: %s\n' "${source_stability_id}" + printf '1000000' + ;; + esac + printf ' day);\n' else # ${force_every_pkg} printf ';\n' fi - printf 'DELETE `moveable_bpir`' - printf ' FROM `moveable_bpir`' - printf ' JOIN `binary_packages_in_repositories`' - printf ' ON `binary_packages_in_repositories`.`id`=`moveable_bpir`.`id`' - mysql_join_binary_packages_in_repositories_binary_packages - mysql_join_binary_packages_in_repositories_repositories - printf ' WHERE `repositories`.`stability`!=%s' \ - "${source_stability_id}" - printf ' OR `repositories`.`architecture`!=%s;\n' \ - "${arch_id}" + printf 'UPDATE `moveable_bpir`' printf ' JOIN `binary_packages_in_repositories`' printf ' ON `binary_packages_in_repositories`.`id`=`moveable_bpir`.`id`' |