From 9e8cd7d6df88f9e9122e47cc3ff52fd7f210156c Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Thu, 25 Jul 2019 18:10:59 +0000 Subject: [PATCH] obs-packaging: support kernel fragments use `merge_config.sh` script to generate the final `.config` file if the `${arch}_kata_kvm_*` file doesn't exist. Signed-off-by: Julio Montes --- obs-packaging/linux-container/debian.rules | 8 ++++++++ .../linux-container/kata-linux-container.spec-template | 9 ++++++++- obs-packaging/linux-container/update.sh | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/obs-packaging/linux-container/debian.rules b/obs-packaging/linux-container/debian.rules index 42545c1c13..98b74db6d2 100755 --- a/obs-packaging/linux-container/debian.rules +++ b/obs-packaging/linux-container/debian.rules @@ -17,7 +17,15 @@ override_dh_auto_build: tar xzf /usr/src/packages/SOURCES/$(KERNEL_CONFIGS).tar.gz rm -f .config find $(KERNEL_CONFIGS) -name "$(KERNEL_ARCH)_kata_kvm_*" -exec cp {} .config \; + if [ ! -f .config ]; then + # Use fragments to generate the .config + frag_dir="kata-kernel-configs/fragments" + err_msg="not in final" + r="$(KCONFIG_CONFIG=.config ARCH=${kernelArch} scripts/kconfig/merge_config.sh -r -n ${frag_dir}/common/* ${frag_dir}/${kernelArch}/* | grep "${err_msg}")" || true + [ -z "${r}" ] || (@echo "ERROR: ${r}"; exit 1) + fi [ -f .config ] || (@echo "ERROR: cannot find the kernel config file for the $(KERNEL_ARCH) architecture"; exit 1) + # https://github.com/kata-containers/packaging/issues/394 enable reproducible builds: export KBUILD_BUILD_USER=katabuilduser export KBUILD_BUILD_HOST=katabuildhost diff --git a/obs-packaging/linux-container/kata-linux-container.spec-template b/obs-packaging/linux-container/kata-linux-container.spec-template index dac7d1c79a..5d2eea875b 100644 --- a/obs-packaging/linux-container/kata-linux-container.spec-template +++ b/obs-packaging/linux-container/kata-linux-container.spec-template @@ -80,7 +80,14 @@ BuildKernel() { # Runtime .config selection based on kernelArch rm -f .config find kata-kernel-configs -name "${kernelArch}_kata_kvm_*" -exec cp {} .config \; - [ -f .config ] || (echo "ERROR: cannot find the kernel config file for the ${kernelArch} architecture"; exit 1) + if [ ! -f .config ]; then + # Use fragments to generate the .config + frag_dir="kata-kernel-configs/fragments" + err_msg="not in final" + r="$(KCONFIG_CONFIG=.config ARCH=${kernelArch} scripts/kconfig/merge_config.sh -r -n ${frag_dir}/common/* ${frag_dir}/${kernelArch}/* | grep "${err_msg}")" || true + [ -z "${r}" ] || (echo "ERROR: ${r}"; exit 1) + fi + [ -f .config ] || (echo "ERROR: cannot find the kernel config file for the ${kernelArch} architecture"; exit 1) %if 0%{?rhel_version} || 0%{?suse_version} # RHEL in OBS has updated gcc. diff --git a/obs-packaging/linux-container/update.sh b/obs-packaging/linux-container/update.sh index ad612c932b..874a039a76 100755 --- a/obs-packaging/linux-container/update.sh +++ b/obs-packaging/linux-container/update.sh @@ -50,10 +50,10 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}") kernel_sha256=$(curl -L -s -f ${KR_SHA} | awk '/linux-'${VERSION}'.tar.xz/ {print $1}') -# Copy the kernel config files for all architecture +# Copy the kernel config files and fragments for all architecture mkdir -p configs readonly configs_dir="kernel/configs" -find "${SCRIPT_DIR}/../../${configs_dir}" -name "*_kata_kvm_${KR_LTS}.x" -exec tar --transform="s,${configs_dir},${KR_CONFIGS}," -czf ${KR_CONFIGS}.tar.gz {} + +find "${SCRIPT_DIR}/../../${configs_dir}" \( -name "*_kata_kvm_${KR_LTS}.x" -o -name fragments \) -exec tar --transform="s,${configs_dir},${KR_CONFIGS}," -czf ${KR_CONFIGS}.tar.gz {} + replace_list=( "VERSION=${VERSION}"