Debian: kpatch: Support the multikernel

After multikernel support was added, both std and rt packages are
installed into the image, so it's confused to find the sign tools
and the source tar files during the build.
According to the ARCHVERSION, the correct path of the tools and the
source tar files kpatch-build used for the different kernel type can
be found now.

Test Plan:
Pass: build-pkgs -a -b std,rt
Pass: build-image
Pass: Verify the kpatch-build building process without errors.

Story: 2009221
Task: 44580

Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
Change-Id: Ic6005ba70db69bb941b8d133cd53b582fbf2bff4
This commit is contained in:
Zhixiong Chi 2022-06-14 00:55:01 -07:00
parent 8dd7885e4e
commit 0a094202c9
2 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,87 @@
From 713fd23d83514ef609bd216d6649ac29a606a83e Mon Sep 17 00:00:00 2001
From: Zhixiong Chi <zhixiong.chi@windriver.com>
Date: Mon, 13 Jun 2022 23:16:59 -0700
Subject: [PATCH] kpatch: Adjust the kpatch-build to support the multikernel
With multikernel support, both the std and rt kernel packages are installed
into the image. This causes confusion in locating the relevant tools or the
source for the kernel type.
Adjust the variables to get the correct tools and source locations.
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
kpatch-build/kpatch-build | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 8a9fa03..af91f5e 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -41,17 +41,14 @@ SCRIPTDIR="$(readlink -f "$(dirname "$(type -p "$0")")")"
ARCH="$(uname -m)"
CPUS="$(getconf _NPROCESSORS_ONLN)"
CACHEDIR="${CACHEDIR:-$HOME/.kpatch}"
-SRCDIR="$CACHEDIR/src"
RPMTOPDIR="$CACHEDIR/buildroot"
VERSIONFILE="$CACHEDIR/version"
TEMPDIR="$CACHEDIR/tmp"
ENVFILE="$TEMPDIR/kpatch-build.env"
LOGFILE="$CACHEDIR/build.log"
RELEASE_FILE=/etc/os-release
+KERNELTYPE=
LINUXSRCDIR=/usr/src
-KVERSION=$(uname -r)
-KEYDIR="${LINUXSRCDIR}/kernels/${KVERSION}"
-SIGNTOOLDIR=(/usr/lib/linux*-kbuild-*/scripts)
SIGNTOOL="sign-file"
SIGHASH="sha256"
DEBUG=0
@@ -711,6 +708,13 @@ fi
[[ -z "$ARCHVERSION" ]] && ARCHVERSION="$(uname -r)"
+[[ "$ARCHVERSION" =~ rt ]] && KERNELTYPE="-rt"
+
+LINUXTYPE="linux${KERNELTYPE}"
+SIGNTOOLDIR=(/usr/lib/${LINUXTYPE}-kbuild-*/scripts)
+SRCDIR="${CACHEDIR}/${LINUXTYPE}-src"
+KEYDIR="${LINUXSRCDIR}/kernels/${ARCHVERSION}"
+
[[ "$SKIPCLEANUP" -eq 0 ]] && trap cleanup EXIT INT TERM HUP
KVER="${ARCHVERSION%%-*}"
@@ -821,10 +825,10 @@ else
# Since the linux-yocto kernel version is used for wrcp project now, so need to ensure the linux-source package had
# already been installed. We don't dowanload the kernel source from the debian any more.
KSRCVER="${KVER%.*}"
- KSRCNAME="$LINUXSRCDIR/linux-source-$KSRCVER.tar.xz"
- if [[ -e "$KSRCNAME" ]]; then
+ KSRCNAME="${LINUXSRCDIR}/${LINUXTYPE}-source-${KSRCVER}.tar.xz"
+ if [[ -e "${KSRCNAME}" ]]; then
tar xvf "${KSRCNAME}" 2>&1 | logger || die
- mv "linux-source-$KSRCVER" "$SRCDIR" || die
+ mv "${LINUXTYPE}-source-${KSRCVER}" "${SRCDIR}" || die
fi
# Due to the ostree mechanism, we need add the prefix for kernel config here
CMDLINE="$(cat /proc/cmdline)"
@@ -835,7 +839,7 @@ else
CONFIGFILE="$SRCDIR/.config"
if [[ "$ARCHVERSION" == *-* ]]; then
- echo "-${ARCHVERSION#*-}" > "$SRCDIR/localversion" || die
+ echo "-${ARCHVERSION#*-}" > "$SRCDIR/localversion${KERNELTYPE}" || die
fi
# for some reason the Ubuntu kernel versions don't follow the
# upstream SUBLEVEL; they are always at SUBLEVEL 0
@@ -1076,6 +1080,8 @@ if [[ -z "$MODNAME" ]] ; then
MODNAME="kpatch-$MODNAME"
fi
+ [[ "$KERNELTYPE" == "-rt" ]] && MODNAME="rt-${MODNAME}"
+
MODNAME="$(module_name_string "$MODNAME")"
fi
FILES="$(cat "$TEMPDIR/changed_objs")"
--
2.34.1

View File

@ -1,2 +1,3 @@
0001-kpatch-Support-for-WRCP.patch 0001-kpatch-Support-for-WRCP.patch
0002-kpatch-Add-the-signature-for-livepatch-kernel-module.patch 0002-kpatch-Add-the-signature-for-livepatch-kernel-module.patch
0003-kpatch-Adjust-the-kpatch-build-to-support-the-multik.patch