Bug 32686

Summary: aarch64 installer fails trying to install grub2-efi(x86_64)
Product: Mageia Reporter: Jybz <j.biernacki+mga>
Component: InstallerAssignee: Thierry Vignaud <thierry.vignaud>
Status: REOPENED --- QA Contact:
Severity: normal    
Priority: Normal CC: mageia, pterjan
Version: CauldronKeywords: PATCH
Target Milestone: ---   
Hardware: All   
OS: Linux   
URL: https://gitweb.mageia.org/software/drakx/log/?h=user/jibz/grub2-efi-aarch64
Whiteboard:
Source RPM: drakx-installer-stage2 CVE:
Status comment:
Attachments: (get_grub2_pkg) split it out
Fix grub2 pkg name on aarch64 (mga#32686)
[DEBUG] simulate UEFI on a !UEFI box (replace 'x64' by 'aa64' for faking aarch64)

Description Jybz 2024-01-04 16:53:51 CET
Hello hello,

I'm trying to port the netinstall. Now I'm blocked right after the partitioning page, it tries to install grub2-efi(x86_64) on aarch64.

The issue is here:
https://gitweb.mageia.org/software/drakx/tree/perl-install/install/any.pm#n776
if not i*86, it defaults to x86_64, the case for aarch64.

I already tried the customization without success: https://wiki.mageia.org/en/Drakx-installer_tips_and_tricks#Customisation_of_the_install_by_patching_it
because the path does not match and the tools unsquashfs is not present on the netinstaller, and my system refuses to mount rw the netinstall generated iso.

In order to help, I'm suggesting a patch:
https://gitweb.mageia.org/software/drakx/diff/?h=user/jibz/grub2-efi-aarch64

Please review the patch, test it if you can (I can't, I even don't have the storage space for a local altered mirror).
Comment 1 Thierry Vignaud 2024-01-04 17:11:30 CET
1) Switch is obsolete, we should use "given/when" instead or a simple hash.
It also mean we would need to include obsolete Switch in stage2 (which is not done in your patch)
See https://metacpan.org/dist/perl/view/pod/perlsyn.pod#Switch-Statements for the "new" way.

2) why do you change the indentation in the else branch?
That will get in the way of "git blame" for no reason

3) anyway the logic already exists in bootloader :
https://gitweb.mageia.org/software/drakx/tree/perl-install/bootloader.pm#n2651
So no need to reinvent the wheel.
We just to split that logic in some function in eg: any.pm.

CC: (none) => thierry.vignaud

Comment 2 Thierry Vignaud 2024-01-04 17:29:45 CET
Created attachment 14241 [details]
(get_grub2_pkg) split it out
Comment 3 Thierry Vignaud 2024-01-04 17:30:04 CET
Created attachment 14242 [details]
Fix grub2 pkg name on aarch64 (mga#32686)
Comment 4 Thierry Vignaud 2024-01-04 17:31:08 CET
Also, the installer is basically frozen for stable release, so let's make this bug happen to Cauldron.
We can always backport it if there's ever a mga9.1 release (like we had mga7.1)

Version: 9 => Cauldron

Thierry Vignaud 2024-01-04 17:31:17 CET

Keywords: (none) => PATCH

Thierry Vignaud 2024-01-04 17:32:14 CET

Source RPM: drakx => drakx-installer-stage2

Comment 5 Jybz 2024-01-04 17:43:06 CET
Wow. Ok.

Why to you work on bugzilla with patches instead of git branches ?
Comment 6 Thierry Vignaud 2024-01-04 17:47:05 CET
(In reply to Jybz from comment #0)

> I already tried the customization without success:
> https://wiki.mageia.org/en/Drakx-
> installer_tips_and_tricks#Customisation_of_the_install_by_patching_it
> because the path does not match and the tools unsquashfs is not present on
> the netinstaller, and my system refuses to mount rw the netinstall generated
> iso.

unsquashfs is part of the squashfs-tools pkg.
This part is meant for customizing a mirror as the stage2 sqfs image is in install/stage2/ on the mirror.
Eg: https://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/cauldron/x86_64/install/stage2/

If you want to do live customization, you need a patch file and thus need to follow https://wiki.mageia.org/en/Drakx-installer_tips_and_tricks#Customisation_of_the_install_by_patching_it

You just need to do a "patch" file and adding it on eg a USB key plugged and add the patch option in the booloader phase to the installer (eg <esc>, then typing "linux patch" <enter> for a ISO boot on ia32)

patch doing sg as the above patches:
<<<<
use bootloader;
bootlooader::get_grub2_pkg = sub {
(…)
};
>
use install::any
undef *default_bootloader;
*default_bootloader = sub {
(…)
};
>>>

See http://gitweb.mageia.org/software/drakx/tree/perl-install/patch?h=distro/mdv2008.0 for examples
Comment 7 Lewis Smith 2024-01-04 20:12:06 CET
Well Thierry, thank you for jumping on this so quickly & thoroughly.
Please excuse assignment to yourself...

Assignee: bugsquad => thierry.vignaud
CC: thierry.vignaud => (none)

Comment 8 Thierry Vignaud 2024-01-04 21:38:19 CET
Why create a temp branch for just 2 small patches ?
Anyway it's fixed in git after a quick test
Comment 9 Thierry Vignaud 2024-01-04 21:42:30 CET
Created attachment 14243 [details]
[DEBUG] simulate UEFI on a !UEFI box (replace 'x64' by 'aa64' for faking aarch64)

For the record, I used the attached patch in order to test just this function with my 2 patches, using :
perl -I. -I/usr/lib/libDrakX -Minstall::any -e 'my $p = install::any::default_bootloader(); warn $p->[0], "\n"'

You can use such tricks in order to test changes if you don't have a local mirror.
I'd a quirk to develop/debug drakx w/o a full local mirror but I don't remember if I described it somewhere.

It was probably using ../tools/drakx-in-chroot --repository=http://… :
https://gitweb.mageia.org/software/drakx/tree/tools/drakx-in-chroot#n22
Comment 10 Thierry Vignaud 2024-01-04 21:44:15 CET
Fixed in git

Status: NEW => RESOLVED
Resolution: (none) => FIXED

Comment 11 Jybz 2024-01-04 21:53:00 CET
Thank you very much.

I need the new version on the mirrors.
Should I reopen the ticket? Or should I create a new one?
Comment 12 Nicolas Lécureuil 2024-01-05 09:28:52 CET
it will be available on the mirors when a new drakx will be pushed on the BS.

CC: (none) => mageia

Comment 13 Jybz 2024-01-07 21:54:44 CET
It works and it does not work.

The error message is now :
can not find grub2-efi(aarch64)

So the package name is now well defined, but despite being present on the mirror:
> [root@raspberry ~]# urpmq --provides grub2-efi
> grub2-efi: bootloader
> grub2-efi: config(grub2-efi)[== 2.06-28.mga9]
> grub2-efi: grub2-efi[== 2.06-28.mga9]
> grub2-efi: grub2-efi(aarch-64)[== 2.06-28.mga9]
> grub2-efi: grub2bootloader[== 2.06-28.mga9]

it does not find it.

Maybe for arm, we should just install grub2-efi (without "(aarch64)" ) ?

I don't know how to debug.
Jybz 2024-01-07 21:54:58 CET

CC: (none) => pterjan

Comment 14 Jybz 2024-01-07 23:22:27 CET
For a trial,
https://gitweb.mageia.org/software/drakx/tree/perl-install/install/any.pm#n591
at this line, I replace:
> install::pkgs::select_by_package_names_or_die($urpm, default_bootloader(), 1) if !$o->{isUpgrade} && !$o->{match_all_hardware};

with
> install::pkgs::select_by_package_names_or_die($urpm, ['grub2-efi'], 1) if !$o->{isUpgrade} && !$o->{match_all_hardware};

(so without (aarch-64))
and it worked for aarch64.

Is the (x86_64) from the "provides" of the package of is it a way forcing the architecture? I will try another day.

Resolution: FIXED => (none)
Status: RESOLVED => REOPENED