#3136 PR open: Include GRUB tools unconditionally and don't create $VAR_DIR/recovery/bootdisk in prep

Labels: bug, cleanup

pcahyna opened issue at 2024-01-25 16:06:

Pull Request Details:
  • Type: Bug Fix

  • Impact: Normal

  • Reference to related issue (URL): see discussion in commit ccae513d8362078c5d4bcffe9b1167835e6449b8

  • How was this pull request tested?

    • touch /boot/grub2FAIL full backup and recovery. Original code fails to recover: "Installing GRUB Legacy boot loader:
      ERROR: Cannot install GRUB Legacy boot loader because there is no 'grub' program." New code works.
    • touch /boot/grub2FAIL && shopt -s nullglob && rear -d mkrescue && find /*/tmp/rear.*/rootfs /tmp/rear.*/rootfs -name grub\*-\* -executable
      original code: nothing
      new code:
  • Description of the changes in this pull request:
    • Do not detect GRUB before including GRUB tools. When there was a file matching grub* in /boot (e.g. /boot/grub2FAIL), the code got confused by the glob pattern intended to match /boot/grub or /boot/grub2 and subsequently the rest of the script was skipped, as grubdir got assigned something like "/boot/grub2 /boot/grub2FAIL", which does not exist, so grubdir was set to /boot/grub, which does not exist either, and grub-probe fails.
      As a result, the GRUB tools were not included in the recovery image.
      The code have been proceeding anyway when neither grub-probe nor grub2-probe was found, so the tests have not been very useful.
      Fix and simplify by not checking for the existence of GRUB and just trying to include the GRUB tools always.
    • Don't create $VAR_DIR/recovery/bootdisk in prep. This file is unused and creating it in prep stage is against the guideline in prep/README:
You should not put scripts into this 'prep' stage that modify things
in ROOTFS_DIR or in VAR_DIR/recovery and VAR_DIR/layout because
scripts for ROOTFS_DIR belong to the 'rescue' stage and scripts
for VAR_DIR/recovery and VAR_DIR/layout belong to the 'layout' stages.

[Export of Github issue for rear/rear.]