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.
This commit is contained in:
Michael Marineau 2013-06-26 10:51:42 -04:00
parent 663798c23d
commit 96186e3c47

View File

@ -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"