38
38
}
39
39
40
40
function downloadImages() {
41
- for img in $( < ${SYNCLIST} ) ; do
42
- curl -L --fail --retry 5 -O $img
41
+ for img in $( < " ${SYNCLIST} " ) ; do
42
+ curl -L --fail --silent -- retry 5 -O " $img "
43
43
done
44
44
# rename files to indicate the release they match (including arch suffix by tradition).
45
45
# also create an unversioned symlink to enable consistent incoming links.
@@ -49,15 +49,15 @@ function downloadImages() {
49
49
# name like "rhcos-buildid-qemu..."
50
50
file=" ${name/ $BUILDID / $release } " # rhcos-release-qemu...
51
51
link=" ${name/ -$BUILDID / } " # rhcos-qemu...
52
- [[ $name == $file ]] && continue # skip files that aren't named that way
52
+ [[ $name == " $file " ]] && continue # skip files that aren't named that way
53
53
mv " $name " " $file "
54
54
ln --symbolic " $file " " $link "
55
55
done
56
56
# Some customer portals point to the deprecated `rhcos-installer` names rather than `rhcos-live`.
57
57
# Fix those links.
58
- for f in $( find . -maxdepth 1 -type l -name ' rhcos-live-*' ) ; do
59
- ln -s " $( readlink $f ) " " ${f / rhcos-live-/ rhcos-installer-} "
60
- done
58
+ find . -maxdepth 1 -type l -name ' rhcos-live-*' -exec sh -c '
59
+ ln -s "$(readlink $1 )" "${1 /rhcos-live-/rhcos-installer-}"
60
+ ' sh {} \;
61
61
}
62
62
63
63
function genSha256() {
@@ -67,19 +67,19 @@ function genSha256() {
67
67
}
68
68
69
69
function genRhcosIdTxt() {
70
- echo ${BUILDID} > rhcos-id.txt
70
+ echo " ${BUILDID} " > rhcos-id.txt
71
71
}
72
72
73
73
function emulateSymlinks() {
74
74
S3_SOURCE=" $1 "
75
- MAJOR_MINOR=$( echo ${VERSION} | awk -F ' [.-]' ' {print $1 "." $2}' ) # e.g. 4.3.0-0.nightly-2019-11-08-080321 -> 4.3
75
+ MAJOR_MINOR=$( echo " ${VERSION} " | awk -F ' [.-]' ' {print $1 "." $2}' ) # e.g. 4.3.0-0.nightly-2019-11-08-080321 -> 4.3
76
76
# We also need to know what Y stream comes after this one.
77
- MAJOR_NEXT_MINOR=$( echo ${MAJOR_MINOR} | awk -F ' [.-]' ' {print $1 "." $2+1}' ) # e.g. 4.3 -> 4.4
77
+ MAJOR_NEXT_MINOR=$( echo " ${MAJOR_MINOR} " | awk -F ' [.-]' ' {print $1 "." $2+1}' ) # e.g. 4.3 -> 4.4
78
78
79
79
if [[ " ${RHCOS_MIRROR_PREFIX} " == " pre-release" ]]; then
80
80
MAJOR_MINOR_LATEST=" latest-${MAJOR_MINOR} "
81
- aws s3 sync --no-progress --delete --exact-timestamps ${S3_SOURCE} s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /${MAJOR_MINOR_LATEST} /
82
- aws s3 sync --no-progress --delete --exact-timestamps ${S3_SOURCE} s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /${MAJOR_MINOR_LATEST} / --profile cloudflare --endpoint-url ${CLOUDFLARE_ENDPOINT}
81
+ " ${SYNC_CMD[@]} " " ${S3_SOURCE} " " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /${MAJOR_MINOR_LATEST} /"
82
+ " ${SYNC_CMD[@]} " " ${S3_SOURCE} " " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /${MAJOR_MINOR_LATEST} /" " ${CLOUDFLARE_OPTS[@]} "
83
83
84
84
# Is this major.minor the latest Y stream? If it is, we need to set
85
85
# the overall 'latest'.
@@ -98,8 +98,8 @@ function emulateSymlinks() {
98
98
# LATEST_LINK will end up being something like 4.9.0-fc.0 if the next major exists or "" if it does not.
99
99
100
100
if [[ -z " ${LATEST_LINK} " ]]; then
101
- aws s3 sync --no-progress --delete --exact-timestamps ${S3_SOURCE} s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /latest/
102
- aws s3 sync --no-progress --delete --exact-timestamps ${S3_SOURCE} s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /latest/ --profile cloudflare --endpoint-url ${CLOUDFLARE_ENDPOINT}
101
+ " ${SYNC_CMD[@]} " " ${S3_SOURCE} " " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /latest/"
102
+ " ${SYNC_CMD[@]} " " ${S3_SOURCE} " " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /latest/" " ${CLOUDFLARE_OPTS[@]} "
103
103
fi
104
104
105
105
else
@@ -109,8 +109,8 @@ function emulateSymlinks() {
109
109
LATEST_CONTENT=$( aws s3 ls " s3://art-srv-enterprise${BASEDIR} /${MAJOR_NEXT_MINOR} /" | grep PRE || true)
110
110
111
111
if [[ -z " ${LATEST_CONTENT} " ]]; then
112
- aws s3 sync --no-progress --delete --exact-timestamps ${S3_SOURCE} s3://art-srv-enterprise${BASEDIR} /latest/
113
- aws s3 sync --no-progress --delete --exact-timestamps ${S3_SOURCE} s3://art-srv-enterprise${BASEDIR} /latest/ --profile cloudflare --endpoint-url ${CLOUDFLARE_ENDPOINT}
112
+ " ${SYNC_CMD[@]} " " ${S3_SOURCE} " " s3://art-srv-enterprise${BASEDIR} /latest/"
113
+ " ${SYNC_CMD[@]} " " ${S3_SOURCE} " " s3://art-srv-enterprise${BASEDIR} /latest/" " ${CLOUDFLARE_OPTS[@]} "
114
114
fi
115
115
fi
116
116
@@ -125,7 +125,7 @@ if [ "${#}" -lt "8" ]; then
125
125
exit 1
126
126
fi
127
127
128
- while [ $1 ]; do
128
+ while [ " $1 " ]; do
129
129
case " $1 " in
130
130
" --prefix" )
131
131
shift
@@ -159,6 +159,14 @@ while [ $1 ]; do
159
159
shift
160
160
done
161
161
162
+ DRY_RUN_FLAG=" "
163
+ if [ $TEST -eq 1 ]; then
164
+ DRY_RUN_FLAG=" --dryrun"
165
+ fi
166
+
167
+ SYNC_CMD=(aws s3 sync --no-progress --exact-timestamps --delete ${DRY_RUN_FLAG} )
168
+ CLOUDFLARE_OPTS=(--profile cloudflare --endpoint-url ${CLOUDFLARE_ENDPOINT} )
169
+
162
170
DESTDIR=" ${PWD} /staging-${VERSION} "
163
171
mkdir -p " ${DESTDIR} "
164
172
@@ -170,28 +178,22 @@ Sync List: ${SYNCLIST}
170
178
Basedir: ${BASEDIR}
171
179
EOF
172
180
173
- pushd $ DESTDIR
181
+ pushd " ${ DESTDIR} "
174
182
downloadImages
175
183
genSha256
176
184
genRhcosIdTxt
177
185
178
- if [ $TEST -eq 1 ]; then
179
- echo Would have copied out to ${BASEDIR} /${RHCOS_MIRROR_PREFIX} /${VERSION} /:
180
- ls
181
- exit 0
182
- fi
183
-
184
186
# Copy the files out to their main location
185
- aws s3 sync --no-progress --delete --exact-timestamps ./ " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /${VERSION} /"
186
- aws s3 sync --no-progress --delete --exact-timestamps ./ " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /${VERSION} /" --profile cloudflare --endpoint-url ${CLOUDFLARE_ENDPOINT}
187
+ " ${SYNC_CMD[@]} " ./ " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /${VERSION} /"
188
+ " ${SYNC_CMD[@]} " ./ " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /${VERSION} /" " ${CLOUDFLARE_OPTS[@]} "
187
189
if [ $NOLATEST -eq 0 ]; then
188
- aws s3 sync --no-progress --delete --exact-timestamps ./ " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /latest/"
189
- aws s3 sync --no-progress --delete --exact-timestamps ./ " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /latest/" --profile cloudflare --endpoint-url ${CLOUDFLARE_ENDPOINT}
190
+ " ${SYNC_CMD[@]} " ./ " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /latest/"
191
+ " ${SYNC_CMD[@]} " ./ " s3://art-srv-enterprise${BASEDIR} /${RHCOS_MIRROR_PREFIX} /latest/" " ${CLOUDFLARE_OPTS[@]} "
190
192
# CloudFlare does not support the full S3 API and we encountered unimplemented APIs using the AWS CLI to sync from one area of R2 to another area.
191
193
# We therefore re-copy from local content to R2, which does not hit these limitations. This is technically slower, but works with R2.
192
194
emulateSymlinks " ./"
193
195
else
194
196
echo " INFO: Not updating 'latest' symlink because --nolatest was given"
195
197
fi
196
198
popd
197
- rm -rf $ DESTDIR
199
+ rm -rf " ${ DESTDIR} "
0 commit comments