kpatch: Allowing passing in KEYDIR and SRCDIR

When the '-k/--keydir' option is used, the variable KEYDIR will
still be the fixed value. Allow the customized value of KEYDIR
to be passed.
It's the same as '-s/--sourcedir' option and the variable SRCDIR.

Test-Plan:
PASS: build-pkgs -c -p kpatch
PASS: build-pkgs -c -p kpatch-prebuilt
PASS: build-pkgs -a --parallel 30
PASS: build-image
PASS: Jenkins installation
PASS: Setup the bullseye repo in /etc/apt/sources.list
PASS: sudo ostree admin unlock --hotfix
PASS: sudo apt install bison flex libssl-dev libelf-dev gcc make
      patch -y
PASS: Copy linux-source-5.10, linux-keys-5.10 and
      linux-image-5.10.0-6-amd64-dbg debian packages to target
PASS:
 mkdir -p kpatch-test/linux
 dpkg -X linux-[source|keys]-5.10....deb kpatch-test/linux
 dpkg -X linux-image-5.10.0-6-amd64-dbg...deb kpatch-test/linux
 cd kpatch-test/linux
 tar xf kpatch-test/linux/usr/src/linux-source-5.10.tar.xz

PASS: sudo kpatch-build
      -s kpatch-test/linux/linux-source-5.10
      -c /ostree/1/boot/config-5.10.0-6-amd64
      -v kpatch-test/linux/usr/lib/debug/boot/vmlinux-5.10.0-6-amd64
      -k kpatch-test/linux/usr/src/kernels/5.10.0-6-amd64
      /var/lib/kpatch/test/meminfo-string.patch -R

Story: 2009221
Task: 44580

Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
Change-Id: I62b973a50e149d51e6bb24223416351a641c10ba
This commit is contained in:
Zhixiong Chi 2022-12-13 17:20:51 +08:00
parent 4c83b058b1
commit c6423587a9
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,33 @@
From a300c15748a84df03d8a6d6f4fd306e00955e885 Mon Sep 17 00:00:00 2001
From: Zhixiong Chi <zhixiong.chi@windriver.com>
Date: Tue, 13 Dec 2022 17:14:51 +0800
Subject: [PATCH] kpatch: Allowing passing in KEYDIR and SRCDIR
When the '-k/--keydir' option is used, the variable KEYDIR will
still be the fixed value. Allow the customized value for KEYDIR
to be passed.
It's the same as '-s/--sourcedir' option and the variable SRCDIR.
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
kpatch-build/kpatch-build | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 45a9757..1f66901 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -712,8 +712,8 @@ fi
LINUXTYPE="linux${KERNELTYPE}"
SIGNTOOLDIR=(/usr/lib/${LINUXTYPE}-kbuild-*/scripts)
-SRCDIR="${CACHEDIR}/${LINUXTYPE}-src"
-KEYDIR="${LINUXSRCDIR}/kernels/${ARCHVERSION}"
+[[ -z "${SRCDIR}" ]] && SRCDIR="${CACHEDIR}/${LINUXTYPE}-src"
+[[ -z "${KEYDIR}" ]] && KEYDIR="${LINUXSRCDIR}/kernels/${ARCHVERSION}"
[[ "$SKIPCLEANUP" -eq 0 ]] && trap cleanup EXIT INT TERM HUP
--
2.25.1

View File

@ -3,3 +3,4 @@
0003-kpatch-Adjust-the-kpatch-build-to-support-the-multik.patch
0004-kpatch-Fix-the-build-failure-when-the-cache-src-dire.patch
0005-kpatch-Support-the-customized-order-for-module-load.patch
0006-kpatch-Allowing-passing-in-KEYDIR-and-SRCDIR.patch