From 50e54cea859efea796c3fab5303f465174496ae7 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Thu, 6 Feb 2014 13:51:09 -0800 Subject: [PATCH] fix(release_util): Move default upload root to common, add --upload_root Make it possible for other scripts to share the same value for our release repository and equally easy to override with a custom value. Also allow setting the root from the command line in addition to the environment. Usually --upload_root is better to use than --upload_path. --- build_library/release_util.sh | 17 +++++++++++++++-- common.sh | 7 +++++++ core_upload_update | 4 ++-- sdk_lib/sdk_util.sh | 3 +-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/build_library/release_util.sh b/build_library/release_util.sh index b9790bb7fc..1015438b54 100644 --- a/build_library/release_util.sh +++ b/build_library/release_util.sh @@ -3,7 +3,7 @@ # found in the LICENSE file. GSUTIL_OPTS= -UPLOAD_ROOT="${COREOS_UPLOAD_ROOT:-gs://storage.core-os.net/coreos}" +UPLOAD_ROOT= UPLOAD_PATH= UPLOAD_DEFAULT=${FLAGS_FALSE} if [[ ${COREOS_OFFICIAL:-0} -eq 1 ]]; then @@ -17,8 +17,10 @@ DEFINE_boolean parallel ${FLAGS_TRUE} \ "Enable parallelism in gsutil." DEFINE_boolean upload ${UPLOAD_DEFAULT} \ "Upload all packages/images via gsutil." +DEFINE_string upload_root "${COREOS_UPLOAD_ROOT}" \ + "Upload prefix, board/version/etc will be appended. Must be a gs:// URL." DEFINE_string upload_path "" \ - "Upload files to an alternative location. Must be a full gs:// URL." + "Full upload path, overrides --upload_root. Must be a full gs:// URL." DEFINE_string sign_digests "" \ "Sign image DIGESTS files with the given GPG key." @@ -29,7 +31,18 @@ check_gsutil_opts() { GSUTIL_OPTS="-m" fi + if [[ -n "${FLAGS_upload_root}" ]]; then + if [[ "${FLAGS_upload_root}" != gs://* ]]; then + die_notrace "--upload_root must be a gs:// URL" + fi + # Make sure the path doesn't end with a slash + UPLOAD_ROOT="${FLAGS_upload_root%%/}" + fi + if [[ -n "${FLAGS_upload_path}" ]]; then + if [[ "${FLAGS_upload_path}" != gs://* ]]; then + die_notrace "--upload_path must be a gs:// URL" + fi # Make sure the path doesn't end with a slash UPLOAD_PATH="${FLAGS_upload_path%%/}" fi diff --git a/common.sh b/common.sh index bd94e09500..c7201ea148 100644 --- a/common.sh +++ b/common.sh @@ -328,6 +328,13 @@ COREOS_VERSION_STRING="${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}" readonly COREOS_EPOCH=1372636800 TODAYS_VERSION=$(( (`date +%s` - ${COREOS_EPOCH}) / 86400 )) +# Builds are uploaded to our Google Cloud Storage space, +# can be overridden from the environment. +: ${COREOS_UPLOAD_ROOT:=gs://storage.core-os.net/coreos} + +# And the corresponding http download url +: ${COREOS_DOWNLOAD_ROOT:=http://storage.core-os.net/coreos} + # Load developer's custom settings. Default location is in scripts dir, # since that's available both inside and outside the chroot. By convention, # settings from this file are variables starting with 'CHROMEOS_' diff --git a/core_upload_update b/core_upload_update index 9310fe0e03..5cf866fc88 100755 --- a/core_upload_update +++ b/core_upload_update @@ -77,5 +77,5 @@ core-admin new-version \ # Copy the vagrant boxes and pre-built images over to the track mirror gsutil cp \ - "gs://storage.core-os.net/coreos/amd64-generic/${FLAGS_version}/*" \ - "gs://storage.core-os.net/coreos/amd64-generic/${FLAGS_track}/" + "${COREOS_UPLOAD_ROOT}/amd64-generic/${FLAGS_version}/*" \ + "${COREOS_UPLOAD_ROOT}/amd64-generic/${FLAGS_track}/" diff --git a/sdk_lib/sdk_util.sh b/sdk_lib/sdk_util.sh index 401b818d52..1dd4ff0376 100644 --- a/sdk_lib/sdk_util.sh +++ b/sdk_lib/sdk_util.sh @@ -11,8 +11,7 @@ COREOS_SDK_ARCH="amd64" # We are unlikely to support anything else. COREOS_SDK_TARBALL="coreos-sdk-${COREOS_SDK_ARCH}-${COREOS_SDK_VERSION}.tar.bz2" COREOS_SDK_TARBALL_CACHE="${REPO_CACHE_DIR}/sdks" COREOS_SDK_TARBALL_PATH="${COREOS_SDK_TARBALL_CACHE}/${COREOS_SDK_TARBALL}" -COREOS_SDK_URL_PREFIX="http://storage.core-os.net/coreos/sdk" -COREOS_SDK_URL="${COREOS_SDK_URL_PREFIX}/${COREOS_SDK_ARCH}/${COREOS_SDK_VERSION}/${COREOS_SDK_TARBALL}" +COREOS_SDK_URL="${COREOS_DOWNLOAD_ROOT}/sdk/${COREOS_SDK_ARCH}/${COREOS_SDK_VERSION}/${COREOS_SDK_TARBALL}" # Download the current SDK tarball (if required) and verify digests/sig sdk_download_tarball() {