From d04f5723bc6f66d0b77d977520ea06275fd8578b Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Fri, 1 Jun 2018 18:58:28 -0500 Subject: [PATCH] kpatch-build: RHEL kernel-alt support Deal with a few RHEL kernel-alt quirks for ppc64le: - The RPM and spec names are "kernel-alt". - 7.6 ALT is based on 4.14 but it doesn't have the 'immediate' flag. Signed-off-by: Josh Poimboeuf --- kmod/patch/livepatch-patch-hook.c | 8 ++++---- kpatch-build/kpatch-build | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kmod/patch/livepatch-patch-hook.c b/kmod/patch/livepatch-patch-hook.c index 338e323..e864a21 100644 --- a/kmod/patch/livepatch-patch-hook.c +++ b/kmod/patch/livepatch-patch-hook.c @@ -47,13 +47,13 @@ #define HAVE_SYMPOS #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) && \ - LINUX_VERSION_CODE <= KERNEL_VERSION(4, 15, 0)) -# define HAVE_IMMEDIATE -#elif defined(RHEL_RELEASE_CODE) +#ifdef RHEL_RELEASE_CODE # if RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7, 5) # define HAVE_IMMEDIATE # endif +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) && \ + LINUX_VERSION_CODE <= KERNEL_VERSION(4, 15, 0)) +# define HAVE_IMMEDIATE #endif #ifdef RHEL_RELEASE_CODE diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index cf44789..f1c1f22 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -488,6 +488,7 @@ if [[ -n "$SRCRPM" ]]; then rpmname="$(basename "$SRCRPM")" ARCHVERSION="${rpmname%.src.rpm}.$(uname -m)" ARCHVERSION="${ARCHVERSION#kernel-}" + ARCHVERSION="${ARCHVERSION#alt-}" fi # ensure cachedir and tempdir are setup properly and cleaned @@ -517,6 +518,7 @@ KVER="${ARCHVERSION%%-*}" if [[ "$ARCHVERSION" =~ - ]]; then KREL="${ARCHVERSION##*-}" KREL="${KREL%.*}" + [[ "$KREL" =~ .el7a. ]] && ALT="-alt" fi [[ -z "$TARGETS" ]] && TARGETS="vmlinux modules" @@ -572,15 +574,15 @@ else wget -P "$TEMPDIR" "http://kojipkgs.fedoraproject.org/packages/kernel/$KVER/$KREL/src/kernel-$KVER-$KREL.src.rpm" 2>&1 | logger || die else rpm -q --quiet yum-utils || die "yum-utils not installed" - yumdownloader --source --destdir "$TEMPDIR" "kernel-$ARCHVERSION" 2>&1 | logger || die + yumdownloader --source --destdir "$TEMPDIR" "kernel$ALT-$ARCHVERSION" 2>&1 | logger || die fi - SRCRPM="$TEMPDIR/kernel-$KVER-$KREL.src.rpm" + SRCRPM="$TEMPDIR/kernel$ALT-$KVER-$KREL.src.rpm" fi echo "Unpacking kernel source" rpm -D "_topdir $RPMTOPDIR" -ivh "$SRCRPM" 2>&1 | logger || die - rpmbuild -D "_topdir $RPMTOPDIR" -bp "--target=$(uname -m)" "$RPMTOPDIR"/SPECS/kernel.spec 2>&1 | logger || + rpmbuild -D "_topdir $RPMTOPDIR" -bp "--target=$(uname -m)" "$RPMTOPDIR"/SPECS/kernel$ALT.spec 2>&1 | logger || die "rpmbuild -bp failed. you may need to run 'yum-builddep kernel' first." mv "$RPMTOPDIR"/BUILD/kernel-*/linux-"${ARCHVERSION%.*}"*"${ARCHVERSION##*.}" "$SRCDIR" 2>&1 | logger || die