mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-06 20:47:00 +02:00
Most of this hinges on the --upload option being passed, and it never is any more. Much of it also uses Google Buckets, which we no longer use, save for some GCE-specific bits. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
91 lines
2.4 KiB
Bash
Executable File
91 lines
2.4 KiB
Bash
Executable File
#!/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."
|
|
|
|
MIRROR_ROOT="${DEFAULT_BUILD_ROOT}/mirror"
|
|
|
|
# Parse flags
|
|
FLAGS "$@" || exit 1
|
|
eval set -- "${FLAGS_ARGV}"
|
|
switch_to_strict_mode
|
|
|
|
declare -A repos=(
|
|
[portage-stable]="portage-stable"
|
|
[coreos-overlay]="coreos"
|
|
)
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
set -- "${!repos[@]}"
|
|
fi
|
|
|
|
EXIT_CODE=0
|
|
|
|
|
|
update_local_mirror() {
|
|
local repo_name="$1"
|
|
local repo_mirror="${MIRROR_ROOT}/${repos[$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
|
|
|
|
rm -rf "${repo_mirror}/log" # clear old logs
|
|
mkdir -p "${repo_mirror}/"{distfiles,info,log,tmp}
|
|
emirrordist --mirror --verbose $extra_flags \
|
|
--jobs=${NUM_JOBS} --repo="${repo_name}" \
|
|
--distfiles="${repo_mirror}/distfiles" \
|
|
--distfiles-local="$(portageq envvar DISTDIR)" \
|
|
--fetch-log-dir="${repo_mirror}/log" \
|
|
--failure-log="${repo_mirror}/log/failure.log" \
|
|
--success-log="${repo_mirror}/log/success.log" \
|
|
--distfiles-db="${repo_mirror}/info/distfiles.db" \
|
|
--restrict-mirror-exemptions="gentoo" \
|
|
--temp-dir="${repo_mirror}/tmp" \
|
|
--verify-existing-digest
|
|
|
|
if [[ ! -s "${repo_mirror}/log/failure.log" ]]; then
|
|
info "Completed distfiles update for $repo_name without error"
|
|
return
|
|
fi
|
|
|
|
# report what went wrong :(
|
|
local lastpkg pkg file error
|
|
while read pkg file error; do
|
|
local log="${repo_mirror}/log/${file}.log"
|
|
if [[ "${pkg}" != "${lastpkg}" ]]; then
|
|
error "${pkg} failed:"
|
|
lastpkg="${pkg}"
|
|
fi
|
|
error " ${file} ${error}"
|
|
[[ -s "${log}" ]] && cat "${log}"
|
|
done <"${repo_mirror}/log/failure.log"
|
|
|
|
EXIT_CODE=1
|
|
}
|
|
|
|
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_dry_run} == ${FLAGS_TRUE} ]]; then
|
|
info "Dry-run complete."
|
|
exit
|
|
fi
|
|
|
|
command_completed
|
|
exit $EXIT_CODE
|