summaryrefslogtreecommitdiffstats
path: root/perl-install/network/tools.pm
blob: 33c4f300c8d67e96266b0c463cdaa08273062f29 (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
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
package network::tools;

use common;
use run_program;
use c;
use vars qw(@ISA @EXPORT);
use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_prog $connect_file $disconnect_file);

@ISA = qw(Exporter);
@EXPORT = qw(write_cnx_script write_secret_backend write_initscript ask_connect_now connect_backend disconnect_backend read_providers_backend ask_info2 type2interface connected connected_bg connected2 disconnected);
@EXPORT_OK = qw($in);

sub write_cnx_script {
    my ($netc, $type, $up, $down, $type2) = @_;
    if ($type) {
	$netc->{internet_cnx}{$type}{$_->[0]}=$_->[1] foreach ([$connect_file, $up], [$disconnect_file, $down]);
	$netc->{internet_cnx}{$type}{type} = $type2;
    } else {
	foreach ($connect_file, $disconnect_file) {
	    output ("$prefix$_",
'#!/bin/bash
' . if_(!$netc->{at_boot}, 'if [ "x$1" == "x--boot_time" ]; then exit; fi
') . $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{$_});
	chmod 0755, "$prefix" . $_;
	}
    }
}

sub write_secret_backend {
    my ($a, $b) = @_;
    foreach my $i ("pap-secrets", "chap-secrets") {
	substInFile { s/^'$a'.*\n//; $_ .= "\n'$a' * '$b' * \n" if eof  } "$prefix/etc/ppp/$i";
    }
}

sub ask_connect_now {
    $::Wizard_no_previous=1;
    #- FIXME : code the exception to be generated by ask_yesorno, to be able to remove the $::Wizard_no_previous=1;
    if ($in->ask_yesorno(_("Internet configuration"),
			 _("Do you want to try to connect to the Internet now?")
			)) {
	my $up;
	{
	    my $w = $in->wait_message('', _("Testing your connection..."), 1);
	    connect_backend();
	    sleep 10;
	    my $netc = {};
	    $up=connected();
	}
	my $m = $up ? (_("The system is now connected to Internet.") .
		     if_($::isInstall, _("For Security reason, it will be disconnected now.")) ) :
		       _("The system doesn't seem to be connected to internet.
Try to reconfigure your connection.");
	if ($::isWizard) {
	    $::Wizard_no_previous=1;
	    $::Wizard_finished=1;
	    $in->ask_okcancel(_("Network Configuration"), $m, 1);
	    undef $::Wizard_no_previous;
	    undef $::Wizard_finished;
	} else {  $in->ask_warn('', $m ); }
	$::isInstall and disconnect_backend();
    }
    undef $::Wizard_no_previous;
    1;
}

sub connect_backend { run_program::rooted($prefix, "$connect_prog &") }

sub disconnect_backend { run_program::rooted($prefix, "$disconnect_file &") }

sub read_providers_backend { my ($file) = @_; map { /(.*?)=>/ } catMaybeCompressed($file) }

sub ask_info2 {
    my ($cnx, $netc) = @_;
    $::isInstall and $in->set_help('configureNetworkDNS');
    $in->ask_from(_("Connection Configuration"),
		  _("Please fill or check the field below"),
		  [
		   if__($cnx->{irq}, { label => _("Card IRQ"), val => \$cnx->{irq} })  ,
		   if__($cnx->{mem}, { label => _("Card mem (DMA)"), val => \$cnx->{mem} }),
		   if__($cnx->{io}, { label => _("Card IO"), val => \$cnx->{io} }),
		   if__($cnx->{io0}, { label => _("Card IO_0"), val => \$cnx->{io0} }),
		   if__($cnx->{io1}, { label => _("Card IO_1"), val => \$cnx->{io1} }),
		   if__($cnx->{phone_in}, { label => _("Your personal phone number"), val => \$cnx->{phone_in} }),
		   if__($netc->{DOMAINNAME2}, { label => _("Provider name (ex provider.net)"), val => \$netc->{DOMAINNAME2} }),
		   if__($cnx->{phone_out}, { label => _("Provider phone number"), val => \$cnx->{phone_out} }),
		   if__($netc->{dnsServer2}, { label => _("Provider dns 1 (optional)"), val => \$netc->{dnsServer2} }),
		   if__($netc->{dnsServer3}, { label => _("Provider dns 2 (optional)"), val => \$netc->{dnsServer3} }),
		   if__($cnx->{vpivci}, { label => _("Choose your country"), val => \$netc->{vpivci}, list => ['Netherlands', 'France', 'Belgium', 'Italy', 'UK', 'USA'] }),
		   if__($cnx->{dialing_mode}, { label => _("Dialing mode"), val => \$cnx->{dialing_mode},list=>["auto","manual"]}),
		   if__($cnx->{speed}, { label => _("Connection speed"), val => \$cnx->{speed}, list => ["64 Kb/s", "128 Kb/s"]}),
		   if__($cnx->{huptimeout}, { label => _("Connection timeout (in sec)"), val => \$cnx->{huptimeout} }),
		   if__($cnx->{login}, { label => _("Account Login (user name)"), val => \$cnx->{login} }),
		   if__($cnx->{passwd}, { label => _("Account Password"),  val => \$cnx->{passwd} }),
		  ]
		 ) or return;
    if ($netc->{vpivci}) {
	foreach (['Netherlands', '8_48'], ['France', '8_35'], ['Belgium', '8_35'], ['Italy', '8_35'], ['UK', '0_38'], ['USA', '8_35']) {
	    $netc->{vpivci} eq $_->[0] and $netc->{vpivci} = $_->[1];
	}
    }
    1;
}

sub type2interface {
    my ($i) = @_;
    $i=~/$_->[0]/ and return $_->[1] foreach (
					      [ modem => 'ppp'],
					      [ isdn_internal => 'ippp'],
					      [ isdn_external => 'ppp'],
					      [ adsl => 'ppp'],
					      [ cable => 'eth'],
					      [ lan => 'eth']);
}

sub connected { gethostbyname("mandrakesoft.com") ? 1 : 0 }

my $kid_pipe;
sub connected_bg {
    local $|=1;
    my ($ref) = @_;
    if (defined $kid_pipe) {
	local *F;
	*F = *$kid_pipe;
	fcntl(F, c::F_SETFL(), c::O_NONBLOCK()) or die "can't fcntl F_SETFL: $!";
	my $a;
  	if ($a = <F> ) {
	    close($kid_pipe) || warn "kid exited $?";
	    undef $kid_pipe;
	    $a eq '1' and $$ref = 1;
	    $a eq '0' and $$ref = 0;
  	}
    } else { $kid_pipe = connected2() }
    1;
}

sub connected2 {
    my $pid = open(KID_TO_READ, "-|");
    if ($pid) {   # parent
	return \*KID_TO_READ;
    } else {      # child
	my $a = gethostbyname("mandrakesoft.com") ? 1 : 0;
	print "$a";
	c::_exit(0);
    }
}

sub disconnected { }


sub write_initscript {
    output ("$prefix/etc/rc.d/init.d/internet",
	    q{
#!/bin/bash
#
# internet       Bring up/down internet connection
#
# chkconfig: 2345 11 89
# description: Activates/Deactivates the internet interfaces
#
# dam's (damien@mandrakesoft.com)

# Source function library.
. /etc/rc.d/init.d/functions

	case "$1" in
		start)
                if [ -e } . $connect_file . q{ ]; then
			action "Checking internet connections to start at boot" "} . "$connect_file --boot_time" . q{"
		else
			action "No connection to start" "true"
		fi
		touch /var/lock/subsys/internet
		;;
	stop)
                if [ -e } . $disconnect_file . q{ ]; then
			action "Stopping internet connection if needed: " "} . "$disconnect_file --boot_time" . q{"
		else
			action "No connection to stop" "true"
		fi
		rm -f /var/lock/subsys/internet
		;;
	restart)
		$0 stop
		echo "Waiting 10 sec before restarting the internet connection."
		sleep 10
		$0 start
		;;
	status)
		;;
	*)
	echo "Usage: internet {start|stop|status|restart}"
	exit 1
esac
exit 0
 });
    chmod 0755, "$prefix/etc/rc.d/init.d/internet";
    $::isStandalone ? system("/sbin/chkconfig --add internet") : do {
	symlinkf ("../init.d/internet", "$prefix/etc/rc.d/rc$_") foreach
	  '0.d/K11internet', '1.d/K11internet', '2.d/K11internet', '3.d/S89internet', '5.d/S89internet', '6.d/K11internet';
    };
}

1;
an class="hl opt">(), install_any::g_auto_install(1)); } foreach my $s (@{$o->{orderedSteps}}) { #- the reachability property must be recomputed each time to take #- into account failed step. next if $o->{steps}{$s}{done} && !$o->{steps}{$s}{redoable}; 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; } $o->{steps}{$step}{reachable} = $o->{steps}{$step}{redoable}; while (my $f = shift @{$o->{steps}{$step}{toBeDone} || []}) { eval { &$f() }; $o->ask_warn(N("Error"), [ N("An error occurred, but I don't know how to handle it nicely. Continue at your own risk."), formatError($@) ]) if $@; } } sub errorInStep { my ($_o, $_err) = @_; print "error :(\n"; c::_exit(1); } sub kill_action {} #-###################################################################################### #- Steps Functions #-###################################################################################### #------------------------------------------------------------------------------ sub selectLanguage { my ($o) = @_; #- for auto_install compatibility with old $o->{lang} $o->{locale} = lang::system_locales_to_ourlocale($o->{lang}, $o->{lang}) if $o->{lang}; $o->{locale}{langs} ||= { $o->{locale}{lang} => 1 }; if (!exists $o->{locale}{country}) { $o->{locale}{country} = $1 if lang::l2locale($o->{locale}{lang}) =~ /^.._(..)/; } lang::set($o->{locale}, !$o->isa('interactive::gtk')); lang::langs_selected($o->{locale}); log::l("selectLanguage: pack_langs: ", lang::pack_langs($o->{locale}{langs}), " utf8-flag: ", to_bool($o->{locale}{utf8})); #- for auto_install compatibility with old $o->{keyboard} containing directly $o->{keyboard}{KEYBOARD} $o->{keyboard} = { KEYBOARD => $o->{keyboard} } if $o->{keyboard} && !ref($o->{keyboard}); if (!$o->{keyboard} || $o->{keyboard}{unsafe}) { $o->{keyboard} = keyboard::from_usb() || keyboard::lang2keyboard($o->{locale}{lang}); $o->{keyboard}{unsafe} = 1; keyboard::setup($o->{keyboard}); } $o->charsetChanged; addToBeDone { lang::write_langs($o->{prefix}, $o->{locale}{langs}); } 'formatPartitions'; addToBeDone { lang::write($o->{prefix}, $o->{locale}); } 'installPackages'; } #------------------------------------------------------------------------------ sub selectKeyboard { my ($o) = @_; $o->{keyboard}{KBCHARSET} = lang::l2charset($o->{locale}{lang}); keyboard::setup($o->{keyboard}); addToBeDone { keyboard::write($o->{keyboard}); } 'installPackages' if !$o->{isUpgrade} || !$o->{keyboard}{unsafe}; if ($o->{raw_X}) { require Xconfig::default; Xconfig::default::config_keyboard($o->{raw_X}, $o->{keyboard}); $o->{raw_X}->write; } } #------------------------------------------------------------------------------ sub acceptLicense {} #------------------------------------------------------------------------------ sub setupSCSI { my ($o) = @_; modules::configure_pcmcia($o->{pcmcia}) if $o->{pcmcia}; modules::load(modules::category2modules('disk/cdrom')); modules::load_category('bus/firewire'); modules::load_category('disk/scsi|hardware_raid|firewire'); install_any::getHds($o); } #------------------------------------------------------------------------------ sub selectInstallClass { my ($o) = @_; if ($o->{partitioning}{use_existing_root} || $o->{isUpgrade}) { # either one root is defined (and all is ok), or we take the first one we find my $p = fsedit::get_root_($o->{fstab}) || (first(install_any::find_root_parts($o->{fstab}, $o->{prefix})) || die)->{part}; install_any::use_root_part($o->{all_hds}, $p, $o->{prefix}); } } #------------------------------------------------------------------------------ sub doPartitionDisksBefore { my ($o) = @_; eval { eval { fs::umount("$o->{prefix}/proc") }; eval { fs::umount_all($o->{fstab}, $o->{prefix}) }; eval { sleep 1; fs::umount_all($o->{fstab}, $o->{prefix}) } if $@; #- HACK } if $o->{fstab} && !$::testing; } #------------------------------------------------------------------------------ sub doPartitionDisksAfter { my ($o) = @_; if (!$::testing) { my $hds = $o->{all_hds}{hds}; partition_table::write($_) foreach @$hds; $_->{rebootNeeded} and $o->rebootNeeded foreach @$hds; } fs::set_removable_mntpoints($o->{all_hds}); fs::set_all_default_options($o->{all_hds}, %$o, lang::fs_options($o->{locale})) if !$o->{isUpgrade}; $o->{fstab} = [ fsedit::get_all_fstab($o->{all_hds}) ]; fsedit::get_root_($o->{fstab}) or die "Oops, no root partition"; if (arch() =~ /ppc/ && detect_devices::get_mac_generation() =~ /NewWorld/) { die "Need bootstrap partition to boot system!" if !(defined $partition_table::mac::bootstrap_part); } if (arch() =~ /ia64/ && !fsedit::has_mntpoint("/boot/efi", $o->{all_hds})) { die \N("You must have a FAT partition mounted in /boot/efi"); } if ($o->{partitioning}{use_existing_root} && !$::recovery) { #- ensure those partitions are mounted so that they are not proposed in choosePartitionsToFormat fs::mount_part($_, $o->{prefix}) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} } grep { $_->{mntpoint} && maybeFormatted($_) } @{$o->{fstab}}; } cat_("/proc/mounts") =~ m|(\S+)\s+/tmp/image nfs| && !any { $_->{mntpoint} eq "/mnt/nfs" } @{$o->{all_hds}{nfss}} and push @{$o->{all_hds}{nfss}}, { type => 'nfs', mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,soft,rsize=8192,wsize=8192" }; } #------------------------------------------------------------------------------ sub doPartitionDisks { my ($o) = @_; if ($o->{partitioning}{auto_allocate}) { fsedit::auto_allocate($o->{all_hds}, $o->{partitions}); } } #------------------------------------------------------------------------------ sub ask_mntpoint_s {#-}}} my ($_o, $fstab) = @_; #- TODO: set the mntpoints my %m; foreach (@$fstab) { my $m = $_->{mntpoint}; next if !$m || $m eq 'swap'; #- there may be a lot of swap. $m{$m} and die \N("Duplicate mount point %s", $m); $m{$m} = 1; #- in case the type does not correspond, force it to ext3 $_->{type} = 0x483 if $m =~ m|^/| && !isTrueFS($_) && !isOtherAvailableFS($_); } 1; } sub rebootNeeded($) { my ($_o) = @_; log::l("Rebooting..."); c::_exit(0); } sub choosePartitionsToFormat($$) { my ($_o, $fstab) = @_; foreach (@$fstab) { $_->{mntpoint} = "swap" if isSwap($_); $_->{mntpoint} or next; add2hash_($_, { toFormat => $_->{notFormatted} }); $_->{$::recovery ? 'toFormat' : 'toFormatUnsure'} ||= member($_->{mntpoint}, '/', '/usr'); if (!$_->{toFormat}) { my $t = fsedit::typeOfPart($_->{device}); $_->{toFormatUnsure} ||= #- if detected dos/win, it's not precise enough to just compare the types (too many of them) (!$t || isOtherAvailableFS({ type => $t }) ? !isOtherAvailableFS($_) : $t != $_->{type}); } } } sub formatMountPartitions { my ($o) = @_; fs::formatMount_all($o->{all_hds}{raids}, $o->{fstab}, $o->{prefix}); } #------------------------------------------------------------------------------ sub setPackages { my ($o, $rebuild_needed) = @_; install_any::setPackages($o, $rebuild_needed); pkgs::selectPackagesAlreadyInstalled($o->{packages}, $o->{prefix}); $rebuild_needed and pkgs::selectPackagesToUpgrade($o->{packages}, $o->{prefix}); } sub choosePackages { my ($o, $packages, $_compssUsers, $first_time) = @_; #- now for upgrade, package that must be upgraded are #- selected first, after is used the same scheme as install. #- make sure we kept some space left for available else the system may #- not be able to start (xfs at least). my $available = install_any::getAvailableSpace($o); my $availableCorrected = pkgs::invCorrectSize($available / sqr(1024)) * sqr(1024); log::l(sprintf "available size %s (corrected %s)", formatXiB($available), formatXiB($availableCorrected)); add2hash_($o, { compssListLevel => 5 }) if !$::auto_install; #- avoid destroying user selection of packages but only #- for expert, as they may have done individual selection before. if ($first_time || !$::expert) { exists $o->{compssListLevel} and pkgs::setSelectedFromCompssList($packages, $o->{compssUsersChoice}, $o->{compssListLevel}, $availableCorrected); } $availableCorrected; } sub beforeInstallPackages { my ($o) = @_; #- save these files in case of upgrade failure. if ($o->{isUpgrade}) { foreach (@filesToSaveForUpgrade) { unlink "$o->{prefix}/$_.mdkgisave"; if (-e "$o->{prefix}/$_") { eval { cp_af("$o->{prefix}/$_", "$o->{prefix}/$_.mdkgisave") }; } } foreach (@filesNewerToUseAfterUpgrade) { unlink "$o->{prefix}/$_.rpmnew"; } } #- some packages need such files for proper installation. install_any::write_fstab($o); require network::network; network::network::add2hosts("$o->{prefix}/etc/hosts", "localhost.localdomain", "127.0.0.1"); log::l("setting excludedocs to $o->{excludedocs}"); substInFile { s/%_excludedocs.*//; $_ .= "%_excludedocs yes\n" if eof && $o->{excludedocs} } "$o->{prefix}/etc/rpm/macros"; #- add oem theme if the files exists. mkdir_p("$o->{prefix}/usr/share"); install_any::getAndSaveFile("Mandrake/base/oem-theme.rpm", "$o->{prefix}/usr/share/oem-theme.rpm"); } sub pkg_install { my ($o, @l) = @_; log::l("selecting packages ".join(" ", @l)); require pkgs; if ($::testing) { log::l(qq(selecting package "$_")) foreach @l; } else { $o->{packages}{rpmdb} ||= pkgs::rpmDbOpen($o->{prefix}); pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, $_) || die "$_ rpm not found") foreach @l; } my @toInstall = pkgs::packagesToInstall($o->{packages}); if (@toInstall) { log::l("installing packages"); $o->installPackages; } else { log::l("all packages selected are already installed, nothing to do") } } sub pkg_install_if_requires_satisfied { my ($o, @l) = @_; require pkgs; $o->{packages}{rpmdb} ||= pkgs::rpmDbOpen($o->{prefix}); foreach (@l) { my %newSelection; my $pkg = pkgs::packageByName($o->{packages}, $_) || die "$_ rpm not found"; pkgs::selectPackage($o->{packages}, $pkg, 0, \%newSelection); if (scalar(keys %newSelection) == 1) { pkgs::selectPackage($o->{packages}, $pkg); } else { log::l("pkg_install_if_requires_satisfied: not selecting $_ because of ", join(", ", keys %newSelection)); } } $o->installPackages; } sub installPackages($$) { #- complete REWORK, TODO and TOCHECK! my ($o) = @_; my $packages = $o->{packages}; if (%{$packages->{state}{ask_remove} || {}}) { log::l("removing : ", join ', ', keys %{$packages->{state}{ask_remove}}); pkgs::remove($o->{prefix}, [ keys %{$packages->{state}{ask_remove}} ], $packages); } #- small transaction will be built based on this selection and depslist. my @toInstall = pkgs::packagesToInstall($packages); my $time = time(); $ENV{DURING_INSTALL} = 1; pkgs::install($o->{prefix}, $o->{isUpgrade}, \@toInstall, $packages); any::writeandclean_ldsoconf($o->{prefix}); delete $ENV{DURING_INSTALL}; run_program::rooted_or_die($o->{prefix}, 'ldconfig'); log::l("Install took: ", formatTimeRaw(time() - $time)); install_any::log_sizes($o); scalar(@toInstall); #- return number of packages installed. } sub afterInstallPackages($) { my ($o) = @_; die \N("Some important packages didn't get installed properly. Either your cdrom drive or your cdrom is defective. Check the cdrom on an installed computer using \"rpm -qpl Mandrake/RPMS/*.rpm\" ") if any { m|read failed: Input/output error| } cat_("$o->{prefix}/root/drakx/install.log"); if (arch() !~ /^sparc/) { #- TODO restore it as may be needed for sparc -x "$o->{prefix}/usr/bin/dumpkeys" or $::testing or die "Some important packages didn't get installed properly. Please switch to console 2 (using ctrl-alt-f2) and look at the log file /tmp/ddebug.log Consoles 1,3,4,7 may also contain interesting information"; } #- why not? cuz weather is nice today :-) [pixel] common::sync(); common::sync(); my $have_devfsd = do { my $p = pkgs::packageByName($o->{packages}, 'devfsd'); $p && $p->flag_installed }; if ($have_devfsd) { require bootloader; bootloader::may_append($o->{bootloader}, devfs => 'mount'); } #- generate /etc/lvmtab needed for rc.sysinit run_program::rooted($o->{prefix}, 'lvm2', 'vgscan') if -e '/etc/lvmtab'; #- configure PCMCIA services if needed. modules::write_pcmcia($o->{prefix}, $o->{pcmcia}); #- for mandrake_firstime touch "$o->{prefix}/var/lock/TMP_1ST"; any::config_dvd($o->{prefix}, $have_devfsd); any::config_mtools($o->{prefix}); #- make sure wins is disabled in /etc/nsswitch.conf #- else if eth0 is not existing, glibc segfaults. substInFile { s/\s*wins// if /^\s*hosts\s*:/ } "$o->{prefix}/etc/nsswitch.conf"; #- make sure some services have been enabled (or a catastrophic restart will occur). #- these are normally base package post install scripts or important services to start. run_program::rooted($o->{prefix}, "chkconfig", "--add", $_) foreach qw(random netfs network rawdevices sound kheader keytable syslog crond portmap); if ($o->{mouse}{device} =~ /ttyS/) { log::l("disabling gpm for serial mice (doesn't get along nicely with X)"); run_program::rooted($o->{prefix}, "chkconfig", "--del", "gpm") } #- install urpmi before as rpmdb will be opened, this will cause problem with update-menus. $o->install_urpmi; #- update menu scheme before calling update menus if desktop mode. if ($o->{meta_class} eq 'desktop') { run_program::rooted($o->{prefix}, "touch", "/etc/menu/do-not-create-menu-link"); run_program::rooted($o->{prefix}, "touch", "/etc/menu/enable_simplified"); } elsif (!$o->{isUpgrade}) { run_program::rooted($o->{prefix}, "touch", "/etc/menu/do-not-create-menu-link"); } if ($o->{pcmcia}) { substInFile { s/.*(TaskBarShowAPMStatus).*/$1=1/ } "$o->{prefix}/usr/lib/X11/icewm/preferences"; eval { cp_af("$o->{prefix}/usr/share/applnk/System/kapm.kdelnk", "$o->{prefix}/etc/skel/Desktop/Autostart/kapm.kdelnk") }; } if ($o->{brltty}) { output("$o->{prefix}/etc/brltty.conf", <<EOF); braille-driver $o->{brltty}{driver} braille-device $o->{brltty}{device} text-table $o->{brltty}{table} EOF } install_any::disable_user_view() if $o->{security} >= 3 || $o->{authentication}{NIS}; run_program::rooted($o->{prefix}, "kdeDesktopCleanup"); foreach (list_skels($o->{prefix}, '.kde/share/config/kfmrc')) { my $found; substInFile { $found ||= /KFM Misc Defaults/; $_ .= "[KFM Misc Defaults] GridWidth=85 GridHeight=70 " if eof && !$found; } $_ } #- move some file after an upgrade that may be seriously annoying. #- and rename saved files to .mdkgiorig. if ($o->{isUpgrade}) { my $pkg = pkgs::packageByName($o->{packages}, 'rpm'); $pkg && ($pkg->flag_selected || $pkg->flag_installed) && $pkg->compare(">= 4.0") and pkgs::cleanOldRpmDb($o->{prefix}); log::l("moving previous desktop files that have been updated to Trash of each user"); install_any::kdemove_desktop_file($o->{prefix}); foreach (@filesToSaveForUpgrade) { renamef("$o->{prefix}/$_.mdkgisave", "$o->{prefix}/$_.mdkgiorig") if -e "$o->{prefix}$_.mdkgisave"; } foreach (@filesNewerToUseAfterUpgrade) { if (-e "$o->{prefix}/$_.rpmnew" && -e "$o->{prefix}/$_") { renamef("$o->{prefix}/$_", "$o->{prefix}/$_.mdkgiorig"); renamef("$o->{prefix}/$_.rpmnew", "$o->{prefix}/$_"); } } } any::fix_broken_alternatives(); #- update theme directly from a package (simplest). if (-s "$o->{prefix}/usr/share/oem-theme.rpm") { run_program::rooted($o->{prefix}, "rpm", "-U", "/usr/share/oem-theme.rpm"); unlink "/usr/share/oem-theme.rpm"; } #- call update-menus at the end of package installation push @{$o->{waitpids}}, run_program::raw({ root => $o->{prefix}, detach => 1 }, "update-menus", "-n"); if ($o->{blank} || $o->{updatemodules}) { my @l = detect_devices::floppies_dev(); foreach (qw(blank updatemodules)) { $o->{$_} eq "1" and $o->{$_} = $l[0] || die \N("No floppy drive available"); } $o->{blank} and $o->copyKernelFromFloppy; $o->{updatemodules} and $o->updateModulesFromFloppy; } } sub copyKernelFromFloppy { my ($o) = @_; return if $::testing || !$o->{blank}; fs::mount($o->{blank}, "/floppy", "vfat", 0); eval { cp_af("/floppy/vmlinuz", "$o->{prefix}/boot/vmlinuz-default") }; if ($@) { log::l("copying of /floppy/vmlinuz from blank modified disk failed: $@"); } fs::umount("/floppy"); } sub install_urpmi { my ($o) = @_; my $pkg = pkgs::packageByName($o->{packages}, 'urpmi'); if ($pkg && ($pkg->flag_selected || $pkg->flag_installed)) { install_any::install_urpmi($o->{prefix}, $o->{method}, $o->{packages}, $o->{packages}{mediums}); pkgs::saveCompssUsers($o->{prefix}, $o->{packages}, $o->{compssUsers}, $o->{compssUsersSorted}); } } sub updateModulesFromFloppy { my ($o) = @_; return if $::testing || !$o->{updatemodules}; fs::mount($o->{updatemodules}, "/floppy", "ext2", 0); foreach (glob_("$o->{prefix}/lib/modules/*")) { my ($kernelVersion) = m,lib/modules/(\S*),; log::l("examining updated modules for kernel $kernelVersion"); if (-d "/floppy/$kernelVersion") { my @src_files = glob_("/floppy/$kernelVersion/*"); my @dest_files = map { chomp_($_) } run_program::rooted_get_stdout($o->{prefix}, 'find', '/lib/modules'); foreach my $s (@src_files) { log::l("found updatable module $s"); my ($sfile, $sext) = $s =~ m!([^/\.]*\.k?o)(?:\.gz|\.bz2)?$!; my $qsfile = quotemeta $sfile; my $qsext = quotemeta $sext; foreach my $target (@dest_files) { $target =~ /$qsfile/ or next; eval { cp_af($s, $target) }; if ($@) { log::l("updating module $target by $s failed: $@"); } else { log::l("updating module $target by $s"); } if ($target !~ /$qsfile$qsext$/) { #- extension differ, first rename target file correctly, #- then uncompress source file, then compress it as expected. my ($basetarget, $text) = $target =~ /(.*?)(\.gz|\.bz2)$/; rename $target, "$basetarget$sext"; $sext eq '.gz' and run_program::run("gzip", "-d", "$basetarget$sext"); $sext eq '.bz2' and run_program::run("bzip2", "-d", "$basetarget$sext"); $text eq '.gz' and run_program::run("gzip", $basetarget); $text eq '.bz2' and run_program::run("bzip2", $basetarget); } } } } } fs::umount("/floppy"); } #------------------------------------------------------------------------------ sub selectMouse($) { my ($_o) = @_; } #------------------------------------------------------------------------------ sub configureNetwork { my ($o) = @_; require network::network; network::network::configureNetwork2($o, $o->{prefix}, $o->{netc}, $o->{intf}); if ($o->{method} =~ /ftp|http|nfs/) { $o->{netcnx}{type} = 'lan'; foreach ("up", "down") { my $f = "$o->{prefix}/etc/sysconfig/network-scripts/net_cnx_$_"; output_with_perm($f, 0755, "\nif$_ eth0\n"); } output "$o->{prefix}/etc/sysconfig/network-scripts/net_cnx_pg", "\n/usr/sbin/drakconnect\n"; require network::netconnect; $o->{netcnx}{$_} = $o->{netc}{$_} foreach qw(NET_DEVICE NET_INTERFACE); } } #------------------------------------------------------------------------------ sub installUpdates { my ($o) = @_; my $u = $o->{updates} or return; $u->{updates} or return; upNetwork($o); require crypto; crypto::getPackages($o->{prefix}, $o->{packages}, $u->{mirror}) and $o->pkg_install(@{$u->{packages} || []}); #- re-install urpmi with update security medium. $o->install_urpmi; } sub summaryBefore {} sub summary { my ($o) = @_; configureTimezone($o); configurePrinter($o) if $o->{printer}; } sub summaryAfter { my ($o) = @_; require bootloader; my $acpi = bootloader::get_append($o->{bootloader}, 'acpi'); if (!member($acpi, 'off', 'ht') && !(-x "$::prefix/usr/bin/acpi" && -x "$::prefix/usr/sbin/acpid")) { $o->do_pkgs->install(qw(acpi acpid)); } } #------------------------------------------------------------------------------ sub configureTimezone { my ($o) = @_; install_any::preConfigureTimezone($o); $o->pkg_install('ntp') if $o->{timezone}{ntp}; require timezone; timezone::write($o->{timezone}); } #------------------------------------------------------------------------------ sub configureServices { my ($o) = @_; if ($o->{services}) { require services; services::doit($o, $o->{services}); } } #------------------------------------------------------------------------------ sub configurePrinter { my ($o) = @_; $o->do_pkgs->install('foomatic-filters', 'foomatic-db-engine', 'foomatic-db', 'printer-utils', 'printer-testpages', if_($o->do_pkgs->is_installed('gimp'), 'gimpprint')); require printer::main; eval { add2hash($o->{printer} ||= {}, printer::main::getinfo($o->{prefix})) }; #- get existing configuration. require printer::printerdrake; printer::printerdrake::install_spooler($o->{printer}, $o); #- not interactive... foreach (values %{$o->{printer}{configured} || {}}) { log::l("configuring printer queue " . $_->{queuedata}{queue} || $_->{QUEUE}); #- when copy is so adulée (sorry french taste :-) #- and when there are some configuration in one place and in another place... $o->{printer}{currentqueue} = {}; printer::main::copy_printer_params($_->{queuedata}, $o->{printer}{currentqueue}); printer::main::copy_printer_params($_, $o->{printer}); #- setup all configured queues, which is not the case interactively where #- only the working queue is setup on configuration. printer::main::configure_queue($o->{printer}); } } #------------------------------------------------------------------------------ sub setRootPassword { my ($o) = @_; $o->{superuser} ||= {}; $o->{superuser}{name} = 'root'; any::write_passwd_user($o->{superuser}, $o->{authentication}{md5}); delete $o->{superuser}{name}; install_any::set_authentication($o); }