summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/livedrake
blob: 397294543bfae6e2e446f9140186a4b873f1cf1d (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
#!/usr/bin/perl

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

use common qw(:common :system);
use interactive;
use mouse;
use c;

local $_ = join '', @ARGV;

/-h/ and die "usage: livedrake [--auto] [--testing]\n";

$::auto = /-auto/;
$::testing = /-testing/;
$::isStandalone = 1;

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

my $cd_mntpoint = "/mnt/cdrom";

while (! -x "$cd_mntpoint/Mandrake/mdkinst/usr/bin/perl-install/live_install") {
    ejectCdrom();
    $in->ask_okcancel(_("Change Cd-Rom"),
_("Please insert the Installation Cd-Rom in your drive and press Ok when done.
If you don't have it, press Cancel to avoid live upgrade."), 1) or $in->exit(0);
    eval { fs::mount("/mnt/cdrom") };
}

if (-x "$cd_mntpoint/Mandrake/mdkinst/usr/bin/perl-install/live_install") {
    chdir "/$cd_mntpoint/Mandrake/mdkinst/usr/bin/perl-install/";
    exec "./live_install";
}

$in->ask_warn('', _("Unable to start live upgrade !!!\n"));
$in->exit(1);

sub unlockCdrom(;$) {
    my ($cdrom) = @_;
    $cdrom or cat_("/proc/mounts") =~ m|(/dev/\S+)\s+/mnt/cdrom\s| and $cdrom = $1;
    $cdrom or cat_("/etc/fstab") =~ m|(/dev/\S+)\s+/mnt/cdrom\s| and $cdrom = $1;
    eval { $cdrom and ioctl detect_devices::tryOpen($1), c::CDROM_LOCKDOOR(), 0 };
}

sub ejectCdrom(;$) {
    my ($cdrom) = @_;
    $cdrom or cat_("/proc/mounts") =~ m|(/dev/\S+)\s+/mnt/cdrom\s| and $cdrom = $1;
    my $f = eval { $cdrom && detect_devices::tryOpen($cdrom) } or return;
    getFile("XXX"); #- close still opened filehandle
    eval { fs::umount("/mnt/cdrom") };
    ioctl $f, c::CDROMEJECT(), 1;
}