summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakboot
blob: 68e67d396d6a5a8eb461b140f31a3644896f47c3 (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
#!/usr/bin/perl

# DrakBoot
# Copyright (C) 2001-2008 Mandriva
# Yves Duret, Thierry Vignaud
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

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

use standalone; #- warning, standalone must be loaded very first, for 'explanations'
use common;
use interactive;
use any;
use bootloader;
use fsedit;
use fs;

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

my $all_hds;
my $fstab;
my $bootloader;
my $cmdline = cat_('/proc/cmdline');

my $is_bootloader_mode = !$in->isa('interactive::gtk') || any { /^--boot$/ } @ARGV;

if ($is_bootloader_mode) {
    $all_hds = fsedit::get_hds();
    fs::get_raw_hds('', $all_hds);
    fs::get_info_from_fstab($all_hds);
    $fstab = [ fs::get::fstab($all_hds) ];
    $bootloader = bootloader::read($all_hds);
    if (!$bootloader) {
        $in->ask_okcancel('', N("No bootloader found, creating a new configuration"), 0) or $in->exit;
        any::setupBootloaderBeforeStandalone($in->do_pkgs, $bootloader ||= {}, $all_hds, $fstab);
    }
}

if ($is_bootloader_mode) {
    $::isWizard = 1;
    require security::level;
    my $level = security::level::from_string(security::level::get());
    eval { any::setupBootloaderUntilInstalled($in, $bootloader, $all_hds, $fstab, $level) };
    die if $@ && $@ !~ /^wizcancel/;
    $in->exit(0);
}