87 lines
4.4 KiB
Diff
87 lines
4.4 KiB
Diff
From 0e49cc38358147a06f2ddcb0888553eb57e47274 Mon Sep 17 00:00:00 2001
|
|
From: xuezhixin <xuezhixin@uniontech.com>
|
|
Date: Tue, 14 Nov 2023 09:37:02 +0800
|
|
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=9D=E5=A7=8B=E5=8C=96re?=
|
|
=?UTF-8?q?pos=E6=96=87=E4=BB=B6?=
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
---
|
|
sysmig_agent/short_task.py | 46 ++++++++++++++++++++++++--------------
|
|
1 file changed, 29 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/sysmig_agent/short_task.py b/sysmig_agent/short_task.py
|
|
index 4e4dae3..2ef4ac6 100644
|
|
--- a/sysmig_agent/short_task.py
|
|
+++ b/sysmig_agent/short_task.py
|
|
@@ -160,36 +160,48 @@ def init_remove_oldrepo():
|
|
os.remove(path_file)
|
|
|
|
|
|
-#初始化repo文件
|
|
+# 初始化repo文件
|
|
def initRepoFile(baseurl):
|
|
os_version_ret = platform.dist()
|
|
- version = os_version_ret[1].split('.',-1)
|
|
- reposdir = '/etc/yum.repos.d/'
|
|
+ version = os_version_ret[1].split('.', -1)
|
|
+ AGENT_OS = os_version_ret[0] + version[0]
|
|
+ if re.search('7', AGENT_OS):
|
|
+ reposdir = '/etc/yum.repos.d/'
|
|
+ else:
|
|
+ reposdir = '/etc/yum.repos.d/'
|
|
+ # reposdir = dnf.Base().conf.get_reposdir
|
|
h = 0
|
|
- if re.match('file:',baseurl):
|
|
- str0, path = baseurl.split('://',1)
|
|
+ if re.search('file', baseurl):
|
|
+ str0, path = baseurl.split('://', 1)
|
|
path = '/' + path.strip('/') + '/'
|
|
else:
|
|
- h = 1
|
|
- if re.fullmatch('8',version[0]):
|
|
- path_appstream = baseurl+'/AppStream'
|
|
- path_baseos = baseurl+'/BaseOS'
|
|
- path_310 = baseurl+'/kernel-3.10'
|
|
- path_419 = baseurl+'/kernel419'
|
|
- path_510 = baseurl+'/kernel510'
|
|
+ h = 1
|
|
+ if re.fullmatch('8', version[0]):
|
|
+ path_appstream = baseurl + '/AppStream'
|
|
+ path_baseos = baseurl + '/BaseOS'
|
|
+ path_310 = baseurl + '/kernel-3.10'
|
|
+ path_418 = baseurl + '/kernel-4.18'
|
|
+ path_419 = baseurl + '/kernel419'
|
|
+ path_510 = baseurl + '/kernel510'
|
|
|
|
- repostr_uos = '''[UniontechOS-AppStream]\nname = UniontechOS AppStream\nbaseurl = '''+path_appstream.strip('\n')+'''\nenabled = 1\ngpgcheck = 0\n\n[UniontechOS-BaseOS]\nname = UniontechOS BaseOS\nbaseurl = '''+path_baseos.strip('\n')+'''\nenabled = 1\ngpgcheck = 0\n\n[UniontechOS-kernel-4.19.0]\nname = UniontechOS Kernel-4.19.0\nbaseurl = '''+path_419.strip('\n')+'''\nenabled = 0\ngpgcheck = 0\nskip_if_unavailable = 1\n\n[UniontechOS-kernel-5.10.0]\nname = UniontechOS Kernel-5.10.0\nbaseurl = '''+path_510.strip('\n')+'''\nenabled = 0\ngpgcheck = 0\nskip_if_unavailable = 1\n\n
|
|
+ repostr_uos = '''[UniontechOS-AppStream]\nname = UniontechOS AppStream\nbaseurl = ''' + path_appstream.strip(
|
|
+ '\n') + '''\nenabled = 1\ngpgcheck = 0\n\n[UniontechOS-BaseOS]\nname = UniontechOS BaseOS\nbaseurl = ''' + path_baseos.strip(
|
|
+ '\n') + '''\nenabled = 1\ngpgcheck = 0\n\n[UniontechOS-kernel-4.18.0]\nname = UniontechOS Kernel-4.18.0\nbaseurl = ''' + path_418.strip(
|
|
+ '\n') + '''\nenabled = 0\ngpgcheck = 0\nskip_if_unavailable = 1\n\n[UniontechOS-kernel-4.19.0]\nname = UniontechOS Kernel-4.19.0\nbaseurl = ''' + path_419.strip(
|
|
+ '\n') + '''\nenabled = 1\ngpgcheck = 0\nskip_if_unavailable = 1\n\n[UniontechOS-kernel-5.10.0]\nname = UniontechOS Kernel-5.10.0\nbaseurl = ''' + path_510.strip(
|
|
+ '\n') + '''\nenabled = 0\ngpgcheck = 0\nskip_if_unavailable = 1\n\n
|
|
'''
|
|
else:
|
|
- path_310 = baseurl+'/kernel-3.10'
|
|
- repostr_uos = '''[UniontechOS-AppStream]\nname = UniontechOS AppStream\nbaseurl = '''+baseurl.strip('\n')+'''\nenabled = 1\ngpgcheck = 0\n\n[UniontechOS-kernel-3.10.0]\nname = UniontechOS Kernel-3.10.0\nbaseurl = '''+path_310.strip('\n')+'''\nenabled = 0\ngpgcheck = 0\nskip_if_unavailable = 1\n
|
|
+ path_310 = baseurl + '/kernel-3.10'
|
|
+ repostr_uos = '''[UniontechOS-AppStream]\nname = UniontechOS AppStream\nbaseurl = ''' + baseurl.strip(
|
|
+ '\n') + '''\nenabled = 1\ngpgcheck = 0\n\n[UniontechOS-kernel-3.10.0]\nname = UniontechOS Kernel-3.10.0\nbaseurl = ''' + path_310.strip(
|
|
+ '\n') + '''\nenabled = 0\ngpgcheck = 0\nskip_if_unavailable = 1\n
|
|
'''
|
|
repofile = os.path.join(reposdir, 'switch-to-uos.repo')
|
|
- with open(repofile,'w') as f_repo:
|
|
+ with open(repofile, 'w') as f_repo:
|
|
f_repo.write(repostr_uos)
|
|
f_repo.close()
|
|
|
|
-
|
|
#检测repo文件创建缓存
|
|
def checkRepoMakeCache():
|
|
os.system('yum clean all')
|
|
--
|
|
2.20.1
|
|
|