mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 19:56:32 +02:00
commit
663798c23d
82
update_distfiles
Executable file
82
update_distfiles
Executable file
@ -0,0 +1,82 @@
|
||||
#!/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.
|
||||
|
||||
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
|
||||
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
||||
|
||||
DEFINE_boolean dry_run ${FLAGS_FALSE} "Trial run, makes no changes."
|
||||
DEFINE_boolean upload ${FLAGS_FALSE} "Upload distfile mirror via gsutil."
|
||||
|
||||
MIRROR_ROOT="${DEFAULT_BUILD_ROOT}/mirror"
|
||||
UPLOAD_ROOT="gs://storage.core-os.net/mirror"
|
||||
|
||||
# Parse flags
|
||||
FLAGS "$@" || exit 1
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
switch_to_strict_mode
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
eval set -- portage-stable coreos
|
||||
fi
|
||||
|
||||
update_local_mirror() {
|
||||
local repo_name="$1"
|
||||
local repo_mirror="${MIRROR_ROOT}/$repo_name"
|
||||
local extra_flags=""
|
||||
|
||||
if [[ ${FLAGS_dry_run} == ${FLAGS_TRUE} ]]; then
|
||||
info "Pretend distfiles update for $repo_name"
|
||||
extra_flags+=" --dry-run "
|
||||
else
|
||||
info "Starting distfiles update for $repo_name"
|
||||
fi
|
||||
|
||||
mkdir -p "${repo_mirror}/"{distfiles,info,log}
|
||||
emirrordist --mirror --verbose $extra_flags \
|
||||
--jobs=${NUM_JOBS} --repo="${repo_name}" \
|
||||
--distfiles="${repo_mirror}/distfiles" \
|
||||
--distfiles-local="/var/lib/portage/distfiles" \
|
||||
--fetch-log-dir="${repo_mirror}/log" \
|
||||
--failure-log="${repo_mirror}/log/failure.log" \
|
||||
--success-log="${repo_mirror}/log/success.log" \
|
||||
--scheduled-deletion-log="${repo_mirror}/log/deletion.log" \
|
||||
--deletion-db="${repo_mirror}/info/deletion.db" \
|
||||
--distfiles-db="${repo_mirror}/info/distfiles.db" \
|
||||
--deletion-delay=$((86400 * 14)) \
|
||||
--restrict-mirror-exemptions="gentoo" \
|
||||
--verify-existing-digest
|
||||
}
|
||||
upload_mirror() {
|
||||
local repo_name="$1"
|
||||
local local_mirror="${MIRROR_ROOT}/$repo_name"
|
||||
local remote_mirror="${UPLOAD_ROOT}/$repo_name"
|
||||
|
||||
info "Uploading public distfiles for $repo_name"
|
||||
gsutil -m cp -n \
|
||||
"${local_mirror}/distfiles/*" "${remote_mirror}/distfiles"
|
||||
|
||||
info "Uploading private metadata for $repo_name"
|
||||
gsutil cp -a project-private \
|
||||
"${local_mirror}/info/*" "${remote_mirror}/info"
|
||||
}
|
||||
|
||||
for repo in "$@"; do
|
||||
if ! portageq get_repo_path / "$repo" >/dev/null; then
|
||||
die_notrace "Unknown repo name '$repo'"
|
||||
fi
|
||||
update_local_mirror "$repo"
|
||||
done
|
||||
|
||||
if [[ ${FLAGS_upload} -eq ${FLAGS_TRUE} ]]; then
|
||||
if [[ ! -f "$HOME/.boto" ]]; then
|
||||
die_notrace "Please run gsutil config to create ~/.boto"
|
||||
fi
|
||||
for repo in "$@"; do
|
||||
upload_mirror "$repo"
|
||||
done
|
||||
fi
|
||||
|
||||
info "Done!"
|
||||
@ -13,6 +13,9 @@ DEFINE_string portage_stable "${SRC_ROOT}/third_party/portage-stable" \
|
||||
"Path to the portage-stable git checkout."
|
||||
DEFINE_string cvsroot ":pserver:anonymous@anoncvs.gentoo.org:/var/cvsroot" \
|
||||
"CVS location for gentoo-x86 to use when --portage isn't provided."
|
||||
DEFINE_boolean commit ${FLAGS_FALSE} \
|
||||
"Commit all changes after updating portage-stable."
|
||||
|
||||
|
||||
# Parse flags
|
||||
FLAGS "$@" || exit 1
|
||||
@ -55,4 +58,19 @@ for pkg in "$@"; do
|
||||
|
||||
# TODO(marineam): Update metadata directory?
|
||||
done
|
||||
git status
|
||||
|
||||
if [[ $FLAGS_commit -eq $FLAGS_TRUE ]]; then
|
||||
if [[ $# -eq 1 ]]; then
|
||||
git commit -e -m "bump($1): sync with upstream"
|
||||
else
|
||||
cat > .git/COMMIT_EDITMSG <<EOF
|
||||
bump($1): sync with upstream
|
||||
|
||||
Packages updated:
|
||||
$(for p in "$@"; do echo " $p"; done | sort)
|
||||
EOF
|
||||
fi
|
||||
git commit -e -F .git/COMMIT_EDITMSG
|
||||
else
|
||||
git status
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user