summaryrefslogtreecommitdiff
path: root/bin/db-update
diff options
context:
space:
mode:
Diffstat (limited to 'bin/db-update')
-rwxr-xr-xbin/db-update91
1 files changed, 66 insertions, 25 deletions
diff --git a/bin/db-update b/bin/db-update
index 7c5a8cf..88c567d 100755
--- a/bin/db-update
+++ b/bin/db-update
@@ -27,6 +27,8 @@ usage() {
>&2 echo ' move possible packages from staging to testing.'
>&2 echo ''
>&2 echo 'possible options:'
+ >&2 echo ' -e|--everything:'
+ >&2 echo ' Force movement of every package and 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:'
@@ -50,19 +52,24 @@ 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 f:hino:pw \
- --long force \
+ getopt -o ef:hino:psw \
+ --long everything \
+ --long force: \
--long help \
--long ignore-insanity \
--long no-action \
--long only: \
--long progressive \
+ --long stuck \
--long wait \
-n "$(basename "$0")" -- "$@" || \
echo usage
@@ -73,11 +80,16 @@ ignore_insanity=false
no_action_flag=''
progressive=false
force_pkgs=''
+force_every_pkg=false
+force_stuck_pkgs=false
only=''
while true
do
case "$1" in
+ -e|--everything)
+ force_every_pkg=true
+ ;;
-f|--force)
shift
force_pkgs=$(
@@ -109,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=''
;;
@@ -129,8 +144,17 @@ if [ $# -ne 0 ]; then
usage
fi
-if ${progressive} && \
- [ -n "${force_pkgs}" ]; then
+number_of_force_flags=0
+${progressive} \
+&& number_of_force_flags=$((number_of_force_flags+1))
+[ -n "${force_pkgs}" ] \
+&& 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'
usage
fi
@@ -157,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' \
@@ -295,7 +319,9 @@ 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}" ] || \
+ ${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'
@@ -306,31 +332,46 @@ 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`'
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/'
- 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}"
+ 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/'
+ 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 'UPDATE `moveable_bpir`'
printf ' JOIN `binary_packages_in_repositories`'
printf ' ON `binary_packages_in_repositories`.`id`=`moveable_bpir`.`id`'