From 64290b3c755b2e1968c11ed2fd556596afe031ff Mon Sep 17 00:00:00 2001 From: Renato Botelho do Couto Date: Mon, 2 Sep 2019 15:14:49 -0300 Subject: [PATCH] Do not send unneeded files to S3 and also delete old files from it --- tools/builder_common.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/builder_common.sh b/tools/builder_common.sh index b06a3cbcd1..6cab4816fd 100644 --- a/tools/builder_common.sh +++ b/tools/builder_common.sh @@ -1325,6 +1325,7 @@ finish() { pkg_repo_rsync() { local _repo_path_param="${1}" local _ignore_final_rsync="${2}" + local _aws_sync_cmd="aws s3 sync --quiet --exclude '.real*/*' --exclude '.latest/*'" if [ -z "${_repo_path_param}" -o ! -d "${_repo_path_param}" ]; then return @@ -1462,7 +1463,17 @@ pkg_repo_rsync() { echo -n ">>> Sending updated packages to AWS ${PKG_FINAL_S3_PATH}... " | tee -a ${_logfile} if script -aq ${_logfile} ssh -p ${PKG_FINAL_RSYNC_SSH_PORT} \ ${PKG_FINAL_RSYNC_USERNAME}@${_pkg_final_rsync_hostname} \ - "aws s3 sync --quiet ${_repo} ${PKG_FINAL_S3_PATH}/$(basename ${_repo})"; then + "${_aws_sync_cmd} ${_repo} ${PKG_FINAL_S3_PATH}/$(basename ${_repo})"; then + echo "Done!" | tee -a ${_logfile} + else + echo "Failed!" | tee -a ${_logfile} + echo ">>> ERROR: An error occurred sending files to AWS S3" + print_error_pfS + fi + echo -n ">>> Cleaning up packages at AWS ${PKG_FINAL_S3_PATH}... " | tee -a ${_logfile} + if script -aq ${_logfile} ssh -p ${PKG_FINAL_RSYNC_SSH_PORT} \ + ${PKG_FINAL_RSYNC_USERNAME}@${_pkg_final_rsync_hostname} \ + "${_aws_sync_cmd} --delete ${_repo} ${PKG_FINAL_S3_PATH}/$(basename ${_repo})"; then echo "Done!" | tee -a ${_logfile} else echo "Failed!" | tee -a ${_logfile}