From ed6bf930fc3177f920908e2421adf980710ec57f Mon Sep 17 00:00:00 2001
From: Super User <root@localhost.localdomain>
Date: Wed, 8 Mar 2023 11:36:07 +0800
Subject: [PATCH] fix engine-setup problem

---
 packaging/bin/engine-backup.sh.in                          | 3 ++-
 packaging/setup/bin/ovirt-engine-upgrade-check.in          | 6 ++----
 .../setup/ovirt_engine_setup/engine_common/postgres.py     | 6 ++----
 .../ovirt-engine-common/base/core/offlinepackager.py       | 6 ++----
 .../ovirt-engine-common/core/offlinepackager.py            | 6 ++----
 .../ovirt-engine-common/dialog/titles.py                   | 6 ++----
 .../ovirt-engine-common/distro-rpm/packages.py             | 6 ++----
 .../ovirt-engine-common/distro-rpm/versionlock_config.py   | 7 ++++---
 .../plugins/ovirt-engine-setup/ovirt-engine/system/nfs.py  | 6 ++----
 9 files changed, 20 insertions(+), 32 deletions(-)

diff --git a/packaging/bin/engine-backup.sh.in b/packaging/bin/engine-backup.sh.in
index fd3151b..25120e8 100755
--- a/packaging/bin/engine-backup.sh.in
+++ b/packaging/bin/engine-backup.sh.in
@@ -994,7 +994,8 @@ dobackup() {
 }
 
 getOSVersion() {
-	python@PY_VERSION@ -c 'import platform; d = platform.linux_distribution(full_distribution_name=0); print("%s%s" % (d[0], d[1].split(".")[0]))'
+#	python@PY_VERSION@ -c 'import platform; d = platform.linux_distribution(full_distribution_name=0); print("%s%s" % (d[0], d[1].split(".")[0]))'
+        python@PY_VERSION@ -c 'import distro; print("%s%s" % (distro.id(), distrio.version().split(".")[0]))'
 }
 
 createtar() {
diff --git a/packaging/setup/bin/ovirt-engine-upgrade-check.in b/packaging/setup/bin/ovirt-engine-upgrade-check.in
index f357f01..2bae272 100755
--- a/packaging/setup/bin/ovirt-engine-upgrade-check.in
+++ b/packaging/setup/bin/ovirt-engine-upgrade-check.in
@@ -15,7 +15,7 @@ import platform
 import optparse
 import gettext
 import glob
-
+import distro
 
 from otopi import common
 from otopi import constants as otopicons
@@ -118,9 +118,7 @@ def main():
     setup_packages = get_setup_packages()
 
     try:
-        if platform.linux_distribution(
-            full_distribution_name=0
-        )[0] not in ('redhat', 'fedora', 'centos'):
+        if distro.id() not in ('redhat', 'fedora', 'centos','openeuler'):
             raise RuntimeError(_('Unsupported distribution'))
 
         exit = 1
diff --git a/packaging/setup/ovirt_engine_setup/engine_common/postgres.py b/packaging/setup/ovirt_engine_setup/engine_common/postgres.py
index 51c9c4b..bd8ba4b 100644
--- a/packaging/setup/ovirt_engine_setup/engine_common/postgres.py
+++ b/packaging/setup/ovirt_engine_setup/engine_common/postgres.py
@@ -15,7 +15,7 @@ import random
 import re
 import shutil
 import time
-
+import distro
 from otopi import base
 from otopi import constants as otopicons
 from otopi import filetransaction
@@ -449,9 +449,7 @@ class Provisioning(base.Base):
         self.command.detect('psql')
 
     def supported(self):
-        return platform.linux_distribution(
-            full_distribution_name=0
-        )[0] in ('redhat', 'fedora', 'centos')
+        return distro.id() in ('redhat', 'fedora', 'centos','openeuler') 
 
     def validate(self):
         if not self.services.exists(
diff --git a/packaging/setup/plugins/ovirt-engine-common/base/core/offlinepackager.py b/packaging/setup/plugins/ovirt-engine-common/base/core/offlinepackager.py
index 7108668..629930a 100644
--- a/packaging/setup/plugins/ovirt-engine-common/base/core/offlinepackager.py
+++ b/packaging/setup/plugins/ovirt-engine-common/base/core/offlinepackager.py
@@ -12,7 +12,7 @@
 
 import gettext
 import platform
-
+import distro
 from otopi import constants as otopicons
 from otopi import packager
 from otopi import plugin
@@ -52,9 +52,7 @@ class Plugin(plugin.PluginBase, packager.PackagerBase):
 
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
-        self._distribution = platform.linux_distribution(
-            full_distribution_name=0
-        )[0]
+        self._distribution = distro.id()
 
     @plugin.event(
         stage=plugin.Stages.STAGE_INIT,
diff --git a/packaging/setup/plugins/ovirt-engine-provisiondb/ovirt-engine-common/core/offlinepackager.py b/packaging/setup/plugins/ovirt-engine-provisiondb/ovirt-engine-common/core/offlinepackager.py
index 911357c..fbdfc98 100644
--- a/packaging/setup/plugins/ovirt-engine-provisiondb/ovirt-engine-common/core/offlinepackager.py
+++ b/packaging/setup/plugins/ovirt-engine-provisiondb/ovirt-engine-common/core/offlinepackager.py
@@ -14,7 +14,7 @@
 
 import gettext
 import platform
-
+import distro
 from otopi import constants as otopicons
 from otopi import packager
 from otopi import plugin
@@ -54,9 +54,7 @@ class Plugin(plugin.PluginBase, packager.PackagerBase):
 
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
-        self._distribution = platform.linux_distribution(
-            full_distribution_name=0
-        )[0]
+        self._distribution = distro.id()
 
     @plugin.event(
         stage=plugin.Stages.STAGE_INIT,
diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/dialog/titles.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/dialog/titles.py
index 5f8d02f..9cc2958 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/dialog/titles.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/dialog/titles.py
@@ -12,7 +12,7 @@
 
 import gettext
 import platform
-
+import distro
 from otopi import plugin
 from otopi import util
 
@@ -35,9 +35,7 @@ class Plugin(plugin.PluginBase):
 
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
-        self._distribution = platform.linux_distribution(
-            full_distribution_name=0
-        )[0]
+        self._distribution = distro.id()
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/distro-rpm/packages.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/distro-rpm/packages.py
index 2987052..e7a29ef 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/distro-rpm/packages.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/distro-rpm/packages.py
@@ -15,7 +15,7 @@ import datetime
 import gettext
 import os
 import platform
-
+import distro
 from otopi import constants as otopicons
 from otopi import plugin
 from otopi import transaction
@@ -266,9 +266,7 @@ class Plugin(plugin.PluginBase):
         super(Plugin, self).__init__(context=context)
         self._shouldResultVersionLock = False
         self._enabled = False
-        self._distribution = platform.linux_distribution(
-            full_distribution_name=0
-        )[0]
+        self._distribution = distro.id()
 
     @plugin.event(
         stage=plugin.Stages.STAGE_INIT,
diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/distro-rpm/versionlock_config.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/distro-rpm/versionlock_config.py
index 7e9fd9b..47b1f09 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/distro-rpm/versionlock_config.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-common/distro-rpm/versionlock_config.py
@@ -12,7 +12,7 @@
 
 import os
 import platform
-
+import distro
 from otopi import constants as otopicons
 from otopi import filetransaction
 from otopi import plugin
@@ -40,9 +40,10 @@ class Plugin(plugin.PluginBase):
             os.path.exists(YUM_VERSIONLOCK_CONF) and
             not self.environment[osetupcons.CoreEnv.DEVELOPER_MODE] and
             not self.environment[osetupcons.CoreEnv.OFFLINE_PACKAGER] and
-            platform.linux_distribution(full_distribution_name=0)[0] in (
+            distro.id() in (
                 'redhat',
-                'centos'
+                'centos',
+                'openeuler'
             )
         )
     )
diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/nfs.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/nfs.py
index a09934d..e43a771 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/nfs.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/nfs.py
@@ -15,7 +15,7 @@ NFS and RPCbind services configuration plugin.
 import gettext
 import os
 import platform
-
+import distro
 from otopi import constants as otopicons
 from otopi import filetransaction
 from otopi import plugin
@@ -47,9 +47,7 @@ class Plugin(plugin.PluginBase):
 
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
-        self._distribution = platform.linux_distribution(
-            full_distribution_name=0
-        )[0]
+        self._distribution = distro.id()
 
     @plugin.event(
         stage=plugin.Stages.STAGE_INIT,
-- 
2.39.1

