From 678aa093a297e48931afd7f7654e34ada9f63dad Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Tue, 9 Aug 2022 15:07:07 +0100 Subject: drakboot: add options to change the rEFInd background (mga#28073) --- perl-install/bootloader.pm | 53 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) (limited to 'perl-install/bootloader.pm') diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index afd3ed91a..b3156ddff 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -713,12 +713,17 @@ sub read_refind_config { my ($bootloader) = @_; #- These are the rEFInd default values. - $bootloader->{use_nvram} = 1; + $bootloader->{use_nvram} = 1; + $bootloader->{banner_path} = ''; + $bootloader->{banner_scale} = 'noscale'; if (-r "$::prefix/boot/EFI/EFI/refind/refind.conf") { read_refind_conf($bootloader, "$::prefix/boot/EFI/EFI/refind/refind.conf"); } elsif (-r "$::prefix/boot/EFI/EFI/BOOT/refind.conf") { read_refind_conf($bootloader, "$::prefix/boot/EFI/EFI/BOOT/refind.conf"); + } else { + #- This is the preferred value if rEFInd is not yet installed, + $bootloader->{banner_path} = 'refind_banner.png'; } } @@ -727,6 +732,10 @@ sub read_refind_conf { foreach (cat_utf8($config_file)) { if ($_ =~ /^\s*use_nvram\s+(false|off|0)/) { $bootloader->{use_nvram} = 0; + } elsif ($_ =~ /^\s*banner\s+(\S*)/) { + $bootloader->{banner_path} = $1; + } elsif ($_ =~ /^\s*banner_scale\s+(\S*)/) { + $bootloader->{banner_scale} = $1; } } } @@ -2512,21 +2521,43 @@ sub install_refind { or die "refind-install failed: $error"; } + #- This file is not used by rEFInd itself. It just defines the paths to the image + #- files used for the standard banner choices. + my %h = getVarsFromSh("$::prefix/etc/sysconfig/refind"); + + my $banner_source; + if ($bootloader->{banner_path} eq 'refind_banner.png') { + $banner_source = "$::prefix" . $h{REFIND_BANNER}; + } elsif ($bootloader->{banner_path} eq 'mageia_theme.png') { + $banner_source = "$::prefix" . $h{MAGEIA_THEME}; + } + if (defined $banner_source && ! (-f $banner_source && -r $banner_source)) { + log::l("$banner_source does not exist or is not readable"); + $bootloader->{banner_path} = ''; + $bootloader->{banner_scale} = 'noscale'; + undef $banner_source; + } + #- Try both possible locations for the main config file. - modify_refind_config($bootloader, "$::prefix/boot/EFI/EFI/refind"); - modify_refind_config($bootloader, "$::prefix/boot/EFI/EFI/BOOT"); + modify_refind_config($bootloader, $banner_source, "$::prefix/boot/EFI/EFI/refind"); + modify_refind_config($bootloader, $banner_source, "$::prefix/boot/EFI/EFI/BOOT"); write_refind($bootloader, $all_hds); } sub modify_refind_config { - my ($bootloader, $esp_dir) = @_; + my ($bootloader, $banner_source, $esp_dir) = @_; my $config_file = "$esp_dir/refind.conf"; return if ! -f $config_file || ! -w $config_file; my $use_nvram = $bootloader->{use_nvram} ? 'true' : 'false'; + my $banner_path = $bootloader->{banner_path}; + cp_f($banner_source, "$esp_dir/$banner_path") if (defined $banner_source); + + my $banner_scale = $bootloader->{banner_scale}; + my @config; my %done; @@ -2536,6 +2567,20 @@ sub modify_refind_config { push @config, "use_nvram $use_nvram\n" ; $done{use_nvram} = 1; } + } elsif ($_ =~ /^#?banner\s/) { + if (! $done{banner_path}) { + if ($banner_path eq '') { + push @config, "#banner my_banner.png\n"; + } else { + push @config, "banner $banner_path\n"; + } + $done{banner_path} = 1; + } + } elsif ($_ =~ /^#?banner_scale\s/) { + if (! $done{banner_scale}) { + push @config, "banner_scale $banner_scale\n"; + $done{banner_scale} = 1; + } } else { push @config, $_; } -- cgit v1.2.1