89 lines
3.0 KiB
Diff
89 lines
3.0 KiB
Diff
From 3d0c21042808eda903270365aaf45446f81c30c8 Mon Sep 17 00:00:00 2001
|
|
From: yangchenguang <yangchenguang@kylinsec.com.cn>
|
|
Date: Thu, 13 Apr 2023 10:51:46 +0800
|
|
Subject: [PATCH] fix(*): the problem of using hplip in python3.9
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
- 修复在线安装hp打印机驱动时报错
|
|
|
|
Signed-off-by: yangchenguang <yangchenguang@kylinsec.com.cn>
|
|
---
|
|
base/password.py | 15 +++++++++++++--
|
|
installer/core_install.py | 25 ++++++++++++++++++++++---
|
|
2 files changed, 35 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/base/password.py b/base/password.py
|
|
index c634f88..61c5b7e 100644
|
|
--- a/base/password.py
|
|
+++ b/base/password.py
|
|
@@ -56,6 +56,7 @@ AUTH_TYPES = {'mepis': 'su',
|
|
'boss': 'su',
|
|
'lfs': 'su',
|
|
'manjarolinux': 'sudo',
|
|
+ 'kylinsec': 'su',
|
|
}
|
|
|
|
|
|
@@ -76,8 +77,18 @@ def showPasswordPrompt(prompt):
|
|
def get_distro_name():
|
|
os_name = None
|
|
try:
|
|
- import platform
|
|
- os_name = platform.dist()[0]
|
|
+ _release_filename = re.compile(r'(\w+)[-_](release|version)', re.ASCII)
|
|
+ supported_dists = (
|
|
+ 'fedora', 'redhat', 'kylinsec', 'KylinSec'
|
|
+ )
|
|
+ for file in os.listdir("/etc"):
|
|
+ m = _release_filename.match(file)
|
|
+ if m is not None:
|
|
+ _distname, dummy = m.groups()
|
|
+ if _distname in supported_dists:
|
|
+ os_name = _distname
|
|
+ break
|
|
+
|
|
except ImportError:
|
|
os_name = None
|
|
|
|
diff --git a/installer/core_install.py b/installer/core_install.py
|
|
index 2b6046d..6b9a1ec 100644
|
|
--- a/installer/core_install.py
|
|
+++ b/installer/core_install.py
|
|
@@ -611,9 +611,28 @@ class CoreInstall(object):
|
|
|
|
# Getting distro information using platform module
|
|
try:
|
|
- import platform
|
|
- name = platform.dist()[0].lower()
|
|
- ver = platform.dist()[1]
|
|
+ _release_filename = re.compile(r'(\w+)[-_](release|version)', re.ASCII)
|
|
+ _lsb_release_version = re.compile(r'(.+)'
|
|
+ r' release '
|
|
+ r'([\d.]+)'
|
|
+ r'[^(]*(?:\((.+)\))?', re.ASCII)
|
|
+ supported_dists = (
|
|
+ 'fedora', 'redhat', 'kylinsec', 'KylinSec', 'system'
|
|
+ )
|
|
+ for file in os.listdir("/etc"):
|
|
+ m = _release_filename.match(file)
|
|
+ if m is not None:
|
|
+ _distname, dummy = m.groups()
|
|
+ if _distname in supported_dists:
|
|
+ name = _distname.lower()
|
|
+ break
|
|
+
|
|
+ with open(os.path.join("/etc/", file), r, encoding='utf-8', errors='surrogateescape') as f:
|
|
+ firstline = r.readline()
|
|
+ n = _lsb_release_version.match(firstline)
|
|
+ if n is not None:
|
|
+ ver = tuple(n.group())[1]
|
|
+
|
|
if not name:
|
|
found = False
|
|
log.debug("Not able to detect distro")
|
|
--
|
|
2.33.0
|
|
|