flatcar-scripts/sdk_lib/sdk_util.sh
Michael Marineau 2e9911b978 fix(*): Migrate image storage to new buckets
- Automated builds drop SDK and binary packages into
  gs://builds.developer.core-os.net/ and the new download URL is
  http://builds.developer.core-os.net/ (COREOS_DEV_BUILDS)
- Change default upload path to gs://users.developer.core-os.net/ for
  misc developer builds. Official builds go elsewhere and will just be
  configured in buildbot/jenkins so some COREOS_OFFICIAL stuff is gone.
- Automated builds of images go to a private bucket,
  gs://builds.release.core-os.net which later gets copied to
  gs://alpha.release.core-os.net and friends by core_promote.
2014-05-21 13:21:07 -07:00

60 lines
1.9 KiB
Bash

#!/bin/bash
# Copyright (c) 2013 The CoreOS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# common.sh must be properly sourced before this file.
[[ -n "${COREOS_SDK_VERSION}" ]] || exit 1
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="${COREOS_DEV_BUILDS}/sdk/${COREOS_SDK_ARCH}/${COREOS_SDK_VERSION}/${COREOS_SDK_TARBALL}"
# Download the current SDK tarball (if required) and verify digests/sig
sdk_download_tarball() {
if sdk_verify_digests; then
return 0
fi
info "Downloading ${COREOS_SDK_TARBALL}"
info "URL: ${COREOS_SDK_URL}"
local suffix
for suffix in "" ".DIGESTS"; do # TODO(marineam): download .asc
wget --tries=3 --timeout=30 --continue \
-O "${COREOS_SDK_TARBALL_PATH}${suffix}" \
"${COREOS_SDK_URL}${suffix}" \
|| die_notrace "SDK download failed!"
done
sdk_verify_digests || die_notrace "SDK digest verification failed!"
sdk_clean_cache
}
sdk_verify_digests() {
if [[ ! -f "${COREOS_SDK_TARBALL_PATH}" || \
! -f "${COREOS_SDK_TARBALL_PATH}.DIGESTS" ]]; then
return 1
fi
# TODO(marineam): Add gpg signature verification too.
verify_digests "${COREOS_SDK_TARBALL_PATH}" || return 1
}
sdk_clean_cache() {
pushd "${COREOS_SDK_TARBALL_CACHE}" >/dev/null
local filename
for filename in *; do
if [[ "${filename}" == "${COREOS_SDK_TARBALL}"* ]]; then
continue
fi
info "Cleaning up ${filename}"
# Not a big deal if this fails
rm -f "${filename}" || true
done
popd >/dev/null
}