From 7e3ecbebee96416f11af739f531a2aa2c9829bf5 Mon Sep 17 00:00:00 2001 From: Dan McDonald Date: Fri, 18 Nov 2022 14:55:50 -0500 Subject: [PATCH 1/3] OS-xxxx use more content-type: in manta uploads --- tools/build_ctftools | 33 ++++++++++++++++++++++++++++++++- tools/build_strap | 32 +++++++++++++++++++++++++++++++- tools/smartos-release | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 96 insertions(+), 6 deletions(-) diff --git a/tools/build_ctftools b/tools/build_ctftools index c14722da8..d5f6be200 100755 --- a/tools/build_ctftools +++ b/tools/build_ctftools @@ -12,6 +12,7 @@ # # Copyright 2020 Joyent, Inc. +# Copyright 2022 MNX Cloud, Inc. # # @@ -23,6 +24,34 @@ usage="$0 make -j maxjobs -o tarball" usage="$usage | upload -D bits -d path -p platform -t timestamp" +function content_type +{ + filename="$1" + # basename <.ext> will strip .ext off. Will be == name if it's + # not .ext. + if [[ "$(basename $filename .tgz)" != "$filename" ]]; then + content_type="content-type: application/gzip" + elif [[ "$(basename $filename .gz)" != "$filename" ]]; then + content_type="content-type: application/gzip" + elif [[ "$(basename $filename .txt)" != "$filename" ]]; then + content_type="content-type: text/plain" + elif [[ "$(basename $filename .log)" != "$filename" ]]; then + content_type="content-type: text/plain" + elif [[ "$(basename $filename .html)" != "$filename" ]]; then + content_type="content-type: text/html" + elif [[ "$(basename $filename .json)" != "$filename" ]]; then + content_type="content-type: application/json" + elif [[ "$(basename $filename .iso)" != "$filename" ]]; then + content_type="content-type: application/octet-stream" + else + # Default value... XXX KEBE ASKS use text/plain instead? + content_type="content-type: application/octet-stream" + fi + + # Caller should use quotes around this. + echo $content_type +} + function fatal { local msg="$*" @@ -133,7 +162,9 @@ function upload verbose mmkdir -p "$mbdir" for file in $bits_dir/*; do - verbose mput -f "$file" "$mbdir/$(basename $file)" + filename="$(basename $file)" + verbose mput -H "$(content_type $filename)" -f "$file" \ + "$mbdir/$filename" done echo "$mbdir" | mput -H "content-type: text/plain" "$mdir/latest" diff --git a/tools/build_strap b/tools/build_strap index e8ebf2ac9..c1f716add 100755 --- a/tools/build_strap +++ b/tools/build_strap @@ -46,6 +46,34 @@ max_jobs=$($wsroot/tools/optimize_jobs) force_build="no" tarfile="" +function content_type +{ + filename="$1" + # basename <.ext> will strip .ext off. Will be == name if it's + # not .ext. + if [[ "$(basename $filename .tgz)" != "$filename" ]]; then + content_type="content-type: application/gzip" + elif [[ "$(basename $filename .gz)" != "$filename" ]]; then + content_type="content-type: application/gzip" + elif [[ "$(basename $filename .txt)" != "$filename" ]]; then + content_type="content-type: text/plain" + elif [[ "$(basename $filename .log)" != "$filename" ]]; then + content_type="content-type: text/plain" + elif [[ "$(basename $filename .html)" != "$filename" ]]; then + content_type="content-type: text/html" + elif [[ "$(basename $filename .json)" != "$filename" ]]; then + content_type="content-type: application/json" + elif [[ "$(basename $filename .iso)" != "$filename" ]]; then + content_type="content-type: application/octet-stream" + else + # Default value... XXX KEBE ASKS use text/plain instead? + content_type="content-type: application/octet-stream" + fi + + # Caller should use quotes around this. + echo $content_type +} + function fatal { local msg="$*" @@ -290,7 +318,9 @@ function upload_strap verbose mmkdir -p "$mbdir" for file in $bits_dir/*; do - verbose mput -f $file $mbdir/$(basename $file) + filename="$(basename $file)" + verbose mput -H "$(content_type $filename)" -f $file \ + "$mbdir/$filename" done echo $mbdir | mput -H "content-type: text/plain" "$mdir/latest" diff --git a/tools/smartos-release b/tools/smartos-release index e00cc339a..cc0771453 100755 --- a/tools/smartos-release +++ b/tools/smartos-release @@ -7,6 +7,7 @@ # # Copyright 2020 Joyent, Inc. +# Copyright 2022 MNX Cloud, Inc. # # @@ -41,6 +42,34 @@ fi # --- support functions +function content_type +{ + filename="$1" + # basename <.ext> will strip .ext off. Will be == name if it's + # not .ext. + if [[ "$(basename $filename .tgz)" != "$filename" ]]; then + content_type="content-type: application/gzip" + elif [[ "$(basename $filename .gz)" != "$filename" ]]; then + content_type="content-type: application/gzip" + elif [[ "$(basename $filename .txt)" != "$filename" ]]; then + content_type="content-type: text/plain" + elif [[ "$(basename $filename .log)" != "$filename" ]]; then + content_type="content-type: text/plain" + elif [[ "$(basename $filename .html)" != "$filename" ]]; then + content_type="content-type: text/html" + elif [[ "$(basename $filename .json)" != "$filename" ]]; then + content_type="content-type: application/json" + elif [[ "$(basename $filename .iso)" != "$filename" ]]; then + content_type="content-type: application/octet-stream" + else + # Default value... XXX KEBE ASKS use text/plain instead? + content_type="content-type: application/octet-stream" + fi + + # Caller should use quotes around this. + echo $content_type +} + function fatal { echo "$(basename $0): error: $1" exit 1 @@ -98,14 +127,14 @@ BUILD_FILES="platform-${BRANCH}-${TIMESTAMP}.tgz index.html md5sums.txt" for file in ${BUILD_FILES}; do - mput -f ${BITS}/$file ${SMARTOS_RELEASE}/$file + mput -H "$(content_type $file) -f ${BITS}/$file ${SMARTOS_RELEASE}/$file done echo "Uploading 'latest' ${SMARTOS} objects to ${SMARTOS}" -mput -f $BITS/platform-${BRANCH}-${TIMESTAMP}.tgz ${SMARTOS}/platform-latest.tgz +mput -H "content-type: application/gzip" -f $BITS/platform-${BRANCH}-${TIMESTAMP}.tgz ${SMARTOS}/platform-latest.tgz mput -f $BITS/smartos-${TIMESTAMP}.iso ${SMARTOS}/smartos-latest.iso -mput -f $BITS/smartos-${TIMESTAMP}-USB.img.gz ${SMARTOS}/smartos-latest-USB.img.gz -mput -f $BITS/smartos-${TIMESTAMP}.vmwarevm.tar.gz ${SMARTOS}/smartos-latest.vmwarevm.tar.gz +mput -H "content-type: application/gzip" -f $BITS/smartos-${TIMESTAMP}-USB.img.gz ${SMARTOS}/smartos-latest-USB.img.gz +mput -H "content-type: application/gzip" -f $BITS/smartos-${TIMESTAMP}.vmwarevm.tar.gz ${SMARTOS}/smartos-latest.vmwarevm.tar.gz echo "Updating ${SMARTOS}/latest object" echo ${SMARTOS_RELEASE} | mput -H 'content-type: text/plain' ${SMARTOS}/latest From 66c4e6378311f83c2c48010b8dbe00580d7489ec Mon Sep 17 00:00:00 2001 From: Dan McDonald Date: Tue, 22 Nov 2022 09:53:19 -0500 Subject: [PATCH 2/3] submodule --- deps/eng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/eng b/deps/eng index e64e97054..02c1a2b8d 160000 --- a/deps/eng +++ b/deps/eng @@ -1 +1 @@ -Subproject commit e64e970546007111d0c5dd4ecb47070daa33b4ea +Subproject commit 02c1a2b8d33486b1631495fe13642cecf4d6ebe7 From f2bf1e374c7a01977208ec0abe2e40e2d61fd1fd Mon Sep 17 00:00:00 2001 From: Dan McDonald Date: Tue, 29 Nov 2022 12:11:12 -0500 Subject: [PATCH 3/3] Fix .iso type --- tools/build_ctftools | 2 +- tools/build_strap | 2 +- tools/smartos-release | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/build_ctftools b/tools/build_ctftools index d5f6be200..ccdf51304 100755 --- a/tools/build_ctftools +++ b/tools/build_ctftools @@ -42,7 +42,7 @@ function content_type elif [[ "$(basename $filename .json)" != "$filename" ]]; then content_type="content-type: application/json" elif [[ "$(basename $filename .iso)" != "$filename" ]]; then - content_type="content-type: application/octet-stream" + content_type="content-type: application/x-iso9660-image" else # Default value... XXX KEBE ASKS use text/plain instead? content_type="content-type: application/octet-stream" diff --git a/tools/build_strap b/tools/build_strap index c1f716add..1a88ddfef 100755 --- a/tools/build_strap +++ b/tools/build_strap @@ -64,7 +64,7 @@ function content_type elif [[ "$(basename $filename .json)" != "$filename" ]]; then content_type="content-type: application/json" elif [[ "$(basename $filename .iso)" != "$filename" ]]; then - content_type="content-type: application/octet-stream" + content_type="content-type: application/x-iso9660-image" else # Default value... XXX KEBE ASKS use text/plain instead? content_type="content-type: application/octet-stream" diff --git a/tools/smartos-release b/tools/smartos-release index cc0771453..eb1cc41fd 100755 --- a/tools/smartos-release +++ b/tools/smartos-release @@ -60,7 +60,7 @@ function content_type elif [[ "$(basename $filename .json)" != "$filename" ]]; then content_type="content-type: application/json" elif [[ "$(basename $filename .iso)" != "$filename" ]]; then - content_type="content-type: application/octet-stream" + content_type="content-type: application/x-iso9660-image" else # Default value... XXX KEBE ASKS use text/plain instead? content_type="content-type: application/octet-stream"