From e989e7ee4e0f7a4b838dc0ef80a5f1e237db2113 Mon Sep 17 00:00:00 2001 From: Emanuel Lima Date: Mon, 7 Oct 2024 15:23:02 -0300 Subject: [PATCH] build: Fix RPM build fail due to AGENT_POLICY By checking for AGENT_POLICY we ensure we only try to read allow-all.rego if AGENT_POLICY is set to "yes" Signed-off-by: Emanuel Lima --- tools/osbuilder/rootfs-builder/rootfs.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/osbuilder/rootfs-builder/rootfs.sh b/tools/osbuilder/rootfs-builder/rootfs.sh index 21816a2cf3..04a855a0ce 100755 --- a/tools/osbuilder/rootfs-builder/rootfs.sh +++ b/tools/osbuilder/rootfs-builder/rootfs.sh @@ -39,7 +39,9 @@ PAUSE_IMAGE_TARBALL=${PAUSE_IMAGE_TARBALL:-""} lib_file="${script_dir}/../scripts/lib.sh" source "$lib_file" -agent_policy_file="$(readlink -f -v "${AGENT_POLICY_FILE:-"${script_dir}/../../../src/kata-opa/allow-all.rego"}")" +if [[ "${AGENT_POLICY}" == "yes" ]]; then + agent_policy_file="$(readlink -f -v "${AGENT_POLICY_FILE:-"${script_dir}/../../../src/kata-opa/allow-all.rego"}")" +fi #For cross build CROSS_BUILD=${CROSS_BUILD:-false} @@ -361,7 +363,9 @@ check_env_variables() [ -n "${KERNEL_MODULES_DIR}" ] && [ ! -d "${KERNEL_MODULES_DIR}" ] && die "KERNEL_MODULES_DIR defined but is not an existing directory" - [ ! -f "${agent_policy_file}" ] && die "agent policy file not found in '${agent_policy_file}'" + if [[ "${AGENT_POLICY}" == "yes" ]]; then + [ ! -f "${agent_policy_file}" ] && die "agent policy file not found in '${agent_policy_file}'" + fi [ -n "${OSBUILDER_VERSION}" ] || die "need osbuilder version" } @@ -724,7 +728,7 @@ EOF fi fi - if [ "${AGENT_POLICY}" == "yes" ]; then + if [[ "${AGENT_POLICY}" == "yes" ]]; then info "Install the default policy" # Install default settings for the kata-opa service. local opa_settings_dir="/etc/kata-opa"