diff --git a/0001-contrib-disable-upstart-kpatch.conf-install.patch b/0001-contrib-disable-upstart-kpatch.conf-install.patch new file mode 100644 index 0000000000000000000000000000000000000000..44eb5b4468689d620234df6fe8bb41cfffa9ed06 --- /dev/null +++ b/0001-contrib-disable-upstart-kpatch.conf-install.patch @@ -0,0 +1,46 @@ +From f056d60fb309896a52882fd3fc10fb5305f5a47e Mon Sep 17 00:00:00 2001 +From: Joe Lawrence +Date: Thu, 21 Jun 2018 15:40:20 -0400 +Subject: [PATCH] contrib: disable upstart kpatch.conf install + +Do not install the upstart configuration file to avoid this rhpkg +build complaint: + + Checking for unpackaged file(s): /usr/lib/rpm/check-files /builddir/build/BUILDROOT/kpatch-0.6.1-1.el7.noarch + error: Installed (but unpackaged) file(s) found: + /etc/init/kpatch.conf + Installed (but unpackaged) file(s) found: + /etc/init/kpatch.conf + +We'll need to think of a better way to do this upstream, but for now, +just skip the unneeded file on RHEL. + +Signed-off-by: Joe Lawrence +--- + contrib/Makefile | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/contrib/Makefile b/contrib/Makefile +index 0b0eeeb23a56..e873f27d6eae 100644 +--- a/contrib/Makefile ++++ b/contrib/Makefile +@@ -6,12 +6,12 @@ install: all + $(INSTALL) -d $(SYSTEMDDIR) + $(INSTALL) -m 0644 kpatch.service $(SYSTEMDDIR) + sed -i 's~PREFIX~$(PREFIX)~' $(SYSTEMDDIR)/kpatch.service +- $(INSTALL) -d $(UPSTARTDIR) +- $(INSTALL) -m 0644 kpatch.conf $(UPSTARTDIR) +- sed -i 's~PREFIX~$(PREFIX)~' $(UPSTARTDIR)/kpatch.conf ++# $(INSTALL) -d $(UPSTARTDIR) ++# $(INSTALL) -m 0644 kpatch.conf $(UPSTARTDIR) ++# sed -i 's~PREFIX~$(PREFIX)~' $(UPSTARTDIR)/kpatch.conf + + uninstall: + $(RM) $(SYSTEMDDIR)/kpatch.service +- $(RM) $(UPSTARTDIR)/kpatch.conf ++# $(RM) $(UPSTARTDIR)/kpatch.conf + + clean: +-- +1.8.3.1 + diff --git a/0002-kpatch-clarify-unload-unsupport.patch b/0002-kpatch-clarify-unload-unsupport.patch new file mode 100644 index 0000000000000000000000000000000000000000..b1c0d2dae4c4b4d1277de4e8fbae86f5f7eabb22 --- /dev/null +++ b/0002-kpatch-clarify-unload-unsupport.patch @@ -0,0 +1,78 @@ +kpatch: clarify that "kpatch unload" isn't supported + +Add a user-prompt to the kpatch unload subcommand and make a similiar +mention in the manual page. + +Provide an undocumented force option so that QE and dev scripts can +still run unload kpatch modules from scripts. + +RHEL-only. + +Signed-off-by: Joe Lawrence +diff -Nupr kpatch-0.6.1.old/kpatch/kpatch kpatch-0.6.1/kpatch/kpatch +--- kpatch-0.9.2.old/kpatch/kpatch 2019-08-28 10:35:01.191259434 -0400 ++++ kpatch-0.9.2/kpatch/kpatch 2019-08-28 16:11:13.067926576 -0400 +@@ -49,8 +49,8 @@ usage () { + echo >&2 + usage_cmd "load --all" "load all installed patch modules into the running kernel" + usage_cmd "load " "load patch module into the running kernel" +- usage_cmd "unload --all" "unload all patch modules from the running kernel" +- usage_cmd "unload " "unload patch module from the running kernel" ++ usage_cmd "unload --all (UNSUPPORTED)" "unload all patch modules from the running kernel" ++ usage_cmd "unload (UNSUPPORTED)" "unload patch module from the running kernel" + echo >&2 + usage_cmd "info " "show information about a patch module" + echo >&2 +@@ -71,6 +71,16 @@ die() { + exit 1 + } + ++confirm_prompt() { ++ local prompt="$1" ++ local answer ++ while true; do ++ read -rp "$prompt [Y/N] " answer ++ [[ $answer == 'Y' || $answer == 'y' ]] && return 0 ++ [[ $answer == 'N' || $answer == 'n' ]] && return 1 ++ done ++} ++ + __find_module () { + MODULE="$1" + [[ -f "$MODULE" ]] && return +@@ -406,6 +416,19 @@ unset MODULE + init_sysfs_var + + [[ "$#" -lt 1 ]] && usage ++ ++# RHEL-specific support options ++case "$1" in ++"force") ++ # For scripting purposes, support "kpatch force unload". ++ # Shift out the "force" to avoid the user-prompt check below. ++ shift ++ ;; ++"unload") ++ confirm_prompt "WARNING: Red Hat doesn't support unloading of kpatches, continue anyway?" || exit 1 ++ ;; ++esac ++ + case "$1" in + "load") + [[ "$#" -ne 2 ]] && usage +diff -Nupr kpatch-0.6.1.old/man/kpatch.1 kpatch-0.6.1/man/kpatch.1 +--- kpatch-0.9.2.old/man/kpatch.1 2019-08-28 10:35:01.191259434 -0400 ++++ kpatch-0.9.2/man/kpatch.1 2019-08-28 14:51:23.268198897 -0400 +@@ -23,10 +23,10 @@ load --all + load + load patch module into the running kernel + +-unload --all ++unload --all (UNSUPPORTED) + unload all patch modules from the running kernel + +-unload ++unload (UNSUPPORTED) + unload patch module from the running kernel + + info diff --git a/0003-do-not-rm-selinux-rpm-owned-directory.patch b/0003-do-not-rm-selinux-rpm-owned-directory.patch new file mode 100644 index 0000000000000000000000000000000000000000..a38e831d918802d92dcd106c391956bcd56ab08a --- /dev/null +++ b/0003-do-not-rm-selinux-rpm-owned-directory.patch @@ -0,0 +1,28 @@ +kpatch: do not rm selinux rpm owned directory + +As part of the kpatch rpm package installation, the /var/lib/kpatch directory +gets created and is set to be selinux owned by the kpatch rpm package. + +There is a problem where uninstalling the last kpatch-patch will also remove +this directory. When another kpatch-patch installation occurs, the +/var/lib/kpatch get recreated but withtout the selinux context which triggers a +policy error. + +Since /var/lib/kpatch is now created by the rpm spec file, do not remove it +from the uinstall target of the kpatch script. This insures selinux context +consistency. + +RHEL-only. + +Signed-off-by: Yannick Cote +diff -Nupr kpatch-0.9.4.old/kpatch/kpatch kpatch-0.9.4/kpatch/kpatch +--- kpatch-0.9.4.old/kpatch/kpatch 2021-08-26 15:31:07.000000000 -0400 ++++ kpatch-0.9.4/kpatch/kpatch 2022-06-10 12:19:55.791538218 -0400 +@@ -584,7 +584,6 @@ case "$1" in + echo "uninstalling $PATCH ($KVER)" + rm -f "$MODULE" || die "failed to uninstall module $PATCH" + rmdir --ignore-fail-on-non-empty "$INSTALLDIR/$KVER" || die "failed to remove directory $INSTALLDIR/$KVER" +- rmdir --ignore-fail-on-non-empty "$INSTALLDIR" || die "failed to remove directory $INSTALLDIR" + + ;; + diff --git a/0004-remove-confirm-prompt-when-unloading-patches.patch b/0004-remove-confirm-prompt-when-unloading-patches.patch new file mode 100644 index 0000000000000000000000000000000000000000..d90dba2a26a8d1024b38bf08994eb775a1704d03 --- /dev/null +++ b/0004-remove-confirm-prompt-when-unloading-patches.patch @@ -0,0 +1,25 @@ +From 51808080d474112f3206a7aad94930d274c248e2 Mon Sep 17 00:00:00 2001 +From: "zhangyongde.zyd" +Date: Fri, 24 Feb 2023 17:36:20 +0800 +Subject: [PATCH] remove confirm prompt when unloading patches + +--- + kpatch/kpatch | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kpatch/kpatch b/kpatch/kpatch +index 7506a05..aafa938 100755 +--- a/kpatch/kpatch ++++ b/kpatch/kpatch +@@ -470,7 +470,7 @@ case "$1" in + shift + ;; + "unload") +- confirm_prompt "WARNING: Red Hat doesn't support unloading of kpatches, continue anyway?" || exit 1 ++ echo "WARNING: Anolis don't suggest unloading of kpatches." || exit 1 + ;; + esac + +-- +2.37.0 (Apple Git-136) + diff --git a/download b/download new file mode 100644 index 0000000000000000000000000000000000000000..5b21263ac204cbbdabbe2847859c3a3d56d88470 --- /dev/null +++ b/download @@ -0,0 +1,2 @@ +21d48a6aa2ff4f3afd934f7fced99018 kpatch-dnf-v0.4.tar.gz +f38426f46e798bcc8fccdb7ec1c5ae14 v0.9.4.tar.gz diff --git a/kpatch.spec b/kpatch.spec new file mode 100644 index 0000000000000000000000000000000000000000..6b8270b0dd51e5c37a9d02b041cdc0b0101678cc --- /dev/null +++ b/kpatch.spec @@ -0,0 +1,81 @@ +%define anolis_release 1 +%define kpatch_dnf_ver 0.4 + +Name: kpatch +Version: 0.9.4 +Release: %{anolis_release}%{?dist} +Summary: Dynamic kernel patch manager + +Group: System Environment/Kernel +License: GPLv2 +URL: https://github.com/dynup/kpatch +Source0: https://github.com/dynup/kpatch/archive/v%{version}.tar.gz +Source1: kpatch-dnf-v%{kpatch_dnf_ver}.tar.gz + +Patch0: 0001-contrib-disable-upstart-kpatch.conf-install.patch +Patch1: 0002-kpatch-clarify-unload-unsupport.patch +Patch2: 0003-do-not-rm-selinux-rpm-owned-directory.patch +Patch3: 0004-remove-confirm-prompt-when-unloading-patches.patch + +Requires: bash kmod binutils +Recommends: kpatch-dnf + +BuildArch: noarch + + +%description +kpatch is a live kernel patch module manager. It allows the user to manage +a collection of binary kernel patch modules which can be used to dynamically +patch the kernel without rebooting. + +%package -n kpatch-dnf +Summary: kpatch-patch manager plugin for DNF +Version: %kpatch_dnf_ver +BuildRequires: python3-devel python3-dnf +Requires: python3-dnf python3-hawkey +Provides: kpatch-dnf + +%description -n kpatch-dnf +kpatch-dnf is a DNF plugin that manages subscription to kpatch-patch updates. +When enabled, kernel packages are automatically subscribed to corresponding +kpatch-patch packages updates. + +%prep +%autosetup -n %{name}-0.9.4 -p1 -a 1 +cd kpatch-dnf-%{kpatch_dnf_ver} +cd .. + +%build +make -C man + +make -C kpatch-dnf-%{kpatch_dnf_ver} + +%install +make install PREFIX=/usr DESTDIR=%{buildroot} -C kpatch +make install PREFIX=/usr DESTDIR=%{buildroot} -C man +make install PREFIX=/usr DESTDIR=%{buildroot} -C contrib +mkdir -p %{buildroot}/%{_sharedstatedir}/kpatch +rm -f %{buildroot}/usr/share/man/man1/kpatch-build.1.zst + +make install PREFIX=/usr DESTDIR=%{buildroot} PYTHONSITES=%{python3_sitelib} -C kpatch-dnf-%{kpatch_dnf_ver} + +%files +%{_sbindir}/kpatch +%{_usr}/lib/systemd/system/kpatch.service +%{_sharedstatedir}/kpatch +%{_mandir}/man1/kpatch.1.zst +%exclude %{_mandir}/man1/kpatch-build.1.zst + +%files -n kpatch-dnf +%config(noreplace) %{_sysconfdir}/dnf/plugins/kpatch.conf +%{python3_sitelib}/dnf-plugins/kpatch.py +%{python3_sitelib}/dnf-plugins/__pycache__ +%{_mandir}/man8/dnf.kpatch.8.zst + +%post -n kpatch-dnf +echo "To enable automatic kpatch-patch subscription, run:" +echo -e "\t$ dnf kpatch auto" + +%changelog +* Tue Apr 11 2023 happy_orange - 0.9.4-1 +- init package