Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-01-25 16:50:53 +0100
committerErich Eckner <git@eckner.net>2018-01-25 16:50:53 +0100
commit28b7053f6f94b02e14456f455747db75368b29d8 (patch)
treec96fed827411d4741f5fecaea8dd95b3142ac5d7 /bin
parentb34ca5d528f3f3aa569dffcda2d68e26849cecd1 (diff)
bin/get-assignment: dummy test for getting next-to-built id
Diffstat (limited to 'bin')
-rwxr-xr-xbin/get-assignment45
1 files changed, 45 insertions, 0 deletions
diff --git a/bin/get-assignment b/bin/get-assignment
index f90bea2..4f66235 100755
--- a/bin/get-assignment
+++ b/bin/get-assignment
@@ -111,6 +111,51 @@ clean_up() {
tmp_dir=$(mktemp -d 'tmp.get-assignment.XXXXXXXXXX' --tmpdir)
trap clean_up EXIT
+# shellcheck disable=SC2016
+{
+ printf 'SELECT'
+ printf ' COALESCE('
+ printf '('
+ printf 'SELECT'
+ printf ' `build_slaves`.`currently_building`'
+ printf ' FROM `build_slaves`'
+ printf ' JOIN `build_assignments`'
+ printf ' ON `build_slaves`.`currently_building`=`build_assignments`.`id`'
+ printf ' WHERE `build_slaves`.`name`=from_base64("%s")' \
+ "$(printf '%s' "${slave}" | base64 -w0)"
+ printf '),('
+ printf 'SELECT `to_dos`.`id` FROM'
+ printf '('
+ printf 'SELECT'
+ printf ' `build_assignments`.`id`,'
+ printf '('
+ printf 'SELECT COUNT(*)'
+ printf ' FROM `failed_builds`'
+ printf ' WHERE `failed_builds`.`build_assignment`=`build_assignments`.`id`'
+ printf ') AS `trials`'
+ printf ' FROM `build_assignments`'
+ printf ' JOIN `binary_packages`'
+ printf ' ON `binary_packages`.`build_assignment`=`build_assignments`.`id`'
+ printf ' JOIN `repositories`'
+ printf ' ON `binary_packages`.`repository`=`repositories`.`id`'
+ printf ' WHERE `repositories`.`name`="build-list"'
+ printf ' AND NOT EXISTS ('
+ printf ' SELECT *'
+ printf ' FROM `build_slaves`'
+ printf ' WHERE `build_slaves`.`currently_building`=`build_assignments`.`id`'
+ printf ' )'
+ printf ' ORDER BY `trials`, `build_assignments`.`id`'
+ printf ' LIMIT 1'
+ printf ') AS `to_dos`'
+ printf ')'
+ printf ')'
+} | \
+ ${mysql_command} --batch --raw | \
+ sed '
+ 1d
+ y/\t/ /
+ ' >&2
+
# Check if there are any pending packages at all and if the requester
# has already got an assignment.