forked from flatcar/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_metadata
executable file
·53 lines (41 loc) · 1.31 KB
/
update_metadata
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Copyright (c) 2014 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 commit ${FLAGS_FALSE} \
"Commit all changes after updating."
# Parse flags
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
switch_to_strict_mode
if [[ $# -eq 0 ]]; then
eval set -- portage-stable coreos-overlay
fi
update_overlay() {
local repo_name="$1"
local repo_path=$(portageq get_repo_path / "${repo_name}")
local job_opts=$(portageq envvar MAKEOPTS)
info "Updating metadata in ${repo_name}..."
egencache ${job_opts} --repo="${repo_name}" --update
pushd "${repo_path}" >/dev/null
git add -A metadata/md5-cache
if git diff --quiet --cached; then
info "Nothing to update in ${repo_name}"
return 0
fi
if [[ ${FLAGS_commit} -eq ${FLAGS_TRUE} ]]; then
git commit -m "chore(metadata): Regenerate cache" metadata/md5-cache
else
git status metadata/md5-cache
fi
popd >/dev/null
}
for repo in "$@"; do
if ! portageq get_repo_path / "$repo" >/dev/null; then
die_notrace "Unknown repo name '$repo'"
fi
update_overlay "$repo"
done
command_completed