repository file choose kernel version to migration
This commit is contained in:
parent
1dfe4b6902
commit
124d12b9de
@ -0,0 +1,74 @@
|
|||||||
|
From 6047fe2bac9d1b63fd9099f1ca4944cc9c647d0a Mon Sep 17 00:00:00 2001
|
||||||
|
From: xuezhixin <xuezhixin@uniontech.com>
|
||||||
|
Date: Fri, 10 Nov 2023 14:10:28 +0800
|
||||||
|
Subject: [PATCH] =?UTF-8?q?repo=E6=96=87=E4=BB=B6=E9=80=89=E6=8B=A9kernel?=
|
||||||
|
=?UTF-8?q?=E8=BF=81=E7=A7=BB?=
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
---
|
||||||
|
sysmig_agent/migration.py | 50 +++++++++++++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 50 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/sysmig_agent/migration.py b/sysmig_agent/migration.py
|
||||||
|
index e510680..00b3c89 100644
|
||||||
|
--- a/sysmig_agent/migration.py
|
||||||
|
+++ b/sysmig_agent/migration.py
|
||||||
|
@@ -121,3 +121,53 @@ def ifnot_mig_kernel(kernel_version):
|
||||||
|
f.write(kernel_patterns)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
+def disable_exclude():
|
||||||
|
+ with open('/etc/yum.conf', 'r') as f:
|
||||||
|
+ content = f.read()
|
||||||
|
+ f.close()
|
||||||
|
+ if re.search(r'^exclude=', content, re.MULTILINE):
|
||||||
|
+ content = re.sub(r"\n(exclude=)", r"\n#\1", content)
|
||||||
|
+ #content = re.sub(r"\nexclude=", r"\n#exclude=", content)
|
||||||
|
+ with open('/etc/yum.conf','w+') as f:
|
||||||
|
+ f.write(content)
|
||||||
|
+ f.close()
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+# migration kernel
|
||||||
|
+def mig_kernel(kernel_version):
|
||||||
|
+ disable_exclude()
|
||||||
|
+ cwd = '/var/tmp/uos-migration/kernel/'
|
||||||
|
+ if not os.path.exists(cwd):
|
||||||
|
+ os.mkdir(cwd)
|
||||||
|
+ ret = os.listdir(cwd)
|
||||||
|
+ for i in ret:
|
||||||
|
+ os.unlink(cwd+i)
|
||||||
|
+ cmd = ' rpm -qa | grep "kernel\|bpftool\|perf" |xargs -i rpm -q --qf "%{NAME}\\n" {}'
|
||||||
|
+ if '0' == kernel_version:
|
||||||
|
+ return None
|
||||||
|
+ else:
|
||||||
|
+ repo = ''
|
||||||
|
+ if '4.18.0' == kernel_version:
|
||||||
|
+ repo = 'UniontechOS-kernel-'+kernel_version.strip()
|
||||||
|
+ elif '5.10.0' == kernel_version:
|
||||||
|
+ repo = 'UniontechOS-kernel-'+kernel_version.strip()
|
||||||
|
+ elif '3.10.0' == kernel_version:
|
||||||
|
+ repo = 'UniontechOS-kernel-' + kernel_version.strip()
|
||||||
|
+ else:
|
||||||
|
+ return 1
|
||||||
|
+ down_cmd = 'yumdownloader --destdir "/var/tmp/uos-migration/kernel" --enablerepo '+repo
|
||||||
|
+ ret = os.popen(cmd).readlines()
|
||||||
|
+ for i in ret:
|
||||||
|
+ downpackage = down_cmd+' '+i.strip()+'-'+kernel_version.strip()
|
||||||
|
+ # os.system(downpackage)
|
||||||
|
+ run_subprocess(downpackage)
|
||||||
|
+
|
||||||
|
+ cwd = '/var/tmp/uos-migration/kernel/'
|
||||||
|
+ if os.listdir(cwd):
|
||||||
|
+ cmd = 'rpm -Uvh "{}*" --nodeps --oldpackage'.format(cwd)
|
||||||
|
+ # os.system(cmd)
|
||||||
|
+ run_subprocess(cmd)
|
||||||
|
+ else:
|
||||||
|
+ # loggen.debug('Can not download kernel .')
|
||||||
|
+ #log.err
|
||||||
|
+ return 1
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: migration-tools
|
Name: migration-tools
|
||||||
Version: 1.0.2
|
Version: 1.0.2
|
||||||
Release: 38
|
Release: 39
|
||||||
License: MulanPSL-2.0
|
License: MulanPSL-2.0
|
||||||
Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system
|
Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system
|
||||||
Source0: %{name}-%{version}.tar.gz
|
Source0: %{name}-%{version}.tar.gz
|
||||||
@ -45,6 +45,7 @@ Patch35: 0035-the-migration-process-can-choose-not-to-migrate-the-kernel.patc
|
|||||||
Patch36: 0036-add-an-interface-to-obtain-kernel-information.patch
|
Patch36: 0036-add-an-interface-to-obtain-kernel-information.patch
|
||||||
Patch37: 0037-add-subprocess-function-and-loggin.patch
|
Patch37: 0037-add-subprocess-function-and-loggin.patch
|
||||||
Patch38: 0038-obtain-kernel-data.patch
|
Patch38: 0038-obtain-kernel-data.patch
|
||||||
|
Patch39: 0039-repository-file-choose-kernel-version-to-migration.patch
|
||||||
|
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
@ -144,6 +145,9 @@ rm -rf /usr/bin/migration-tools
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-39
|
||||||
|
- 0039-repository-file-choose-kernel-version-to-migration.patch
|
||||||
|
|
||||||
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-38
|
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-38
|
||||||
- 0038-obtain-kernel-data.patch
|
- 0038-obtain-kernel-data.patch
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user