diff --git a/0001-revise-the-query-method-for-installed-kernel-package.patch b/0001-revise-the-query-method-for-installed-kernel-package.patch new file mode 100644 index 0000000..a4c1407 --- /dev/null +++ b/0001-revise-the-query-method-for-installed-kernel-package.patch @@ -0,0 +1,57 @@ +From 0e84a02e690017f62fc42f3ea1597a4e40c2ec66 Mon Sep 17 00:00:00 2001 +From: wang-guangge +Date: Mon, 23 Oct 2023 21:37:39 +0800 +Subject: [PATCH] revise the query method for installed kernel packages + +--- + hotpatch/updateinfo_parse.py | 26 +++++++++++++++++++++++++- + 1 file changed, 25 insertions(+), 1 deletion(-) + +diff --git a/hotpatch/updateinfo_parse.py b/hotpatch/updateinfo_parse.py +index 7395dc6..4322eee 100644 +--- a/hotpatch/updateinfo_parse.py ++++ b/hotpatch/updateinfo_parse.py +@@ -286,8 +286,14 @@ class HotpatchUpdateInfo(object): + # check whether the relevant target required package is installed on this machine + if not inst_pkgs: + return ++ # for kernel rpm, inst_pkgs is based on the kernel version of the current system ++ if required_pkg_name == "kernel": ++ inst_pkgs = [self.get_kernel_version_of_system()] + for inst_pkg in inst_pkgs: +- inst_pkg_vere = '%s-%s' % (inst_pkg.version, inst_pkg.release) ++ if isinstance(inst_pkg, str): ++ inst_pkg_vere = inst_pkg.rsplit(".", 1)[0] ++ else: ++ inst_pkg_vere = '%s-%s' % (inst_pkg.version, inst_pkg.release) + if not self.version.larger_than(required_pkg_vere, inst_pkg_vere): + hotpatch.state = self.UNRELATED + elif required_pkg_vere != inst_pkg_vere: +@@ -304,6 +310,24 @@ class HotpatchUpdateInfo(object): + hotpatch.state = self.INSTALLABLE + return + ++ def get_kernel_version_of_system(self) -> str: ++ """ ++ Get the kernel version of current system, according to the command of 'uname -r'. ++ ++ Returns: ++ str: kernel version ++ """ ++ cmd = ["uname", "-r"] ++ kernel_version = '' ++ kernel_version, return_code = cmd_output(cmd) ++ # 'uname -r' show the kernel version-release.arch of the current system ++ # [root@openEuler hotpatch]# uname -r ++ # 5.10.0-136.12.0.86.oe2203sp1.x86_64 ++ if return_code != SUCCEED: ++ return kernel_version ++ kernel_version = kernel_version.split('\n')[0] ++ return kernel_version ++ + def _parse_and_store_from_xml(self, updateinfoxml: str): + """ + Parse and store hotpatch update information from xxx-updateinfo.xml.gz +-- +2.33.0 + diff --git a/aops-ceres.spec b/aops-ceres.spec index 7e7bde3..c8d899e 100644 --- a/aops-ceres.spec +++ b/aops-ceres.spec @@ -1,10 +1,11 @@ Name: aops-ceres Version: v1.3.3 -Release: 1 +Release: 2 Summary: An agent which needs to be adopted in client, it managers some plugins, such as gala-gopher(kpi collection), fluentd(log collection) and so on. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz +Patch0001: 0001-revise-the-query-method-for-installed-kernel-package.patch BuildRequires: python3-setuptools @@ -28,7 +29,7 @@ dnf hotpatch plugin, it's about hotpatch query and fix %prep -%autosetup -n %{name}-%{version} +%autosetup -n %{name}-%{version} -p1 # build for aops-ceres @@ -57,6 +58,9 @@ cp -r hotpatch %{buildroot}/%{python3_sitelib}/dnf-plugins/ %changelog +* Mon Oct 23 2023 wangguangge - v1.3.3-2 +- revise the query method for installed kernel packages + * Wed Oct 11 2023 wenxin - v1.3.3-1 - add hotpatch plugin