Skip to content

Commit 2e2070c

Browse files
authored
Merge pull request #1491 from flatcar/t-lo/build-dev-packages
T lo/build dev packages
2 parents 80a25d7 + d52d89d commit 2e2070c

File tree

3 files changed

+104
-2
lines changed

3 files changed

+104
-2
lines changed

build_dev_binpkgs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
# Copyright (c) 2023 by the Flatcar Maintainers.
3+
# Use of this source code is governed by the Apache 2.0 license.
4+
5+
. "$(dirname "$0")/common.sh" || exit 1
6+
7+
# Script must run inside the chroot
8+
assert_inside_chroot
9+
assert_not_root_user
10+
11+
# Dependencies and packages to include by default.
12+
packages_default=( "coreos-devel/board-packages" )
13+
14+
# Packages that are rdeps of the above but should not be included.
15+
# (mostly large packages, e.g. programming languages etc.)
16+
skip_packages_default="dev-lang/rust,virtual/rust,dev-lang/go,dev-lang/go-bootstrap,dev-go/go-md2man"
17+
18+
19+
# Developer-visible flags.
20+
DEFINE_string board "${DEFAULT_BOARD}" \
21+
"The board to build packages for."
22+
DEFINE_string skip_packages "${skip_packages_default[@]}" \
23+
"Comma-separated list of packages in the dependency tree to skip."
24+
DEFINE_boolean pretend "${FLAGS_FALSE}" \
25+
"List packages that would be built but do not actually build."
26+
27+
FLAGS_HELP="usage: $(basename $0) [flags] [packages]
28+
29+
build_dev_binpkgs builds binary packages for all dependencies of [packages]
30+
that are not present in '/build/<board>/var/lib/portage/pkgs/'.
31+
Useful for publishing a complete set of packages to a binhost.
32+
33+
[packages] defaults to '${packages_default}' if not specified.
34+
"
35+
36+
# Parse command line
37+
FLAGS "$@" || exit 1
38+
eval set -- "${FLAGS_ARGV}"
39+
40+
# Die on any errors.
41+
switch_to_strict_mode
42+
43+
if [[ $# -eq 0 ]]; then
44+
set -- "${packages_default[@]}"
45+
fi
46+
# --
47+
48+
function my_board_emerge() {
49+
PORTAGE_CONFIGROOT="/build/${FLAGS_board}" SYSROOT="${SYSROOT:-/build/${FLAGS_board}}" ROOT="/build/${FLAGS_board}" sudo -E emerge --root-deps=rdeps "${@}"
50+
}
51+
# --
52+
53+
pkg_build_list="$(mktemp)"
54+
pkg_skipped_list="${pkg_build_list}-skip"
55+
trap 'rm -f "${pkg_build_list}" "${pkg_skipped_list}"' EXIT
56+
57+
info "Collecting list of binpkgs to build"
58+
59+
my_board_emerge --pretend --root-deps=rdeps --emptytree ${@} \
60+
| grep '\[ebuild' \
61+
| sed 's/^\[[^]]\+\] \([^ :]\+\)*:.*/\1/' \
62+
| while read pkg; do
63+
if [ -f "/build/${FLAGS_board}/var/lib/portage/pkgs/${pkg}.tbz2" ] ; then
64+
continue
65+
fi
66+
skip=""
67+
for s in ${FLAGS_skip_packages//,/ }; do
68+
if [[ ${pkg} = ${s}-* ]] ; then
69+
echo -n "${pkg} " >> "${pkg_skipped_list}"
70+
skip="true"
71+
break
72+
fi
73+
done
74+
[[ -z ${skip} ]] || continue
75+
echo "=${pkg}" | tee -a "${pkg_build_list}" | sed 's/^/ /'
76+
done
77+
# --
78+
79+
if [ -f "${pkg_skipped_list}" ] ; then
80+
info "Skipping binpkgs '$(cat "${pkg_skipped_list}")' because these are in the skip list."
81+
fi
82+
83+
pretend=""
84+
if [[ "${FLAGS_pretend}" -eq "${FLAGS_TRUE}" ]]; then
85+
pretend="--pretend"
86+
fi
87+
88+
my_board_emerge --buildpkg ${pretend} $(cat "${pkg_build_list}")

build_packages

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ DEFINE_boolean skip_toolchain_update "${FLAGS_FALSE}" \
3636
"Don't update toolchain automatically."
3737
DEFINE_boolean skip_chroot_upgrade "${FLAGS_FALSE}" \
3838
"Don't run the chroot upgrade automatically; use with care."
39+
DEFINE_boolean only_resolve_circular_deps "${FLAGS_FALSE}" \
40+
"Don't build all packages; only resolve circular dependencies, then stop."
3941

4042
# include upload options
4143
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
@@ -275,6 +277,11 @@ if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_FALSE}" ]]; then
275277
net-libs/nghttp2 systemd
276278
fi
277279

280+
if [[ "${FLAGS_only_resolve_circular_deps}" -eq "${FLAGS_TRUE}" ]]; then
281+
info "Circular dependencies resolved. Stopping as requested."
282+
exit
283+
fi
284+
278285
export KBUILD_BUILD_USER="${BUILD_USER:-build}"
279286
export KBUILD_BUILD_HOST="${BUILD_HOST:-pony-truck.infra.kinvolk.io}"
280287

ci-automation/push_pkgs.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# This script will publish the packages from a pre-built packages container to
1313
# the buildcache server, effectively turning the build cache into a
1414
# binary packages server for the SDK.
15+
# Before pushing packages the script will run ./build_dev_binpkgs to ensure all
16+
# binary packages for the development container are actually built.
17+
# Note that this may build packages not previously built by the "build_packages"
18+
# step.
1519
#
1620
# PREREQUISITES:
1721
#
@@ -88,11 +92,14 @@ function _push_packages_impl() {
8892

8993
docker_image_from_buildcache "${packages}" "${docker_vernum}"
9094

95+
local my_name="flatcar-packages-publisher-${arch}-${docker_vernum}"
96+
./run_sdk_container -x ./ci-cleanup.sh -n "${my_name}" -C "${packages_image}" \
97+
./build_dev_binpkgs --board="${arch}-usr"
98+
9199
local cmd="source ci-automation/push_pkgs.sh"
92100
cmd="$cmd; image_build__copy_to_bincache '$arch' '$vernum'"
93101

94-
local my_name="flatcar-packages-publisher-${arch}-${docker_vernum}"
95-
./run_sdk_container -x ./ci-cleanup.sh -n "${my_name}" -C "${packages_image}" \
102+
./run_sdk_container -x ./ci-cleanup.sh -n "${my_name}" \
96103
bash -c "$cmd"
97104
}
98105
# --

0 commit comments

Comments
 (0)