#801 Issue closed: ebiso (wrongly) called even if BIOS is used

Labels: bug, cleanup, fixed / solved / done

jsmeix opened issue at 2016-03-23 12:55:

I am using rear 1.18
on a QEMU/KVM virtual machine
with BIOS.

Nevertheless I have in /etc/rear/local.conf

ISO_MKISOFS_BIN=/usr/bin/ebiso

That leads to the following:

# rear -d -D mkbackup
Relax-and-Recover 1.18 / Git
Using log file: /var/log/rear/rear-g34.log
mkdir: created directory '/var/lib/rear/output'
Creating disk layout
Creating root filesystem layout
Copying files and directories
Copying binaries and libraries
Copying kernel modules
Creating initramfs
Making ISO image
Wrote ISO image: /var/lib/rear/output/rear-g34.iso ()
Copying resulting files to nfs location
ERROR: Could not copy files to nfs location
Aborting due to an error, check /var/log/rear/rear-g34.log for details
You should also rm -Rf /tmp/rear.tZn8Fadjbn7L2EI
Terminated

In /var/log/rear/rear-g34.log there is

+ source /usr/share/rear/prep/ISO/GNU/Linux/32_verify_mkisofs.sh
++ '[' -x /usr/bin/ebiso ']'
++ StopIfError 'Could not find '\''mkisofs'\'' compatible program. Please install '\''mkisofs'\'', '\''genisoimage'\'' or '\''ebiso'\'' into your path or manually set ISO_MKISOFS_BIN [/usr/bin/ebiso]'
++ ((  0 != 0  ))
++ Log 'Using '\''/usr/bin/ebiso'\'' to create ISO images'
...
+ source /usr/share/rear/output/ISO/Linux-i386/80_create_isofs.sh
++ '[' -x /usr/bin/ebiso ']'
++ StopIfError 'ISO_MKISOFS_BIN [/usr/bin/ebiso] not an executable !'
++ ((  0 != 0  ))
+++ basename /usr/bin/ebiso
++ [[ ebiso = \e\b\i\s\o ]]
+++ basename
basename: missing operand
Try 'basename --help' for more information.
...
+ source /usr/share/rear/output/ISO/Linux-i386/82_create_iso_image.sh
++ Log 'Starting '\''/usr/bin/ebiso'\'''
...
++ echo -e 'Making ISO image'
++ ((  USING_UEFI_BOOTLOADER  ))
++ EFIBOOT=
++ pushd /tmp/rear.tZn8Fadjbn7L2EI/tmp/isofs
+++ basename /usr/bin/ebiso
++ [[ ebiso = \e\b\i\s\o ]]
++ [[ '' == 1 ]]
++ /usr/bin/ebiso -v -o /var/lib/rear/output/rear-g34.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -volid RELAXRECOVER -v -iso-level 3 .
++ StopIfError 'Could not create ISO image (with /usr/bin/ebiso)'
++ ((  0 != 0  ))
++ popd

What that wrong ebiso call results on command line:

# pushd /tmp/rear.tZn8Fadjbn7L2EI/tmp/isofs
/tmp/rear.tZn8Fadjbn7L2EI/tmp/isofs ~

# /usr/bin/ebiso -v -o /var/lib/rear/output/rear-g34.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -volid RELAXRECOVER -v -iso-level 3 .

0.2.1

# echo $?
0

The wrong ebiso call results actually only a "ebiso -v" which runs successfully so that no error is detected here.

In particular the following if else clause in
usr/share/rear/output/ISO/Linux-i386/82_create_iso_image.sh
does not work in practice:

pushd $TMP_DIR/isofs >&8
# ebiso currenlty works only with UEFI
if [[ $(basename $ISO_MKISOFS_BIN) = "ebiso" && $USING_UEFI_BOOTLOADER == 1 ]]; then
   $ISO_MKISOFS_BIN -R -o $ISO_DIR/$ISO_PREFIX.iso -e boot/efiboot.img .
else
   $ISO_MKISOFS_BIN $v -o "$ISO_DIR/$ISO_PREFIX.iso" -b isolinux/isolinux.bin -c isolinux/boot.cat \
       -no-emul-boot -boot-load-size 4 -boot-info-table \
       -R -J -volid "$ISO_VOLID" $EFIBOOT -v -iso-level 3 .  >&8
       ##-R -J -volid "$ISO_VOLID" $EFIBOOT  "${ISO_FILES[@]}"  >&8
fi
StopIfError "Could not create ISO image (with $ISO_MKISOFS_BIN)"
popd >&8

@gozora
I will try to fix it...

gozora commented at 2016-03-23 13:16:

For me it looks like $USING_UEFI_BOOTLOADER is not set for whatever reason ...
By checking usr/share/rear/prep/default/32_include_uefi_env.sh you'd need to have existing /sys/firmware/efi/vars or /sys/firmware/efi/efivars, directory /boot/efi must exist and UEFI_FS_TYPE must be vfat ..

gozora commented at 2016-03-23 13:37:

@jsmeix or, did I just misunderstood and you try to use ebiso on non-UEFI system?

jsmeix commented at 2016-03-23 13:52:

By accident I used ebiso on a non-UEFI system
but rear "fails falsely" in this case - i.e. rear falsely proceeds
and then fails late at an arbitrary unexpected place - instead
rear should have directly aborted with an error where the
actual issue happened.

The following change makes rear "fail correctly" for me
when using ebiso on a non-UEFI system:

 fi

 pushd $TMP_DIR/isofs >&8
-# ebiso currenlty works only with UEFI
-if [[ $(basename $ISO_MKISOFS_BIN) = "ebiso" && $USING_UEFI_BOOTLOADER == 1 ]]; then
+# ebiso uses different command line options and parameters:
+if test "ebiso" = $( basename $ISO_MKISOFS_BIN ) ; then
+    # ebiso currently works only with UEFI:
+    if is_true $USING_UEFI_BOOTLOADER ; then
    $ISO_MKISOFS_BIN -R -o $ISO_DIR/$ISO_PREFIX.iso -e boot/efiboot.img .
 else
+        Error "$ISO_MKISOFS_BIN works only with UEFI"
+    fi
+else
    $ISO_MKISOFS_BIN $v -o "$ISO_DIR/$ISO_PREFIX.iso" -b isolinux/isolinux.bin -c isolinux/boot.cat \
        -no-emul-boot -boot-load-size 4 -boot-info-table \
        -R -J -volid "$ISO_VOLID" $EFIBOOT -v -iso-level 3 .  >&8

Now I get:

# rear -d -D mkbackup
Relax-and-Recover 1.18 / Git
Using log file: /var/log/rear/rear-g34.log
Creating disk layout
Creating root filesystem layout
Copying files and directories
Copying binaries and libraries
Copying kernel modules
Creating initramfs
Making ISO image
ERROR: /usr/bin/ebiso works only with UEFI
Aborting due to an error, check /var/log/rear/rear-g34.log for details
You should also rm -Rf /tmp/rear.S1nhzKTZMm9mfqJ
Terminated

jsmeix commented at 2016-03-23 13:56:

@gdha
I wonder what is better coding style:

The currently "everywhere else" used

if (( USING_UEFI_BOOTLOADER )) ; then

or a more general test via

if is_true $USING_UEFI_BOOTLOADER ; then

Personally I would prefer the latter
and furthermore that matches better
https://github.com/rear/rear/wiki/Coding-Style

gozora commented at 2016-03-23 13:57:

@jsmeix, yes that was certainly a logical error ...

gdha commented at 2016-03-23 16:42:

@jsmeix if is_true $USING_UEFI_BOOTLOADER ; then is indeed preferred.

jsmeix commented at 2016-03-24 10:14:

O.k.
I will do a pull request that fixes the actual issue here
plus
using is_true $USING_UEFI_BOOTLOADER everywhere.

jsmeix commented at 2016-03-24 13:10:

A first pull request https://github.com/rear/rear/pull/806 only fixes the actual issue here.

A second separated pull request will using is_true $USING_UEFI_BOOTLOADER everywhere - i.e. it will implement an enhancement change from current numerical-only values for USING_UEFI_BOOTLOADER to general yes/no values.

jsmeix commented at 2016-03-24 14:35:

The second pull request https://github.com/rear/rear/pull/807 allows generic yes/no values for USING_UEFI_BOOTLOADER

As a consequence it use everywhere generic tests via
is_true $USING_UEFI_BOOTLOADER and
is_false $USING_UEFI_BOOTLOADER

The latter requires the new counterpart function
is_false to test for an explicit 'no' value.

jsmeix commented at 2016-03-31 12:10:

Because there are no objections so far
I assume it is o.k. that I meged
https://github.com/rear/rear/pull/806 (error out if ebiso is used but no UEFI)
and
https://github.com/rear/rear/pull/807 (allow generic yes/no values for USING_UEFI_BOOTLOADER)
myself.

With both pull requests merged,
I consider this issue here as fixed.


[Export of Github issue for rear/rear.]