From 96186e3c47e0bc3a255c4599a8693b2bf01de4ec Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Wed, 26 Jun 2013 10:51:42 -0400 Subject: [PATCH] fix(update_distfiles): Add --download option to for incremental updates Temporary workaround until we have a version of emirrordist that can operate directly on remote storage. Download the entire mirror (if it isn't already local) so emirrordist can make an incremental update. Not great but it will do for now. --- update_distfiles | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/update_distfiles b/update_distfiles index a61ba63c02..8b2fc316a8 100755 --- a/update_distfiles +++ b/update_distfiles @@ -10,6 +10,11 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) DEFINE_boolean dry_run ${FLAGS_FALSE} "Trial run, makes no changes." DEFINE_boolean upload ${FLAGS_FALSE} "Upload distfile mirror via gsutil." +# FIXME(marineam): We need to add gs support to emirrordist so it +# doesn't have to operate on a local copy of the complete mirror. +DEFINE_boolean download ${FLAGS_FALSE} \ + "Download the current mirror before making updates to it." + MIRROR_ROOT="${DEFAULT_BUILD_ROOT}/mirror" UPLOAD_ROOT="gs://storage.core-os.net/mirror" @@ -62,6 +67,28 @@ upload_mirror() { gsutil cp -a project-private \ "${local_mirror}/info/*" "${remote_mirror}/info" } +download_mirror() { + local repo_name="$1" + local local_mirror="${MIRROR_ROOT}/$repo_name" + local remote_mirror="${UPLOAD_ROOT}/$repo_name" + + info "Downloading public distfiles for $repo_name" + mkdir -p "${local_mirror}/"{distfiles,info} + gsutil -m cp -n \ + "${remote_mirror}/distfiles/*" "${local_mirror}/distfiles" + + info "Downloading private metadata for $repo_name" + gsutil cp "${remote_mirror}/info/*" "${local_mirror}/info" +} + +if [[ ${FLAGS_download} -eq ${FLAGS_TRUE} ]]; then + if [[ ! -f "$HOME/.boto" ]]; then + die_notrace "Please run gsutil config to create ~/.boto" + fi + for repo in "$@"; do + download_mirror "$repo" + done +fi for repo in "$@"; do if ! portageq get_repo_path / "$repo" >/dev/null; then @@ -70,6 +97,11 @@ for repo in "$@"; do update_local_mirror "$repo" done +if [[ ${FLAGS_dry_run} == ${FLAGS_TRUE} ]]; then + info "Dry-run complete." + exit +fi + if [[ ${FLAGS_upload} -eq ${FLAGS_TRUE} ]]; then if [[ ! -f "$HOME/.boto" ]]; then die_notrace "Please run gsutil config to create ~/.boto"