index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-09-26 09:39:07 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-09-26 09:39:07 +0200 |
commit | 20ad7b8c89a6a0d53a15ecb8f5d7be5676fd8b5c (patch) | |
tree | d940ca8bc23e36ca0f38a94fb51b6bbc4827833e /bin/harvest-commit-times | |
parent | 6a9164dbd3a8d111b48f7f74477cb65fc745c1a7 (diff) |
-rwxr-xr-x | bin/harvest-commit-times | 31 |
diff --git a/bin/harvest-commit-times b/bin/harvest-commit-times index 38d84c4..325da70 100755 --- a/bin/harvest-commit-times +++ b/bin/harvest-commit-times @@ -61,6 +61,13 @@ fi tmp_file=$(mktemp 'tmp.harvest-commit-times.XXXXXXXXXX' --tmpdir) trap 'rm "${tmp_file}"' EXIT +if ! ${i_am_the_master}; then + tmp_remote_file=$( + ssh buildmaster "mktemp 'tmp.harvest-commit-times.remotely.XXXXXXXXXX' --tmpdir" + ) + trap 'rm "${tmp_file}"; ssh buildmaster rm "${tmp_remote_file}"' EXIT +fi + while true; do # shellcheck disable=SC2016 @@ -77,6 +84,9 @@ while true; do mysql_join_upstream_repositories_git_repositories printf ' WHERE `package_sources`.`commit_time`="0000-00-00 00:00:00"' printf ' AND `package_sources`.`uses_upstream`' + if ! ${i_am_the_master}; then + printf ' ORDER BY RAND()' + fi printf ' LIMIT 10' } | \ mysql_run_query 'unimportant' | \ @@ -100,19 +110,34 @@ while true; do done > \ "${tmp_file}" + >&2 printf '.' + if [ -s "${tmp_file}" ]; then + if ! ${i_am_the_master}; then + ssh buildmaster 'cat > "'"${tmp_remote_file}"'"' < \ + "${tmp_file}" + fi # shellcheck disable=SC2016 { printf 'CREATE TEMPORARY TABLE `cts` (`id` BIGINT, `ct` BIGINT);\n' - printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `cts`(`id`,`ct`);\n' \ - "${tmp_file}" + if ${i_am_the_master}; then + printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `cts`(`id`,`ct`);\n' \ + "${tmp_file}" + else + printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `cts`(`id`,`ct`);\n' \ + "${tmp_remote_file}" + fi printf 'UPDATE `cts`' printf ' JOIN `package_sources`' printf ' ON `package_sources`.`id`=`cts`.`id`' printf ' AND `package_sources`.`commit_time`="0000-00-00 00:00:00"' printf ' SET `package_sources`.`commit_time`=from_unixtime(`cts`.`ct`);\n' } | \ - mysql_run_query 'unimportant' + if ${i_am_the_master}; then + mysql_run_query 'unimportant' + else + ssh buildmaster 'mysql buildmaster -N --raw --batch' + fi else break fi |