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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
package install_any;
use diagnostics;
use strict;
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK);
@ISA = qw(Exporter);
%EXPORT_TAGS = (
all => [ qw(versionString getNextStep spawnSync spawnShell addToBeDone) ],
);
@EXPORT_OK = map { @$_ } values %EXPORT_TAGS;
use common qw(:common :system);
use pkgs;
use smp;
use log;
1;
sub relGetFile($) {
local $_ = member($_[0], qw(compss compssList depslist hdlist)) ? "base" : "RPMS";
$_ = "Mandrake/$_/$_[0]";
s/i386/i586/;
$_;
}
sub getFile($) {
open getFile, "/tmp/rhimage/" . relGetFile($_[0]) or return;
\*getFile;
}
sub versionString {
local $_ = readlink("$::o->{prefix}/boot/vmlinuz") or die "I couldn't find the kernel package!";
first(/vmlinuz-(.*)/);
}
sub getNextStep {
my ($s) = $::o->{steps}{first};
$s = $::o->{steps}{$s}{next} while $::o->{steps}{$s}{done};
$s;
}
sub spawnSync {
return if $::o->{localInstall} || $::testing;
fork and return;
while (1) { sleep(30); sync(); }
}
sub spawnShell {
return if $::o->{localInstall} || $::testing;
-x "/bin/sh" or die "cannot open shell - /usr/bin/sh doesn't exist";
fork and return;
local *F;
sysopen F, "/dev/tty2", 2 or die "cannot open /dev/tty2 -- no shell will be provided";
open STDIN, "<&F" or die;
open STDOUT, ">&F" or die;
open STDERR, ">&F" or die;
close F;
c::setsid();
ioctl(STDIN, c::TIOCSCTTY(), 0) or warn "could not set new controlling tty: $!";
exec {"/bin/sh"} "-/bin/sh" or log::l("exec of /bin/sh failed: $!");
}
sub mouse_detect() {
my %l;
@l{qw(MOUSETYPE XMOUSETYPE DEVICE)} = split("\n", `mouseconfig --nointeractive 2>/dev/null`) or die "mouseconfig failed";
\%l;
}
sub shells($) {
my ($o) = @_;
my @l = grep { -x "$o->{prefix}$_" } @{$o->{shells}};
@l ? @l : "/bin/bash";
}
sub getAvailableSpace {
my ($o) = @_;
do { $_->{mntpoint} eq '/usr' and return $_->{size} << 9 } foreach @{$o->{fstab}};
do { $_->{mntpoint} eq '/' and return $_->{size} << 9 } foreach @{$o->{fstab}};
if ($::testing) {
log::l("taking 200MB for testing");
return 200 << 20;
}
die "missing root partition";
}
sub setPackages {
my ($o) = @_;
unless ($o->{package}) {
my $useHdlist = $o->{method} !~ /nfs|hd/;
eval { $o->{packages} = pkgs::psUsingHdlist() } if $useHdlist;
$o->{packages} = pkgs::psUsingDirectory() if !$useHdlist || $@;
pkgs::getDeps($o->{packages});
$o->{compss} = pkgs::readCompss ($o->{packages});
$o->{compssList} = pkgs::readCompssList($o->{packages});
push @{$o->{base}}, "kernel-smp" if smp::detect();
do {
my $p = $o->{packages}{$_} or log::l(), next;
pkgs::select($o->{packages}, $p, 1);
} foreach @{$o->{base}};
}
pkgs::setShowFromCompss($o->{compss}, $o->{installClass}, $o->{lang});
pkgs::setSelectedFromCompssList($o->{compssList}, $o->{packages}, getAvailableSpace($o) * 0.7, $o->{installClass}, $o->{lang});
}
sub addToBeDone(&$) {
my ($f, $step) = @_;
return &$f() if $::o->{steps}{$step}{done};
push @{$::o->{steps}{$step}{toBeDone}}, $f;
}
|