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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
package install_steps;
use diagnostics;
use strict;
#-######################################################################################
#- misc imports
#-######################################################################################
use common qw(:file :system :common);
use install_any qw(:all);
use partition_table qw(:types);
use detect_devices;
use modules;
use run_program;
use lilo;
use lang;
use keyboard;
use printer;
use pkgs;
use log;
use fsedit;
use commands;
use network;
use fs;
#-######################################################################################
#- OO Stuff
#-######################################################################################
sub new($$) {
my ($type, $o) = @_;
bless $o, ref $type || $type;
return $o;
}
#-######################################################################################
#- In/Out Steps Functions
#-######################################################################################
sub enteringStep($$) {
my ($o, $step) = @_;
log::l("starting step `$step'");
for (my $s = $o->{steps}{first}; $s; $s = $o->{steps}{$s}{next}) {
next if $o->{steps}{$s}{done} && !$o->{steps}{$s}{redoable};
next if $o->{steps}{$s}{reachable};
my $reachable = 1;
if (my $needs = $o->{steps}{$s}{needs}) {
my @l = ref $needs ? @$needs : $needs;
$reachable = min(map { $o->{steps}{$_}{done} || 0 } @l);
}
$o->{steps}{$s}{reachable} = 1 if $reachable;
}
}
sub leavingStep($$) {
my ($o, $step) = @_;
log::l("step `$step' finished");
$o->{steps}{$step}{reachable} = $o->{steps}{$step}{redoable};
while (my $f = shift @{$o->{steps}{$step}{toBeDone} || []}) {
eval { &$f() };
$o->ask_warn(_("Error"), [
_("An error occurred, i don't know how to handle it nicely,
so continue at your own risk :("), $@ ]) if $@;
}
}
sub errorInStep($$) { print "error :(\n"; exit 1 }
sub kill_action {}
#-######################################################################################
#- Steps Functions
#-######################################################################################
#------------------------------------------------------------------------------
sub selectLanguage {
my ($o) = @_;
lang::set($o->{lang});
unless ($o->{keyboard_force}) {
$o->{keyboard} = keyboard::lang2keyboard($o->{lang});
selectKeyboard($o);
}
}
#------------------------------------------------------------------------------
sub selectKeyboard {
my ($o) = @_;
keyboard::setup($o->{keyboard})
}
#------------------------------------------------------------------------------
sub selectPath {}
#------------------------------------------------------------------------------
sub selectInstallClass($@) {}
#------------------------------------------------------------------------------
sub setupSCSI { modules::load_thiskind('scsi') }
#------------------------------------------------------------------------------
sub doPartitionDisks($$) {
my ($o, $hds) = @_;
return if $::testing;
partition_table::write($_) foreach $hds;
}
#------------------------------------------------------------------------------
sub rebootNeeded($) {
my ($o) = @_;
log::l("Rebooting...");
exit "true";
}
sub choosePartitionsToFormat($$) {
my ($o, $fstab) = @_;
foreach (@$fstab) {
$_->{toFormat} = ($_->{mntpoint} && isExt2($_) || isSwap($_)) &&
($_->{notFormatted} || $o->{partitioning}{autoformat});
}
}
sub formatPartitions {
my $o = shift;
foreach (@_) {
fs::format_part($_) if $_->{toFormat};
}
}
#------------------------------------------------------------------------------
sub setPackages {
my ($o, $install_classes) = @_;
install_any::setPackages($o, $install_classes);
}
sub choosePackages($$$) {
my ($o, $packages, $compss) = @_;
}
sub beforeInstallPackages {
my ($o) = @_;
network::add2hosts("$o->{prefix}/etc/hosts", "localhost.localdomain", "127.0.0.1");
pkgs::init_db($o->{prefix}, $o->{isUpgrade});
}
sub installPackages($$) {
my ($o, $packages) = @_;
my $toInstall = [ grep { $_->{selected} && !$_->{installed} } values %$packages ];
pkgs::install($o->{prefix}, $toInstall, $o->{isUpgrade}, 0);
}
sub afterInstallPackages($) {
my ($o) = @_;
#- why not? cuz weather is nice today :-) [pixel]
sync(); sync();
# configPCMCIA($o->{rootPath}, $o->{pcmcia});
}
#------------------------------------------------------------------------------
sub mouseConfig($) {
my ($o) = @_;
setVarsInSh("$o->{prefix}/etc/sysconfig/mouse", $o->{mouse});
symlink $o->{mouse}{DEVICE}, "$o->{prefix}/dev/mouse" or log::l("creating /dev/mouse symlink failed");
}
#------------------------------------------------------------------------------
sub configureNetwork($) {
my ($o) = @_;
my $etc = "$o->{prefix}/etc";
network::write_conf("$etc/sysconfig/network", $o->{netc});
network::write_resolv_conf("$etc/resolv.conf", $o->{netc});
network::write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_->{DEVICE}", $_) foreach @{$o->{intf}};
network::add2hosts("$etc/hosts", $o->{netc}{HOSTNAME}, map { $_->{IPADDR} } @{$o->{intf}});
network::sethostname($o->{netc}) unless $::testing;
network::addDefaultRoute($o->{netc}) unless $::testing;
#-res_init(); #- reinit the resolver so DNS changes take affect
}
#------------------------------------------------------------------------------
sub timeConfig {
my ($o, $f) = @_;
my $t = $o->{timezone};
eval { commands::cp("-f", "/usr/share/zoneinfo/$t->{timezone}", "/etc/localtime") };
$@ and log::l("installing /etc/localtime failed");
setVarsInSh($f, {
ZONE => $t->{timezone},
GMT => bool2text($t->{GMT}),
ARC => "false",
});
}
#------------------------------------------------------------------------------
sub servicesConfig {}
#------------------------------------------------------------------------------
sub printerConfig {
my($o) = @_;
if ($o->{printer}{complete}) {
pkgs::select($o->{packages}, $o->{packages}{'rhs-printfilters'});
$o->installPackages($o->{packages});
printer::configure_queue($o->{printer});
}
}
#------------------------------------------------------------------------------
my @etc_pass_fields = qw(name password uid gid realname home shell);
sub setRootPassword($) {
my ($o) = @_;
my %u = %{$o->{superuser}};
my $p = $o->{prefix};
$u{password} = crypt_($u{password}) if $u{password};
my @lines = cat_(my $f = "$p/etc/passwd") or log::l("missing passwd file"), return;
local *F;
open F, "> $f" or die "failed to write file $f: $!\n";
foreach (@lines) {
if (/^root:/) {
chomp;
my %l; @l{@etc_pass_fields} = split ':';
add2hash(\%u, \%l);
$_ = join(':', @u{@etc_pass_fields}) . "\n";
}
print F $_;
}
}
#------------------------------------------------------------------------------
sub addUser($) {
my ($o) = @_;
my %u = %{$o->{user}};
my $p = $o->{prefix};
my @passwd = cat_("$p/etc/passwd");;
!$u{name} || getpwnam($u{name}) and return;
for ($u{uid} = 500; getpwuid($u{uid}); $u{uid}++) {}
for ($u{gid} = 500; getgrgid($u{gid}); $u{gid}++) {}
$u{home} ||= "/home/$u{name}";
$u{password} = crypt_($u{password}) if $u{password};
return if $::testing;
local *F;
open F, ">> $p/etc/passwd" or die "can't append to passwd file: $!";
print F join(':', @u{@etc_pass_fields}), "\n";
open F, ">> $p/etc/group" or die "can't append to group file: $!";
print F "$u{name}::$u{gid}:\n";
eval { commands::cp("-f", "$p/etc/skel", "$p$u{home}") }; $@ and log::l("copying of skel failed: $@"), mkdir("$p$u{home}", 0750);
commands::chown_("-r", "$u{uid}.$u{gid}", "$p$u{home}");
}
#------------------------------------------------------------------------------
sub createBootdisk($) {
my ($o) = @_;
my $dev = $o->{mkbootdisk} or return;
my @l = detect_devices::floppies();
$dev = shift @l || die _("no floppy available")
if $dev eq "1"; #- special case meaning autochoose
return if $::testing;
lilo::mkbootdisk($o->{prefix}, versionString(), $dev);
$o->{mkbootdisk} = $dev;
}
#------------------------------------------------------------------------------
sub setupBootloader($) {
my ($o) = @_;
return if $::g_auto_install;
my $versionString = versionString();
lilo::install($o->{prefix}, $o->{hds}, $o->{fstab}, $versionString, $o->{bootloader});
}
#------------------------------------------------------------------------------
sub setupXfree {
my ($o) = @_;
}
#------------------------------------------------------------------------------
sub exitInstall {}
#-######################################################################################
#- Wonderful perl :(
#-######################################################################################
1;
|