diff --git a/build_library/board_options.sh b/build_library/board_options.sh index c5eb928289..4a706781d4 100644 --- a/build_library/board_options.sh +++ b/build_library/board_options.sh @@ -13,3 +13,14 @@ ARCH=$(get_board_arch ${BOARD}) # What cross-build are we targeting? . "${BOARD_ROOT}/etc/portage/make.conf" + +# check if any of the given use flags are enabled for a pkg +pkg_use_enabled() { + local pkg="$1" + shift + # for every flag argument, turn it into `-e ^+flag` for grep + local grep_args="${@/#/-e ^+}" + + equery-"${BOARD}" -q uses "${pkg}" | grep -q ${grep_args} + return $? +} diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index 847f81e491..fb0a20bd6c 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -299,8 +299,8 @@ finish_image() { fi # Build the selinux policy - if [[ "$BOARD" = amd64* ]]; then - sudo chroot ${root_fs_dir} bash -c "cd /usr/share/selinux/mcs; semodule -i *.pp" + if pkg_use_enabled coreos-base/coreos selinux; then + sudo chroot "${root_fs_dir}" bash -c "cd /usr/share/selinux/mcs && semodule -i *.pp" fi # We only need to disable rw and apply dm-verity in prod with a /usr partition diff --git a/build_packages b/build_packages index 0a9f2ad8e7..b8d6e3cb6f 100755 --- a/build_packages +++ b/build_packages @@ -168,17 +168,6 @@ if [[ ${#CROS_WORKON_PKGS[@]} -gt 0 ]]; then ) fi -# check if any of the given use flags are enabled for a pkg -pkg_use_enabled() { - local pkg="$1" - shift - # for every flag argument, turn it into `-e ^+flag` for grep - local grep_args="${@/#/-e ^+}" - - equery-"${BOARD}" -q uses "${pkg}" | grep -q ${grep_args} - return $? -} - # Goo to attempt to resolve dependency loops on individual packages. # If this becomes insufficient we will need to move to a full multi-stage # bootstrap process like we do with the SDK via catalyst.