Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/slave-build-connect57
1 files changed, 39 insertions, 18 deletions
diff --git a/bin/slave-build-connect b/bin/slave-build-connect
index 5460b7e..13fcf18 100755
--- a/bin/slave-build-connect
+++ b/bin/slave-build-connect
@@ -44,25 +44,46 @@ if [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xget-assignment' ] || \
slave_id="${infos%% *}"
operator="${infos#* }"
- # shellcheck disable=SC2016
- {
- printf 'INSERT IGNORE INTO `ssh_log` (`build_slave`,`action`,`parameters`)'
- printf ' VALUES (%s' \
- "${slave_id}"
- printf ',from_base64("%s")' \
- "$(
- printf '%s' "${SSH_ORIGINAL_COMMAND%% *}" | \
- base64 -w0
- )" \
- "$(
- printf '%s' "${SSH_ORIGINAL_COMMAND#* }" | \
- base64 -w0
- )"
- printf ');\n'
- } | \
- mysql_run_query 'unimportant'
+ ssh_log_id=$(
+ # shellcheck disable=SC2016
+ {
+ printf 'INSERT IGNORE INTO `ssh_log` (`build_slave`,`action`,`parameters`)'
+ printf ' VALUES (%s' \
+ "${slave_id}"
+ printf ',from_base64("%s")' \
+ "$(
+ printf '%s' "${SSH_ORIGINAL_COMMAND%% *}" | \
+ base64 -w0
+ )" \
+ "$(
+ printf '%s' "${SSH_ORIGINAL_COMMAND#* }" | \
+ base64 -w0
+ )"
+ printf ');\n'
+ printf 'SELECT LAST_INSERT_ID();\n'
+ } | \
+ mysql_run_query 'unimportant'
+ )
+ exit_code=0
+
+ slave="$1" slave_id="${slave_id}" operator="${operator}" SKIP_COMMAND_LOG=1 /bin/sh -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}" \
+ || exit_code=$?
+
+ if [ -n "${ssh_log_id}" ]; then
+ # shellcheck disable=SC2016
+ {
+ printf 'UPDATE `ssh_log`'
+ printf ' SET `ssh_log`.`duration`=TIME_TO_SEC(TIMEDIFF(NOW(),`ssh_log`.`date`)),'
+ printf '`ssh_log`.`exit_code`=%s' \
+ "${exit_code}"
+ printf ' WHERE `ssh_log`.`id`=%s' \
+ "${ssh_log_id}"
+ printf ';\n'
+ } | \
+ mysql_run_query 'unimportant'
+ fi
- slave="$1" slave_id="${slave_id}" operator="${operator}" SKIP_COMMAND_LOG=1 /bin/sh -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}"
+ exit ${exit_code}
else