From 22ca63384f669047d4259d746d6c07601bc3bf6c Mon Sep 17 00:00:00 2001 From: lixin Date: Wed, 6 Sep 2023 17:38:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dopeneuler=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 0002-fix-uefi-boot-failed.patch | 32 +++++++++ ...-modify-grub-rules-to-match-NIC-name.patch | 72 +++++++++++++++++++ migration-tools.spec | 10 ++- 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 0002-fix-uefi-boot-failed.patch create mode 100644 0003-modify-grub-rules-to-match-NIC-name.patch diff --git a/0002-fix-uefi-boot-failed.patch b/0002-fix-uefi-boot-failed.patch new file mode 100644 index 0000000..c497ada --- /dev/null +++ b/0002-fix-uefi-boot-failed.patch @@ -0,0 +1,32 @@ +From b7df99566ea6988c5411468b2b9d7e02f25bc85a Mon Sep 17 00:00:00 2001 +From: Super User +Date: Wed, 6 Sep 2023 17:14:29 +0800 +Subject: [PATCH] allow uefi boot + +--- + .../centos7/openeuler/centos72openeuler.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py b/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py +index 1cedebf..f24d765 100644 +--- a/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py ++++ b/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py +@@ -195,7 +195,6 @@ def main(): + + if system_sync(): + subprocess.run('dnf -y groupinstall Minimal Install', shell=True) +- conf_grub() + else: + print("Removing confilct package yum...") + os.system("rpm -e --nodeps yum") +@@ -216,6 +215,7 @@ def main(): + if os.path.exists(yum_conflict_dir): + shutil.rmtree(yum_conflict_dir) + print("Installing yum...") ++ conf_grub() + run_subprocess('dnf install -y yum'.split()) + + print("System migration completed, rebooting system") +-- +2.41.0 + diff --git a/0003-modify-grub-rules-to-match-NIC-name.patch b/0003-modify-grub-rules-to-match-NIC-name.patch new file mode 100644 index 0000000..44d66ad --- /dev/null +++ b/0003-modify-grub-rules-to-match-NIC-name.patch @@ -0,0 +1,72 @@ +From 76920b1ab0b7204c2feaf7dc2fa04b6d72730b5a Mon Sep 17 00:00:00 2001 +From: lixin +Date: Wed, 6 Sep 2023 17:23:29 +0800 +Subject: [PATCH] modify grub rules to match NIC name + +--- + .../centos7/openeuler/centos72openeuler.py | 41 ++++++++++++++++++- + 1 file changed, 40 insertions(+), 1 deletion(-) + +diff --git a/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py b/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py +index f24d765..2be7b6b 100644 +--- a/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py ++++ b/ut-Migration-tools/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py +@@ -83,6 +83,43 @@ def add_boot_option(): + except Exception as e: + print(e) + ++ ++def set_grub_biosdev_rules(): ++ """ ++ Set grub bisodev rule which can be don`t modify network configuration names. ++ When the leapp has been made initrd, the function will set net.ifnames in /etc/default/grub. ++ Returns: ++ """ ++ default_grub_path = "/etc/default/grub" ++ set_content = "net.ifnames=0 biosdevname=0" ++ if not os.path.exists(default_grub_path): ++ return ++ with open(default_grub_path, 'r') as gf: ++ gret = gf.readlines() ++ gf.close() ++ grub_content = '' ++ for i in range(len(gret)): ++ if "GRUB_CMDLINE_LINUX" in gret[i]: ++ cmdline_tmp = gret[i].split('"', -1)[1] ++ grub_content += 'GRUB_CMDLINE_LINUX="' + cmdline_tmp + ' ' + set_content + '"\n' ++ continue ++ grub_content += gret[i] ++ try: ++ if not os.path.exists(default_grub_path + '.disable'): ++ shutil.copyfile(default_grub_path, default_grub_path + '.disable') ++ os.remove(default_grub_path) ++ else: ++ print("grub file has been modified") ++ return ++ except Exception as e: ++ print(e) ++ return ++ with open(default_grub_path, 'w+') as wgf: ++ wgf.write(grub_content) ++ wgf.close() ++ return True ++ ++ + def swap_release(release): + tmp_dir = '/var/tmp' + rpme_release = 'rpm -qf /etc/os-release | xargs -i rpm -e --nodeps {}' +@@ -214,8 +251,10 @@ def main(): + yum_conflict_dir = '/etc/yum/' + if os.path.exists(yum_conflict_dir): + shutil.rmtree(yum_conflict_dir) +- print("Installing yum...") ++ print("Configuring grub...") ++ set_grub_biosdev_rules() + conf_grub() ++ print("Installing yum...") + run_subprocess('dnf install -y yum'.split()) + + print("System migration completed, rebooting system") +-- +2.41.0 + diff --git a/migration-tools.spec b/migration-tools.spec index 2bdbf45..8a0132e 100644 --- a/migration-tools.spec +++ b/migration-tools.spec @@ -1,10 +1,12 @@ Name: migration-tools Version: 1.0.0 -Release: 3 +Release: 4 Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system License: MulanPSL-2.0 Source0: ut-Migration-tools.tar.gz Patch0: 0001-fix-export-error-and-no-migration-details-issue.patch +Patch1: 0002-fix-uefi-boot-failed.patch +Patch2: 0003-modify-grub-rules-to-match-NIC-name.patch BuildArch: noarch %description UOS Migration Software @@ -26,6 +28,8 @@ Migration software server side %prep %setup -c %patch 0 -p1 +%patch 1 -p1 +%patch 2 -p1 %install rm -rf %{buildroot} @@ -61,6 +65,10 @@ rm -rf /usr/lib/systemd/system/migration-tools-server.service /usr/lib/migration-tools-server %changelog +* Wed Sep 06 2023 lixin - 1.0.0-4 +- fix: fix uefi boot failed +- fix: modify grub rules to match NIC name after migration + * Tue Aug 22 2023 lixin - 1.0.0-3 - feat: add aarch64 agent package -- Gitee