migration-tools/0027-fix-grub-file-for-system-option.patch
2024-11-05 16:46:35 +08:00

112 lines
3.7 KiB
Diff

From b47bd5687781d5c82d1cd267c11c690fd01c5317 Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 10:57:31 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=81=E7=A7=BB=E5=90=8E?=
=?UTF-8?q?=E5=BC=95=E5=AF=BC=E9=A1=B9=E8=A6=86=E7=9B=96=E7=B3=BB=E7=BB=9F?=
=?UTF-8?q?=E4=B8=8D=E5=85=A8=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sysmig_agent/share.py | 53 ++++++++++++++++++++++++++++++-------------
1 file changed, 37 insertions(+), 16 deletions(-)
diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py
index 3e7bb30..68fcfa0 100644
--- a/sysmig_agent/share.py
+++ b/sysmig_agent/share.py
@@ -106,6 +106,8 @@ def local_disabled_release_repo():
os.remove(fpath)
+
+
def getSysMigConf():
confpath = '/etc/migration-tools/migration-tools.conf'
if not os.path.exists(confpath):
@@ -234,45 +236,64 @@ def process_special_pkgs():
def title_conf(oldosname):
- oldosname=oldosname.strip()
+ """
+ Change the boot start option after system migration
+ :param oldosname:old system name
+ :return:
+ """
+ oldosname = oldosname.strip()
+ if oldosname == 'redhat':
+ capital = 'Red Hat'
+ elif oldosname == 'centos':
+ capital = 'CentOS'
path = '/boot/loader/entries'
- #path='/root/a'
+ # path='/root/a'
if os.path.exists(path):
file_list = os.listdir(path)
else:
return None
fl = False
for file in file_list:
- fpath = os.path.join(path,file)
+ fpath = os.path.join(path, file)
if os.path.isdir(fpath):
continue
else:
- with open(fpath,'r') as fp:
+ with open(fpath, 'r') as fp:
strall = fp.read()
fp.close()
- if re.search('uniontech',strall,re.IGNORECASE):
+ if re.search('uniontech', strall, re.IGNORECASE):
fl = True
for file in file_list:
- ustr=None
- fpath = os.path.join(path,file)
+ ustr = None
+ brackets = ""
+ fpath = os.path.join(path, file)
if os.path.isdir(fpath):
continue
else:
- with open(fpath,'r') as fp:
+ with open(fpath, 'r') as fp:
strall = fp.read()
fp.close()
- if re.search(oldosname,strall,re.IGNORECASE):
+ '''
+ if re.search(oldosname, strall, re.IGNORECASE):
if fl:
os.remove(fpath)
continue
else:
- ustr = re.sub(oldosname,"UniontechOS",strall,1,flags=re.IGNORECASE)
- if re.search('8 \(Core\)',strall):
- ustr = re.sub(' 8 ',' 20 ',ustr,1,flags=re.IGNORECASE)
- ustr = re.sub("Core","kongzi",ustr,1,flags=re.IGNORECASE)
- with open(fpath,'w') as ptitle:
- ptitle.write(ustr)
- ptitle.close()
+ print(strall,capital)
+ ustr = re.sub(capital, "UniontechOS", strall, 1, flags=re.IGNORECASE)
+ '''
+ if re.search(capital, strall):
+ line = strall.split('\n', -1)[0]
+ for char in range(len(line)):
+ if line[char] == '(':
+ p = char
+ continue
+ if line[char] == ')':
+ e = char+1
+ brackets = line[p:e]
+ break
+ title = 'title UniontechOS Linux ' + brackets + ' 20 (kongzi)'
+ open(fpath, 'w').write(strall.replace(line, title))
def main_conf(osname):
--
2.20.1