From: Matthias Kruk Date: Sat, 24 Apr 2021 13:35:48 +0000 (+0900) Subject: {watch,build,dist}bot: Make all bots use similar commandline options X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=157bb2140777ba23fd331bab76402c4c00c61253;p=foundry {watch,build,dist}bot: Make all bots use similar commandline options Watchbot, buildbot, and distbot do not use the same options for inputs and outputs such as queues or directories. This commit changes the understood commandline arguments so that the same options have the same meaning. Further, this commit updates the three bots to use the opt module in a way thats compatible with toolbox > 0.3. --- diff --git a/buildbot.sh b/buildbot.sh index 78c1110..86a8a99 100755 --- a/buildbot.sh +++ b/buildbot.sh @@ -122,37 +122,22 @@ dispatch_tasks() { main() { local gpgkey - local tqueue - local dqueue + local iqueue + local oqueue - opt_add_arg "k" "gpgkey" "yes" "" "The GPG key id to use" - opt_add_arg "t" "task-queue" "yes" "" "The queue to watch for tasks" - opt_add_arg "d" "done-queue" "yes" "" "The queue to place build artifacts" + opt_add_arg "k" "gpgkey" "rv" "" "The GPG key id to use" + opt_add_arg "i" "input" "rv" "" "The queue from where build tasks will be taken" + opt_add_arg "o" "output" "rv" "" "The queue where build artifacts will be placed" if ! opt_parse "$@"; then return 1 fi gpgkey=$(opt_get "gpgkey") - tqueue=$(opt_get "task-queue") - dqueue=$(opt_get "done-queue") + iqueue=$(opt_get "input") + oqueue=$(opt_get "output") - if [[ -z "$gpgkey" ]]; then - log_error "Need a GPG key id" - return 1 - fi - - if [[ -z "$tqueue" ]]; then - log_error "Need a task queue" - return 1 - fi - - if [[ -z "$dqueue" ]]; then - log_error "Need a queue for finished tasks" - return 1 - fi - - inst_start dispatch_tasks "$gpgkey" "$tqueue" "$dqueue" + inst_start dispatch_tasks "$gpgkey" "$iqueue" "$oqueue" return 0 } diff --git a/distbot.sh b/distbot.sh index 90a7e15..5577a8b 100755 --- a/distbot.sh +++ b/distbot.sh @@ -135,32 +135,26 @@ main() { local gpgkey local desc - opt_add_arg "n" "name" "yes" "" "The name of the repository" - opt_add_arg "p" "path" "yes" "" "The path to the repository" - opt_add_arg "c" "codename" "yes" "stable" "The codename of the distribution (default: stable)" - opt_add_arg "a" "arch" "yes" "" "Comma separated list of supported architectures" - opt_add_arg "k" "gpgkey" "yes" "" "The GPG key used for signing" - opt_add_arg "d" "description" "yes" "" "Description of the repository" - opt_add_arg "i" "incoming" "yes" "" "The queue to watch for incoming packages" + opt_add_arg "n" "name" "rv" "" "The name of the repository" + opt_add_arg "o" "output" "rv" "" "The path to the repository" + opt_add_arg "c" "codename" "v" "stable" "The codename of the distribution (default: stable)" + opt_add_arg "a" "arch" "rv" "" "Comma separated list of supported architectures" + opt_add_arg "k" "gpgkey" "rv" "" "The GPG key used for signing" + opt_add_arg "d" "description" "rv" "" "Description of the repository" + opt_add_arg "i" "input" "rv" "" "The queue to watch for incoming packages" if ! opt_parse "$@"; then return 1 fi - path=$(opt_get "path") + path=$(opt_get "output") codename=$(opt_get "codename") - incoming=$(opt_get "incoming") + incoming=$(opt_get "input") name=$(opt_get "name") arch=$(opt_get "arch") gpgkey=$(opt_get "gpgkey") desc=$(opt_get "description") - if [[ -z "$path" ]] || [[ -z "$incoming" ]] || [[ -z "$name" ]] || - [[ -z "$arch" ]] || [[ -z "$gpgkey" ]] || [[ -z "$desc" ]]; then - log_error "Missing required arguments" - return 1 - fi - if ! [ -d "$path" ]; then # Create new repository log_info "Initializing repository $name:$codename in $path" diff --git a/watchbot.sh b/watchbot.sh index 649d45f..fb76c7b 100755 --- a/watchbot.sh +++ b/watchbot.sh @@ -92,20 +92,15 @@ main() { local queue local watch - opt_add_arg "r" "repo" "yes" "" "Repository to watch (format: /repo/path[#branch])" watchlist_add - opt_add_arg "q" "queue" "yes" "" "Queue used to distribute work" + opt_add_arg "i" "input" "rv" "" "Repository to watch (format: /repo/path[#branch])" \ + watchlist_add + opt_add_arg "o" "output" "rv" "" "Queue where output shall be placed" if ! opt_parse "$@"; then return 1 fi - queue=$(opt_get "queue") - - if [ -z "$queue" ]; then - log_error "Need a queue" - return 1 - fi - + queue=$(opt_get "input") watches=() for watch in "${watchlist[@]}"; do