summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakboot
blob: fc047cf67bda99c6ad342e3f1aa782e85f389fe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/perl

use lib qw(/usr/lib/libDrakX);

use common qw(:system :file :functional);
use interactive;
use any;
use lilo;
use detect_devices;
use fsedit;
use c;

local $_ = join '', @ARGV;

/-h/ and die "usage: drakboot [--expert]\n";

$::expert = /-expert/;
$::isStandalone = 1;

my $in = vnew interactive('su');

my %l = (
	 arch() !~ /sparc|alpha/ ? (
	 _("Configure LILO/GRUB") => '',
				   ) : (),
	 _("Create a boot floppy") => ['/usr/X11R6/bin/drakfloppy'],
	 _("Format floppy") => [ '/usr/bin/kfloppy', '/usr/bin/gfloppy' ],
);

while (my ($k, $v) = each %l) {
    $v or next;
    foreach (@$v) {
	-x $_ and $l{$k} = $_, last;
    }
    -x $l{$k} or delete $l{$_};
}

if ($ENV{DISPLAY} && c::Xtest($ENV{DISPLAY})) {
    my $cmd = $l{$in->ask_from_list(_("Choice"), _("What do you want to do?"), [ keys %l ])};
    exec $cmd if $cmd;
}

my $bootloader = lilo::read('', '/etc/lilo.conf');
local ($_) = `detectloader`;
$bootloader->{methods} = { lilo => 1, grub => !!/grub/i };

my $hds = catch_cdie { fsedit::hds([ detect_devices::hds() ], {}) } sub { 1 };
my $fstab = [ fsedit::get_fstab(@$hds) ];
fs::get_mntpoints_from_fstab($fstab);

ask:
any::setupBootloader($in, $bootloader, $hds, $fstab, $ENV{SECURE_LEVEL}) or $in->exit(0);

eval { lilo::install('', $bootloader, $fstab, $hds) };

if ($@) {
    $in->ask_warn('', 
		 [ _("Installation of LILO failed. The following error occured:"),
		   grep { !/^Warning:/ } cat_("/tmp/.error") ]);
    unlink "/tmp/.error";
    goto ask;
}

$in->exit(0);