index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
-rwxr-xr-x | lib/common-functions | 29 |
diff --git a/lib/common-functions b/lib/common-functions index 6e0892d..7776725 100755 --- a/lib/common-functions +++ b/lib/common-functions @@ -225,12 +225,12 @@ remove_old_package_versions() { # repo-remove packages while read -r arch repo pkgname; do mkdir "${tmp_dir}/transit" - ${master_mirror_rsync_command} \ + failsafe_rsync \ "${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.db."* \ "${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.files."* \ "${tmp_dir}/transit/" repo-remove "${tmp_dir}/transit/${repo}.db.tar.gz" "${pkgname}" - ${master_mirror_rsync_command} \ + failsafe_rsync \ "${tmp_dir}/transit/${repo}.db."* \ "${tmp_dir}/transit/${repo}.files."* \ "${master_mirror_rsync_directory}/${arch}/${repo}/" @@ -709,7 +709,7 @@ trigger_mirror_refreshs() { tmp_file=$(mktemp "tmp.common-functions.trigger_mirror_refreshs.XXXXXXXXXX" --tmpdir) date '+%s' > \ "${tmp_file}" - ${master_mirror_rsync_command} \ + failsafe_rsync \ "${tmp_file}" \ "${master_mirror_rsync_directory}/lastupdate" rm "${tmp_file}" @@ -882,3 +882,26 @@ failsafe_sftp() { ) || \ return $? } + +# failsafe_rsync +# execute rsync with the given parameters on the master mirror, retrying +# if unsuccessful +# caveats: +# - output might be garbled +# - error code will be projected into {0,1} +failsafe_rsync() { + local trial_counter + + trial_counter=20 + if ${master_mirror_rsync_command} "$@"; then + return 0 + fi + while [ ${trial_counter} -gt 0 ]; do + wait_some_time 30 + if ${master_mirror_rsync_command} "$@"; then + return 0 + fi + trial_counter=$((trial_counter-1)) + done + return 1 +} |