forked from flatcar/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebuild_packages
executable file
·86 lines (65 loc) · 2.2 KB
/
rebuild_packages
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Copyright (c) 2016 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
# Script must run inside the chroot
assert_inside_chroot
assert_not_root_user
# Developer-visible flags.
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to build packages for."
# include upload options
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
# Parse flags
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
switch_to_strict_mode
if [[ -z "${FLAGS_board}" ]]; then
echo "Error: --board is required."
exit 1
fi
check_gsutil_opts
# set BOARD and BOARD_ROOT
. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1
declare -A repo_paths
for repo_name in $(portageq-$BOARD get_repos "${BOARD_ROOT}"); do
repo_paths[$repo_name]=$(portageq-$BOARD \
get_repo_path "${BOARD_ROOT}" "$repo_name")
done
rebuild_atoms=()
# a crazy format I can eval inside the loop
list_format='cp="$cp";cpv="$cpv";repo="$repo"'
for pkg_info in $(equery-$BOARD list --format="${list_format}" '*'); do
eval "$pkg_info"
pvr="${cpv#*/}"
pkg_ebuild="${BOARD_ROOT}/var/db/pkg/${cpv}/${pvr}.ebuild"
repo_ebuild="${repo_paths[$repo]}/${cp}/${pvr}.ebuild"
if [[ ! -f "${pkg_ebuild}" ]]; then
die "${pvr} installed but ${pkg_ebuild} is missing!!!"
fi
if [[ ! -f "${repo_ebuild}" ]]; then
error "${pvr} is installed but ${repo_ebuild} is missing."
error "Perhaps run build_packages --board=$BOARD"
exit 1
fi
if cmp -s "${pkg_ebuild}" "${repo_ebuild}"; then
continue
fi
info "${pvr}.ebuild has changed"
rebuild_atoms+=( "=${cpv}" )
done
if [[ "${#rebuild_atoms[@]}" -eq 0 ]]; then
info "No ebuild changes detected"
else
info "Rebuilding ${#rebuild_atoms[@]} packages..."
emerge-$BOARD --verbose "--jobs=${NUM_JOBS}" "${rebuild_atoms[@]}"
info "Checking build root"
test_image_content "${BOARD_ROOT}"
# upload packages if enabled
upload_packages
fi
command_completed