summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2022-08-09 15:07:07 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2022-08-09 15:07:07 +0100
commit678aa093a297e48931afd7f7654e34ada9f63dad (patch)
tree9441e7ca663be0a99b5e6187c597824abcf63e01 /perl-install
parent96505d35f8f447865a64cedae7dfe19745aa7331 (diff)
downloaddrakx-678aa093a297e48931afd7f7654e34ada9f63dad.tar
drakx-678aa093a297e48931afd7f7654e34ada9f63dad.tar.gz
drakx-678aa093a297e48931afd7f7654e34ada9f63dad.tar.bz2
drakx-678aa093a297e48931afd7f7654e34ada9f63dad.tar.xz
drakx-678aa093a297e48931afd7f7654e34ada9f63dad.zip
drakboot: add options to change the rEFInd background (mga#28073)
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/any.pm51
-rw-r--r--perl-install/bootloader.pm53
2 files changed, 97 insertions, 7 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm
index 0a2efa1a7..2c496e39b 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -509,20 +509,63 @@ sub setupBootloader__refind {
my $update_esp = !$already_installed;
my $as_default = $already_in_default || $b->{removable};
- my $use_nvram = $b->{use_nvram};
- $use_nvram //= 1;
+
+ if (!defined $b->{banner_path}) {
+ #- We haven't yet read any existing configuration, either because we are doing a clean
+ #- install or because we are switching from a different bootloader. Try to read it now.
+ #- Even if we are doing a clean install, rEFInd may already be installed in the ESP.
+ bootloader::read_refind_config($b);
+ }
+
+ my $use_nvram = $b->{use_nvram};
+ my $banner_path = $b->{banner_path};
+ my $banner_scale = $b->{banner_scale};
+ my $banner_type = $banner_path eq 'refind_banner.png' ? 'banner'
+ : $banner_path eq 'mageia_theme.png' ? 'theme'
+ : 'custom';
$in->ask_from_(
{
title => N("Bootloader Configuration"),
interactive_help_id => 'setupBootloader',
},
[
+ { label => N("Install Options"), title => 1, },
{ text => N("Install or update rEFInd in the EFI system partition"),
val => \$update_esp, type => 'bool', disabled => sub { !$already_installed } },
{ text => N("Install in /EFI/BOOT (removable device or workaround for some BIOSs)"),
val => \$as_default, type => 'bool', disabled => sub { !$update_esp } },
{ text => N("Configure rEFInd to store its variables in the EFI NVRAM"),
val => \$use_nvram, type => 'bool' },
+ { label => N("Background"), title => 1, },
+ { val => \$banner_type, type => 'combo', list => [ 'banner', 'theme', 'custom' ],
+ format => sub {
+ my ($choice) = @_;
+ +{
+ 'banner' => N("rEFInd banner"),
+ 'theme' => N("Mageia theme"),
+ 'custom' => N("Custom"),
+ }->{$choice};
+ },
+ changed => sub {
+ if ($banner_type eq 'banner') {
+ $banner_path = 'refind_banner.png';
+ $banner_scale = 'noscale';
+ } elsif ($banner_type eq 'theme') {
+ $banner_path = 'mageia_theme.png';
+ $banner_scale = 'fillscreen';
+ }
+ }
+ },
+ { val => \$banner_path, type => 'entry', disabled => sub { $banner_type ne 'custom' } },
+ { val => \$banner_scale, type => 'combo', list => [ 'noscale', 'fillscreen' ],
+ format => sub {
+ my ($choice) = @_;
+ +{
+ 'noscale' => N("No scaling"),
+ 'fillscreen' => N("Scale to fit"),
+ }->{$choice};
+ }
+ },
]
) or return 0;
@@ -531,7 +574,9 @@ sub setupBootloader__refind {
} else {
$b->{install_mode} = $as_default ? 'no_install' : 'nvram_only';
}
- $b->{use_nvram} = $use_nvram;
+ $b->{use_nvram} = $use_nvram;
+ $b->{banner_path} = $banner_path;
+ $b->{banner_scale} = $banner_scale;
if (my @esp = grep { $_->{mntpoint} eq '/boot/EFI' } @$fstab) {
$b->{esp_device} = $esp[0]{real_device} || fs::wild_device::from_part('', $esp[0]);
}
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, $_;
}