Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
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
parentb86d5109e0ae3c3d1a75edc93b7e791bedc55e3a (diff)
bin/get-assignment: check arguments; cleanup
-rwxr-xr-xbin/build-packages8
-rwxr-xr-xbin/get-assignment40
-rwxr-xr-xbin/return-assignment1
3 files changed, 38 insertions, 11 deletions
diff --git a/bin/build-packages b/bin/build-packages
index 6e0554b..01c7b32 100755
--- a/bin/build-packages
+++ b/bin/build-packages
@@ -813,6 +813,14 @@ while [ "${count}" -ne 0 ] && \
;;
+ 4)
+
+ >&2 echo 'get-assignment told me:'
+ >&2 echo ' 4: wrong number of arguments'
+ exit 5
+
+ ;;
+
*)
>&2 echo "ERROR: Unknown exit code ${err} from 'get-assignment'."
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 '
diff --git a/bin/return-assignment b/bin/return-assignment
index a9605b1..fb4d6cb 100755
--- a/bin/return-assignment
+++ b/bin/return-assignment
@@ -13,6 +13,7 @@
# 2: outdated package
# 3: signature error
# 4: package error (e.g. wrong packages sent)
+# 5: wrong number of arguments
# TODO: sign database