Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/get-assignment
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-09-13 09:11:58 +0200
committerErich Eckner <git@eckner.net>2018-09-13 09:11:58 +0200
commite6f5ba6b2baafe8786519452dcfeb87624bec016 (patch)
treeb06c0c51850829965756eca2bf572b849aa034c8 /bin/get-assignment
parentb86d5109e0ae3c3d1a75edc93b7e791bedc55e3a (diff)
bin/get-assignment: check arguments; cleanup
Diffstat (limited to 'bin/get-assignment')
-rwxr-xr-xbin/get-assignment40
1 files changed, 29 insertions, 11 deletions
diff --git a/bin/get-assignment b/bin/get-assignment
index 40acdb2..4e9b040 100755
--- a/bin/get-assignment
+++ b/bin/get-assignment
@@ -11,6 +11,7 @@
# but currently none has all its dependencies ready
# 3: come back after the next run of get-package-updates - currently
# there are no pending packages
+# 4: wrong number of arguments
# shellcheck disable=SC2119,SC2120
@@ -100,6 +101,23 @@ arch=$(
base64 -w0
)
shift
+if [ $# -eq 1 ]; then
+ requested=$(
+ printf '%s' "$1" | \
+ base64 -w0
+ )
+ shift
+else
+ requested=''
+fi
+# shellcheck disable=SC2016
+if [ $# -ne 0 ]; then
+ >&2 echo '"get-assignment" was called with wrong number of arguments.'
+ >&2 echo 'call either:'
+ >&2 echo ' get-assignment $arch'
+ >&2 echo ' get-assignment $arch $favourite_package'
+ exit 4
+fi
# if we're building something already, hand it out (again)
currently_building=$(
@@ -145,11 +163,12 @@ next_building=$(
printf 'SELECT `q`.`ba_id` FROM'
printf '('
printf 'SELECT '
- printf '`package_sources`.`pkgbase`=from_base64("%s") AS `requested`,' \
- "$(
- printf '%s' "$1" | \
- base64 -w0
- )"
+ if [ -n "${requested}" ]; then
+ printf '`package_sources`.`pkgbase`=from_base64("%s") AS `requested`,' \
+ "${requested}"
+ else
+ printf '0 AS `requested`,'
+ fi
printf 'IFNULL(`toolchain_query`.`priority`,3) AS `toolchain_priority`,'
# 0: in toolchain, never blocked
# 1: in toolchain, unblocked exists, not-yet-built
@@ -251,12 +270,11 @@ next_building=$(
printf ' WHERE `build_slaves`.`currently_building`=`build_assignments`.`id`'
printf ') AND ('
printf '`build_assignments`.`is_blocked` IS NULL'
- printf ' OR'
- printf ' `package_sources`.`pkgbase`=from_base64("%s")' \
- "$(
- printf '%s' "$1" | \
- base64 -w0
- )"
+ if [ -n "${requested}" ]; then
+ printf ' OR'
+ printf ' `package_sources`.`pkgbase`=from_base64("%s")' \
+ "${requested}"
+ fi
printf ') AND ('
mysql_query_is_part_of_loop '`build_assignments`.`id`'
printf ' OR NOT '