]> git.corax.cc Git - foundry/commitdiff
{watch,build,dist}bot: Make all bots use similar commandline options
authorMatthias Kruk <m@m10k.eu>
Sat, 24 Apr 2021 13:35:48 +0000 (22:35 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 24 Apr 2021 13:35:48 +0000 (22:35 +0900)
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.

buildbot.sh
distbot.sh
watchbot.sh

index 78c111035a63cfb8364253710f84976033f4b843..86a8a993fc5c552aa15f3896ece946b82bc70110 100755 (executable)
@@ -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
 }
index 90a7e15c4ea3a9fd9ac0bb94f37acbca31c72c3d..5577a8bb1a7c7d4e835efd2f324630bab264bb90 100755 (executable)
@@ -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"
index 649d45f27a25d6532a9cdcd9ba463586eb5a5772..fb76c7b3562b18bc9d6577b50b36dd27bf0b3ceb 100755 (executable)
@@ -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