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.pm91
1 files changed, 69 insertions, 22 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index 11f9d2ae3..0d33fb8ca 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -1,4 +1,4 @@
-package bootloader;
+package bootloader; # $Id$
use diagnostics;
use strict;
@@ -10,6 +10,7 @@ use vars qw(%vga_modes);
use common qw(:common :file :functional :system);
use partition_table qw(:types);
use log;
+use any;
use fsedit;
use loopback;
use commands;
@@ -29,6 +30,10 @@ use modules;
"80x34" => '0x0f05',
"80x60" => '0x0f06',
"100x30" => '0x0122',
+ "640x480 in 16 bits (FrameBuffer only)" => 785,
+ "800x600 in 16 bits (FrameBuffer only)" => 788,
+ "1024x768 in 16 bits (FrameBuffer only)" => 791,
+ "1280x1024 in 16 bits (FrameBuffer only)" => 794,
);
my %vga_modes2nb = (
@@ -113,6 +118,15 @@ sub suggest_onmbr($) {
!$type || member($type, qw(dos dummy lilo grub empty)), !$type;
}
+sub compare_entries($$) {
+ my ($a, $b) = @_;
+ my %entries;
+
+ @entries{keys %$a, keys %$b} = ();
+ $a->{$_} eq $b->{$_} and delete $entries{$_} foreach keys %entries;
+ scalar keys %entries;
+}
+
sub add_entry($$) {
my ($entries, $v) = @_;
my (%usedold, $freeold);
@@ -120,13 +134,18 @@ sub add_entry($$) {
do { $usedold{$1 || 0} = 1 if $_->{label} =~ /^old ([^_]*)_/x } foreach @$entries;
foreach (0..scalar keys %usedold) { exists $usedold{$_} or $freeold = $_ || '', last }
- do { $_->{label} = "old${freeold}_$_->{label}" if $_->{label} eq $v->{label} } foreach @$entries;
+ foreach (@$entries) {
+ if ($_->{label} eq $v->{label}) {
+ compare_entries($_, $v) or return; #- avoid inserting it twice as another entry already exists !
+ $_->{label} = "old${freeold}_$_->{label}";
+ }
+ }
push @$entries, $v;
}
sub add_kernel($$$$$) {
my ($prefix, $lilo, $kernelVersion, $specific, $v) = @_;
- my $ext = $specific && "-$specific";
+ my $ext = $specific && "-$specific"; $specific eq 'hack' and $specific = '';
my ($vmlinuz, $image, $initrdImage) = ("vmlinuz-$kernelVersion$specific", "/boot/vmlinuz$ext", "/boot/initrd$ext.img");
-e "$prefix/boot/$vmlinuz" or log::l("unable to find kernel image $prefix/boot/$vmlinuz"), return;
{
@@ -175,11 +194,12 @@ sub dev2prompath { #- SPARC only
$dev;
}
-sub suggest($$$$$) {
- my ($prefix, $lilo, $hds, $fstab, $kernelVersion) = @_;
+sub suggest {
+ my ($prefix, $lilo, $hds, $fstab, $kernelVersion, $vga_fb) = @_;
my $root_part = fsedit::get_root($fstab);
my $root = isLoopback($root_part) ? "loop7" : $root_part->{device};
my $boot = fsedit::get_root($fstab, 'boot')->{device};
+ my $partition = first($boot =~ /\D*(\d*)/);
require c; c::initSilo() if arch() =~ /sparc/;
@@ -213,9 +233,7 @@ sub suggest($$$$$) {
my $msg_en =
__("Welcome to %s the operating system chooser!
-To list the possible choices, press <TAB>.
-
-To load one of them, write its name and press <ENTER> or
+Choose an operating system in the list above or
wait %d seconds for default boot.
");
@@ -233,22 +251,35 @@ wait %d seconds for default boot.
log::l("SMP machine, but no SMP kernel found") unless $isSecure;
$isSMP = 0;
}
- add_kernel($prefix, $lilo, $kernelVersion, $isSecure ? 'secure' : 'smp',
+ add_kernel($prefix, $lilo, $kernelVersion, $isSecure ? 'secure' : $isSMP ? 'smp' : '',
{
label => 'linux',
root => "/dev/$root",
- }) if $isSecure || $isSMP;
+ $vga_fb ? ( vga => $vga_fb) : (), #- using framebuffer
+ });
add_kernel($prefix, $lilo, $kernelVersion, '',
{
- label => $isSecure || $isSMP ? 'linux-up' : 'linux',
+ label => $isSecure || $isSMP ? 'linux-up' : 'linux-nonfb',
root => "/dev/$root",
- });
+ }) if $isSecure || $isSMP || $vga_fb;
add_kernel($prefix, $lilo, $kernelVersion, '',
{
label => 'failsafe',
root => "/dev/$root",
})->{append} .= " failsafe" unless $lilo->{password};
+ #- manage hackkernel if installed.
+ my $hasHack = -e "$prefix/boot/vmlinuz-hack";
+ if ($hasHack) {
+ my $hackVersion = first(readlink("$prefix/boot/vmlinuz-hack") =~ /vmlinuz-(.*)/);
+ add_kernel($prefix, $lilo, $hackVersion, 'hack',
+ {
+ label => 'hack',
+ root => "/dev/$root",
+ $vga_fb ? ( vga => $vga_fb) : (), #- using framebuffer
+ }) if $hackVersion;
+ }
+
if (arch() =~ /sparc/) {
#- search for SunOS, it could be a really better approach to take into account
#- partition type for mounting point.
@@ -275,6 +306,7 @@ wait %d seconds for default boot.
kernel_or_dev => "/dev/$_->{device}",
label => isDos($_) ? "dos" . ($dos++ ? $dos : '') : "windows" . ($win++ ? $win : '') ,
table => "/dev/$_->{rootDevice}",
+ unsafe => 1
}) if isFat($_) && isFat({ type => fsedit::typeOfPart($_->{device}) });
}
}
@@ -282,7 +314,7 @@ wait %d seconds for default boot.
my %l = (
silo => bool(arch() =~ /sparc/),
lilo => bool(arch() !~ /sparc/) && !isLoopback(fsedit::get_root($fstab)),
- grub => bool(arch() !~ /sparc/) && !$::o->{lnx4win}, #1,#!isReiserfs(fsedit::get_root($fstab, 'boot')),
+ grub => bool(arch() !~ /sparc/ && availableRamMB() < 800), #- don't use grub if more than 800MB
loadlin => bool(arch() !~ /sparc/) && -e "/initrd/loopfs/lnx4win",
);
$lilo->{methods} ||= { map { $_ => 1 } grep { $l{$_} } keys %l };
@@ -405,6 +437,7 @@ sub install_lilo($$) {
#- print F "password=", $lilo->{password} if $lilo->{restricted} && $lilo->{password}; #- done by msec
print F "timeout=", round(10 * $lilo->{timeout}) if $lilo->{timeout};
print F "message=/boot/message" if $lilo->{message};
+ print F "menu-scheme=wb:bw:wb:bw";
foreach (@{$lilo->{entries}}) {
print F "$_->{type}=$_->{kernel_or_dev}";
@@ -513,6 +546,8 @@ sub install_grub {
print F "color black/cyan yellow/cyan";
print F "i18n ", $file2grub->("/boot/grub/messages");
print F "keytable ", $file2grub->($lilo->{keytable}) if $lilo->{keytable};
+ print F "altconfigfile ", $file2grub->(my $once = "/boot/grub/menu.once");
+ output "$prefix$once", " " x 100;
map_index {
print F "default $::i" if $_->{label} eq $lilo->{default};
@@ -545,7 +580,6 @@ sub install_grub {
}
}
}
- my $fd = first(detect_devices::floppies());
my $hd = fsedit::get_root($fstab, 'boot')->{rootDevice};
my $dev = dev2grub($lilo->{boot}, \%dev2bios);
@@ -606,16 +640,31 @@ sub install_loadlin {
my ($winpart) = grep { $_->{device_windobe} eq 'C' } @$fstab;
log::l("winpart is $winpart->{device}");
- my $winhandle = loopback::inspect($winpart, $prefix, 'rw');
+ my $winhandle = any::inspect($winpart, $prefix, 'rw');
my $windrive = $winhandle->{dir};
log::l("windrive is $windrive");
+ my ($label, $cmd) = loadlin_cmd($prefix, $lilo);
+
+ #install_loadlin_config_sys($lilo, $windrive, $label, $cmd);
+ #install_loadlin_desktop($lilo, $windrive);
+
+ output "/initrd/loopfs/lnx4win/linux.bat", unix2dos(
+'@echo off
+echo Linux Mandrake
+smartdrv /C
+' . "$cmd\n");
+
+}
+
+sub install_loadlin_config_sys {
+ my ($lilo, $windrive, $label, $cmd) = @_;
+
my $config_sys = "$windrive/config.sys";
local $_ = cat_($config_sys);
output "$windrive/config.mdk", $_ if $_;
my $timeout = $lilo->{timeout} || 1;
- my ($label, $cmd) = loadlin_cmd($prefix, $lilo);
$_ = "
[Menu]
@@ -637,12 +686,10 @@ menudefault=Windows,$timeout
shell=$cmd
";
output $config_sys, unix2dos($_);
- output "/initrd/loopfs/lnx4win/linux.bat", unix2dos(
-'@echo off
-echo Linux Mandrake
-smartdrv /C
-' . "$cmd\n");
+}
+sub install_loadlin_desktop {
+ my ($lilo, $windrive) = @_;
my $windir = lc(cat_("$windrive/msdos.sys") =~ /^WinDir=.:\\(\S+)/m ? $1 : "windows");
#-PO: "Desktop" and "Start Menu" are the name of the directories found in c:\windows
@@ -658,9 +705,9 @@ IconFile=%s
IconIndex=0
), lnx4win_file($lilo, "/", "/lnx4win.ico"));
}
-
}
+
sub install {
my ($prefix, $lilo, $fstab, $hds) = @_;