From 127d6250e5b659f19e4ab95cdf51f5a3029181c5 Mon Sep 17 00:00:00 2001 From: sxt1001 Date: Mon, 8 Mar 2021 21:04:15 +0800 Subject: [PATCH] add openEuler policy (cherry picked from commit a51869c6b966775fca663e2a0e0c71557da896a7) --- openEuler-add-openEuler-policy.patch | 50 ++++++++++++++++++++++++++++ sos.spec | 6 +++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 openEuler-add-openEuler-policy.patch diff --git a/openEuler-add-openEuler-policy.patch b/openEuler-add-openEuler-policy.patch new file mode 100644 index 0000000..1243a49 --- /dev/null +++ b/openEuler-add-openEuler-policy.patch @@ -0,0 +1,50 @@ +From 3b76979a51f8b8e65991c00cd4ebab2f23a467a6 Mon Sep 17 00:00:00 2001 +From: shixuantong +Date: Mon, 8 Mar 2021 20:56:05 +0800 +Subject: [PATCH] add openEuler policy + +this patch is based on sos-4.0, not applicable to the lower version. +--- + sos/policies/openEuler.py | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + create mode 100644 sos/policies/openEuler.py + +diff --git a/sos/policies/openEuler.py b/sos/policies/openEuler.py +new file mode 100644 +index 0000000..ea65ba2 +--- /dev/null ++++ b/sos/policies/openEuler.py +@@ -0,0 +1,30 @@ ++from __future__ import print_function ++ ++from sos.report.plugins import RedHatPlugin ++from sos.policies.redhat import RedHatPolicy, OS_RELEASE ++import os ++ ++class OpenEulerPolicy(RedHatPolicy): ++ ++ distro = "OpenEuler" ++ vendor = "the openEuler Project" ++ vendor_url = "https://openeuler.org/" ++ ++ def __init__(self, sysroot=None, init=None, probe_runtime=True, ++ remote_exec=None): ++ super(OpenEulerPolicy, self).__init__(sysroot=sysroot, init=init, ++ probe_runtime=probe_runtime, ++ remote_exec=remote_exec) ++ ++ @classmethod ++ def check(cls, remote=''): ++ """This method checks to see if we are running on OpenEuler. It returns ++ True or False.""" ++ if remote: ++ return cls.distro in remote ++ return os.path.isfile('/etc/openEuler-release') ++ ++ def openEuler_version(self): ++ pkg = self.pkg_by_name("openEuler-release") or \ ++ self.all_pkgs_by_name_regex("openEuler-release-.*")[-1] ++ return int(pkg["version"]) +-- +1.8.3.1 + diff --git a/sos.spec b/sos.spec index cff24e1..f47a3a5 100644 --- a/sos.spec +++ b/sos.spec @@ -2,13 +2,14 @@ Name: sos Version: 4.0 -Release: 2 +Release: 3 Summary: A set of tools to gather troubleshooting information from a system License: GPLv2+ URL: https://github.com/sosreport/sos Source0: https://github.com/sosreport/sos/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz Patch6000: backport-Fix-dict-order-py38-incompatibility.patch +Patch9000: openEuler-add-openEuler-policy.patch BuildRequires: python3-devel gettext Requires: libxml2-python3 bzip2 xz python3-rpm tar python3-pexpect @@ -57,6 +58,9 @@ install -m 644 %{name}.conf %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf %{_mandir}/man5/* %changelog +* Mon Mar 08 2021 shixuantong - 4.0-3 +- add openEuler policy + * Tue Mar 03 2021 shixuantong - 4.0-2 - fix unable to read configure file /etc/sos/sos.conf issue