diff --git a/0034-migrear-grub2-entry-recovery.patch b/0034-migrear-grub2-entry-recovery.patch new file mode 100644 index 0000000000000000000000000000000000000000..869a2a0030997bceb0906822bbd596dba98edc24 --- /dev/null +++ b/0034-migrear-grub2-entry-recovery.patch @@ -0,0 +1,173 @@ +From 74d7c269f52ba41c52647978e84d26f2bea87ec9 Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Mon, 5 Dec 2022 08:38:51 +0000 +Subject: [PATCH] Add local backup script. + +Signed-off-by: Weisson +--- + usr/sbin/migrear | 80 +++++++++++++++++++ + .../rear/pack/GNU/Linux/500_local_backup.sh | 55 +++++++++++++ + .../system-setup.d/500-start-recovery.sh | 1 + + 3 files changed, 136 insertions(+) + create mode 100755 usr/sbin/migrear + create mode 100644 usr/share/rear/pack/GNU/Linux/500_local_backup.sh + create mode 100644 usr/share/rear/skel/default/etc/scripts/system-setup.d/500-start-recovery.sh + +diff --git a/usr/sbin/migrear b/usr/sbin/migrear +new file mode 100755 +index 0000000..055a2a9 +--- /dev/null ++++ b/usr/sbin/migrear +@@ -0,0 +1,80 @@ ++#! /usr/bin/env python3 ++# -*- coding:utf-8 -*- ++import argparse ++import os ++import sys ++import platform ++ ++import subprocess ++ ++ ++def check_output(cmd): ++ output = subprocess.check_output(cmd, shell=True) ++ if type(output) is str: ++ return output.strip() ++ elif sys.version_info[0] == 2 and (type(output) is unicode or type(output) is bytes): ++ return output.encode('utf-8').strip() ++ elif sys.version_info[0] == 3 and type(output) is bytes: ++ return str(output, 'utf-8').strip() ++ else: ++ raise TypeError("Expected bytes or string, but got %s." % type(output)) ++ ++ ++def check_call(cmd): ++ return subprocess.check_call(cmd, shell=True) ++ ++ ++def backup(nfs_url): ++ local_cfg = """ ++OUTPUT=RAMDISK ++OUTPUT_URL=file:///storage/ ++BACKUP=NETFS ++BACKUP_URL=%s ++BACKUP_PROG_EXCLUDE=("\${BACKUP_PROG_EXCLUDE[@]}" '/media' '/var/tmp' '/var/crash' '/storage' '/tmp/*') ++NETFS_KEEP_OLD_BACKUP_COPY= ++""" % (nfs_url if nfs_url else "nfs://127.0.0.1/storage/") ++ ++ with open("/etc/rear/local.conf", "w") as f: ++ f.write(local_cfg) ++ ++ backup_mode = " " ++ backup_path = "/storage/" ++ if nfs_url is None: ++ backup_mode = "MBACKUP_MODE=LOCAL_NFS" ++ if not os.path.exists(backup_path): ++ os.mkdir(backup_path) ++ with open("/etc/exports", "a") as f: ++ f.write("\n%s *(fsid=0,rw,sync,no_root_squash,no_subtree_check,crossmnt)" % (backup_path)) ++ ++ check_call("systemctl restart nfs-server") ++ ++ command = " ".join([backup_mode, "rear -v mkbackup"]) ++ check_call(command) ++ ++ # grub ++ vmlinuz = check_output("ls /boot/vmlinuz-$(uname -r)").strip() ++ vmlinux_ver = vmlinuz.rpartition('/')[-1] ++ ++ initramfs_path = "/storage/{0}/initramfs-{0}.img".format(platform.node()) ++ command = "grubby --add-kernel %s --initrd %s --title MigReaR-%s " % (vmlinuz, initramfs_path, vmlinux_ver) ++ if nfs_url: ++ args = " --args='ro console=tty0 console=ttyS0,115200n8 console=ttyS0 unattended'" ++ else: ++ args = " --args='ro console=tty0 console=ttyS0,115200n8 console=ttyS0'" ++ ++ command += args ++ check_call(command) ++ ++ ++def parse_args(): ++ parser = argparse.ArgumentParser(description="Relex and Recover for OS migration.") ++ parser.add_argument('--nfs', default=None, help="url of nfs, e.g. nfs://127.0.0.1/storage/") ++ ++ return parser.parse_args() ++ ++ ++if __name__ == "__main__": ++ parser = parse_args() ++ nfs_url = parser.nfs ++ backup(nfs_url) ++ +diff --git a/usr/share/rear/pack/GNU/Linux/500_local_backup.sh b/usr/share/rear/pack/GNU/Linux/500_local_backup.sh +new file mode 100644 +index 0000000..da58612 +--- /dev/null ++++ b/usr/share/rear/pack/GNU/Linux/500_local_backup.sh +@@ -0,0 +1,55 @@ ++if [ $MBACKUP_MODE = "LOCAL_NFS" ]; then ++ ++LogPrint "Creating recovery script ..." ++cat << SCRIPT >> $ROOTFS_DIR/usr/bin/recovery ++#! /usr/bin/bash ++ ++echo ============= system is recovering in 20 seconds ... ============== ++sleep 20 ++ ++ROOTFS=\$1 ++ ++ROOTFS=\${ROOTFS:-/dev/vda1} ++MOUNT_POINT=/mnt/cdrom/ ++BACKUP_POINT=/storage/ ++ ++echo "Running recover ..." ++echo "Mounting \$ROOTFS ..." ++mount -v \$ROOTFS \$MOUNT_POINT ++cp -r -v \$MOUNT_POINT/\$BACKUP_POINT/ \$BACKUP_POINT ++ ++umount -v \$ROOTFS ++ ++cat << EOF > /etc/rear/local.conf ++OUTPUT_URL=file:///storage/ ++BACKUP=NETFS ++BACKUP_URL=file:///storage/ ++BACKUP_PROG_EXCLUDE=("\${BACKUP_PROG_EXCLUDE[@]}" '/media' '/var/tmp' '/var/crash' '/storage') ++NETFS_KEEP_OLD_BACKUP_COPY= ++EOF ++ ++WORKROUND_ACTOR="/usr/share/rear/lib/framework-functions.sh" ++sed 's/ || BugError "Directory \$BUILD_DIR\/outputfs not empty, can not remove\"\$//g' -i \$WORKROUND_ACTOR ++ ++rear -v recover ++SCRIPT ++chmod +x $ROOTFS_DIR/usr/bin/recovery ++ ++ ++cat << EOF >> $ROOTFS_DIR/etc/systemd/system/SystemRecovery.service ++[Service] ++Type=oneshot ++ExecStart=/usr/bin/recovery ++StandardInput=null ++StandardOutput=journal+console ++StandardError=journal+console ++ ++[Install] ++WantedBy=multi-user.target ++EOF ++ ++# mkdir $ROOTFS_DIR/etc/systemd/system/multi-user.target.wants/ ++# cp $ROOTFS_DIR/etc/systemd/system/SystemRecovery.service $ROOTFS_DIR/etc/systemd/system/multi-user.target.wants/ ++ ++fi ++ +diff --git a/usr/share/rear/skel/default/etc/scripts/system-setup.d/500-start-recovery.sh b/usr/share/rear/skel/default/etc/scripts/system-setup.d/500-start-recovery.sh +new file mode 100644 +index 0000000..30c54db +--- /dev/null ++++ b/usr/share/rear/skel/default/etc/scripts/system-setup.d/500-start-recovery.sh +@@ -0,0 +1 @@ ++systemctl start SystemRecovery +\ No newline at end of file +-- +2.30.1 (Apple Git-130) + diff --git a/leapp-repository.spec b/leapp-repository.spec index 1f1360b73f50f550fdc1b275d429fa5db1d839c9..978d3a307c1f4eba163e800ce462b7c52c6b064c 100644 --- a/leapp-repository.spec +++ b/leapp-repository.spec @@ -11,7 +11,7 @@ }\ py2_byte_compile "%1" "%2"} -%define anolis_release 9 +%define anolis_release 10 Name: leapp-repository Version: 0.13.0 @@ -59,6 +59,7 @@ Patch30: 0030-fix-subprocess-check_output-method-for-backup-service-confi Patch31: 0031-Deal-with-EPEL-repositories-create-by-user-mannally.patch Patch32: 0032-Keep-PermitRootLogin-authentication-behavior-after-m.patch Patch33: 0033-Read-the-driver-list-supported-by-ANCK.patch +Patch34: 0034-migrear-grub2-entry-recovery.patch BuildArch: noarch BuildRequires: python-devel @@ -181,6 +182,9 @@ done; # no files here %changelog +* Thu Dec 8 2022 Weisson - 0.13.0-2.10 +- Migrear grub2 entry recovery is supported. + * Thu Nov 15 2022 Bitao Hu - 0.13.0-2.9 - Read the driver list supported by ANCK to determine driver compatibility problem, when migrating to Anolis8 with ANCK.