/[soft]/drakx/trunk/perl-install/install/steps.pm
ViewVC logotype

Contents of /drakx/trunk/perl-install/install/steps.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3571 - (show annotations) (download)
Mon Mar 19 18:33:40 2012 UTC (12 years, 5 months ago) by colin
File size: 30483 byte(s)
- use "splash" on the kernel command line vs. "splash=silent" as per upstream
  code (e.g. plymouth, systemd and others)
- support the "quiet" kernel command line argument to hide kernel text


1 package install::steps; # $Id: steps.pm 268013 2010-04-29 15:02:04Z pterjan $
2
3 use diagnostics;
4 use strict;
5 use vars qw(@filesToSaveForUpgrade @filesNewerToUseAfterUpgrade);
6
7 #-######################################################################################
8 #- misc imports
9 #-######################################################################################
10 use common;
11 use install::any 'addToBeDone';
12 use partition_table;
13 use detect_devices;
14 use fs::any;
15 use fs::type;
16 use fs::partitioning;
17 use modules;
18 use run_program;
19 use lang;
20 use keyboard;
21 use fsedit;
22 use do_pkgs;
23 use install::pkgs;
24 use any;
25 use log;
26
27 our @ISA = qw(do_pkgs);
28
29 @filesToSaveForUpgrade = qw(
30 /etc/ld.so.conf /etc/fstab /etc/hosts /etc/conf.modules /etc/modules.conf
31 );
32
33 @filesNewerToUseAfterUpgrade = qw(
34 /etc/profile
35 );
36
37 #-######################################################################################
38 #- OO Stuff
39 #-######################################################################################
40 sub new($$) {
41 my ($type, $o) = @_;
42
43 bless $o, ref($type) || $type;
44 return $o;
45 }
46
47 sub charsetChanged {
48 my ($_o) = @_;
49 }
50
51 #-######################################################################################
52 #- In/Out Steps Functions
53 #-######################################################################################
54 sub enteringStep {
55 my ($_o, $step) = @_;
56 log::l("starting step `$step'");
57 }
58 sub leavingStep {
59 my ($o, $step) = @_;
60 log::l("step `$step' finished");
61
62 if (-d "$::prefix/root/drakx") {
63 eval { cp_af("/tmp/ddebug.log", "$::prefix/root/drakx") };
64 output(install::any::auto_inst_file(), install::any::g_auto_install(1));
65 }
66
67 foreach my $s (@{$o->{orderedSteps}}) {
68 #- the reachability property must be recomputed each time to take
69 #- into account failed step.
70 next if $o->{steps}{$s}{done} && !$o->{steps}{$s}{redoable};
71
72 my $reachable = 1;
73 if (my $needs = $o->{steps}{$s}{needs}) {
74 my @l = ref($needs) ? @$needs : $needs;
75 $reachable = min(map { $o->{steps}{$_}{done} || 0 } @l);
76 }
77 $o->{steps}{$s}{reachable} = 1 if $reachable;
78 }
79 $o->{steps}{$step}{reachable} = $o->{steps}{$step}{redoable};
80
81 while (my $f = shift @{$o->{steps}{$step}{toBeDone} || []}) {
82 eval { &$f() };
83 if (my $err = $@) {
84 $o->ask_warn(N("Error"), [
85 N("An error occurred, but I do not know how to handle it nicely.
86 Continue at your own risk."), formatError($err) || $err ]);
87 }
88 }
89 }
90
91 sub errorInStep {
92 my ($_o, $err) = @_;
93 print "error :(\n";
94 print "$err\n\n";
95 c::_exit(1);
96 }
97 sub kill_action {}
98
99 #-######################################################################################
100 #- Steps Functions
101 #-######################################################################################
102 #------------------------------------------------------------------------------
103 sub selectLanguage {
104 my ($o) = @_;
105
106 $o->{locale}{langs} ||= { $o->{locale}{lang} => 1 };
107
108 if (!exists $o->{locale}{country}) {
109 lang::lang_changed($o->{locale});
110 }
111
112 add2hash_($o->{locale}, { utf8 => lang::utf8_should_be_needed($o->{locale}) });
113 lang::set($o->{locale}, !$o->isa('interactive::gtk'));
114
115 log::l("selectLanguage: pack_langs: ", lang::pack_langs($o->{locale}{langs}), " utf8-flag: ", to_bool($o->{locale}{utf8}));
116
117 #- for auto_install compatibility with old $o->{keyboard} containing directly $o->{keyboard}{KEYBOARD}
118 $o->{keyboard} = { KEYBOARD => $o->{keyboard} } if $o->{keyboard} && !ref($o->{keyboard});
119
120 if (!$o->{keyboard} || $o->{keyboard}{unsafe}) {
121 $o->{keyboard} = keyboard::default($o->{locale});
122 $o->{keyboard}{unsafe} = 1;
123 keyboard::setup_install($o->{keyboard});
124 }
125
126 $o->charsetChanged;
127
128 addToBeDone {
129 lang::write_langs($o->{locale}{langs});
130 } 'formatPartitions';
131 addToBeDone {
132 lang::write_and_install($o->{locale}, $o->do_pkgs);
133 } 'installPackages';
134 }
135 #------------------------------------------------------------------------------
136 sub selectKeyboard {
137 my ($o) = @_;
138 keyboard::setup_install($o->{keyboard});
139
140 addToBeDone {
141 #- the bkmap keymaps in installer are deficient, we need to load the real one before keyboard::write which will generate /etc/sysconfig/console/default.kmap
142 run_program::rooted($::prefix, 'loadkeys', keyboard::keyboard2kmap($o->{keyboard}))
143 or log::l("loadkeys failed");
144 keyboard::write($o->{keyboard});
145 } 'installPackages' if !$o->{isUpgrade} || !$o->{keyboard}{unsafe};
146 }
147 #------------------------------------------------------------------------------
148 sub acceptLicense {}
149
150 #------------------------------------------------------------------------------
151 sub setupSCSI {
152 my ($o) = @_;
153 install::any::configure_pcmcia($o);
154 modules::load(modules::category2modules('disk/cdrom'));
155 modules::load_category($o->{modules_conf}, 'bus/firewire');
156 modules::load_category($o->{modules_conf}, 'disk/scsi');
157 #- load disk/scsi before disk/ide since libata is now the default
158 #- (to prevent modules::load_category from loading ide-generic too early)
159 modules::load_category($o->{modules_conf}, 'disk/ide|hardware_raid|sata|firewire');
160
161 install::any::getHds($o);
162 }
163
164 #------------------------------------------------------------------------------
165 sub selectInstallClass {
166 my ($o) = @_;
167
168 if ($o->{partitioning}{use_existing_root} || $o->{isUpgrade}) {
169 # either one root is defined (and all is ok), or we take the first one we find
170 my $p = fs::get::root_($o->{fstab}) || (first(install::any::find_root_parts($o->{fstab}, $::prefix)) || die)->{part};
171 $o->{migrate_device_names} = install::any::use_root_part($o->{all_hds}, $p);
172 $o->{previous_release} = $p if $o->{isUpgrade};
173 }
174 }
175
176 #------------------------------------------------------------------------------
177 sub doPartitionDisksBefore {
178 my ($o) = @_;
179 eval {
180 eval { fs::mount::umount("$::prefix/sys") };
181 eval { fs::mount::umount("$::prefix/proc/bus/usb") };
182 eval { fs::mount::umount("$::prefix/proc") };
183 eval { fs::mount::umount_all($o->{fstab}) };
184 eval { sleep 1; fs::mount::umount_all($o->{fstab}) } if $@; #- HACK
185 } if $o->{fstab} && !$::testing;
186 }
187
188 #------------------------------------------------------------------------------
189 sub doPartitionDisksAfter {
190 my ($o) = @_;
191
192 fs::any::write_hds($o->{all_hds}, $o->{fstab}, !$o->{isUpgrade}, sub { $o->rebootNeeded }, $o);
193
194 if ($::local_install) {
195 my $p = fs::get::mntpoint2part($::prefix, [ fs::read_fstab('', '/proc/mounts') ]);
196 my $part = find { fs::get::is_same_hd($p, $_) } @{$o->{fstab}};
197 $part ||= $o->{fstab}[0];
198 $part->{mntpoint} = '/';
199 $part->{isMounted} = 1;
200 }
201
202 fs::any::check_hds_boot_and_root($o->{all_hds}, $o->{fstab});
203
204 if ($o->{partitioning}{use_existing_root}) {
205 #- ensure those partitions are mounted so that they are not proposed in choosePartitionsToFormat
206 fs::mount::part($_) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} }
207 grep { $_->{mntpoint} && maybeFormatted($_) } @{$o->{fstab}};
208 }
209 }
210
211 #------------------------------------------------------------------------------
212 sub doPartitionDisks {
213 my ($o) = @_;
214
215 if ($o->{partitioning}{auto_allocate}) {
216 catch_cdie { fsedit::auto_allocate($o->{all_hds}, $o->{partitions}) } sub { 1 };
217 }
218 }
219
220 #------------------------------------------------------------------------------
221
222 sub rebootNeeded($) {
223 my ($_o) = @_;
224 log::l("Rebooting...");
225 c::_exit(0);
226 }
227
228 sub choosePartitionsToFormat {
229 my ($o) = @_;
230 fs::partitioning::guess_partitions_to_format($o->{fstab});
231 }
232
233 sub formatMountPartitions {
234 my ($o) = @_;
235 fs::format::formatMount_all($o->{all_hds}, $o->{fstab}, undef);
236 }
237
238 #------------------------------------------------------------------------------
239 sub setPackages {
240 my ($o) = @_;
241
242 install::any::setPackages($o);
243 }
244
245 sub ask_deselect_media__copy_on_disk {
246 my (undef, $_hdlists, $_copy_rpms_on_disk) = @_;
247 0;
248 }
249
250 sub ask_change_cd {
251 my (undef, $phys_m) = @_;
252 log::l("change to medium $phys_m refused (it can't be done automatically)");
253 0;
254 }
255
256 sub selectSupplMedia { '' }
257
258 sub choosePackages {
259 my ($o, $o_compssListLevel) = @_;
260
261 #- clear the mirror cache before upgrading:
262 eval { rm_rf("$::prefix/var/cache/urpmi/mirrors.cache") };
263
264 #- now for upgrade, package that must be upgraded are
265 #- selected first, after is used the same scheme as install.
266
267 #- make sure we kept some space left for available else the system may
268 #- not be able to start
269 my $available = install::any::getAvailableSpace($o);
270 my $availableCorrected = install::pkgs::invCorrectSize($available / sqr(1024)) * sqr(1024);
271 log::l(sprintf "available size %s (corrected %s)", formatXiB($available), formatXiB($availableCorrected));
272
273 #- !! destroying user selection of packages (they may have done individual selection before)
274 exists $o->{compssListLevel} || defined $o_compssListLevel
275 and install::pkgs::setSelectedFromCompssList($o->{packages}, $o->{rpmsrate_flags_chosen}, $o_compssListLevel || $o->{compssListLevel}, $availableCorrected);
276
277 $availableCorrected;
278 }
279
280 sub live_patch_URPM() {
281
282 sub prefering_mga {
283 my ($lpkg, $rpkg_ver, $c) = @_;
284 my $lpkg_ver = $lpkg->version . '-' . $lpkg->release;
285 log::l($lpkg->name . ' ' . ': prefering ' . ($c == 1 ? "$lpkg_ver over $rpkg_ver" : "$rpkg_ver over $lpkg_ver"));
286 }
287
288 my $old_compare_pkg = \&URPM::Package::compare_pkg;
289 undef *URPM::Package::compare_pkg;
290 *URPM::Package::compare_pkg = sub {
291 my ($lpkg, $rpkg) = @_;
292 my $c = ($lpkg->release =~ /mga/ ? 1 : 0) - ($rpkg->release =~ /mga/ ? 1 : 0);
293 if ($c) {
294 prefering_mga($lpkg, $rpkg->version . '-' . $rpkg->release, $c);
295 $c;
296 } else {
297 &$old_compare_pkg;
298 }
299 };
300
301 my $old_compare = \&URPM::Package::compare;
302 undef *URPM::Package::compare;
303 *URPM::Package::compare = sub {
304 my ($lpkg, $rpkg_ver) = @_;
305 my $c = ($lpkg->release =~ /mga/ ? 1 : 0) - ($rpkg_ver =~ /mga/ ? 1 : 0);
306 if ($c) {
307 prefering_mga($lpkg, $rpkg_ver, $c);
308 return $c;
309 }
310 &$old_compare;
311 };
312 }
313
314 sub upgrading_redhat() {
315 #- remove weird config files that bother Xconfig::* too much
316 unlink "$::prefix/etc/X11/XF86Config";
317 unlink "$::prefix/etc/X11/XF86Config-4";
318 }
319
320 sub beforeInstallPackages {
321 my ($o) = @_;
322
323 read_bootloader_config($o);
324
325 if ($o->{isUpgrade}) {
326 $o->{modules_conf}->merge_into(modules::any_conf->read);
327 }
328
329 #- save these files in case of upgrade failure.
330 if ($o->{isUpgrade}) {
331 foreach (@filesToSaveForUpgrade) {
332 unlink "$::prefix/$_.mdkgisave";
333 if (-e "$::prefix/$_") {
334 eval { cp_af("$::prefix/$_", "$::prefix/$_.mdkgisave") };
335 }
336 }
337 foreach (@filesNewerToUseAfterUpgrade) {
338 unlink "$::prefix/$_.rpmnew";
339 }
340 }
341
342 #- mainly for upgrading redhat packages, but it can help other
343 my @should_not_be_dirs = qw(/usr/share/locale/zh_TW/LC_TIME /usr/include/GL);
344 my @should_be_dirs = qw(/etc/X11/xkb);
345 my @to_remove = (
346 (grep { !-l $_ && -d $_ } map { "$::prefix$_" } @should_not_be_dirs),
347 (grep { -l $_ || !-d $_ && -e $_ } map { "$::prefix$_" } @should_be_dirs),
348 );
349 rm_rf(@to_remove);
350
351 live_patch_URPM() if $o->{isUpgrade} !~ /mageia/;
352
353 if ($o->{isUpgrade} eq 'redhat') {
354 upgrading_redhat();
355 }
356
357 if ($o->{isUpgrade} =~ /redhat|conectiva/) {
358 #- to ensure supermount is removed (???)
359 fs::mount_options::set_all_default($o->{all_hds}, %$o, lang::fs_options($o->{locale}));
360 }
361
362
363 #- some packages need such files for proper installation.
364 install::any::write_fstab($o);
365
366 require network::network;
367 network::network::add2hosts("localhost", "127.0.0.1");
368
369 #- resolv.conf will be modified at boot time
370 #- the following will ensure we have a working DNS during install
371 if (-e "/etc/resolv.conf" && ! -e "$::prefix/etc/resolv.conf") {
372 cp_af("/etc/resolv.conf", "$::prefix/etc");
373 }
374
375 if (-e '/tmp/.X11-unix') {
376 mkdir "$::prefix/tmp/.X11-unix";
377 run_program::run('mount', '--bind', '/tmp/.X11-unix', "$::prefix/tmp/.X11-unix");
378 }
379
380 log::l("setting excludedocs to $o->{excludedocs}");
381 substInFile { s/%_excludedocs.*//; $_ .= "%_excludedocs yes\n" if eof && $o->{excludedocs} } "$::prefix/etc/rpm/macros";
382
383 #- add oem theme if the files exists.
384 mkdir_p("$::prefix/usr/share");
385 install::media::getAndSaveFile_($o->{stage2_phys_medium}, "install/oem-theme.rpm", "$::prefix/usr/share/oem-theme.rpm");
386
387 system("sh", "-c", $o->{preInstallNonRooted}) if $o->{preInstallNonRooted};
388 }
389
390 #- returns number of packages installed, 0 if none were selected.
391 sub pkg_install {
392 my ($o, @l) = @_;
393 log::l("selecting packages " . join(" ", @l));
394
395 install::pkgs::select_by_package_names($o->{packages}, \@l);
396
397 my @toInstall = install::pkgs::packagesToInstall($o->{packages});
398 if (@toInstall) {
399 log::l("installing packages");
400 $o->installPackages;
401 } else {
402 log::l("all packages selected are already installed, nothing to do");
403 delete $o->{packages}{rpmdb}; #- make sure rpmdb is closed
404 0;
405 }
406 }
407
408 sub installCallback {
409 # my (undef, $msg, @para) = @_;
410 # log::l("$msg: " . join(',', @para));
411 }
412
413 sub installPackages {
414 my ($o, $o_interactive) = @_;
415
416 my $p = fs::get::root_($o->{fstab});
417 if (isLUKS($p)) {
418 install::pkgs::selectPackage($o->{packages}, install::pkgs::packageByName($o->{packages}, 'plymouth'));
419 }
420
421 my $packages = $o->{packages};
422
423 install::pkgs::remove_marked_ask_remove($packages, \&installCallback);
424
425 #- small transaction will be built based on this selection and depslist.
426 my @toInstall = install::pkgs::packagesToInstall($packages);
427
428 my $time = time();
429 {
430 local $ENV{DURING_INSTALL} = 1;
431 local $ENV{TMPDIR} = '/tmp';
432 local $ENV{TMP} = '/tmp';
433 local $ENV{HOME};
434 local $packages->{options}{auto} = !$o_interactive;
435 install::pkgs::install($o->{isUpgrade}, \@toInstall, $packages, \&installCallback);
436 }
437 any::writeandclean_ldsoconf($::prefix);
438
439 run_program::rooted_or_die($::prefix, 'ldconfig');
440
441 log::l("Install took: ", formatTimeRaw(time() - $time));
442 install::media::log_sizes();
443 scalar(@toInstall); #- return number of packages installed.
444 }
445
446 sub afterInstallPackages($) {
447 my ($o) = @_;
448
449 read_bootloader_config($o) if $o->{isUpgrade} && is_empty_hash_ref($o->{bootloader});
450
451 die N("Some important packages did not get installed properly.
452 Either your cdrom drive or your cdrom is defective.
453 Check the cdrom on an installed computer using \"rpm -qpl media/main/*.rpm\"
454 ") if any { m|read failed: Input/output error| } cat_("$::prefix/root/drakx/install.log");
455
456 if (arch() !~ /^sparc/) { #- TODO restore it as may be needed for sparc
457 -x "$::prefix/usr/bin/dumpkeys" or $::testing or die
458 "Some important packages did not get installed properly.
459
460 Please switch to console 2 (using ctrl-alt-f2)
461 and look at the log file /tmp/ddebug.log
462
463 Consoles 1,3,4,7 may also contain interesting information";
464 }
465
466 #- why not? cuz weather is nice today :-) [pixel]
467 common::sync(); common::sync();
468
469 #- generate /etc/lvmtab needed for rc.sysinit
470 run_program::rooted($::prefix, 'lvm2', 'vgscan') if -e '/etc/lvmtab';
471
472 require harddrake::autoconf;
473 #- configure PCMCIA services if needed.
474 harddrake::autoconf::pcmcia($o->{pcmcia});
475 #- configure CPU frequency modules
476 harddrake::autoconf::cpufreq();
477 harddrake::autoconf::floppy();
478
479 #- for mageia_firstime
480 touch "$::prefix/var/lock/TMP_1ST";
481
482 fs::any::set_cdrom_symlink($o->{all_hds}{raw_hds});
483 any::config_mtools($::prefix);
484
485 #- make sure wins is disabled in /etc/nsswitch.conf
486 #- else if eth0 is not existing, glibc segfaults.
487 substInFile { s/\s*wins// if /^\s*hosts\s*:/ } "$::prefix/etc/nsswitch.conf";
488
489 #- make sure some services have been enabled (or a catastrophic restart will occur).
490 #- these are normally base package post install scripts or important services to start.
491 run_program::rooted($::prefix, "chkconfig", "--add", $_) foreach
492 qw(netfs network rawdevices sound kheader keytable syslog crond portmap);
493
494 if ($o->{mouse}{device} =~ /ttyS/) {
495 log::l("disabling gpm for serial mice (does not get along nicely with X)");
496 run_program::rooted($::prefix, "chkconfig", "--del", "gpm");
497 }
498
499 if ($o->{pcmcia}) {
500 substInFile { s/.*(TaskBarShowAPMStatus).*/$1=1/ } "$::prefix/usr/lib/X11/icewm/preferences";
501 eval { cp_af("$::prefix/usr/share/applnk/System/kapm.kdelnk",
502 "$::prefix/etc/skel/Desktop/Autostart/kapm.kdelnk") };
503 }
504
505 if ($o->{brltty}) {
506 output("$::prefix/etc/brltty.conf", <<EOF);
507 braille-driver $o->{brltty}{driver}
508 braille-device $o->{brltty}{device}
509 text-table $o->{brltty}{table}
510 EOF
511 }
512
513
514 install::any::disable_user_view() if $o->{security} > 1 || $o->{authentication}{NIS};
515 run_program::rooted($::prefix, "kdeDesktopCleanup");
516
517 #- move some file after an upgrade that may be seriously annoying.
518 #- and rename saved files to .mdkgiorig.
519 if ($o->{isUpgrade}) {
520 my $pkg = install::pkgs::packageByName($o->{packages}, 'rpm');
521 $pkg && ($pkg->flag_selected || $pkg->flag_installed) && $pkg->compare(">= 4.0") and install::pkgs::cleanOldRpmDb();
522
523 log::l("moving previous desktop files that have been updated to Trash of each user");
524 install::any::kdemove_desktop_file($::prefix);
525
526 foreach (@filesToSaveForUpgrade) {
527 renamef("$::prefix/$_.mdkgisave", "$::prefix/$_.mdkgiorig")
528 if -e "$::prefix$_.mdkgisave";
529 }
530
531 foreach (@filesNewerToUseAfterUpgrade) {
532 if (-e "$::prefix/$_.rpmnew" && -e "$::prefix/$_") {
533 renamef("$::prefix/$_", "$::prefix/$_.mdkgiorig");
534 renamef("$::prefix/$_.rpmnew", "$::prefix/$_");
535 }
536 }
537 }
538
539 renamef(install::pkgs::removed_pkgs_to_upgrade_file(), install::pkgs::removed_pkgs_to_upgrade_file() . '.done');
540 unlink(glob("$::prefix/root/drakx/*.upgrading"));
541
542 if ($o->{upgrade_by_removing_pkgs_matching}) {
543 if (cat_("$::prefix/etc/inittab.rpmsave") =~ /^id:5:initdefault:\s*$/m) {
544 $o->{X}{xdm} = 1;
545 require Xconfig::various;
546 Xconfig::various::runlevel(5);
547 }
548 }
549
550 any::fix_broken_alternatives($o->{isUpgrade} eq 'redhat');
551
552 #- update theme directly from a package (simplest).
553 if (-s "$::prefix/usr/share/oem-theme.rpm") {
554 run_program::rooted($::prefix, "rpm", "-U", "/usr/share/oem-theme.rpm");
555 unlink "/usr/share/oem-theme.rpm";
556 }
557
558 #- call update-menus at the end of package installation
559 push @{$o->{waitpids}}, run_program::raw({ root => $::prefix, detach => 1 }, "update-menus", "-n");
560
561 $o->install_hardware_packages;
562
563 if ($o->{updatemodules}) {
564 $o->updatemodules($ENV{THIRDPARTY_DEVICE}, $ENV{THIRDPARTY_DIR});
565 }
566 }
567
568 sub install_urpmi {
569 my ($o) = @_;
570
571 my $pkg = install::pkgs::packageByName($o->{packages}, 'urpmi');
572 if ($pkg && ($pkg->flag_selected || $pkg->flag_installed)
573 #- this is a workaround. if many urpmi packages are found in the
574 #- provides of all media, packages_providing() might return the wrong
575 #- one. This probably needs to be fixed in URPM
576 || run_program::rooted_get_stdout($::prefix, '/bin/rpm', '-q', 'urpmi') =~ /urpmi/
577 ) {
578 install::media::install_urpmi($o->{method}, $o->{packages});
579 install::pkgs::saveCompssUsers($o->{packages}, $o->{compssUsers});
580 } else {
581 log::l("skipping install_urpmi, urpmi not installed");
582 }
583 }
584
585 sub install_hardware_packages {
586 my ($o) = @_;
587 if ($o->{match_all_hardware}) {
588 my @l = pkgs::detect_hardware_packages($o->do_pkgs, $o->{match_all_hardware});
589 $o->do_pkgs->install(@l) if @l;
590 }
591 }
592
593 sub updatemodules {
594 my ($_o, $dev, $rel_dir) = @_;
595 return if $::testing;
596
597 $dev = devices::make($dev) or log::l("updatemodules: bad device $dev"), return;
598
599 my $mount_dir = '/updatemodules';
600 find {
601 eval { fs::mount::mount($dev, $mount_dir, $_, 0); 1 };
602 } 'ext2', 'vfat' or log::l("updatemodules: can't mount $dev"), return;
603
604 my $dir = "$mount_dir$rel_dir";
605 foreach my $kernel_version (all("$::prefix/lib/modules")) {
606 log::l("examining updated modules for kernel $kernel_version");
607 -d "$dir/$kernel_version" or next;
608 log::l("found updatable modules");
609 run_program::run("cd $dir/$kernel_version ; find -type f | cpio -pdu $::prefix/lib/modules/$kernel_version");
610 run_program::rooted($::prefix, 'depmod', '-a', '-F', "/boot/System.map-$kernel_version", $kernel_version);
611 }
612
613 my $category;
614 foreach (cat_("$dir/to_load")) {
615 chomp;
616 if (/^#/) {
617 ($category) = $1 if /\[list_modules: (.*?)\]/;
618 } elsif ($category) {
619 log::l("adding $_ to $category\n");
620 my $r = \%list_modules::l;
621 $r = $r->{$_} foreach split('/', $category);
622 push @$r, $_;
623
624 $category = '';
625 }
626 }
627
628 fs::mount::umount($mount_dir);
629 }
630
631 #------------------------------------------------------------------------------
632 sub selectMouse($) {
633 my ($_o) = @_;
634 }
635
636 #------------------------------------------------------------------------------
637 sub configureNetwork {
638 my ($o) = @_;
639 require network::network;
640 network::network::configure_network($o->{net}, $o, $o->{modules_conf});
641 configure_firewall($o) if !$o->{isUpgrade};
642
643 #- only a http proxy can be used by stage1
644 #- the method is http even for ftp connections through a http proxy
645 #- use this http proxy for both http and ftp connections
646 if ($o->{method} eq "http" && $ENV{PROXY}) {
647 my $proxy = "http://$ENV{PROXY}" . ($ENV{PROXYPORT} && ":$ENV{PROXYPORT}");
648 add2hash($o->{miscellaneous} ||= {}, {
649 http_proxy => $proxy,
650 ftp_proxy => $proxy,
651 });
652 network::network::proxy_configure($o->{miscellaneous});
653 }
654 }
655
656 sub configure_firewall {
657 my ($o) = @_;
658
659 #- set up a firewall if ports have been specified or if the security level is high enough
660 $o->{firewall_ports} ||= '' if $o->{security} >= 1 && !exists $o->{firewall_ports};
661
662 if (defined $o->{firewall_ports}) {
663 require network::drakfirewall;
664 $o->{firewall_ports} ||= ''; #- don't open any port by default
665 network::drakfirewall::set_ports($o->do_pkgs, 0, $o->{firewall_ports}, 'log_net_drop');
666 network::drakfirewall::set_ifw($o->do_pkgs, 1, [ 'psd' ], '');
667 }
668 }
669
670 #------------------------------------------------------------------------------
671 sub installUpdates {}
672
673 sub summaryBefore {}
674
675 sub summary {
676 my ($o) = @_;
677 configureTimezone($o);
678 }
679
680 sub summaryAfter {
681 my ($_o) = @_;
682 }
683
684 #------------------------------------------------------------------------------
685 sub configureTimezone {
686 my ($o) = @_;
687 install::any::preConfigureTimezone($o);
688
689 $o->pkg_install('ntp') if $o->{timezone}{ntp};
690
691 require timezone;
692 timezone::write($o->{timezone});
693 }
694
695 #------------------------------------------------------------------------------
696 sub configureServices {
697 my ($o) = @_;
698 if ($o->{services}) {
699 require services;
700 services::doit($o, $o->{services});
701 }
702 }
703
704 #------------------------------------------------------------------------------
705 sub setRootPassword_addUser {
706 my ($o) = @_;
707
708 setRootPassword($o);
709 addUser($o);
710 }
711
712 sub setRootPassword {
713 my ($o) = @_;
714 $o->{superuser} ||= {};
715 require authentication;
716 authentication::set_root_passwd($o->{superuser}, $o->{authentication});
717 install::any::set_authentication($o);
718 }
719
720 sub addUser {
721 my ($o) = @_;
722 my $users = $o->{users} ||= [];
723
724 if ($::prefix) {
725 #- getpwnam, getgrnam, getgrid works
726 symlinkf("$::prefix/etc/passwd", '/etc/passwd');
727 symlinkf("$::prefix/etc/group", '/etc/group');
728 }
729
730 any::add_users($users, $o->{authentication});
731
732 if ($o->{rpmsrate_flags_chosen}{CAT_X}) {
733 my $autologin = any::get_autologin();
734 $autologin->{user} = $o->{autologin};
735 $autologin->{desktop} = $o->{desktop} if $o->{desktop};
736 $autologin->{dm} = $o->{dm} if $o->{dm};
737 any::set_autologin($o->do_pkgs, $autologin);
738 }
739
740 install::any::disable_user_view() if @$users == ();
741 }
742
743 #------------------------------------------------------------------------------
744 sub read_bootloader_config {
745 my ($o) = @_;
746
747 require bootloader;
748 eval { add2hash($o->{bootloader} ||= {}, bootloader::read($o->{all_hds})) };
749 $@ && $o->{isUpgrade} and log::l("read_bootloader_config failed: $@");
750
751 $o->{bootloader}{bootUnsafe} = 0 if $o->{bootloader}{boot}; #- when upgrading, do not ask where to install the bootloader (mbr vs boot partition)
752 }
753
754 sub setupBootloaderBefore {
755 my ($o) = @_;
756 any::setupBootloaderBefore($o->do_pkgs, $o->{bootloader}, $o->{all_hds}, $o->{fstab}, $o->{keyboard},
757 $o->{allowFB}, $o->{vga}, $o->{meta_class} ne 'server', $o->{meta_class} ne 'server');
758 }
759
760 sub setupBootloader {
761 my ($o) = @_;
762
763 any::install_bootloader_pkgs($o->do_pkgs, $o->{bootloader});
764
765 require bootloader;
766 bootloader::install($o->{bootloader}, $o->{all_hds});
767 }
768
769 #------------------------------------------------------------------------------
770 sub configureXBefore {
771 my ($o) = @_;
772
773 #- keep this here if the package has to be updated.
774 $o->pkg_install("task-x11");
775 }
776 sub configureX {
777 my ($o) = @_;
778 configureXBefore($o);
779
780 require Xconfig::default;
781 $o->{raw_X} = Xconfig::default::configure($o->do_pkgs, $o->{keyboard}, $o->{mouse});
782
783 require Xconfig::main;
784 Xconfig::main::configure_everything_auto_install($o->{raw_X}, $o->do_pkgs, $o->{X}, install::any::X_options_from_o($o));
785 configureXAfter($o);
786 }
787 sub configureXAfter {
788 my ($_o) = @_;
789 }
790
791 #------------------------------------------------------------------------------
792 sub miscellaneousBefore {
793 my ($o) = @_;
794
795 require security::level;
796 require security::various;
797 $o->{security} ||= security::level::get();
798 $o->{security_user} ||= security::various::config_security_user($::prefix);
799
800 log::l("security level is $o->{security}");
801 }
802 sub miscellaneous {
803 my ($_o) = @_;
804 #- keep some given parameters
805 #-TODO
806 }
807 sub miscellaneousAfter {
808 my ($o) = @_;
809
810 $ENV{SECURE_LEVEL} = $o->{security}; #- deprecated with chkconfig 1.3.4-2mdk, uses /etc/sysconfig/msec
811
812 addToBeDone {
813 addVarsInSh("$::prefix/etc/sysconfig/system", { META_CLASS => $o->{meta_class} });
814
815 eval { install::any::set_security($o) };
816
817 } 'installPackages';
818 }
819
820 #------------------------------------------------------------------------------
821 sub exitInstall {
822 my ($o) = @_;
823
824 install::any::deploy_server_notify($o) if exists $o->{deploy_server};
825
826 #- mainly for auto_install's
827 #- do not use run_program::xxx because it does not leave stdin/stdout unchanged
828 system("bash", "-c", $o->{postInstallNonRooted}) if $o->{postInstallNonRooted};
829 system("chroot", $::prefix, "bash", "-c", $o->{postInstall}) if $o->{postInstall};
830
831 eval {
832 my $report = '/root/drakx/report.bug';
833 unlink "$::prefix$report", "$::prefix$report.gz";
834 output "$::prefix$report", install::any::report_bug();
835 run_program::rooted($::prefix, 'gzip', $report);
836 };
837 output("$::prefix/root/drakx/package_list.pl", install::any::selected_leaves_pl($o));
838
839 eval { install::any::getAndSaveAutoInstallFloppies($o, 1) } if arch() !~ /^ppc/;
840 eval { output "$::prefix/root/drakx/README", sprintf("This directory contains several installation-related files,
841 mostly log files (very useful if you ever report a bug!).
842
843 Beware that some %s tools rely on the contents of some
844 of these files... so remove any file from here at your own
845 risk!
846 ", "Mageia") };
847 #- wait for remaining processes.
848 foreach (@{$o->{waitpids}}) {
849 waitpid $_, 0;
850 log::l("pid $_ returned $?");
851 }
852 install::media::umount_media($o->{packages});
853 install::media::openCdromTray($o->{stage2_phys_medium}{device}) if !detect_devices::is_xbox() && $o->{method} eq 'cdrom';
854 install::media::log_sizes();
855 }
856
857 #------------------------------------------------------------------------------
858 sub hasNetwork {
859 my ($o) = @_;
860 $o->{net}{type} && $o->{net}{network}{NETWORKING} ne 'no' and return 1;
861 log::l("no network seems to be configured for internet ($o->{net}{type},$o->{net}{network}{NETWORKING})");
862 0;
863 }
864
865 sub network_is_cheap {
866 my ($o) = @_;
867 member($o->{net}{type}, qw(adsl lan cable));
868 }
869
870 sub start_network_interface {
871 my ($o) = @_;
872 require network::tools;
873 network::tools::start_net_interface($o->{net}, 0);
874 }
875
876 sub stop_network_interface {
877 my ($o) = @_;
878 require network::tools;
879 network::tools::stop_net_interface($o->{net}, 0);
880 }
881
882 #------------------------------------------------------------------------------
883 sub upNetwork {
884 my ($o, $b_pppAvoided) = @_;
885
886 install::any::is_network_install($o) || $::local_install and return 1;
887 $o->{modules_conf}->write;
888 if (! -e "/etc/resolv.conf") {
889 #- symlink resolv.conf in install root too so that updates and suppl media can be added
890 symlink "$::prefix/etc/resolv.conf", "/etc/resolv.conf";
891 }
892 if (hasNetwork($o)) {
893 if (network_is_cheap($o)) {
894 log::l("starting network ($o->{net}{type})");
895 start_network_interface($o);
896 return 1;
897 } elsif (!$b_pppAvoided) {
898 log::l("starting network (ppp: $o->{net}{type})");
899 eval { modules::load(qw(serial ppp bsd_comp ppp_deflate)) };
900 run_program::rooted($::prefix, "/etc/rc.d/init.d/syslog", "start");
901 start_network_interface($o);
902 return 1;
903 } else {
904 log::l(qq(not starting network (b/c ppp avoided and type is "$o->{net}{type})"));
905 }
906 }
907 $::testing;
908 }
909
910 #------------------------------------------------------------------------------
911 sub downNetwork {
912 my ($o, $costlyOnly) = @_;
913
914 install::any::is_network_install($o) || $::local_install and return 1;
915 $o->{modules_conf}->write;
916 if (hasNetwork($o)) {
917 if (!$costlyOnly) {
918 stop_network_interface($o);
919 return 1;
920 } elsif (!network_is_cheap($o)) {
921 stop_network_interface($o);
922 run_program::rooted($::prefix, "/etc/rc.d/init.d/syslog", "stop");
923 eval { modules::unload(qw(ppp_deflate bsd_comp ppp serial)) };
924 return 1;
925 }
926 }
927 $::testing;
928 }
929
930 #------------------------------------------------------------------------------
931 sub cleanIfFailedUpgrade($) {
932 my ($o) = @_;
933
934 #- if an upgrade has failed, there should be .mdkgisave files around.
935 if ($o->{isUpgrade}) {
936 foreach (@filesToSaveForUpgrade) {
937 if (-e "$::prefix/$_" && -e "$::prefix/$_.mdkgisave") {
938 rename "$::prefix/$_", "$::prefix/$_.mdkginew"; #- keep new files around in case !
939 rename "$::prefix/$_.mdkgisave", "$::prefix/$_";
940 }
941 }
942 }
943 }
944
945
946 1;

  ViewVC Help
Powered by ViewVC 1.1.30