From fbf85d32f9efd43df8032de71c295b1648e98300 Mon Sep 17 00:00:00 2001 From: Tasos Sahanidis Date: Wed, 7 Feb 2024 10:33:44 +0200 Subject: bin/schedule-for-rebuild: Add interactive option --- bin/schedule-for-rebuild | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/bin/schedule-for-rebuild b/bin/schedule-for-rebuild index de2d733..d8dae5c 100755 --- a/bin/schedule-for-rebuild +++ b/bin/schedule-for-rebuild @@ -49,6 +49,8 @@ usage() { >&2 echo ' Schedule packages with matching pkgname or pkgbase.' >&2 echo ' -s|--skip-arch $arch:' >&2 echo ' Ignore packages, that are outdated on $arch only (-a).' + >&2 echo ' -t|--interactive' + >&2 echo ' Ask which of the matching packages to schedule for rebuild.' >&2 echo ' -w|--wait:' >&2 echo ' Wait for lock if necessary.' [ -z "$1" ] && exit 1 || exit "$1" @@ -59,7 +61,7 @@ tmp_dir=$(mktemp -d 'tmp.schedule-for-rebuild.XXXXXXXXXX' --tmpdir) trap "rm -rf --one-file-system '${tmp_dir:?}'" EXIT eval set -- "$( - getopt -o afhi:jnp:s:w \ + getopt -o afhi:jnp:s:tw \ --long auto \ --long force \ --long help \ @@ -68,6 +70,7 @@ eval set -- "$( --long no-action \ --long package: \ --long skip-arch: \ + --long interactive \ --long wait \ -n "$(basename "$0")" -- "$@" || \ echo usage @@ -77,6 +80,7 @@ auto=false ignore_mysql_generate_package_metadata_errors=false jostle=false update=true +interactive=false wait_for_lock='-n' while true @@ -117,6 +121,9 @@ do printf '%s\n' "$1" >> \ "${tmp_dir}/skip-archs" ;; + -t|--interactive) + interactive=true + ;; -w|--wait) wait_for_lock='' ;; @@ -470,11 +477,20 @@ fi sort -u "${tmp_dir}/pkgbases" \ | sponge "${tmp_dir}/pkgbases" -# get the current HEADs +if ${interactive}; then + echo "Which packages to rebuild? (Comma separated; Empty means all)" + nl "${tmp_dir}/pkgbases" + read -p "Choice: " pkg_rebuild_choice + + if [ -n "$pkg_rebuild_choice" ]; then + readarray -td, pkg_rebuild_choice_array < <( printf '%s' "$pkg_rebuild_choice" | sed 's/\s//g;s/,\{2,\}/,/g' ) + sed -i -n "$(printf "%sp;" "${pkg_rebuild_choice_array[@]}")" "${tmp_dir}/pkgbases" + fi +fi +# get the current HEADs if ${update}; then cut -d' ' -f 2,3,4,5 "${tmp_dir}/pkgbases" \ - | sort -u \ | while read -r pkgbase git_rev git_mod_rev repo; do success=false # shellcheck disable=SC2154 @@ -487,7 +503,6 @@ if ${update}; then done cut -d' ' -f2 "${tmp_dir}/pkgbases" \ - | sort -u \ | sponge "${tmp_dir}/pkgbases" # shellcheck disable=SC2016 -- cgit v1.2.3-70-g09d2