From 9c3ba1293622dd72ac65d857448407b853fb3c5e Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Wed, 6 Oct 2021 18:51:51 +0200 Subject: [PATCH 1/3] release_util.sh: add rsync:// upload --- build_library/release_util.sh | 38 +++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/build_library/release_util.sh b/build_library/release_util.sh index db2e33b220..df2dfc095a 100644 --- a/build_library/release_util.sh +++ b/build_library/release_util.sh @@ -51,24 +51,27 @@ check_gsutil_opts() { fi if [[ -n "${FLAGS_upload_root}" ]]; then - if [[ "${FLAGS_upload_root}" != gs://* ]]; then - die_notrace "--upload_root must be a gs:// URL" + if [[ "${FLAGS_upload_root}" != gs://* ]] \ + && [[ "${FLAGS_upload_root}" != rsync://* ]] ; then + die_notrace "--upload_root must be a gs:// or rsync:// URL" fi # Make sure the path doesn't end with a slash UPLOAD_ROOT="${FLAGS_upload_root%%/}" fi if [[ -n "${FLAGS_torcx_upload_root}" ]]; then - if [[ "${FLAGS_torcx_upload_root}" != gs://* ]]; then - die_notrace "--torcx_upload_root must be a gs:// URL" + if [[ "${FLAGS_torcx_upload_root}" != gs://* ]] \ + && [[ "${FLAGS_torcx_upload_root}" != rsync://* ]] ; then + die_notrace "--torcx_upload_root must be a gs:// or rsync:// URL" fi # Make sure the path doesn't end with a slash TORCX_UPLOAD_ROOT="${FLAGS_torcx_upload_root%%/}" fi if [[ -n "${FLAGS_upload_path}" ]]; then - if [[ "${FLAGS_upload_path}" != gs://* ]]; then - die_notrace "--upload_path must be a gs:// URL" + if [[ "${FLAGS_upload_path}" != gs://* ]] \ + && [[ "${FLAGS_upload_path}" != rsync://* ]] ; then + die_notrace "--upload_path must be a gs:// or rsync:// URL" fi # Make sure the path doesn't end with a slash UPLOAD_PATH="${FLAGS_upload_path%%/}" @@ -105,8 +108,27 @@ upload_files() { fi info "Uploading ${msg} to ${local_upload_path}" - gsutil ${GSUTIL_OPTS} cp -R "$@" \ - "${local_upload_path}/${extra_upload_suffix}" + + if echo "${local_upload_path}" | grep -qE '^rsync://'; then + local rsync_upload_path="$(echo "${local_upload_path}" \ + | sed 's,^rsync://,,')" + local sshcmd="ssh -o BatchMode=yes " + sshcmd="$sshcmd -o StrictHostKeyChecking=no" + sshcmd="$sshcmd -o UserKnownHostsFile=/dev/null" + + # ensure the target path exists + local sshuserhost="$(echo "${rsync_upload_path}" | sed 's/:.*//')" + local destpath="$(echo "${rsync_upload_path}" | sed 's/.*://')" + ${sshcmd} "${sshuserhost}" \ + "mkdir -p ${destpath}/${extra_upload_suffix}" + + # now sync + rsync -Pav -e "${sshcmd}" "$@" \ + "${rsync_upload_path}/${extra_upload_suffix}" + else + gsutil ${GSUTIL_OPTS} cp -R "$@" \ + "${local_upload_path}/${extra_upload_suffix}" + fi } From 0aad4b9dd11044f9fb9a2882a9f810704d735380 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Thu, 7 Oct 2021 10:48:26 +0200 Subject: [PATCH 2/3] release_util.sh: script improvements Co-authored-by: Krzesimir Nowak --- build_library/release_util.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build_library/release_util.sh b/build_library/release_util.sh index df2dfc095a..b96965447f 100644 --- a/build_library/release_util.sh +++ b/build_library/release_util.sh @@ -109,16 +109,15 @@ upload_files() { info "Uploading ${msg} to ${local_upload_path}" - if echo "${local_upload_path}" | grep -qE '^rsync://'; then - local rsync_upload_path="$(echo "${local_upload_path}" \ - | sed 's,^rsync://,,')" + if [[ "${local_upload_path}" = 'rsync://'* ]]; then + local rsync_upload_path="${local_upload_path#rsync://}" local sshcmd="ssh -o BatchMode=yes " sshcmd="$sshcmd -o StrictHostKeyChecking=no" sshcmd="$sshcmd -o UserKnownHostsFile=/dev/null" # ensure the target path exists - local sshuserhost="$(echo "${rsync_upload_path}" | sed 's/:.*//')" - local destpath="$(echo "${rsync_upload_path}" | sed 's/.*://')" + local sshuserhost="${rsync_upload_path%:*}" + local destpath="${rsync_upload_path#*:}" ${sshcmd} "${sshuserhost}" \ "mkdir -p ${destpath}/${extra_upload_suffix}" From cc469d2f475e8dcaa656d8825063ae2982db104d Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Thu, 7 Oct 2021 11:17:33 +0200 Subject: [PATCH 3/3] build_library/release_util.sh: improve ssh opts for rsync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kai Lüke --- build_library/release_util.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build_library/release_util.sh b/build_library/release_util.sh index b96965447f..f1ecc8acc0 100644 --- a/build_library/release_util.sh +++ b/build_library/release_util.sh @@ -114,6 +114,7 @@ upload_files() { local sshcmd="ssh -o BatchMode=yes " sshcmd="$sshcmd -o StrictHostKeyChecking=no" sshcmd="$sshcmd -o UserKnownHostsFile=/dev/null" + sshcmd="$sshcmd -o NumberOfPasswordPrompts=0" # ensure the target path exists local sshuserhost="${rsync_upload_path%:*}"