From: Didier Raboud <odyx@debian.org>
Date: Tue, 31 Mar 2020 20:33:37 +0200
Subject: =?utf-8?q?py3=2E8=3A=C2=A0Assume_the_python3-distro_package_is_ava?=
 =?utf-8?q?ilable?=

---
 base/password.py          | 21 +++++++--------------
 installer/core_install.py | 33 ++++++++++++++++++++++++++++++---
 2 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/base/password.py b/base/password.py
index 1071ea1..c86c844 100644
--- a/base/password.py
+++ b/base/password.py
@@ -80,20 +80,13 @@ def showPasswordPrompt(prompt):
 
 
 # TBD this function shoud be removed once distro class implemented
-def get_distro_std_name(os_name):
-    os_name = os_name.lower()
-    if 'mx' in os_name:
-        os_name = "mxlinux"
-    if "redhatenterprise" in os_name:
-        os_name = 'rhel'    
-    elif "suse" in os_name:
-        os_name = 'suse'
-    elif "arch" in os_name:
-        os_name = 'manjarolinux'
-    elif "fedora" in os_name:
-        os_name = 'fedora'
-
-    return os_name
+def get_distro_name():
+    import distro
+    return distro.linux_distribution(full_distribution_name=False)[0]
+
+# upstream likes to rename stuff
+def get_distro_std_name(os_name1):
+    return get_distro_name()
 
 
 class Password(object):
diff --git a/installer/core_install.py b/installer/core_install.py
index 5b3059e..eb33728 100644
--- a/installer/core_install.py
+++ b/installer/core_install.py
@@ -636,8 +636,35 @@ class CoreInstall(object):
             return ''
 
     def get_distro(self):
-        name,ver = utils.get_distro_name(self.passwordObj)
-        if name:
+        log.debug("Determining distro...")
+        name, ver = '', '0.0'
+        found = False
+
+        import distro
+        ld = distro.linux_distribution(full_distribution_name=False)
+        name = ld[0]
+        ver = ld[1]
+
+        found = True
+
+        # Updating the distro name and version.
+        if found:
+            name = name.lower().strip()
+            log.debug("Distro name=%s" % name)
+            if name.find("redhatenterprise") > -1 or name.find("redhat") > -1:
+                name = "rhel"
+
+            log.debug("Distro version=%s" % ver)
+            if name == "rhel" and ver[0] == "5" and ver[1] == ".":
+                ver = "5.0"
+            elif name == "rhel" and ver[0] == "6" and ver[1] == ".":
+                ver = "6.0"
+            if 'MX' in name:
+                ver = name[3:5]
+                name = "mxlinux"
+            if 'manjaro' in name.lower():
+                version = ver.split('.')
+                ver = version[0] +'.'+version[1]
             found_in_list = False
             for d in self.distros:
                 if name.find(d) > -1:
@@ -651,7 +678,7 @@ class CoreInstall(object):
                             break
                 if found_in_list:
                     break
-                    
+
             self.distro_version = ver
             self.distro_name = name
         else:
