From 93da14508f1605ec28f1af40ae29da8a0ebedd9b Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Wed, 8 Apr 2020 09:57:41 +0100 Subject: [PATCH] kernel: Fix patch ordering Fix the `build-kernel.sh` script to sort patches correctly. Previously, it relied on `find(1)` for the ordering. However, `find(1)` does not guarantee any ordering of files within a directory. Since the ordering could therefore be "random", it was quite possible for patches to be applied in the wrong order, resulting in conflicts. Fixes: #1003. Signed-off-by: James O. D. Hunt --- kernel/build-kernel.sh | 15 ++++++++++++++- kernel/kata_config_version | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/build-kernel.sh b/kernel/build-kernel.sh index 16d5316827..a362508962 100755 --- a/kernel/build-kernel.sh +++ b/kernel/build-kernel.sh @@ -343,7 +343,20 @@ setup_kernel() { local patches_dir_for_version="${patches_path}/${major_kernel}.x" local kernel_patches="" if [ -d "${patches_dir_for_version}" ]; then - kernel_patches=$(find "${patches_dir_for_version}" -name '*.patch' -type f) + # Patches are expected to be named in the standard + # git-format-patch(1) format where the first part of the + # filename represents the patch ordering + # (lowest numbers apply first): + # + # "${number}-${dashed_description}" + # + # For example, + # + # 0001-fix-the-bad-thing.patch + # 0002-improve-the-fix-the-bad-thing-fix.patch + # 0003-correct-compiler-warnings.patch + kernel_patches=$(find "${patches_dir_for_version}" -name '*.patch' -type f |\ + sort -t- -k1,1n) else info "kernel patches directory does not exit" fi diff --git a/kernel/kata_config_version b/kernel/kata_config_version index 39f5b69311..ea70ce0134 100644 --- a/kernel/kata_config_version +++ b/kernel/kata_config_version @@ -1 +1 @@ -71 +72