summaryrefslogtreecommitdiffstats
path: root/perl-install/bootloader.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/bootloader.pm')
-rw-r--r--perl-install/bootloader.pm94
1 files changed, 87 insertions, 7 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index 643b67e46..d3783ed49 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -583,10 +583,52 @@ sub read_grub_menu_lst {
\%b;
}
-# FIXME: actually read back previous conf
+sub _parse_extlinux_conf() {
+ my $global = 1;
+ my ($e, %b);
+
+ my $f = "$::prefix/boot/extlinux/extlinux.conf";
+ -e $f or return;
+
+ foreach (cat_utf8($f)) {
+ chomp;
+ s/^\s*//; s/\s*$//;
+ next if /^#/ || /^$/;
+ my ($keyword, $v) = split('[ \t=]+', $_, 2) or
+ warn qq(unknown line in $f: "$_"\n), next;
+
+ $keyword = lc($keyword);
+
+ if ($keyword eq 'label') {
+ push @{$b{entries}}, $e = { label => $v };
+ $global = 0;
+ } elsif ($global) {
+ $b{$keyword} = $v;
+ } else {
+ if ($keyword eq 'kernel') {
+ $e->{type} = 'image';
+ $e->{kernel_or_dev} = $v;
+ } else {
+ $e->{$keyword} = $v;
+ }
+ }
+ }
+
+ %b;
+}
+
sub read_uboot() {
- +{ method => 'uboot' };
+ my %b = _parse_extlinux_conf();
+
+ $b{method} = 'uboot';
+ $b{timeout} //= 30;
+
+ $b{perImageAppend} //= $b{entries}[0]{append};
+
+ \%b;
}
+
+# FIXME: actually read back previous conf
sub read_cromwell() {
+{ method => 'cromwell' };
}
@@ -1294,6 +1336,7 @@ sub config_files() {
lilo => '/etc/lilo.conf',
grub => '/boot/grub/menu.lst',
grub_install => '/boot/grub/install.sh',
+ uboot => '/boot/extlinux/extlinux.conf',
);
map_each {
@@ -1310,6 +1353,7 @@ sub method2text {
'grub2' => N("GRUB2 with text menu"),
'grub-graphic' => N("GRUB with graphical menu"),
'grub-menu' => N("GRUB with text menu"),
+ 'uboot' => N("U-Boot/Extlinux with text menu"),
}->{$method};
}
@@ -1401,13 +1445,49 @@ sub check_enough_space() {
}
sub install_uboot {
- my ($_bootloader, $_all_hds) = @_;
- log::l("uboot - nothing to install...");
+ my ($bootloader, $all_hds) = @_;
+ write_uboot($bootloader, $all_hds);
+ when_config_changed_uboot($bootloader);
}
-sub write_uboot {
- my ($_bootloader, $_all_hds) = @_;
- log::l("uboot - nothing to write...");
+
+sub _write_extlinux_conf {
+ my ($bootloader, $_all_hds) = @_;
+
+ if (!get_label($bootloader->{default}, $bootloader)) {
+ log::l("default bootloader entry $bootloader->{default} is invalid, choosing another one");
+ $bootloader->{default} = $bootloader->{entries}[0]{label};
+ }
+
+ my @conf;
+ push @conf, "# File generated by DrakX/drakboot";
+ push @conf, "default " . $bootloader->{default} if $bootloader->{default};
+ push @conf, "timeout " . $bootloader->{timeout} if $bootloader->{timeout};
+ # needed to show boot menu and enable timeout
+ push @conf, "menu title Boot Menu" if $bootloader->{timeout};
+
+ foreach my $entry (@{$bootloader->{entries}}) {
+ push @conf, "\nlabel $entry->{label}";
+ push @conf, " kernel $entry->{kernel_or_dev}";
+ push @conf, " initrd $entry->{initrd}" if $entry->{initrd};
+ push @conf, " fdtdir $entry->{fdtdir}" if $entry->{fdtdir};
+
+ my @append;
+ push @append, "root=" . $entry->{root} if $entry->{root};
+ push @append, $entry->{append} if $entry->{append};
+ push @conf, " append " . join(' ', @append) if @append;
+ }
+
+ my $f = "$::prefix/boot/extlinux/extlinux.conf";
+ log::l("writing extlinux config to $f");
+ renamef($f, $f . '.old');
+ output_with_perm($f, 0600, map { "$_\n" } @conf);
+}
+
+sub write_uboot {
+ my ($bootloader, $all_hds) = @_;
+ _write_extlinux_conf($bootloader, $all_hds);
}
+
sub when_config_changed_uboot {
my ($_bootloader) = @_;
#- do not do anything