Skip to content

Commit f4be446

Browse files
committed
build_library: Pass --selinux flag to build_sysext
Signed-off-by: Krzesimir Nowak <knowak@microsoft.com>
1 parent 1e5adbd commit f4be446

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

build_library/prod_image_util.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
55

6+
source "${BUILD_LIBRARY_DIR}/pkg_util.sh" || exit 1
7+
68
# Lookup the current version of a binary package, downloading it if needed.
79
# Usage: get_binary_pkg some-pkg/name
810
# Prints: some-pkg/name-1.2.3
@@ -222,6 +224,14 @@ create_prod_tar() {
222224
create_prod_sysexts() {
223225
local image_name="$1"
224226
local image_sysext_base="${image_name%.bin}_sysext.squashfs"
227+
local -a extra_args
228+
229+
local selinux=''
230+
if is_selinux_enabled "${BOARD}"; then
231+
selinux=x
232+
fi
233+
234+
local sysext
225235
for sysext in "${EXTRA_SYSEXTS[@]}"; do
226236
local name pkgs useflags arches
227237
IFS="|" read -r name pkgs useflags arches <<< "$sysext"
@@ -230,9 +240,13 @@ create_prod_sysexts() {
230240
local arch_array=(${arches//,/ })
231241
local useflags_array=(${useflags//,/ })
232242

243+
extra_args=()
233244
local mangle_script="${BUILD_LIBRARY_DIR}/sysext_mangle_${name}"
234-
if [[ ! -x "${mangle_script}" ]]; then
235-
mangle_script=
245+
if [[ -x "${mangle_script}" ]]; then
246+
extra_args+=( --manglefs_script="${mangle_script}" )
247+
fi
248+
if [[ -n ${selinux} ]]; then
249+
extra_args+=( --selinux )
236250
fi
237251

238252
if [[ -n "$arches" ]]; then
@@ -248,8 +262,8 @@ create_prod_sysexts() {
248262
fi
249263

250264
sudo rm -f "${BUILD_DIR}/${name}.raw" \
251-
"${BUILD_DIR}/flatcar-test-update-${name}.gz" \
252-
"${BUILD_DIR}/${name}_*"
265+
"${BUILD_DIR}/flatcar-test-update-${name}.gz" \
266+
"${BUILD_DIR}/${name}_*"
253267
# we use -E to pass the USE flags, but also MODULES_SIGN variables
254268
#
255269
# The --install_root_basename="${name}-extra-sysext-rootfs" flag
@@ -260,8 +274,8 @@ create_prod_sysexts() {
260274
--squashfs_base="${BUILD_DIR}/${image_sysext_base}" \
261275
--image_builddir="${BUILD_DIR}" \
262276
--install_root_basename="${name}-extra-sysext-rootfs" \
263-
${mangle_script:+--manglefs_script=${mangle_script}} \
264277
--forbidden_packages='sec-policy/selinux-.*;selinux policy packages must be in base image' \
278+
"${extra_args[@]}" \
265279
"${name}" "${pkg_array[@]}"
266280
delta_generator \
267281
-private_key "/usr/share/update_engine/update-payload-key.key.pem" \

build_library/sysext_prod_builder

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ assert_inside_chroot
1616
switch_to_strict_mode
1717

1818
. "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1
19+
. "${BUILD_LIBRARY_DIR}/pkg_util.sh" || exit 1
1920

2021
# Create a sysext from a package and install it to the OS image.
2122
# Conventions:
@@ -54,6 +55,13 @@ create_prod_sysext() {
5455
msg="${msg}, FS mangle script 'sysext_mangle_${name}'"
5556
fi
5657

58+
if is_selinux_enabled "${BOARD}"; then
59+
build_sysext_opts+=(
60+
--selinux
61+
--forbidden_packages='sec-policy/selinux-.*;selinux policy packages must be in base image'
62+
)
63+
fi
64+
5765
info "${msg}."
5866

5967
# Pass the build ID extracted from root FS to build_sysext. This prevents common.sh
@@ -69,7 +77,6 @@ create_prod_sysext() {
6977
--squashfs_base="${base_sysext}" \
7078
--generate_pkginfo \
7179
--install_root_basename="${name}-base-sysext-rootfs" \
72-
--forbidden_packages='sec-policy/selinux-.*;selinux policy packages must be in base image' \
7380
"${build_sysext_opts[@]}" \
7481
"${name}" "${grp_pkg[@]}"
7582

build_library/vm_image_util.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# Format options. Each variable uses the form IMG_<type>_<opt>.
66
# Default values use the format IMG_DEFAULT_<opt>.
77

8+
. "${BUILD_LIBRARY_DIR}/pkg_util.sh" || exit 1
9+
810
VALID_IMG_TYPES=(
911
akamai
1012
ami
@@ -593,6 +595,9 @@ install_oem_sysext() {
593595
--install_root_basename="${VM_IMG_TYPE}-oem-sysext-rootfs"
594596
--forbidden_packages='sec-policy/selinux-.*;selinux policy packages must be in base image' \
595597
)
598+
if is_selinux_enabled "${BOARD}"; then
599+
build_sysext_flags+=( --selinux )
600+
fi
596601
local overlay_path mangle_fs
597602
overlay_path=$(portageq get_repo_path / coreos-overlay)
598603
mangle_fs="${overlay_path}/${metapkg}/files/manglefs.sh"

0 commit comments

Comments
 (0)