diff options
author | Olivier Blin <dev@blino.org> | 2018-04-09 22:28:24 +0200 |
---|---|---|
committer | Olivier Blin <dev@blino.org> | 2018-05-16 02:10:35 +0200 |
commit | 006edf2c7e85f4d81a3548fd280b7804991daeb4 (patch) | |
tree | 757dc0261c2d70647f33503a5a0272fa3a432550 /perl-install | |
parent | 28043924cf781f55a79c8f3542dc5cc7009df35b (diff) | |
download | drakx-006edf2c7e85f4d81a3548fd280b7804991daeb4.tar drakx-006edf2c7e85f4d81a3548fd280b7804991daeb4.tar.gz drakx-006edf2c7e85f4d81a3548fd280b7804991daeb4.tar.bz2 drakx-006edf2c7e85f4d81a3548fd280b7804991daeb4.tar.xz drakx-006edf2c7e85f4d81a3548fd280b7804991daeb4.zip |
bootloader: read/write extlinux.conf in U-Boot backend for ARM
Read and write an extlinux.conf file in /boot/extlinux, it will be
automatically found by U-boot if located on an active partition.
Keep the "uboot" backend name, since we may do some U-Boot
installation steps later on.
Also, the extlinux.conf code could be used to support other
bootloaders from the syslinux family.
fixup extlinux
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/NEWS | 1 | ||||
-rw-r--r-- | perl-install/bootloader.pm | 94 |
2 files changed, 88 insertions, 7 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS index 4c9f08905..b71697a7d 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -1,6 +1,7 @@ - harddrake2: o don't list HDA "input" devices as keyboards (mga#9986) - drakboot: + o read/write extlinux.conf in U-Boot backend for ARM o build initrd for ARM arch o create /usr/lib/linux symlink for devicee tree files 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 |