diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-11-16 09:39:28 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-11-16 09:39:28 +0000 |
commit | 0e6f5ac2bfb2bd2ebd481b55dc9b63c78d81b9dc (patch) | |
tree | e62ea914ca4edb3737bf3c7a384690e2f36a06d9 /perl-install | |
parent | dcbdd2aa1b731418c649d4d9c4a6148111d17ded (diff) | |
download | drakx-backup-do-not-use-0e6f5ac2bfb2bd2ebd481b55dc9b63c78d81b9dc.tar drakx-backup-do-not-use-0e6f5ac2bfb2bd2ebd481b55dc9b63c78d81b9dc.tar.gz drakx-backup-do-not-use-0e6f5ac2bfb2bd2ebd481b55dc9b63c78d81b9dc.tar.bz2 drakx-backup-do-not-use-0e6f5ac2bfb2bd2ebd481b55dc9b63c78d81b9dc.tar.xz drakx-backup-do-not-use-0e6f5ac2bfb2bd2ebd481b55dc9b63c78d81b9dc.zip |
- create yaboot2file() and use it
- update read_lilo() for yaboot
- update write_yaboot()
- remove {useboot}
- set {boot} to /dev/sda1 in suggest() instead of handling it in write_yaboot()
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/bootloader.pm | 164 |
1 files changed, 88 insertions, 76 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index 65ddf0d1d..ecb5428d7 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -243,6 +243,15 @@ sub read_grub { \%b; } +# assumes file is in /boot +sub yaboot2file { + my ($of_path) = @_; + + #- example of of_path: /pci@f4000000/ata-6@d/disk@0:3,/initrd-2.6.8.1-8mdk.img + + "$::prefix/boot/" . basename($of_path); +} + sub read_yaboot() { &read_lilo } sub read_lilo() { my $file = sprintf("$::prefix/etc/%s.conf", arch() =~ /ppc/ ? 'yaboot' : 'lilo'); @@ -255,9 +264,7 @@ sub read_lilo() { ($_, $v) = /^\s*([^=\s]+)\s*(?:=\s*(.*?))?\s*$/ or log::l("unknown line in $file: $_"), next; if (/^(image|other)$/) { - if (arch() =~ /ppc/) { - $v =~ s/hd:\d+,//g; - } + $v = yaboot2file($v) if arch() =~ /ppc/; push @{$b{entries}}, $e = { type => $_, kernel_or_dev => $v }; $global = 0; } elsif ($global) { @@ -276,26 +283,29 @@ sub read_lilo() { if ((/map-drive/ .. /to/) && /to/) { $e->{mapdrive}{$e->{'map-drive'}} = $v; } else { - if (arch() =~ /ppc/) { - $v =~ s/hd:\d+,//g; - $v =~ s/"//g; + if (arch() =~ /ppc/ && $_ eq 'initrd') { + $v = yaboot2file($v); } $e->{$_} = $v || 1 if !member($_, 'read-only'); } } } - if (arch() !~ /ppc/) { + + sub remove_quotes_and_spaces { + local ($_) = @_; + s/^\s*//; s/\s*$//; + s/^"(.*?)"$/$1/; + s/^\s*//; s/\s*$//; #- do it again for append=" foo" + $_; + } + + $_->{append} = remove_quotes_and_spaces($_->{append}) foreach \%b, @{$b{entries}}; + $_->{label} = remove_quotes_and_spaces($_->{label}) foreach @{$b{entries}}; + $b{default} = remove_quotes_and_spaces($b{default}) if $b{default}; + if (arch() =~ /ppc/) { + $b{method} = 'yaboot'; + } else { delete $b{timeout} unless $b{prompt}; - sub remove_quotes_and_spaces { - local ($_) = @_; - s/^\s*//; s/\s*$//; - s/^"(.*?)"$/$1/; - s/^\s*//; s/\s*$//; #- do it again for append=" foo" - $_; - } - $_->{append} = remove_quotes_and_spaces($_->{append}) foreach \%b, @{$b{entries}}; - $_->{label} = remove_quotes_and_spaces($_->{label}) foreach @{$b{entries}}; - $b{default} = remove_quotes_and_spaces($b{default}) if $b{default}; $b{timeout} = $b{timeout} / 10 if $b{timeout}; $b{method} = 'lilo-' . (member($b{install}, 'text', 'menu', 'graphic') ? $b{install} : 'graphic'); delete $b{message}; @@ -694,7 +704,9 @@ sub suggest { timeout => 50, enableofboot => 1, enablecdboot => 1, - useboot => $boot, + if_(detect_devices::get_mac_model() =~ /IBM/, + boot => "/dev/sda1", + ), xfsroot => $xfsroot, } : { @@ -878,12 +890,12 @@ sub create_link_source() { } sub get_of_dev { - my ($unix_dev) = @_; + my ($dev) = @_; - devices::make("$::prefix$unix_dev"); + devices::make("$::prefix$dev"); #- create it in the chroot my $of_dev; - run_program::rooted_or_die($::prefix, "/usr/sbin/ofpath", ">", \$of_dev, $unix_dev); + run_program::rooted_or_die($::prefix, "/usr/sbin/ofpath", ">", \$of_dev, $dev); chomp($of_dev); log::l("OF Device: $of_dev"); $of_dev; @@ -896,8 +908,16 @@ sub check_enough_space() { } sub write_yaboot { - my ($bootloader, $_all_hds) = @_; + my ($bootloader, $all_hds) = @_; + + my $fstab = [ fs::get::fstab($all_hds) ]; + + my $file2yaboot = sub { + my ($part, $file) = fs::get::file2part($fstab, $_[0]); + get_of_dev('/dev/' . $part->{device}) . "," . $file; + }; + #- do not write yaboot.conf for old-world macs my $mac_type = detect_devices::get_mac_model(); return if $mac_type =~ /Power Macintosh/; @@ -907,63 +927,55 @@ sub write_yaboot { eval { output("$::prefix/boot/message", $bootloader->{message}) } or $bootloader->{message} = 0; } - { - my @conf; - push @conf, "#yaboot.conf - generated by DrakX"; - push @conf, sprintf('init-message="\n%s\n"', $bootloader->{'init-message'}) if $bootloader->{'init-message'}; - - if ($bootloader->{boot}) { - push @conf, "boot=$bootloader->{boot}"; - push @conf, "ofboot=" . get_of_dev($bootloader->{boot}) - } elsif ($mac_type =~ /IBM/) { - push @conf, "boot=/dev/sda1"; - } else { - die "no bootstrap partition defined." - } - - push @conf, map { "$_=$bootloader->{$_}" } grep { $bootloader->{$_} } (qw(delay timeout default), if_($mac_type !~ /IBM/, 'defaultos')); - push @conf, "install=/usr/lib/yaboot/yaboot"; - if ($mac_type =~ /IBM/) { - push @conf, 'nonvram'; - } else { - push @conf, 'magicboot=/usr/lib/yaboot/ofboot'; - push @conf, grep { $bootloader->{$_} } qw(enablecdboot enableofboot); - } - my $boot = $bootloader->{useboot} && "/dev/" . $bootloader->{useboot}; - - foreach (@{$bootloader->{entries}}) { - if ($_->{type} eq "image") { - my $of_dev = ''; - if ($boot !~ /$_->{root}/ && $boot) { - $of_dev = get_of_dev($boot); - push @conf, "$_->{type}=$of_dev," . substr($_->{kernel_or_dev}, 5); - } else { - $of_dev = get_of_dev($_->{root}); - push @conf, "$_->{type}=$of_dev,$_->{kernel_or_dev}"; - } - push @conf, "\tlabel=" . make_label_lilo_compatible($_->{label}); - push @conf, "\troot=$_->{root}"; - if ($boot !~ /$_->{root}/ && $boot) { - push @conf, "\tinitrd=$of_dev," . substr($_->{initrd}, 5) if $_->{initrd}; - } else { - push @conf, "\tinitrd=$of_dev,$_->{initrd}" if $_->{initrd}; - } - #- xfs module on PPC requires larger initrd - say 6MB? - push @conf, "\tinitrd-size=6144" if $bootloader->{xfsroot}; - push @conf, qq(\tappend=" $_->{append}") if $_->{append}; - push @conf, "\tread-write" if $_->{'read-write'}; - push @conf, "\tread-only" if !$_->{'read-write'}; - } else { - my $of_dev = get_of_dev($_->{kernel_or_dev}); - push @conf, "$_->{label}=$of_dev"; - } + my @conf; + + if (!get_label($bootloader->{default}, $bootloader)) { + log::l("default bootloader entry $bootloader->{default} is invalid, choose another one"); + $bootloader->{default} = $bootloader->{entries}[0]{label}; + } + push @conf, "# yaboot.conf - generated by DrakX/drakboot"; + push @conf, "# WARNING: do not forget to run ybin after modifying this file\n"; + push @conf, "default=" . make_label_lilo_compatible($bootloader->{default}) if $bootloader->{default}; + push @conf, sprintf('init-message="\n%s\n"', $bootloader->{'init-message'}) if $bootloader->{'init-message'}; + + if ($bootloader->{boot}) { + push @conf, "boot=$bootloader->{boot}"; + push @conf, "ofboot=" . get_of_dev($bootloader->{boot}) if $mac_type !~ /IBM/; + } else { + die "no bootstrap partition defined."; + } + + push @conf, map { "$_=$bootloader->{$_}" } grep { $bootloader->{$_} } (qw(delay timeout), if_($mac_type !~ /IBM/, 'defaultos')); + push @conf, "install=/usr/lib/yaboot/yaboot"; + if ($mac_type =~ /IBM/) { + push @conf, 'nonvram'; + } else { + push @conf, 'magicboot=/usr/lib/yaboot/ofboot'; + push @conf, grep { $bootloader->{$_} } qw(enablecdboot enableofboot); + } + foreach my $entry (@{$bootloader->{entries}}) { + + if ($entry->{type} eq "image") { + push @conf, "$entry->{type}=" . $file2yaboot->($entry->{kernel_or_dev}); + my @entry_conf; + push @entry_conf, "label=" . make_label_lilo_compatible($entry->{label}); + push @entry_conf, "root=$entry->{root}"; + push @entry_conf, "initrd=" . $file2yaboot->($entry->{initrd}) if $entry->{initrd}; + #- xfs module on PPC requires larger initrd - say 6MB? + push @entry_conf, "initrd-size=6144" if $bootloader->{xfsroot}; + push @entry_conf, qq(append=" $entry->{append}") if $entry->{append}; + push @entry_conf, $entry->{'read-write'} ? "read-write" : "read-only"; + push @conf, map { "\t$_" } @entry_conf; + } else { + my $of_dev = get_of_dev($entry->{kernel_or_dev}); + push @conf, "$entry->{label}=$of_dev"; } - my $f = "$::prefix/etc/yaboot.conf"; - log::l("writing yaboot config to $f"); - rename $f, "$f.old"; - output($f, map { "$_\n" } @conf); } + my $f = "$::prefix/etc/yaboot.conf"; + log::l("writing yaboot config to $f"); + rename $f, "$f.old"; + output($f, map { "$_\n" } @conf); } sub install_yaboot { |