check kernel version in repository
This commit is contained in:
parent
a8bf58375a
commit
90bef33139
102
0047-check-kernel-version-in-repository.patch
Normal file
102
0047-check-kernel-version-in-repository.patch
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
From 0dfa49f9703103dd8f978d419555f5a4e8d72caf Mon Sep 17 00:00:00 2001
|
||||||
|
From: xuezhixin <xuezhixin@uniontech.com>
|
||||||
|
Date: Fri, 10 Nov 2023 15:01:48 +0800
|
||||||
|
Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E8=BD=AF=E4=BB=B6=E6=BA=90?=
|
||||||
|
=?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=86=85=E6=A0=B8=E7=89=88=E6=9C=AC?=
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
---
|
||||||
|
sysmig_agent/short_task.py | 79 ++++++++++++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 79 insertions(+)
|
||||||
|
create mode 100644 sysmig_agent/short_task.py
|
||||||
|
|
||||||
|
diff --git a/sysmig_agent/short_task.py b/sysmig_agent/short_task.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..1e1a1c8
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/sysmig_agent/short_task.py
|
||||||
|
@@ -0,0 +1,79 @@
|
||||||
|
+# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||||
|
+# SPDX-License-Identifier: MulanPubL-2.0-or-later
|
||||||
|
+
|
||||||
|
+# import os
|
||||||
|
+# import platform
|
||||||
|
+# from share import list_to_json
|
||||||
|
+# import sys
|
||||||
|
+# import re
|
||||||
|
+# import subprocess
|
||||||
|
+# import json
|
||||||
|
+from sysmig_agent.share import *
|
||||||
|
+from flask import Flask, render_template, url_for, redirect, make_response, session, Response
|
||||||
|
+import urllib.request
|
||||||
|
+from sysmig_agent.agent_request import post_server
|
||||||
|
+
|
||||||
|
+sys.path.append("..")
|
||||||
|
+from connect_sql import DBHelper
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def os_kernel():
|
||||||
|
+ platformInfo = platform.platform()
|
||||||
|
+ systemKernelVersion = platformInfo.split('-', -1)
|
||||||
|
+ agent_kernel = systemKernelVersion[1]
|
||||||
|
+ return agent_kernel
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def os_repo_kernel():
|
||||||
|
+ version_list = []
|
||||||
|
+ os_version_ret = platform.dist()
|
||||||
|
+ version = os_version_ret[1].split('.', -1)
|
||||||
|
+ AGENT_OS = os_version_ret[0] + version[0]
|
||||||
|
+ try:
|
||||||
|
+ ret = os.popen("yum repolist all|awk '{print $1}'")
|
||||||
|
+ except:
|
||||||
|
+ ret = os.popen("yum repolist --all|awk '{print $1}'")
|
||||||
|
+ kernel_repo = kernel_repo_name = []
|
||||||
|
+ str_kernel = ''
|
||||||
|
+ for r in ret.readlines():
|
||||||
|
+ if not r:
|
||||||
|
+ continue
|
||||||
|
+ if 'UniontechOS' in r:
|
||||||
|
+ kernel_repo.append(r.strip('\n'))
|
||||||
|
+ if '8' == version[0]:
|
||||||
|
+ for i in range(len(kernel_repo)):
|
||||||
|
+ # cmd = 'yum repoquery --nvr kernel --enablerepo ' + kernel_repo[i]
|
||||||
|
+ cmd = 'yum repoquery --repo ' + kernel_repo[i] + ' kernel'
|
||||||
|
+ ret = str(subprocess.check_output(cmd, shell=True), 'utf-8')[:-1]
|
||||||
|
+ # except Exception:
|
||||||
|
+ ret = ret.split('\n', -1)
|
||||||
|
+ for i in range(len(ret)):
|
||||||
|
+ if re.match('kernel', ret[i]):
|
||||||
|
+ kernel_version = re.sub('kernel-.*:', '', ret[i])
|
||||||
|
+ kernel_version = re.sub('-.*$', '', kernel_version)
|
||||||
|
+ version_list.append(kernel_version.strip())
|
||||||
|
+ if not str_kernel:
|
||||||
|
+ str_kernel = kernel_version.strip()
|
||||||
|
+ else:
|
||||||
|
+ str_kernel = str_kernel + ',' + kernel_version.strip()
|
||||||
|
+ # print(version_list)
|
||||||
|
+ elif '7' == version[0]:
|
||||||
|
+ for i in range(len(kernel_repo)):
|
||||||
|
+ cmd = 'yum list --enablerepo {} kernel'.format(kernel_repo[i])
|
||||||
|
+ if '3.10.0' in kernel_repo[i]:
|
||||||
|
+ cmd = 'yum list --enablerepo {} --disablerepo UniontechOS-AppStream kernel'.format(kernel_repo[i])
|
||||||
|
+ ret = str(subprocess.check_output(cmd, shell=True), 'utf-8')[:-1]
|
||||||
|
+ ret = ret.split('\n', -1)
|
||||||
|
+ for n in range(len(ret)):
|
||||||
|
+ if 'uelc' in ret[n]:
|
||||||
|
+ # kernel_version = re.sub('kernel-.* ', '', ret[n])
|
||||||
|
+ kernel_version = re.sub('-.*$', '', ret[n])
|
||||||
|
+ kernel_version = kernel_version.split(' ',-1)
|
||||||
|
+ kernel_version = kernel_version[len(kernel_version)-1]
|
||||||
|
+ version_list.append(kernel_version.strip())
|
||||||
|
+ if not str_kernel:
|
||||||
|
+ str_kernel = kernel_version.strip()
|
||||||
|
+ else:
|
||||||
|
+ str_kernel = str_kernel + ',' + kernel_version.strip()
|
||||||
|
+ return str_kernel
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: migration-tools
|
Name: migration-tools
|
||||||
Version: 1.0.2
|
Version: 1.0.2
|
||||||
Release: 46
|
Release: 47
|
||||||
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
|
||||||
@ -53,7 +53,7 @@ Patch43: 0043-process-os-version-and-os-name.patch
|
|||||||
Patch44: 0044-migrate-in-myutiple-steps.patch
|
Patch44: 0044-migrate-in-myutiple-steps.patch
|
||||||
Patch45: 0045-modify-repository-file.patch
|
Patch45: 0045-modify-repository-file.patch
|
||||||
Patch46: 0046-agent-sends-task-update-requrst-to-the-server.patch
|
Patch46: 0046-agent-sends-task-update-requrst-to-the-server.patch
|
||||||
|
Patch47: 0047-check-kernel-version-in-repository.patch
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: systemd
|
BuildRequires: systemd
|
||||||
@ -152,6 +152,9 @@ rm -rf /usr/bin/migration-tools
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-47
|
||||||
|
- 0047-check-kernel-version-in-repository.patch
|
||||||
|
|
||||||
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-46
|
* Tue Nov 5 2024 xuezhixin <xuezhixin@uniontech.com> - 1.0.2-46
|
||||||
- 0046-agent-sends-task-update-requrst-to-the-server.patch
|
- 0046-agent-sends-task-update-requrst-to-the-server.patch
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user