From 1da2dfe89d77d730db89fed5a68bdb593d515101 Mon Sep 17 00:00:00 2001 From: xuezhixin Date: Tue, 5 Nov 2024 17:20:05 +0800 Subject: [PATCH] json and list format interchange --- 0029-json-and-list-format-interchange.patch | 86 +++++++++++++++++++++ migration-tools.spec | 7 +- 2 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 0029-json-and-list-format-interchange.patch diff --git a/0029-json-and-list-format-interchange.patch b/0029-json-and-list-format-interchange.patch new file mode 100644 index 0000000..5245672 --- /dev/null +++ b/0029-json-and-list-format-interchange.patch @@ -0,0 +1,86 @@ +From dd381efe588297b6f450665d374fcaafab0206e5 Mon Sep 17 00:00:00 2001 +From: xuezhixin +Date: Fri, 10 Nov 2023 11:07:17 +0800 +Subject: [PATCH] =?UTF-8?q?json=E5=92=8Clist=E6=A0=BC=E5=BC=8F=E4=BA=92?= + =?UTF-8?q?=E6=8D=A2?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + sysmig_agent/share.py | 35 ++++++++++++++++++++++++++--------- + 1 file changed, 26 insertions(+), 9 deletions(-) + +diff --git a/sysmig_agent/share.py b/sysmig_agent/share.py +index 68fcfa0..1a12a7e 100644 +--- a/sysmig_agent/share.py ++++ b/sysmig_agent/share.py +@@ -1,14 +1,17 @@ + # SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. + # SPDX-License-Identifier: MulanPubL-2.0-or-later + +-import logging + import os +-import platform ++import sys ++import json + import re +-import shutil + import subprocess ++import shutil + import socket +-from sysmig_agent.utils import list_to_json ++import platform ++import logging ++ ++sys.path.append("..") + from connect_sql import DBHelper + + def get_local_ip(): +@@ -192,17 +195,19 @@ def get_disk_info(string): + + + def add_boot_option(): +- print("Current system is uefi, add boot option to boot manager.") +- subprocess.run('which efibootmgr > /dev/null 2>&1 || dnf install -y efibootmgr', shell=True) ++ """ ++ Current system is uefi, add boot option to boot manager. ++ """ ++ subprocess.run('which efibootmgr > /dev/null 2>&1 || yum install -y efibootmgr', shell=True) + disk_name = subprocess.check_output('mount | grep /boot/efi | awk \'{print $1}\'', shell=True) + disk_name = str(disk_name, 'utf-8') + disk_name = disk_name.split('\n')[0] +- dev_name,part_num = get_disk_info(disk_name) ++ dev_name, part_num = get_disk_info(disk_name) + if dev_name == "" or part_num == "": +- print("Parse /boot/efi disk info failed, update boot loader failed.") ++ # "Parse /boot/efi disk info failed, update boot loader failed. + return + +- cmd="" ++ cmd = "" + arch = platform.machine() + if arch == "x86_64": + cmd = 'efibootmgr -c -d ' + dev_name + ' -p ' + part_num + ' -l "/EFI/uos/grubx86.efi" -L "Uniontech OS"' +@@ -296,6 +301,18 @@ def title_conf(oldosname): + open(fpath, 'w').write(strall.replace(line, title)) + + ++def json_list_to_json(keylist, valuelist): ++ res = dict(zip(keylist, valuelist)) ++ # logdss.info (res) ++ return json.dumps(res) ++ ++def list_to_json(keylist, valuelist): ++ res = dict(zip(keylist, valuelist)) ++ res = json.dumps(res) ++ # logdss.info (res) ++ return json.dumps(res) ++ ++ + def main_conf(osname): + logger = logging.getLogger() + logger.setLevel(logging.INFO) +-- +2.20.1 + diff --git a/migration-tools.spec b/migration-tools.spec index e9f415c..3906460 100644 --- a/migration-tools.spec +++ b/migration-tools.spec @@ -1,6 +1,6 @@ Name: migration-tools Version: 1.0.2 -Release: 28 +Release: 29 License: MulanPSL-2.0 Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system Source0: %{name}-%{version}.tar.gz @@ -35,7 +35,7 @@ Patch25: 0025-update-migration-status-to-database.patch Patch26: 0026-create-repository-and-disable-local-repofile.patch Patch27: 0027-fix-grub-file-for-system-option.patch Patch28: 0028-send-agent-task.patch - +Patch29: 0029-json-and-list-format-interchange.patch BuildArch: noarch BuildRequires: systemd %description @@ -133,6 +133,9 @@ rm -rf /usr/bin/migration-tools %endif %changelog +* Tue Nov 5 2024 xuezhixin - 1.0.2-29 +- 0029-json-and-list-format-interchange.patch + * Tue Nov 5 2024 xuezhixin - 1.0.2-28 - 0028-send-agent-task.patch -- Gitee