Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 310_include_uefi_tools.sh #1477

Closed
wants to merge 2 commits into from
Closed

Conversation

jmazanek
Copy link

@jmazanek jmazanek commented Sep 8, 2017

This change should resolve issue of rear terminating if /boot/efi directory is not mounted

@jmazanek
Copy link
Author

jmazanek commented Sep 8, 2017

Related issue: #1478

@jsmeix jsmeix requested review from gdha and gozora September 8, 2017 11:44
@jsmeix
Copy link
Member

jsmeix commented Sep 8, 2017

@gdha
I added you as reviewer because
"git log -p --follow usr/share/rear/prep/default/310_include_uefi_tools.sh"
lists you as the main author.

@gozora
I added you as reviewer because it is about "UEFI".

@@ -8,7 +8,9 @@ if [[ ! -d /boot/[eE][fF][iI] ]]; then
if is_true $USING_UEFI_BOOTLOADER; then
Error "USING_UEFI_BOOTLOADER = 1 but there is no directory at /boot/efi or /boot/EFI" # abort
fi
return # skip
if ! grep -q '/boot/efi' /proc/mounts; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that using mountpoint -q /boot/efi is more elegant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or rather mountpoint -q /boot/[Ee][Ff][Ii] as we want to be case-insensitive.

@gozora
Copy link
Member

gozora commented Sep 8, 2017

I'd say that whole condition

if [[ ! -d /boot/[eE][fF][iI] ]]; then
    if is_true $USING_UEFI_BOOTLOADER; then
        Error "USING_UEFI_BOOTLOADER = 1 but there is no directory at /boot/efi or /boot/EFI" # abort
    fi
    return # skip
 fi

is somehow "off topic".

Is there benefit from such check?

V.

@gozora
Copy link
Member

gozora commented Sep 8, 2017

Hmm, OK maybe not fully "off topic", but maybe we could simplify it bit.

Something like

if ! is_true $USING_UEFI_BOOTLOADER; then
    return 
fi

V.

@jsmeix
Copy link
Member

jsmeix commented Sep 8, 2017

@gozora cf.
9bb0735
and for more check
"git log -p --follow usr/share/rear/prep/default/310_include_uefi_tools.sh"

@@ -8,7 +8,9 @@ if [[ ! -d /boot/[eE][fF][iI] ]]; then
if is_true $USING_UEFI_BOOTLOADER; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the whole block is executed when the directory does not exist, what is the point of checking whether it is a mount point?
Shouldn't it be rather

if [[ ! -d /boot/[eE][fF][iI] || ! mountpoint -q /boot/[eE][fF][iI] ]]; then

?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcahyna , correct . I have edited the code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this is not correct either, i will provide a better fix later today.

@pcahyna
Copy link
Member

pcahyna commented Sep 8, 2017

I can reproduce the problem with rear-2.00, but not with the git master branch (revision 0828079). I suspect this fix does not apply to master anymore.

@OliverO2
Copy link
Contributor

OliverO2 commented Sep 8, 2017

I have tested the current master branch on Ubuntu 16.04.3 LTS. On my UEFI boot system, rear mkrescue failed to include efibootmgr and thus rear recover failed to create a booting system. Seems like two effects contributed to the problem:

1. The test in line 7 of 310_include_uefi_tools.sh returns the wrong result if /boot/[eE][fF][iI] exists:

Quoting the bash manual page:

Word splitting and pathname expansion are not performed on the words between the [[ and ]];

Changing the test to [ ! -d /boot/[eE][fF][iI] ] (single brackets) makes it work.

Script to demonstrate:

#!/usr/bin/env bash

ls -ld /boot/[eE][fF][iI]

if [[ ! -d /boot/[eE][fF][iI] ]]; then
    echo "/boot/[eE][fF][iI] not found (original test)"
else
    echo "/boot/[eE][fF][iI] found (original test)"
fi

if [ ! -d /boot/[eE][fF][iI] ]; then
    echo "/boot/[eE][fF][iI] not found (modified test)"
else
    echo "/boot/[eE][fF][iI] found (modified test)"
fi

Script output:

drwxr-xr-x 3 root root 512 Jan  1  1970 /boot/efi
/boot/[eE][fF][iI] not found (original test)
/boot/[eE][fF][iI] found (modified test)

2. USING_UEFI_BOOTLOADER is used before initalization

310_include_uefi_tools.sh requires a correctly set USING_UEFI_BOOTLOADER variable, but this is only set afterwards in 320_include_uefi_env.sh. Renaming 310_include_uefi_tools.sh to 330_include_uefi_tools.sh fixed that problem for me.

@pcahyna
Copy link
Member

pcahyna commented Sep 8, 2017

@OliverO2

On my UEFI boot system, rear mkrescue failed to include efibootmgr and thus rear recover failed to create a booting system.

Thanks for the testing with EFI. When I wrote

I can reproduce the problem with rear-2.00, but not with the git master branch

I was speaking about the problem of rear not working on systems without EFI, and no statement about systems with EFI was intended.

Word splitting and pathname expansion are not performed on the words between the [[ and ]];

Indeed, see my recent comment jsmeix@9bb0735#commitcomment-24177948 on 9bb0735 (which introduced this problem).

USING_UEFI_BOOTLOADER is used before initalization

I also wondered why the variable is being set in 320_xxx and being used in 310_xxx .

@jsmeix
Copy link
Member

jsmeix commented Sep 11, 2017

With
6e05b6f
I use simpler code in 310_include_uefi_tools.sh to fix
jsmeix@9bb0735#commitcomment-24177948
and I did some general cleanup there.
Currently I don't have an UEFI test system running so that
I could not test it myself.
@pcahyna @OliverO2 please test if the current
GitHub master code works for you.

@gozora
please have a look if 310_include_uefi_tools.sh looks better now
(but I do not intend to do a complete overhaul of that script).

@OliverO2
Copy link
Contributor

OliverO2 commented Sep 11, 2017

@jsmeix
I'll test later today. Looks like it will probably work but the problem with $USING_UEFI_BOOTLOADER being used before initialization in 320_include_uefi_env.sh remains. I'd suggest

  • renaming 310_include_uefi_tools.sh to 330_include_uefi_tools.sh and
  • relying on the UEFI presence checks already done in 320_include_uefi_env.sh replacing the two if statements at the top of in 330_include_uefi_tools.sh with this test:
is_true $USING_UEFI_BOOTLOADER || return

@jsmeix
Copy link
Member

jsmeix commented Sep 11, 2017

@OliverO2
my immediate
6e05b6f
was only meant to fix your particular reported
jsmeix@9bb0735#commitcomment-24177948
but currently I do not intend to do a complete overhaul
of the UEFI functionality in ReaR, cf. my
#1477 (comment)
"I do not intend to do a complete overhaul"

@OliverO2
Copy link
Contributor

@jsmeix OK. As I only have a limited amount of time available, I'll wait with testing until both known problems are addressed. I could also provide a PR with a complete UEFI-tested fix if that's what you'd prefer.

@pcahyna
Copy link
Member

pcahyna commented Sep 11, 2017

@jsmeix with this commit you unfortunately broke it for the non-UEFI case, i.e. you reintroduced issue #1478

@jsmeix
Copy link
Member

jsmeix commented Sep 11, 2017

@pcahyna
because my
6e05b6f
is based on the GitHub master code
it did not include anything from this pull request here
so that it cannot fix #1478
but my
6e05b6f
never was intended to fix #1478
it was only intended to make the existing code actually working
as it was menat to work - i.e. to fix only the particular reported
jsmeix@9bb0735#commitcomment-24177948
and nothing more.

@OliverO2
I would very much appreciate it if you coud do a further
pull request with a complete UEFI-tested fix.
Many thanks in advance for it!
And no rush - we all have only limited amount of time available.

@pcahyna
Copy link
Member

pcahyna commented Sep 11, 2017

@jsmeix I see. My point was that before your commit the master branch did not suffer from issue #1478 anymore and so this pull request was actually not needed. See #1477 (comment) (Arguably, this was purely coincidental and #1478 had not been fixed properly.) Anyway, we now need again to fix it.

@jsmeix
Copy link
Member

jsmeix commented Sep 12, 2017

I close this pull request because it is
superseded by
#1481

@jsmeix jsmeix closed this Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants