packaging: Restrict kernel patches applied to top-level dir

The apply_patches.sh script applies all patches in the patches
directory,  as well as subdirectories. This means if there is a sub-dir
called "experimental" under a major kernel version directory,
experimental patches would be applied to the default kernel supported by
Kata.
We did not come accross this issue earlier as typically the experimental
kernel version was different from the default kernel.
With both the default kernel and the arm-experimental kernel having the
same major kernel version (5.15.x) at this time, trying to update the
kernel patch version revealed that arm-experimental patches were being
applied to the default kernel.

Restricting the patches to be applied to the top level directory will
solve the issue. The apply_patches script should ignore any
sub-directories meant for experimental patches.

Fixes #4520

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde 2022-06-23 10:17:07 -07:00
parent 07b1367c2b
commit 93874cb3bb
2 changed files with 3 additions and 3 deletions

View File

@ -47,7 +47,7 @@ Options:
-g <vendor> : GPU vendor, intel or nvidia. -g <vendor> : GPU vendor, intel or nvidia.
-h : Display this help. -h : Display this help.
-k <path> : Path to kernel to build. -k <path> : Path to kernel to build.
-p <path> : Path to a directory with patches to apply to kernel. -p <path> : Path to a directory with patches to apply to kernel, only patches in top-level directory are applied.
-t <hypervisor> : Hypervisor_target. -t <hypervisor> : Hypervisor_target.
-v <version> : Kernel version to use if kernel path not provided. -v <version> : Kernel version to use if kernel path not provided.
``` ```
@ -76,7 +76,7 @@ $ ./build-kernel.sh setup
The script `./build-kernel.sh` tries to apply the patches from The script `./build-kernel.sh` tries to apply the patches from
`${GOPATH}/src/github.com/kata-containers/kata-containers/tools/packaging/kernel/patches/` when it `${GOPATH}/src/github.com/kata-containers/kata-containers/tools/packaging/kernel/patches/` when it
sets up a kernel. If you want to add a source modification, add a patch on this sets up a kernel. If you want to add a source modification, add a patch on this
directory. directory. Patches present in the top-level directory are applied, with subdirectories being ignored.
The script also adds a kernel config file from The script also adds a kernel config file from
`${GOPATH}/src/github.com/kata-containers/kata-containers/tools/packaging/kernel/configs/` to `.config` `${GOPATH}/src/github.com/kata-containers/kata-containers/tools/packaging/kernel/configs/` to `.config`

View File

@ -36,7 +36,7 @@ fi
echo "INFO: Apply patches from $patches_dir" echo "INFO: Apply patches from $patches_dir"
if [ -d "$patches_dir" ]; then if [ -d "$patches_dir" ]; then
patches=($(find "$patches_dir" -name '*.patch'|sort -t- -k1,1n)) patches=($(find "$patches_dir" -maxdepth 1 -name '*.patch'|sort -t- -k1,1n))
echo "INFO: Found ${#patches[@]} patches" echo "INFO: Found ${#patches[@]} patches"
for patch in ${patches[@]}; do for patch in ${patches[@]}; do
echo "INFO: Apply $patch" echo "INFO: Apply $patch"