diff --git a/dist b/dist new file mode 100644 index 0000000000000000000000000000000000000000..9c0e36ec42a2d9bfefacb21ac6354c9ddd910533 --- /dev/null +++ b/dist @@ -0,0 +1 @@ +an8 diff --git a/pxe-rsync-output.patch b/pxe-rsync-output.patch new file mode 100644 index 0000000000000000000000000000000000000000..c7844ffd1c255a4a20d08f4801adef5aef48c5d8 --- /dev/null +++ b/pxe-rsync-output.patch @@ -0,0 +1,36 @@ +diff --git a/usr/share/rear/output/PXE/default/820_copy_to_net.sh b/usr/share/rear/output/PXE/default/820_copy_to_net.sh +new file mode 100644 +index 00000000..dba1e526 +--- /dev/null ++++ b/usr/share/rear/output/PXE/default/820_copy_to_net.sh +@@ -0,0 +1,30 @@ ++ ++# 820_copy_to_net.sh ++ ++# Check if we have a target location OUTPUT_URL ++test "$OUTPUT_URL" || return 0 ++ ++local scheme=$( url_scheme $OUTPUT_URL ) ++local result_file="" ++local path="" ++ ++case "$scheme" in ++ (nfs|cifs|usb|tape|file|davfs) ++ # The ISO has already been transferred by NETFS. ++ return 0 ++ ;; ++ (fish|ftp|ftps|hftp|http|https|sftp) ++ # output/default/950_copy_result_files.sh will transfer them ++ return 0 ++ ;; ++ (rsync) ++ LogPrint "Transferring PXE files to $OUTPUT_URL" ++ for result_file in "${RESULT_FILES[@]}" ; do ++ LogPrint "Transferring file: $result_file" ++ rsync -a $v "$result_file" "$OUTPUT_URL" || Error "Problem transferring '$result_file' to $OUTPUT_URL" ++ done ++ ;; ++ (*) Error "Invalid scheme '$scheme' in '$OUTPUT_URL'." ++ ;; ++esac ++ diff --git a/rear-bz2083272.patch b/rear-bz2083272.patch new file mode 100644 index 0000000000000000000000000000000000000000..03c8a8a0ef820296c46f245e073c14808c1e9fdb --- /dev/null +++ b/rear-bz2083272.patch @@ -0,0 +1,171 @@ +commit 3d1bcf1b50ca8201a3805bc7cab6ca69c14951a1 +Author: pcahyna +Date: Thu May 5 12:11:55 2022 +0200 + + Merge pull request #2795 from pcahyna/recover-check-sums + + Verify file hashes at the end of recover after file restore from backup + +diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf +index f231bf3d..881a0af0 100644 +--- a/usr/share/rear/conf/default.conf ++++ b/usr/share/rear/conf/default.conf +@@ -313,8 +313,30 @@ CDROM_SIZE=20 + # which exits with non-zero exit code when the disk layout or those files changed + # (cf. https://github.com/rear/rear/issues/1134) but the checklayout workflow + # does not automatically recreate the rescue/recovery system. ++# Files matching FILES_TO_PATCH_PATTERNS are added to this list automatically. + CHECK_CONFIG_FILES=( '/etc/drbd/' '/etc/drbd.conf' '/etc/lvm/lvm.conf' '/etc/multipath.conf' '/etc/rear/' '/etc/udev/udev.conf' ) + ++# FILES_TO_PATCH_PATTERNS is a space-separated list of shell glob patterns. ++# Files that match are eligible for a final migration of UUIDs and other ++# identifiers after recovery (if the layout recreation process has led ++# to a change of an UUID or a device name and a corresponding change needs ++# to be performed on restored configuration files ). ++# See finalize/GNU/Linux/280_migrate_uuid_tags.sh ++# The [] around the first letter make sure that shopt -s nullglob removes this file from the list if it does not exist ++ ++FILES_TO_PATCH_PATTERNS="[b]oot/{grub.conf,menu.lst,device.map} [e]tc/grub.* \ ++ [b]oot/grub/{grub.conf,grub.cfg,menu.lst,device.map} \ ++ [b]oot/grub2/{grub.conf,grub.cfg,menu.lst,device.map} \ ++ [e]tc/sysconfig/grub [e]tc/sysconfig/bootloader \ ++ [e]tc/lilo.conf [e]tc/elilo.conf \ ++ [e]tc/yaboot.conf \ ++ [e]tc/mtab [e]tc/fstab \ ++ [e]tc/mtools.conf \ ++ [e]tc/smartd.conf [e]tc/sysconfig/smartmontools \ ++ [e]tc/sysconfig/rawdevices \ ++ [e]tc/security/pam_mount.conf.xml \ ++ [b]oot/efi/*/*/grub.cfg" ++ + ## + # Relax-and-Recover recovery system update during "rear recover" + # +diff --git a/usr/share/rear/finalize/GNU/Linux/250_migrate_disk_devices_layout.sh b/usr/share/rear/finalize/GNU/Linux/250_migrate_disk_devices_layout.sh +index 1a91a0e3..e869e5e9 100644 +--- a/usr/share/rear/finalize/GNU/Linux/250_migrate_disk_devices_layout.sh ++++ b/usr/share/rear/finalize/GNU/Linux/250_migrate_disk_devices_layout.sh +@@ -29,19 +29,9 @@ LogPrint "The original restored files get saved in $save_original_file_dir (in $ + + local symlink_target="" + local restored_file="" +-# the funny [] around the first letter make sure that shopt -s nullglob removes this file from the list if it does not exist +-# the files without a [] are mandatory, like fstab FIXME: but below there is [e]tc/fstab not etc/fstab - why? +- +-for restored_file in [b]oot/{grub.conf,menu.lst,device.map} [e]tc/grub.* [b]oot/grub/{grub.conf,menu.lst,device.map} \ +- [b]oot/grub2/{grub.conf,grub.cfg,menu.lst,device.map} \ +- [e]tc/sysconfig/grub [e]tc/sysconfig/bootloader \ +- [e]tc/lilo.conf \ +- [e]tc/yaboot.conf \ +- [e]tc/mtab [e]tc/fstab \ +- [e]tc/mtools.conf \ +- [e]tc/smartd.conf [e]tc/sysconfig/smartmontools \ +- [e]tc/sysconfig/rawdevices \ +- [e]tc/security/pam_mount.conf.xml [b]oot/efi/*/*/grub.cfg ++# The variable expansion is deliberately not quoted in order to perform ++# pathname expansion on the variable value. ++for restored_file in $FILES_TO_PATCH_PATTERNS + do + # Silently skip directories and file not found: + test -f "$restored_file" || continue +diff --git a/usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh b/usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh +index 074689a1..d994ce8e 100644 +--- a/usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh ++++ b/usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh +@@ -23,18 +23,9 @@ LogPrint "Migrating filesystem UUIDs in certain restored files in $TARGET_FS_ROO + + local symlink_target="" + local restored_file="" +-# the funny [] around the first letter make sure that shopt -s nullglob removes this file from the list if it does not exist +-# the files without a [] are mandatory, like fstab FIXME: but below there is [e]tc/fstab not etc/fstab - why? +-for restored_file in [b]oot/{grub.conf,menu.lst,device.map} [e]tc/grub.* \ +- [b]oot/grub/{grub.conf,grub.cfg,menu.lst,device.map} \ +- [b]oot/grub2/{grub.conf,grub.cfg,menu.lst,device.map} \ +- [e]tc/sysconfig/grub [e]tc/sysconfig/bootloader \ +- [e]tc/lilo.conf [e]tc/elilo.conf \ +- [e]tc/mtab [e]tc/fstab \ +- [e]tc/mtools.conf \ +- [e]tc/smartd.conf [e]tc/sysconfig/smartmontools \ +- [e]tc/sysconfig/rawdevices \ +- [e]tc/security/pam_mount.conf.xml [b]oot/efi/*/*/grub.cfg ++# The variable expansion is deliberately not quoted in order to perform ++# pathname expansion on the variable value. ++for restored_file in $FILES_TO_PATCH_PATTERNS + do + # Silently skip directories and file not found: + test -f "$restored_file" || continue +diff --git a/usr/share/rear/finalize/default/060_compare_files.sh b/usr/share/rear/finalize/default/060_compare_files.sh +new file mode 100644 +index 00000000..6947fda9 +--- /dev/null ++++ b/usr/share/rear/finalize/default/060_compare_files.sh +@@ -0,0 +1,6 @@ ++if [ -e $VAR_DIR/layout/config/files.md5sum ] ; then ++ if ! chroot $TARGET_FS_ROOT md5sum -c --quiet < $VAR_DIR/layout/config/files.md5sum 1>> >( tee -a "$RUNTIME_LOGFILE" 1>&7 ) 2>> >( tee -a "$RUNTIME_LOGFILE" 1>&8 ) ; then ++ LogPrintError "Error: Restored files do not match the recreated system in $TARGET_FS_ROOT" ++ return 1 ++ fi ++fi +diff --git a/usr/share/rear/layout/save/default/490_check_files_to_patch.sh b/usr/share/rear/layout/save/default/490_check_files_to_patch.sh +new file mode 100644 +index 00000000..ee717063 +--- /dev/null ++++ b/usr/share/rear/layout/save/default/490_check_files_to_patch.sh +@@ -0,0 +1,43 @@ ++# FILES_TO_PATCH_PATTERNS is a space-separated list of shell glob patterns. ++# Files that match are eligible for a final migration of UUIDs and other ++# identifiers after recovery (if the layout recreation process has led ++# to a change of an UUID or a device name and a corresponding change needs ++# to be performed on restored configuration files ). ++# See finalize/GNU/Linux/280_migrate_uuid_tags.sh ++# We should add all such files to CHECK_CONFIG_FILES - if they change, ++# we risk inconsistencies between the restored files and recreated layout, ++# or failures of UUID migration. ++ ++local file final_file symlink_target ++ ++# The patterns are relative to /, change directory there ++# so that the shell finds the files during pathname expansion ++pushd / >/dev/null ++# The variable expansion is deliberately not quoted in order to perform ++# pathname expansion on the variable value. ++for file in $FILES_TO_PATCH_PATTERNS ; do ++ final_file="/$file" ++ IsInArray "$final_file" "${CHECK_CONFIG_FILES[@]}" && continue ++ # Symlink handling (partially from 280_migrate_uuid_tags.sh): ++ # avoid dead symlinks, and symlinks to files on dynamic filesystems ++ # ( /proc etc.) - they are expected to change and validating ++ # their checksums has no sense ++ if test -L "$final_file" ; then ++ if symlink_target="$( readlink -e "$final_file" )" ; then ++ # If the symlink target contains /proc/ /sys/ /dev/ or /run/ we skip it because then ++ # the symlink target is considered to not be a restored file that needs to be patched ++ # and thus we don't need to generate and check its hash, either ++ # cf. https://github.com/rear/rear/pull/2047#issuecomment-464846777 ++ if echo $symlink_target | egrep -q '/proc/|/sys/|/dev/|/run/' ; then ++ Log "Skip adding symlink $final_file target $symlink_target on /proc/ /sys/ /dev/ or /run/ to CHECK_CONFIG_FILES" ++ continue ++ fi ++ Debug "Adding symlink $final_file with target $symlink_target to CHECK_CONFIG_FILES" ++ else ++ LogPrint "Skip adding dead symlink $final_file to CHECK_CONFIG_FILES" ++ continue ++ fi ++ fi ++ CHECK_CONFIG_FILES+=( "$final_file" ) ++done ++popd >/dev/null +diff --git a/usr/share/rear/layout/save/default/600_snapshot_files.sh b/usr/share/rear/layout/save/default/600_snapshot_files.sh +index 0ebf197c..3ac6b07e 100644 +--- a/usr/share/rear/layout/save/default/600_snapshot_files.sh ++++ b/usr/share/rear/layout/save/default/600_snapshot_files.sh +@@ -3,7 +3,8 @@ if [ "$WORKFLOW" = "checklayout" ] ; then + return 0 + fi + +-config_files=() ++local obj ++local config_files=() + for obj in "${CHECK_CONFIG_FILES[@]}" ; do + if [ -d "$obj" ] ; then + config_files+=( $( find "$obj" -type f ) ) diff --git a/rear-bz2091163.patch b/rear-bz2091163.patch new file mode 100644 index 0000000000000000000000000000000000000000..3a68a342b08eb1fab1e7ae0dbe7d6a6542147f79 --- /dev/null +++ b/rear-bz2091163.patch @@ -0,0 +1,46 @@ +diff --git a/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh b/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh +index d3c9ae86..f21845df 100644 +--- a/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh ++++ b/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh +@@ -70,14 +70,20 @@ local lvs_exit_code + # Get physical_device configuration. + # Format: lvmdev [] [] + header_printed="no" +- # Example output of "lvm pvdisplay -c": +- # /dev/sda1:system:41940992:-1:8:8:-1:4096:5119:2:5117:7wwpcO-KmNN-qsTE-7sp7-JBJS-vBdC-Zyt1W7 ++ # Set pvdisplay separator to '|' to prevent issues with a colon in the path under /dev/disk/by-path ++ # that contains a ':' in the SCSI slot name. ++ # Example output of "lvm pvdisplay -C --separator '|' --noheadings --nosuffix --units=b -o pv_name,vg_name,pv_size,pv_uuid" ++ # on a system where LVM is configured to show the /dev/disk/by-path device names instead of the usual ++ # /dev/sda etc. (by using a setting like ++ # filter = [ "r|/dev/disk/by-path/.*-usb-|", "a|/dev/disk/by-path/pci-.*-nvme-|", "a|/dev/disk/by-path/pci-.*-scsi-|", "a|/dev/disk/by-path/pci-.*-ata-|", "a|/dev/disk/by-path/pci-.*-sas-|", "a|loop|", "r|.*|" ] ++ # in /etc/lvm/lvm.conf): ++ # /dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:1:0-part1|system|107340627968|7wwpcO-KmNN-qsTE-7sp7-JBJS-vBdC-Zyt1W7 + # There are two leading blanks in the output (at least on SLES12-SP4 with LVM 2.02.180). +- lvm pvdisplay -c | while read line ; do ++ lvm pvdisplay -C --separator '|' --noheadings --nosuffix --units=b -o pv_name,vg_name,pv_size,pv_uuid | while read line ; do + +- # With the above example pdev=/dev/sda1 ++ # With the above example pdev=/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:1:0-part1 + # (the "echo $line" makes the leading blanks disappear) +- pdev=$( echo $line | cut -d ":" -f "1" ) ++ pdev=$( echo $line | cut -d "|" -f "1" ) + + # Skip lines that are not describing physical devices + # i.e. lines where pdev does not start with a leading / character: +@@ -91,11 +97,11 @@ local lvs_exit_code + fi + + # With the above example vgrp=system +- vgrp=$( echo $line | cut -d ":" -f "2" ) +- # With the above example size=41940992 +- size=$( echo $line | cut -d ":" -f "3" ) ++ vgrp=$( echo $line | cut -d "|" -f "2" ) ++ # With the above example size=107340627968 ++ size=$( echo $line | cut -d "|" -f "3" ) + # With the above example uuid=7wwpcO-KmNN-qsTE-7sp7-JBJS-vBdC-Zyt1W7 +- uuid=$( echo $line | cut -d ":" -f "12" ) ++ uuid=$( echo $line | cut -d "|" -f "4" ) + + # Translate pdev through diskbyid_mappings file: + pdev=$( get_device_mapping $pdev ) diff --git a/rear-bz2104005.patch b/rear-bz2104005.patch new file mode 100644 index 0000000000000000000000000000000000000000..db2c9dc849d8e0d97f4aece21ba4778228add811 --- /dev/null +++ b/rear-bz2104005.patch @@ -0,0 +1,21 @@ +commit 40ec3bf072a51229e81bfbfa7cedb8a7c7902dbd +Author: Johannes Meixner +Date: Fri Jun 24 15:11:27 2022 +0200 + + Merge pull request #2827 from rear/jsmeix-fail-safe-yes-pipe-lvcreate + + and commit b3fd58fc871e00bd713a0cb081de54d746ffffb3 from pull request #2839 + +diff --git a/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh b/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh +index 1be17ba8..d34ab335 100644 +--- a/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh ++++ b/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh +@@ -263,7 +263,7 @@ $ifline + + LogPrint "Creating LVM volume '$vg/$lvname'; Warning: some properties may not be preserved..." + $warnraidline +- lvm lvcreate $lvopts $vg << +Date: Wed May 25 13:51:14 2022 +0200 + + Merge pull request #2808 from rear/jsmeix-exclude-watchdog + + Exclude dev/watchdog* from the ReaR recovery system: + In default.conf add dev/watchdog* to COPY_AS_IS_EXCLUDE + because watchdog functionality is not wanted in the recovery system + because we do not want any automated reboot functionality + while disaster recovery happens via "rear recover", + see https://github.com/rear/rear/pull/2808 + Furthermore having a copy of dev/watchdog* + during "rear mkrescue" in ReaR's build area + may even trigger a system crash that is caused by a + buggy TrendMicro ds_am module touching dev/watchdog + in ReaR's build area (/var/tmp/rear.XXX/rootfs), + see https://github.com/rear/rear/issues/2798 + +diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf +index 881a0af0..cb14da8b 100644 +--- a/usr/share/rear/conf/default.conf ++++ b/usr/share/rear/conf/default.conf +@@ -1414,7 +1414,12 @@ COPY_AS_IS=( $SHARE_DIR $VAR_DIR ) + # We let them being recreated by device mapper in the recovery system during the recovery process. + # Copying them into the recovery system would let "rear recover" avoid the migration process. + # See https://github.com/rear/rear/pull/1393 for details. +-COPY_AS_IS_EXCLUDE=( $VAR_DIR/output/\* dev/.udev dev/shm dev/shm/\* dev/oracleasm dev/mapper ) ++# /dev/watchdog /dev/watchdog\* functionality is not wanted in the ReaR rescue/recovery system ++# because we do not want any automated reboot while disaster recovery happens via "rear recover". ++# Furthermore having dev/watchdog* during "rear mkrescue" may even trigger a system "crash" that is ++# caused by TrendMicro ds_am module touching dev/watchdog in ReaR's build area (/var/tmp/rear.XXX/rootfs). ++# See https://github.com/rear/rear/issues/2798 ++COPY_AS_IS_EXCLUDE=( $VAR_DIR/output/\* dev/.udev dev/shm dev/shm/\* dev/oracleasm dev/mapper dev/watchdog\* ) + # Array of user names that are trusted owners of files where RequiredSharedObjects calls ldd (cf. COPY_AS_IS) + # and where a ldd test is run inside the recovery system that tests all binaries for 'not found' libraries. + # The default is 'root' plus those standard system users that have a 'bin' or 'sbin' or 'root' home directory diff --git a/rear-bz2111059.patch b/rear-bz2111059.patch new file mode 100644 index 0000000000000000000000000000000000000000..fff1437737e423c99b2b4279c46cd3b1bfed19a6 --- /dev/null +++ b/rear-bz2111059.patch @@ -0,0 +1,105 @@ +commit 552dd6bfb20fdb3dc712b5243656d147392c27c3 +Author: Johannes Meixner +Date: Thu Jun 2 15:25:52 2022 +0200 + + Merge pull request #2811 from rear/jsmeix-RECOVERY_COMMANDS + + Add PRE_RECOVERY_COMMANDS and POST_RECOVERY_COMMANDS + as alternative to PRE_RECOVERY_SCRIPT and POST_RECOVERY_SCRIPT + see the description in default.conf how to use them and how they work. + See https://github.com/rear/rear/pull/2811 and see also + https://github.com/rear/rear/pull/2735 therein in particular + https://github.com/rear/rear/pull/2735#issuecomment-1134686196 + Additionally use LogPrint to show the user the executed commands, + see https://github.com/rear/rear/pull/2789 + +diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf +index cb14da8b..b14525da 100644 +--- a/usr/share/rear/conf/default.conf ++++ b/usr/share/rear/conf/default.conf +@@ -3117,14 +3117,37 @@ ELILO_BIN= + ################ ---- custom scripts + # + # NOTE: The scripts can be defined as an array to better handly spaces in parameters. +-# The scripts are called like this: eval "${PRE_RECOVERY_SCRIPT[@]}" ++# The scripts are called like this: ++# eval "${PRE_RECOVERY_SCRIPT[@]}" ++# ++# Alternatively, commands can be executed by using the corresponding ++# PRE_RECOVERY_COMMANDS and POST_RECOVERY_COMMANDS array variables ++# which evaluate like this: ++# for command in "${PRE_RECOVERY_COMMANDS[@]}" ; do ++# eval "$command" ++# done ++# ++# Using PRE_RECOVERY_COMMANDS and POST_RECOVERY_COMMANDS ++# is simpler when multiple commands should be executed. ++# For example, ++# PRE_RECOVERY_SCRIPT=( 'echo Hello' ';' 'sleep 3' ) ++# can be rewritten as ++# PRE_RECOVERY_COMMANDS=( 'echo Hello' 'sleep 3' ) ++# or ++# PRE_RECOVERY_COMMANDS=( 'echo Hello' ) ++# PRE_RECOVERY_COMMANDS+=( 'sleep 3' ) ++ ++# Those get called at the very beginning of "rear recover". ++# The PRE_RECOVERY_COMMANDS are called directly before the PRE_RECOVERY_SCRIPT. ++# Nothing was recreated and you have only the plain ReaR rescue/recovery system: ++PRE_RECOVERY_COMMANDS=() ++PRE_RECOVERY_SCRIPT= + +-# Call this after Relax-and-Recover did everything in the recover workflow. +-# Use $TARGET_FS_ROOT (by default '/mnt/local') to refer to the recovered system. ++# Those get called at the very end of "rear recover". ++# The POST_RECOVERY_COMMANDS are called directly after the POST_RECOVERY_SCRIPT. ++# Use $TARGET_FS_ROOT (by default '/mnt/local') to access the recreated target system. + POST_RECOVERY_SCRIPT= +- +-# Call this before Relax-and-Recover starts to do anything in the recover workflow. You have the rescue system but nothing else +-PRE_RECOVERY_SCRIPT= ++POST_RECOVERY_COMMANDS=() + + # PRE/POST Backup scripts will provide the ability to run certain tasks before and after a ReaR backup. + # for example: +diff --git a/usr/share/rear/setup/default/010_pre_recovery_script.sh b/usr/share/rear/setup/default/010_pre_recovery_script.sh +index 005107cc..8b4e4a36 100644 +--- a/usr/share/rear/setup/default/010_pre_recovery_script.sh ++++ b/usr/share/rear/setup/default/010_pre_recovery_script.sh +@@ -1,4 +1,14 @@ ++ ++# The PRE_RECOVERY_COMMANDS are called directly before the PRE_RECOVERY_SCRIPT ++# so PRE_RECOVERY_COMMANDS can also be used to prepare things for the PRE_RECOVERY_SCRIPT: ++ ++local command ++for command in "${PRE_RECOVERY_COMMANDS[@]}" ; do ++ LogPrint "Running PRE_RECOVERY_COMMANDS '$command'" ++ eval "$command" ++done ++ + if test "$PRE_RECOVERY_SCRIPT" ; then +- Log "Running PRE_RECOVERY_SCRIPT '${PRE_RECOVERY_SCRIPT[@]}'" +- eval "${PRE_RECOVERY_SCRIPT[@]}" ++ LogPrint "Running PRE_RECOVERY_SCRIPT '${PRE_RECOVERY_SCRIPT[@]}'" ++ eval "${PRE_RECOVERY_SCRIPT[@]}" + fi +diff --git a/usr/share/rear/wrapup/default/500_post_recovery_script.sh b/usr/share/rear/wrapup/default/500_post_recovery_script.sh +index 77751800..866c9368 100644 +--- a/usr/share/rear/wrapup/default/500_post_recovery_script.sh ++++ b/usr/share/rear/wrapup/default/500_post_recovery_script.sh +@@ -1,4 +1,14 @@ ++ ++# The POST_RECOVERY_COMMANDS are called directly after the POST_RECOVERY_SCRIPT ++# so POST_RECOVERY_COMMANDS can also be used to clean up things after the POST_RECOVERY_SCRIPT: ++ + if test "$POST_RECOVERY_SCRIPT" ; then +- Log "Running POST_RECOVERY_SCRIPT '${POST_RECOVERY_SCRIPT[@]}'" +- eval "${POST_RECOVERY_SCRIPT[@]}" ++ LogPrint "Running POST_RECOVERY_SCRIPT '${POST_RECOVERY_SCRIPT[@]}'" ++ eval "${POST_RECOVERY_SCRIPT[@]}" + fi ++ ++local command ++for command in "${POST_RECOVERY_COMMANDS[@]}" ; do ++ LogPrint "Running POST_RECOVERY_COMMANDS '$command'" ++ eval "$command" ++done diff --git a/rear-bz2119501.patch b/rear-bz2119501.patch new file mode 100644 index 0000000000000000000000000000000000000000..71b4d47ce5715e327b57332b7847b9a0e282213c --- /dev/null +++ b/rear-bz2119501.patch @@ -0,0 +1,39 @@ +diff --git a/usr/share/rear/build/default/490_fix_broken_links.sh b/usr/share/rear/build/default/490_fix_broken_links.sh +index 5bace664..cf960be8 100644 +--- a/usr/share/rear/build/default/490_fix_broken_links.sh ++++ b/usr/share/rear/build/default/490_fix_broken_links.sh +@@ -7,6 +7,23 @@ + # see https://github.com/rear/rear/issues/1638 + # and https://github.com/rear/rear/pull/1734 + ++# Some broken symlinks are expected. The 'build' and 'source' symlinks in kernel modules point to kernel sources ++# and are broken untol one installs the kernel-debug-devel or kernel-devel packages (on Fedora) and even then ++# the targets are jot included in the rescue system by default. ++# Do not warn about those, it is just noise. ++local irrelevant_symlinks=( '*/lib/modules/*/build' '*/lib/modules/*/source' ) ++function symlink_is_irrelevant () { ++ for i in "${irrelevant_symlinks[@]}"; do ++ # do not quote $i, it is a glob pattern, matching will be performed by [[ ... == ... ]] ++ # quoting inside [[ ]] prevents pattern matching ++ if [[ "$1" == $i ]]; then ++ return 0 ++ fi ++ done ++ return 1 ++} ++ ++ + # FIXME: The following code fails if symlinks or their targets contain characters from IFS (e.g. blanks), + # cf. the same kind of comments in build/default/990_verify_rootfs.sh + # and layout/prepare/GNU/Linux/130_include_mount_subvolumes_code.sh +@@ -38,6 +55,10 @@ pushd $ROOTFS_DIR + local broken_symlink='' + local link_target='' + for broken_symlink in $broken_symlinks ; do ++ if symlink_is_irrelevant "$broken_symlink" ; then ++ DebugPrint "Ignoring irrelevant broken symlink $broken_symlink" ++ continue ++ fi + # For each broken symlink absolute path inside ROOTFS_DIR + # we call "readlink -e" in the original system to get its link target there. + # If in the original system there was a chain of symbolic links like diff --git a/rear-bz2120736.patch b/rear-bz2120736.patch new file mode 100644 index 0000000000000000000000000000000000000000..8bcce79c39f44f56826d12dec64fdb7483bcdf60 --- /dev/null +++ b/rear-bz2120736.patch @@ -0,0 +1,18 @@ +diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf +index b14525da..23a83b71 100644 +--- a/usr/share/rear/conf/default.conf ++++ b/usr/share/rear/conf/default.conf +@@ -1841,10 +1841,10 @@ OBDR_BLOCKSIZE=2048 + # BACKUP=NBU stuff (Symantec/Veritas NetBackup) + ## + # +-COPY_AS_IS_NBU=( /usr/openv/bin/vnetd /usr/openv/bin/vopied /usr/openv/lib /usr/openv/netbackup /usr/openv/var/auth/[mn]*.txt /opt/VRTSpbx /etc/vx/VxICS /etc/vx/vrtslog.conf ) +-COPY_AS_IS_EXCLUDE_NBU=( /usr/openv/netbackup/logs "/usr/openv/netbackup/bin/bpjava*" /usr/openv/netbackup/bin/xbp /usr/openv/netbackup/bin/private /usr/openv/lib/java /usr/openv/lib/shared/vddk /usr/openv/netbackup/baremetal ) ++COPY_AS_IS_NBU=( /usr/openv/bin/vnetd /usr/openv/bin/vopied /usr/openv/lib /usr/openv/netbackup /usr/openv/var/auth/[mn]*.txt /usr/openv/var/vxss /usr/openv/var/webtruststore /usr/openv/resources/nbpxyhelper /opt/VRTSpbx /etc/vx/VxICS /etc/vx/vrtslog.conf /var/log/VRTSpbx ) ++COPY_AS_IS_EXCLUDE_NBU=( "/usr/openv/netbackup/logs/*" "/usr/openv/netbackup/bin/bpjava*" /usr/openv/netbackup/bin/xbp /usr/openv/netbackup/bin/private /usr/openv/lib/java "/usr/openv/lib/*-plugins" /usr/openv/lib/shared/vddk /usr/openv/netbackup/baremetal "/var/log/VRTSpbx/*" ) + # See https://github.com/rear/rear/issues/2105 why /usr/openv/netbackup/sec/at/lib/ is needed: +-NBU_LD_LIBRARY_PATH="/usr/openv/lib:/usr/openv/netbackup/sec/at/lib/" ++NBU_LD_LIBRARY_PATH="/usr/openv/lib:/usr/openv/netbackup/sec/at/lib/:/usr/openv/lib/boost" + PROGS_NBU=( ) + + ## diff --git a/rear-bz2130945.patch b/rear-bz2130945.patch new file mode 100644 index 0000000000000000000000000000000000000000..5291d1320ba3958fb21cb506354c5e6e935e1cf1 --- /dev/null +++ b/rear-bz2130945.patch @@ -0,0 +1,20 @@ +diff --git a/usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh b/usr/share/rear/finalize/Fedora/550_rebuild_initramfs.sh +similarity index 100% +rename from usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh +rename to usr/share/rear/finalize/Fedora/550_rebuild_initramfs.sh +diff --git a/usr/share/rear/finalize/Fedora/ppc64/550_rebuild_initramfs.sh b/usr/share/rear/finalize/Fedora/ppc64/550_rebuild_initramfs.sh +deleted file mode 120000 +index 22eede59..00000000 +--- a/usr/share/rear/finalize/Fedora/ppc64/550_rebuild_initramfs.sh ++++ /dev/null +@@ -1 +0,0 @@ +-../i386/550_rebuild_initramfs.sh +\ No newline at end of file +diff --git a/usr/share/rear/finalize/Fedora/ppc64le/550_rebuild_initramfs.sh b/usr/share/rear/finalize/Fedora/ppc64le/550_rebuild_initramfs.sh +deleted file mode 120000 +index 22eede59..00000000 +--- a/usr/share/rear/finalize/Fedora/ppc64le/550_rebuild_initramfs.sh ++++ /dev/null +@@ -1 +0,0 @@ +-../i386/550_rebuild_initramfs.sh +\ No newline at end of file diff --git a/rear-bz2131946.patch b/rear-bz2131946.patch new file mode 100644 index 0000000000000000000000000000000000000000..1ee90bafac2d77dff2287067b1b08e936994b888 --- /dev/null +++ b/rear-bz2131946.patch @@ -0,0 +1,129 @@ +diff --git a/usr/share/rear/layout/prepare/GNU/Linux/131_include_filesystem_code.sh b/usr/share/rear/layout/prepare/GNU/Linux/131_include_filesystem_code.sh +index 172ac032..9cff63a0 100644 +--- a/usr/share/rear/layout/prepare/GNU/Linux/131_include_filesystem_code.sh ++++ b/usr/share/rear/layout/prepare/GNU/Linux/131_include_filesystem_code.sh +@@ -143,9 +143,9 @@ function create_fs () { + # unless the user has explicitly specified XFS filesystem options: + local xfs_opts + local xfs_device_basename="$( basename $device )" +- local xfs_info_filename="$LAYOUT_XFS_OPT_DIR/$xfs_device_basename.xfs" ++ local xfs_info_filename="$LAYOUT_XFS_OPT_DIR_RESTORE/$xfs_device_basename.xfs" + # Only uppercase letters and digits are used to ensure mkfs_xfs_options_variable_name is a valid bash variable name +- # even in case of complicated device nodes e.g. things like /dev/mapper/SIBM_2810XIV_78033E7012F-part3 ++ # even in case of complicated device nodes e.g. things like /dev/mapper/SIBM_2810XIV_78033E7012F-part3 + # cf. current_orig_device_basename_alnum_uppercase in layout/prepare/default/300_map_disks.sh + local xfs_device_basename_alnum_uppercase="$( echo $xfs_device_basename | tr -d -c '[:alnum:]' | tr '[:lower:]' '[:upper:]' )" + # cf. predefined_input_variable_name in the function UserInput in lib/_input-output-functions.sh +diff --git a/usr/share/rear/layout/prepare/default/010_prepare_files.sh b/usr/share/rear/layout/prepare/default/010_prepare_files.sh +index 85964712..7a980e63 100644 +--- a/usr/share/rear/layout/prepare/default/010_prepare_files.sh ++++ b/usr/share/rear/layout/prepare/default/010_prepare_files.sh +@@ -5,6 +5,7 @@ LAYOUT_DEPS="$VAR_DIR/layout/diskdeps.conf" + LAYOUT_TODO="$VAR_DIR/layout/disktodo.conf" + LAYOUT_CODE="$VAR_DIR/layout/diskrestore.sh" + LAYOUT_XFS_OPT_DIR="$VAR_DIR/layout/xfs" ++LAYOUT_XFS_OPT_DIR_RESTORE="$LAYOUT_XFS_OPT_DIR/restore" + + FS_UUID_MAP="$VAR_DIR/layout/fs_uuid_mapping" + LUN_WWID_MAP="$VAR_DIR/layout/lun_wwid_mapping" +diff --git a/usr/share/rear/layout/prepare/default/319_rename_xfs_configs.sh b/usr/share/rear/layout/prepare/default/319_rename_xfs_configs.sh +new file mode 100644 +index 00000000..406afa61 +--- /dev/null ++++ b/usr/share/rear/layout/prepare/default/319_rename_xfs_configs.sh +@@ -0,0 +1,83 @@ ++# Cleanup directory which hold XFS configuration file for `rear recover'. ++# This will avoid possible mess in LAYOUT_XFS_OPT_DIR_RESTORE if `rear recover' ++# would be launched multiple times, where user will choose different disk ++# mapping each time. ++# Removing and creating LAYOUT_XFS_OPT_DIR_RESTORE will ensure that ReaR will ++# have only current files available during current session. ++rm -rf "$LAYOUT_XFS_OPT_DIR_RESTORE" ++mkdir -p "$LAYOUT_XFS_OPT_DIR_RESTORE" ++ ++local excluded_configs=() ++ ++# Read $MAPPING_FILE (disk_mappings) to discover final disk mapping. ++# Once mapping is known, configuration files can be renamed. ++# (e.g. sds2.xfs to sdb2.xfs, ...) ++while read source target junk ; do ++ # Disks in MAPPING_FILE are listed with full device path. Since XFS config ++ # files are created in format e.g. sda2.xfs strip prefixed path to have ++ # only short device name available. ++ base_source=$(basename "$source") ++ base_target=$(basename "$target") ++ ++ # Check if XFS configuration file for whole device (unpartitioned) ++ # is available (sda, sdb, ...). If so, rename and copy it to ++ # LAYOUT_XFS_OPT_DIR_RESTORE. ++ if [ -e "$LAYOUT_XFS_OPT_DIR/$base_source.xfs" ]; then ++ Log "Migrating XFS configuration file $base_source.xfs to $base_target.xfs" ++ cp "$v" "$LAYOUT_XFS_OPT_DIR/$base_source.xfs" \ ++ "$LAYOUT_XFS_OPT_DIR_RESTORE/$base_target.xfs" ++ ++ # Replace old device name in meta-data= option in XFS ++ # configuration file as well. ++ sed -i s#"meta-data=${source}\(\s\)"#"meta-data=${target}\1"# \ ++ "$LAYOUT_XFS_OPT_DIR_RESTORE/$base_target.xfs" ++ ++ # Mark XFS config file as processed to avoid copying it again later. ++ # More details on why are configs excluded can be found near the ++ # end of this script (near `tar' command). ++ excluded_configs+=("--exclude=$base_source.xfs") ++ fi ++ ++ # Find corresponding partitions to source disk in LAYOUT_FILE ++ # and migrate/rename them too if necessary. ++ while read _ layout_device _ _ _ _ layout_partition; do ++ if [[ "$source" = "$layout_device" ]]; then ++ base_src_layout_partition=$(basename "$layout_partition") ++ base_dst_layout_partition=${base_src_layout_partition//$base_source/$base_target} ++ dst_layout_partition=${layout_partition//$base_source/$base_target} ++ ++ if [ -e "$LAYOUT_XFS_OPT_DIR/$base_src_layout_partition.xfs" ]; then ++ Log "Migrating XFS configuration $base_src_layout_partition.xfs to $base_dst_layout_partition.xfs" ++ cp "$v" "$LAYOUT_XFS_OPT_DIR/$base_src_layout_partition.xfs" \ ++ "$LAYOUT_XFS_OPT_DIR_RESTORE/$base_dst_layout_partition.xfs" ++ ++ # Replace old device name in meta-data= option in XFS ++ # configuration file as well. ++ sed -i s#"meta-data=${layout_partition}\(\s\)"#"meta-data=${dst_layout_partition}\1"# \ ++ "$LAYOUT_XFS_OPT_DIR_RESTORE/$base_dst_layout_partition.xfs" ++ ++ # Mark XFS config file as processed to avoid copying it again later. ++ # More details on why are configs excluded can be found near the ++ # end of this script (near `tar' command). ++ excluded_configs+=("--exclude=$base_src_layout_partition.xfs") ++ fi ++ fi ++ done < <( grep -E "^part " "$LAYOUT_FILE" ) ++done < <( grep -v '^#' "$MAPPING_FILE" ) ++ ++pushd "$LAYOUT_XFS_OPT_DIR" >/dev/null ++# Copy remaining files ++# We need to copy remaining files into LAYOUT_XFS_OPT_DIR_RESTORE which will ++# serve as base dictionary where ReaR will look for XFS config files. ++# It is necessary to copy only files that were not previously processed, ++# because in LAYOUT_XFS_OPT_DIR they are still listed with ++# original name and copy to LAYOUT_XFS_OPT_DIR_RESTORE could overwrite ++# XFS configs already migrated. ++# e.g. with following disk mapping situation: ++# /dev/sda2 => /dev/sdb2 ++# /dev/sdb2 => /dev/sda2 ++# Files in LAYOUT_XFS_OPT_DIR_RESTORE would be overwritten by XFS configs with ++# wrong names. ++# tar is used to take advantage of its exclude feature. ++tar cf - --exclude=restore "${excluded_configs[@]}" . | tar xfp - -C "$LAYOUT_XFS_OPT_DIR_RESTORE" ++popd >/dev/null +diff --git a/usr/share/rear/layout/save/GNU/Linux/100_create_layout_file.sh b/usr/share/rear/layout/save/GNU/Linux/100_create_layout_file.sh +index 7895e4ee..fc0fa8fc 100644 +--- a/usr/share/rear/layout/save/GNU/Linux/100_create_layout_file.sh ++++ b/usr/share/rear/layout/save/GNU/Linux/100_create_layout_file.sh +@@ -10,6 +10,7 @@ mkdir -p $v $VAR_DIR/layout/config + # We need directory for XFS options only if XFS is in use: + if test "$( mount -t xfs )" ; then + LAYOUT_XFS_OPT_DIR="$VAR_DIR/layout/xfs" ++ rm -rf $LAYOUT_XFS_OPT_DIR + mkdir -p $v $LAYOUT_XFS_OPT_DIR + fi + diff --git a/rear.spec b/rear.spec index ebbe9a60b34b8aa44199f27fcf16d92e773a4284..a83036cf1c8dd2c9c0202cea78fe553e236163a3 100644 --- a/rear.spec +++ b/rear.spec @@ -4,7 +4,7 @@ Summary: Relax-and-Recover is a Linux disaster recovery and system migration tool Name: rear Version: 2.6 -Release: 4%{anolis_release}%{?dist} +Release: 9%{anolis_release}%{?dist} License: GPLv3 Group: Applications/File URL: http://relax-and-recover.org/ @@ -24,6 +24,17 @@ Patch38: rear-bz2049091.patch Patch39: rear-pr2675.patch Patch40: rear-bz2048454.patch Patch41: rear-bz2035939.patch +Patch42: rear-bz2083272.patch +Patch43: rear-bz2111049.patch +Patch44: rear-bz2104005.patch +Patch48: rear-bz2111059.patch +Patch49: pxe-rsync-output.patch +Patch50: rear-bz2119501.patch +Patch51: rear-bz2120736.patch +Patch52: rear-bz2091163.patch +Patch53: rear-bz2130945.patch +Patch54: rear-bz2131946.patch +Patch56: s390-no-clobber-disks.patch ### Dependencies on all distributions BuildRequires: asciidoc @@ -59,7 +70,11 @@ Provides: /usr/sbin/rear #Requires: cfg2html %ifarch x86_64 i686 -Requires: syslinux +Requires: syslinux +%endif +%ifarch x86_64 i686 aarch64 +# We need mkfs.vfat for recreating EFI System Partition +Recommends: dosfstools %endif %ifarch ppc ppc64 Requires: yaboot @@ -71,6 +86,11 @@ Requires: /usr/sbin/ofpathname # Needed to make PowerVM LPARs bootable Requires: /usr/sbin/bootlist %endif +%ifarch s390x +# Contain many utilities for working with DASDs +Requires: s390utils-base +Requires: s390utils-core +%endif Requires: crontabs Requires: iproute @@ -141,6 +161,17 @@ fi %patch39 -p1 %patch40 -p1 %patch41 -p1 +%patch42 -p1 +%patch43 -p1 +%patch44 -p1 +%patch48 -p1 +%patch49 -p1 +%patch50 -p1 +%patch51 -p1 +%patch52 -p1 +%patch53 -p1 +%patch54 -p1 +%patch56 -p1 echo "30 1 * * * root test -f /var/lib/rear/layout/disklayout.conf && /usr/sbin/rear checklayout || /usr/sbin/rear mkrescue" >rear.cron @@ -176,9 +207,36 @@ TZ=UTC %{__make} -C doc %doc %{_mandir}/man8/rear.8* %changelog -* Fri Jul 15 2022 Xiaoping Liu - 2.6-4.0.1 +* Wed May 31 2023 Xiaoping Liu - 2.6-9.0.1 - Add doc sub package +* Wed Feb 22 2023 Pavel Cahyna - 2.6-9 +- Backport PR2943 to fix s390x dasd formatting +- Require s390utils-{core,base} on s390x + +* Sun Jan 15 2023 Pavel Cahyna - 2.6-8 +- Apply PR2903 to protect against colons in pvdisplay output +- Apply PR2873 to fix initrd regeneration on s390x +- Apply PR2431 to migrate XFS configuration files + +* Wed Aug 24 2022 Pavel Cahyna - 2.6-7 +- Avoid stderr message about irrelevant broken links +- Changes for NetBackup (NBU) 9.x support + +* Tue Aug 9 2022 Pavel Cahyna - 2.6-6 +- Restore usr/share/rear/output/PXE/default/820_copy_to_net.sh + removed in 2.4-19 with rsync refactor. + It is still needed to use a rsync OUTPUT_URL when OUTPUT=PXE and BACKUP=RSYNC + +* Mon Aug 8 2022 Pavel Cahyna - 2.6-5 +- Apply PR2795 to detect changes in system files between backup + and rescue image +- Apply PR2808 to exclude dev/watchdog* from recovery system +- Backport upstream PRs 2827 and 2839 to pass -y to lvcreate instead of one "y" + on stdin +- Apply PR2811 to add the PRE/POST_RECOVERY_COMMANDS directives +- Recommend dosfstools on x86 and aarch64, needed for EFI System Partition + * Sun Feb 27 2022 Pavel Cahyna - 2.6-4 - Apply PR2675 to fix leftover temp dir bug (introduced in backported PR2625) - Apply PR2603 to ignore unused PV devices diff --git a/s390-no-clobber-disks.patch b/s390-no-clobber-disks.patch new file mode 100644 index 0000000000000000000000000000000000000000..8d2f81ae15889fddb647c97384d2e8c9b4fff097 --- /dev/null +++ b/s390-no-clobber-disks.patch @@ -0,0 +1,751 @@ +diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf +index 23a83b71..0d13b487 100644 +--- a/usr/share/rear/conf/default.conf ++++ b/usr/share/rear/conf/default.conf +@@ -416,6 +416,18 @@ test "$RECOVERY_UPDATE_URL" || RECOVERY_UPDATE_URL="" + # export MIGRATION_MODE='true' + # directly before he calls "rear recover": + test "$MIGRATION_MODE" || MIGRATION_MODE='' ++#### ++ ++#### ++# Formatting DASDs (S/390 specific) ++# DASD (Direct Access Storage Device) denotes a disk drive on the S/390 architecture. ++# DASDs need to be formatted before use (even before creating a partition table on them). ++# By default ReaR will format the DASDs that are going to be used to recreate the system ++# (are referenced in disklayout.conf) before recreating the disk layout. ++# This can be suppressed by setting FORMAT_DASDS="false". It can be useful when one intends ++# to use already formatted DASDs as recovery target. ++FORMAT_DASDS="" ++#### + + ## + # Resizing partitions in MIGRATION_MODE during "rear recover" +diff --git a/usr/share/rear/layout/prep-for-mount/Linux-s390/205_s390_enable_disk.sh b/usr/share/rear/layout/prep-for-mount/Linux-s390/205_s390_enable_disk.sh +new file mode 120000 +index 00000000..5f7a2ac0 +--- /dev/null ++++ b/usr/share/rear/layout/prep-for-mount/Linux-s390/205_s390_enable_disk.sh +@@ -0,0 +1 @@ ++../../prepare/Linux-s390/205_s390_enable_disk.sh +\ No newline at end of file +diff --git a/usr/share/rear/layout/prepare/GNU/Linux/100_include_partition_code.sh b/usr/share/rear/layout/prepare/GNU/Linux/100_include_partition_code.sh +index 13c69ce8..2a2bc33f 100644 +--- a/usr/share/rear/layout/prepare/GNU/Linux/100_include_partition_code.sh ++++ b/usr/share/rear/layout/prepare/GNU/Linux/100_include_partition_code.sh +@@ -24,6 +24,7 @@ fi + ### Prepare a disk for partitioning/general usage. + create_disk() { + local component disk size label junk ++ local blocksize layout dasdtype dasdcyls junk2 + read component disk size label junk < <(grep "^disk $1 " "$LAYOUT_FILE") + + ### Disks should be block devices. +@@ -67,7 +68,8 @@ sync + + EOF + +- create_partitions "$disk" "$label" ++ # $junk can contain useful DASD-specific fields ++ create_partitions "$disk" "$label" "$junk" + + cat >> "$LAYOUT_CODE" <> "$LAYOUT_CODE" <"$DASD_FORMAT_CODE" ++ ++# Show the current output of lsdasd, it can be useful for identifying disks ++# (in particular it shows the Linux device name <-> virtual device number mapping, ++# formatted / unformatted status and the number/size of blocks when formatted ) ++echo "# Current output of 'lsdasd':" >>"$DASD_FORMAT_CODE" ++lsdasd | sed -e 's/^/# /' >>"$DASD_FORMAT_CODE" ++ ++cat <>"$DASD_FORMAT_CODE" ++ ++LogPrint "Start DASD format restoration." ++ ++set -e ++set -x ++ ++EOF ++ ++while read component disk size label junk; do ++ if [ "$label" == dasd ]; then ++ # Ignore excluded components. ++ # Normally they are removed in 520_exclude_components.sh, ++ # but we run before it, so we must skip them here as well. ++ if IsInArray "$disk" "${EXCLUDE_RECREATE[@]}" ; then ++ Log "Excluding $disk from DASD reformatting." ++ continue ++ fi ++ # dasd has more fields - junk is not junk anymore ++ read blocksize layout dasdtype dasdcyls junk2 <<<$junk ++ dasd_format_code "$disk" "$size" "$blocksize" "$layout" "$dasdtype" "$dasdcyls" >> "$DASD_FORMAT_CODE" || \ ++ LogPrintError "Error producing DASD format code for $disk" ++ fi ++done < <(grep "^disk " "$LAYOUT_FILE") ++ ++cat <>"$DASD_FORMAT_CODE" ++ ++set +x ++set +e ++ ++LogPrint "DASD(s) formatted." ++ ++EOF +diff --git a/usr/share/rear/layout/prepare/Linux-s390/370_confirm_dasd_format_code.sh b/usr/share/rear/layout/prepare/Linux-s390/370_confirm_dasd_format_code.sh +new file mode 100644 +index 00000000..5ba4edd5 +--- /dev/null ++++ b/usr/share/rear/layout/prepare/Linux-s390/370_confirm_dasd_format_code.sh +@@ -0,0 +1,69 @@ ++# adapted from 100_confirm_layout_code.sh ++# ++# Let the user confirm the ++# DASD format code (dasdformat.sh) script. ++# ++ ++is_false "$FORMAT_DASDS" && return 0 ++ ++# Show the user confirmation dialog in any case but when not in migration mode ++# automatically proceed with less timeout USER_INPUT_INTERRUPT_TIMEOUT (by default 10 seconds) ++# to avoid longer delays (USER_INPUT_TIMEOUT is by default 300 seconds) in case of unattended recovery: ++# (taken from 120_confirm_wipedisk_disks.sh) ++local timeout="$USER_INPUT_TIMEOUT" ++is_true "$MIGRATION_MODE" || timeout="$USER_INPUT_INTERRUPT_TIMEOUT" ++ ++rear_workflow="rear $WORKFLOW" ++original_disk_space_usage_file="$VAR_DIR/layout/config/df.txt" ++rear_shell_history="$( echo -e "cd $VAR_DIR/layout/\nvi $DASD_FORMAT_CODE\nless $DASD_FORMAT_CODE" )" ++unset choices ++choices[0]="Confirm DASD format script and continue '$rear_workflow'" ++choices[1]="Edit DASD format script ($DASD_FORMAT_CODE)" ++choices[2]="View DASD format script ($DASD_FORMAT_CODE)" ++choices[3]="View original disk space usage ($original_disk_space_usage_file)" ++choices[4]="Confirm what is currently on the DASDs, skip formatting them and continue '$rear_workflow'" ++choices[5]="Use Relax-and-Recover shell and return back to here" ++choices[6]="Abort '$rear_workflow'" ++prompt="Confirm or edit the DASD format script" ++choice="" ++wilful_input="" ++# When USER_INPUT_DASD_FORMAT_CODE_CONFIRMATION has any 'true' value be liberal in what you accept and ++# assume choices[0] 'Confirm DASD format' was actually meant: ++is_true "$USER_INPUT_DASD_FORMAT_CODE_CONFIRMATION" && USER_INPUT_DASD_FORMAT_CODE_CONFIRMATION="${choices[0]}" ++while true ; do ++ choice="$( UserInput -I DASD_FORMAT_CODE_CONFIRMATION -t "$timeout" -p "$prompt" -D "${choices[0]}" "${choices[@]}" )" && wilful_input="yes" || wilful_input="no" ++ case "$choice" in ++ (${choices[0]}) ++ # Confirm DASD format file and continue: ++ is_true "$wilful_input" && LogPrint "User confirmed DASD format script" || LogPrint "Continuing '$rear_workflow' by default" ++ break ++ ;; ++ (${choices[1]}) ++ # Run 'vi' with the original STDIN STDOUT and STDERR when 'rear' was launched by the user: ++ vi $DASD_FORMAT_CODE 0<&6 1>&7 2>&8 ++ ;; ++ (${choices[2]}) ++ # Run 'less' with the original STDIN STDOUT and STDERR when 'rear' was launched by the user: ++ less $DASD_FORMAT_CODE 0<&6 1>&7 2>&8 ++ ;; ++ (${choices[3]}) ++ # Run 'less' with the original STDIN STDOUT and STDERR when 'rear' was launched by the user: ++ less $original_disk_space_usage_file 0<&6 1>&7 2>&8 ++ ;; ++ (${choices[4]}) ++ # Confirm what is on the disks and continue without formatting ++ FORMAT_DASDS="false" ++ ;; ++ (${choices[5]}) ++ # rear_shell runs 'bash' with the original STDIN STDOUT and STDERR when 'rear' was launched by the user: ++ rear_shell "" "$rear_shell_history" ++ ;; ++ (${choices[6]}) ++ abort_dasd_format ++ Error "User chose to abort '$rear_workflow' in ${BASH_SOURCE[0]}" ++ ;; ++ esac ++done ++ ++chmod +x $DASD_FORMAT_CODE ++ +diff --git a/usr/share/rear/layout/prepare/Linux-s390/400_run_dasd_format_code.sh b/usr/share/rear/layout/prepare/Linux-s390/400_run_dasd_format_code.sh +new file mode 100644 +index 00000000..16451af6 +--- /dev/null ++++ b/usr/share/rear/layout/prepare/Linux-s390/400_run_dasd_format_code.sh +@@ -0,0 +1,185 @@ ++# adapted from 200_run_layout_code.sh ++# ++# Run the DASD format code (dasdformat.sh) ++# again and again until it succeeds or the user aborts. ++# ++ ++# Skip DASD formatting when the user has explicitly specified to not format them ++# or when the user selected "Confirm what is currently on the DASDs, skip formatting them" ++# in 370_confirm_dasd_format_code.sh ++ ++is_false "$FORMAT_DASDS" && return 0 ++ ++function lsdasd_output () { ++ lsdasd 1>> >( tee -a "$RUNTIME_LOGFILE" 1>&7 ) ++} ++ ++rear_workflow="rear $WORKFLOW" ++original_disk_space_usage_file="$VAR_DIR/layout/config/df.txt" ++rear_shell_history="$( echo -e "cd $VAR_DIR/layout/\nvi $DASD_FORMAT_CODE\nless $RUNTIME_LOGFILE" )" ++wilful_input="" ++ ++unset choices ++choices[0]="Rerun DASD format script ($DASD_FORMAT_CODE)" ++choices[1]="View '$rear_workflow' log file ($RUNTIME_LOGFILE)" ++choices[2]="Edit DASD format script ($DASD_FORMAT_CODE)" ++choices[3]="Show what is currently on the disks ('lsdasd' device list)" ++choices[4]="View original disk space usage ($original_disk_space_usage_file)" ++choices[5]="Use Relax-and-Recover shell and return back to here" ++choices[6]="Confirm what is currently on the disks and continue '$rear_workflow'" ++choices[7]="Abort '$rear_workflow'" ++prompt="DASD format choices" ++ ++choice="" ++# When USER_INPUT_DASD_FORMAT_CODE_RUN has any 'true' value be liberal in what you accept and ++# assume choices[0] 'Rerun DASD format script' was actually meant ++# regardless that this likely lets 'rear recover' run an endless loop ++# of failed DASD format attempts but ReaR must obey what the user specified ++# (perhaps it is intended to let 'rear recover' loop here until an admin intervenes): ++is_true "$USER_INPUT_DASD_FORMAT_CODE_RUN" && USER_INPUT_DASD_FORMAT_CODE_RUN="${choices[0]}" ++ ++unset confirm_choices ++confirm_choices[0]="Confirm recreated DASD format and continue '$rear_workflow'" ++confirm_choices[1]="Go back one step to redo DASD format" ++confirm_choices[2]="Use Relax-and-Recover shell and return back to here" ++confirm_choices[3]="Abort '$rear_workflow'" ++confirm_prompt="Confirm the recreated DASD format or go back one step" ++confirm_choice="" ++# When USER_INPUT_DASD_FORMAT_MIGRATED_CONFIRMATION has any 'true' value be liberal in what you accept and ++# assume confirm_choices[0] 'Confirm recreated DASD format and continue' was actually meant: ++is_true "$USER_INPUT_DASD_FORMAT_MIGRATED_CONFIRMATION" && USER_INPUT_DASD_FORMAT_MIGRATED_CONFIRMATION="${confirm_choices[0]}" ++ ++# Run the DASD format code (dasdformat.sh) ++# again and again until it succeeds or the user aborts ++# or the user confirms to continue with what is currently on the disks ++# (the user may have setup manually what he needs via the Relax-and-Recover shell): ++while true ; do ++ prompt="The DASD format had failed" ++ # After switching to recreating with DASD format script ++ # change choices[0] from "Run ..." to "Rerun ...": ++ choices[0]="Rerun DASD format script ($DASD_FORMAT_CODE)" ++ # Run DASD_FORMAT_CODE in a sub-shell because it sets 'set -e' ++ # so that it exits the running shell in case of an error ++ # but that exit must not exit this running bash here: ++ ( source $DASD_FORMAT_CODE ) ++ # One must explicitly test whether or not $? is zero in a separated bash command ++ # because with bash 3.x and bash 4.x code like ++ # # ( set -e ; cat qqq ; echo "hello" ) && echo ok || echo failed ++ # cat: qqq: No such file or directory ++ # hello ++ # ok ++ # does not work as one may expect (cf. what "man bash" describes for 'set -e'). ++ # There is a subtle behavioural difference between bash 3.x and bash 4.x ++ # when a script that has 'set -e' set gets sourced: ++ # With bash 3.x the 'set -e' inside the sourced script is effective: ++ # # echo 'set -e ; cat qqq ; echo hello' >script.sh ++ # # ( source script.sh ) && echo ok || echo failed ++ # cat: qqq: No such file or directory ++ # failed ++ # With bash 4.x the 'set -e' inside the sourced script gets noneffective: ++ # # echo 'set -e ; cat qqq ; echo hello' >script.sh ++ # # ( source script.sh ) && echo ok || echo failed ++ # cat: qqq: No such file or directory ++ # hello ++ # ok ++ # With bash 3.x and bash 4.x testing $? in a separated bash command ++ # keeps the 'set -e' inside the sourced script effective: ++ # # echo 'set -e ; cat qqq ; echo hello' >script.sh ++ # # ( source script.sh ) ; (( $? == 0 )) && echo ok || echo failed ++ # cat: qqq: No such file or directory ++ # failed ++ # See also https://github.com/rear/rear/pull/1573#issuecomment-344303590 ++ if (( $? == 0 )) ; then ++ prompt="DASD format had been successful" ++ # When DASD_FORMAT_CODE succeeded and when not in migration mode ++ # break the outer while loop and continue the "rear recover" workflow ++ # which means continue with restoring the backup: ++ is_true "$MIGRATION_MODE" || break ++ # When DASD_FORMAT_CODE succeeded in migration mode ++ # let the user explicitly confirm the recreated (and usually migrated) format ++ # before continuing the "rear recover" workflow with restoring the backup. ++ # Show the recreated DASD format to the user on his terminal (and also in the log file): ++ LogPrint "Recreated DASD format:" ++ lsdasd_output ++ # Run an inner while loop with a user dialog so that the user can inspect the recreated DASD format ++ # and perhaps even manually fix the recreated DASD format if it is not what the user wants ++ # (e.g. by using the Relax-and-Recover shell and returning back to this user dialog): ++ while true ; do ++ confirm_choice="$( UserInput -I DASD_FORMAT_MIGRATED_CONFIRMATION -p "$confirm_prompt" -D "${confirm_choices[0]}" "${confirm_choices[@]}" )" && wilful_input="yes" || wilful_input="no" ++ case "$confirm_choice" in ++ (${confirm_choices[0]}) ++ # Confirm recreated DASD format and continue: ++ is_true "$wilful_input" && LogPrint "User confirmed recreated DASD format" || LogPrint "Continuing with recreated DASD format by default" ++ # Break the outer while loop and continue with restoring the backup: ++ break 2 ++ ;; ++ (${confirm_choices[1]}) ++ # Go back one step to redo DASD format: ++ # Only break the inner while loop (i.e. this user dialog loop) ++ # and continue with the next user dialog below: ++ break ++ ;; ++ (${confirm_choices[2]}) ++ # rear_shell runs 'bash' with the original STDIN STDOUT and STDERR when 'rear' was launched by the user: ++ rear_shell "" "$rear_shell_history" ++ ;; ++ (${confirm_choices[3]}) ++ abort_dasd_format ++ Error "User did not confirm the recreated DASD format but aborted '$rear_workflow' in ${BASH_SOURCE[0]}" ++ ;; ++ esac ++ done ++ fi ++ # Run an inner while loop with a user dialog so that the user can fix things ++ # when DASD_FORMAT_CODE failed. ++ # Such a fix does not necessarily mean the user must change ++ # the dasdformat.sh script when DASD_FORMAT_CODE failed. ++ # The user might also fix things by only using the Relax-and-Recover shell and ++ # then confirm what is on the disks and continue with restoring the backup ++ # or abort this "rear recover" run to re-try from scratch. ++ while true ; do ++ choice="$( UserInput -I DASD_FORMAT_CODE_RUN -p "$prompt" -D "${choices[0]}" "${choices[@]}" )" && wilful_input="yes" || wilful_input="no" ++ case "$choice" in ++ (${choices[0]}) ++ # Rerun or run (after switching to recreating with DASD format script) DASD format script: ++ is_true "$wilful_input" && LogPrint "User runs DASD format script" || LogPrint "Running DASD format script by default" ++ # Only break the inner while loop (i.e. the user dialog loop): ++ break ++ ;; ++ (${choices[1]}) ++ # Run 'less' with the original STDIN STDOUT and STDERR when 'rear' was launched by the user: ++ less $RUNTIME_LOGFILE 0<&6 1>&7 2>&8 ++ ;; ++ (${choices[2]}) ++ # Run 'vi' with the original STDIN STDOUT and STDERR when 'rear' was launched by the user: ++ vi $DASD_FORMAT_CODE 0<&6 1>&7 2>&8 ++ ;; ++ (${choices[3]}) ++ LogPrint "This is the current list of DASDs:" ++ lsdasd_output ++ ;; ++ (${choices[4]}) ++ # Run 'less' with the original STDIN STDOUT and STDERR when 'rear' was launched by the user: ++ less $original_disk_space_usage_file 0<&6 1>&7 2>&8 ++ ;; ++ (${choices[5]}) ++ # rear_shell runs 'bash' with the original STDIN STDOUT and STDERR when 'rear' was launched by the user: ++ rear_shell "" "$rear_shell_history" ++ ;; ++ (${choices[6]}) ++ # Confirm what is on the disks and continue: ++ # Break the outer while loop and continue with restoring the backup: ++ break 2 ++ ;; ++ (${choices[7]}) ++ abort_dasd_format ++ Error "User chose to abort '$rear_workflow' in ${BASH_SOURCE[0]}" ++ ;; ++ esac ++ done ++# End of the outer while loop: ++done ++ ++# Local functions must be 'unset' because bash does not support 'local function ...' ++# cf. https://unix.stackexchange.com/questions/104755/how-can-i-create-a-local-function-in-my-bashrc ++unset -f lsdasd_output +diff --git a/usr/share/rear/layout/prepare/default/010_prepare_files.sh b/usr/share/rear/layout/prepare/default/010_prepare_files.sh +index 7a980e63..4191be33 100644 +--- a/usr/share/rear/layout/prepare/default/010_prepare_files.sh ++++ b/usr/share/rear/layout/prepare/default/010_prepare_files.sh +@@ -7,6 +7,8 @@ LAYOUT_CODE="$VAR_DIR/layout/diskrestore.sh" + LAYOUT_XFS_OPT_DIR="$VAR_DIR/layout/xfs" + LAYOUT_XFS_OPT_DIR_RESTORE="$LAYOUT_XFS_OPT_DIR/restore" + ++DASD_FORMAT_CODE="$VAR_DIR/layout/dasdformat.sh" ++ + FS_UUID_MAP="$VAR_DIR/layout/fs_uuid_mapping" + LUN_WWID_MAP="$VAR_DIR/layout/lun_wwid_mapping" + +diff --git a/usr/share/rear/layout/prepare/default/250_compare_disks.sh b/usr/share/rear/layout/prepare/default/250_compare_disks.sh +index c459b928..751433ba 100644 +--- a/usr/share/rear/layout/prepare/default/250_compare_disks.sh ++++ b/usr/share/rear/layout/prepare/default/250_compare_disks.sh +@@ -54,7 +54,9 @@ local more_than_one_same_orig_size='' + # Cf. the "Compare disks one by one" code below: + while read disk dev size junk ; do + if IsInArray "$size" "${original_system_used_disk_sizes[@]}" ; then +- more_than_one_same_orig_size='true' ++ if ! has_mapping_hint "$dev" ; then ++ more_than_one_same_orig_size='true' ++ fi + else + original_system_used_disk_sizes+=( "$size" ) + fi +@@ -109,14 +111,17 @@ fi + # No further disk comparisons are needed when MIGRATION_MODE is already set true above: + if ! is_true "$MIGRATION_MODE" ; then + # Compare original disks and their possible target disk one by one: +- while read disk dev size junk ; do +- dev=$( get_sysfs_name $dev ) ++ while read disk devnode size junk ; do ++ dev=$( get_sysfs_name $devnode ) + Log "Comparing $dev" + if test -e "/sys/block/$dev" ; then + Log "Device /sys/block/$dev exists" + newsize=$( get_disk_size $dev ) + if test "$newsize" -eq "$size" ; then + LogPrint "Device $dev has expected (same) size $size bytes (will be used for '$WORKFLOW')" ++ elif test "$( get_mapping_hint $devnode )" == "$devnode" ; then ++ Debug "Found identical mapping hint ${devnode} -> ${devnode}" ++ LogPrint "Device $dev found according to mapping hints (will be used for '$WORKFLOW')" + else + LogPrint "Device $dev has size $newsize bytes but $size bytes is expected (needs manual configuration)" + MIGRATION_MODE='true' +diff --git a/usr/share/rear/layout/prepare/default/300_map_disks.sh b/usr/share/rear/layout/prepare/default/300_map_disks.sh +index 2e90768c..468aa35c 100644 +--- a/usr/share/rear/layout/prepare/default/300_map_disks.sh ++++ b/usr/share/rear/layout/prepare/default/300_map_disks.sh +@@ -112,7 +112,14 @@ while read keyword orig_device orig_size junk ; do + # Continue with next original device when it is already used as source in the mapping file: + is_mapping_source "$orig_device" && continue + # First, try to find if there is a current disk with same name and same size as the original: +- sysfs_device_name="$( get_sysfs_name "$orig_device" )" ++ # (possibly influenced by mapping hints if known) ++ if has_mapping_hint "$orig_device" ; then ++ candidate_target_device_name="$( get_mapping_hint "$orig_device" )" ++ Debug "Using mapping hint ${candidate_target_device_name} as candidate for $orig_device mapping" ++ else ++ candidate_target_device_name="$orig_device" ++ fi ++ sysfs_device_name="$( get_sysfs_name "$candidate_target_device_name" )" + current_device="/sys/block/$sysfs_device_name" + if test -e $current_device ; then + current_size=$( get_disk_size $sysfs_device_name ) +@@ -122,11 +129,16 @@ while read keyword orig_device orig_size junk ; do + # Continue with next one if the current one is already used as target in the mapping file: + is_mapping_target "$preferred_target_device_name" && continue + # Use the current one if it is of same size as the old one: +- if test "$orig_size" -eq "$current_size" ; then ++ if has_mapping_hint "$orig_device" || test "$orig_size" -eq "$current_size" ; then + # Ensure the determined target device is really a block device: + if test -b "$preferred_target_device_name" ; then ++ if has_mapping_hint "$orig_device" ; then ++ mapping_reason="determined by mapping hint" ++ else ++ mapping_reason="same name and same size $current_size" ++ fi + add_mapping "$orig_device" "$preferred_target_device_name" +- LogPrint "Using $preferred_target_device_name (same name and same size) for recreating $orig_device" ++ LogPrint "Using $preferred_target_device_name ($mapping_reason) for recreating $orig_device" + # Continue with next original device in the LAYOUT_FILE: + continue + fi +diff --git a/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh b/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh +index 3ab7357d..da6ce64c 100644 +--- a/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh ++++ b/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh +@@ -362,18 +362,27 @@ Log "Saving disk partitions." + + if [[ $blockd == dasd* && "$ARCH" == "Linux-s390" ]] ; then + devname=$(get_device_name $disk) ++ dasdnum=$( lsdasd | awk "\$3 == \"$blockd\" { print \$1}" ) ++ dasdstatus=$( lsdasd | awk "\$3 == \"$blockd\" { print \$2}" ) ++ # ECKD or FBA ++ dasdtype=$( lsdasd | awk "\$3 == \"$blockd\" { print \$5}" ) ++ if [ "$dasdtype" != ECKD ] && [ "$dasdtype" != FBA ]; then ++ LogPrint "Type $dasdtype of DASD $blockd unexpected: neither ECKD nor FBA" ++ fi + +- echo "# active dasd bus and channel" +- echo "# bus-id type" +- echo "dasd_channel $( lsdasd|grep $blockd|awk '{ print $1 " " $2 " " $3 " " $4}' )" +- +- echo "# dasdfmt - disk layout is either cdl for the compatible disk layout (default) or ldl" +- echo "# example usage: dasdfmt -b 4096 -d cdl -y /dev/dasda" +- layout=$(dasdview -x /dev/$blockd|grep "^format"|awk '{print $7}') +- blocksize=$( dasdview -i /dev/$blockd|grep blocksize|awk '{print $6}' ) +- echo "# dasdfmt $devname" +- echo "# dasdfmt -b -d -y " +- echo "dasdfmt -b $blocksize -d $layout -y $devname" ++ echo "# every DASD bus and channel" ++ echo "# Format: dasd_channel " ++ echo "dasd_channel $dasdnum $blockd" ++ ++ # We need to print the dasd_channel line even for ignored devices, ++ # otherwise we could have naming gaps and naming would change when ++ # recreating layout. ++ # E.g. if dasda is ignored, and dasdb is not, we would create only dasdb ++ # during recreation, but it would be named dasda. ++ if [ "$dasdstatus" != active ]; then ++ Log "Ignoring $blockd: it is not active (Status is $dasdstatus)" ++ continue ++ fi + fi + + #FIXME: exclude *rpmb (Replay Protected Memory Block) for nvme*, mmcblk* and uas +@@ -387,11 +396,38 @@ Log "Saving disk partitions." + devname=$(get_device_name $disk) + devsize=$(get_disk_size ${disk#/sys/block/}) + disktype=$(parted -s $devname print | grep -E "Partition Table|Disk label" | cut -d ":" -f "2" | tr -d " ") +- +- echo "# Disk $devname" +- echo "# Format: disk " +- echo "disk $devname $devsize $disktype" +- ++ if [ "$disktype" != "dasd" ]; then ++ echo "# Disk $devname" ++ echo "# Format: disk " ++ echo "disk $devname $devsize $disktype" ++ elif [[ $blockd == dasd* && "$ARCH" == "Linux-s390" ]] ; then ++ layout=$(dasdview -x $devname |grep "^format"|awk '{print $7}') ++ case "$layout" in ++ (NOT) ++ # NOT -> dasdview has printed "NOT formatted" ++ LogPrintError "Ignoring $blockd: it is not formatted" ++ continue ++ ;; ++ (LDL|CDL) ++ ;; ++ (*) ++ BugError "Invalid 'disk $devname' entry (unknown DASD layout $layout)" ++ ;; ++ esac ++ test $disktype || Error "No partition label type for DASD entry 'disk $devname'" ++ blocksize=$( get_block_size "$blockd" ) ++ if ! test $blocksize ; then ++ # fallback - ugly method ++ blocksize=$( dasdview -i $devname |grep blocksize|awk '{print $6}' ) ++ test $blocksize || Error "Unknown block size of DASD $devname" ++ fi ++ dasdcyls=$( get_dasd_cylinders "$blockd" ) ++ echo "# Disk $devname" ++ echo "# Format: disk " ++ echo "disk $devname $devsize $disktype $blocksize $layout $dasdtype $dasdcyls" ++ else ++ Error "Invalid 'disk $devname' entry (DASD partition label on non-s390 arch $ARCH)" ++ fi + echo "# Partitions on $devname" + echo "# Format: part /dev/" + extract_partitions "$devname" +diff --git a/usr/share/rear/lib/layout-functions.sh b/usr/share/rear/lib/layout-functions.sh +index 91c5ff73..4f5b8f6f 100644 +--- a/usr/share/rear/lib/layout-functions.sh ++++ b/usr/share/rear/lib/layout-functions.sh +@@ -93,6 +93,12 @@ abort_recreate() { + restore_original_file "$LAYOUT_FILE" + } + ++abort_dasd_format() { ++ Log "Error detected during DASD formatting." ++ Log "Restoring saved original $DASD_FORMAT_FILE" ++ restore_original_file "$DASD_FORMAT_FILE" ++} ++ + # Test and log if a component $1 (type $2) needs to be recreated. + create_component() { + local device="$1" +@@ -722,6 +728,46 @@ get_block_size() { + fi + } + ++# Get the number of cylinders of a DASD. ++# The number of cylinders has the advantage of being fixed - size depends on formatting ++# and number of cylinders is valid even for unformatted DASDs, size is not. ++get_dasd_cylinders() { ++ local disk_name="${1##*/}" # /some/path/dasda -> dasda ++ local dasd_cyls ++ ++ dasd_cyls=$(dasdview -i /dev/$disk_name | grep cylinders | cut -d ':' -f2 | awk '{print $4}') ++ ### Make sure we always return a number ++ echo $(( dasd_cyls )) ++} ++ ++# Sometimes we know what the new device for the original device should be in a more reliable way ++# than by looking at disk sizes. THis information is called "mapping hints". Let's pass them ++# to the mapping code using the DISK_MAPPING_HINTS array. Each element of the array has the form ++# "/dev/source /dev/target" (space-separated). ++ ++# Output the mapping hint for the original device. ++function get_mapping_hint () { ++ local device="$1" ++ local hint mapping_hint_source mapping_hint_target ++ ++ for hint in "${DISK_MAPPING_HINTS[@]}"; do ++ mapping_hint_source=${hint%% *} ++ mapping_hint_target=${hint##* } ++ if [ "${device}" == "${mapping_hint_source}" ] ; then ++ echo "$mapping_hint_target" ++ return 0 ++ fi ++ done ++ return 1 ++} ++ ++# Determine if there is a mapping hint for the original device. ++function has_mapping_hint () { ++ local device="$1" ++ ++ get_mapping_hint "$device" > /dev/null ++} ++ + # Get the UUID of a device. + # Device is something like /dev/sda1. + blkid_uuid_of_device() {