summaryrefslogtreecommitdiffstats
path: root/perl-install/network/isdn.pm
blob: 5646ca01f455cac7e60e9a5bd853ba10249fcc1a (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
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
package network::isdn;

use network::isdn_consts;
use common;
use any;
use modules;
use run_program;
use log;
use network::tools;
use vars qw(@ISA @EXPORT);
use MDK::Common::Globals "network", qw($in $prefix);
use MDK::Common::File;
@ISA = qw(Exporter);
@EXPORT = qw(isdn_write_config isdn_write_config_backend get_info_providers_backend isdn_ask_info isdn_ask_protocol isdn_ask isdn_detect isdn_detect_backend isdn_get_list isdn_get_info);

sub configure {
    my ($netcnx, $netc) = @_;
  isdn_step_1:
    defined $netc->{autodetect}{isdn}{id} and goto intern_pci;
    $::isInstall and $in->set_help('configureNetworkISDN');
    my $e = $in->ask_from_list_(_("Network Configuration Wizard"),
				_("What kind is your ISDN connection?"), [ __("Internal ISDN card"), __("External ISDN modem")]
			       ) or return;
    if ($e =~ /card/) {
      intern_pci:
	$netc->{isdntype}='isdn_internal';
	$netcnx->{isdn_internal}={};
	$netcnx->{isdn_internal}{$_} = $netc->{autodetect}{isdn}{$_} foreach ('description', 'vendor', 'id', 'driver', 'card_type', 'type');
	isdn_detect($netcnx->{isdn_internal}, $netc) or return;
    } else {
	$netc->{isdntype}='isdn_external';
	$netcnx->{isdn_external}={};
	$netcnx->{isdn_external}{device}=$netc->{autodetect}{modem};
	$netcnx->{isdn_external}{special_command}='AT&F&O2B40';
	require network::modem;
	network::modem::pppConfig($netcnx->{isdn_external}, $mouse, $netc) or goto isdn_step_1;
    }
    1;
}

sub isdn_write_config {
    my ($isdn, $netc) = @_;
  isdn_write_config_step_1:
    my $e = $in->ask_from_list_(_("Network Configuration Wizard"),
				    _("Which ISDN configuration do you prefer?

* The Old configuration uses isdn4net. It contains powerfull
  tools, but is tricky to configure, and not standard.

* The New configuration is easier to understand, more
  standard, but with less tools.

We recommand the light configuration.
"), [ __("New configuration (isdn-light)"), __("Old configuration (isdn4net)")]
			       ) or return;
    my ($rmpackage, $instpackage) = $e =~ /light/ ? ('isdn4net', 'isdn-light') : ('isdn-light', 'isdn4net');
    if (!$::isStandalone) {
	require pkgs;
	my $p = pkgs::packageByName($in->{packages}, $rmpackage);
	$p && pkgs::packageFlagSelected($p) and pkgs::unselectPackage($in->{packages}, $p);
    }
    run_program::rooted($prefix, "rpm", "-e", "$rmpackage");
    $in->do_pkgs->install($instpackage, if_($isdn->{speed} =~ /128/, 'ibod'), 'isdn4k-utils');
    my $light = $e =~ /light/ ? 1 : 0;
    isdn_write_config_backend($isdn, $light, $netc);
    1;
}

sub isdn_write_config_backend {
    my ($isdn, $light, $netc, $netcnx) = @_;
    defined $netcnx and $netc->{isdntype} = $netcnx->{type};
    if ($light) {
	modules::mergein_conf("$prefix/etc/modules.conf");
	if ($isdn->{id}) {
	    isdn_detect_backend($isdn);
	} else {
	    my $a="";
	    defined $isdn->{$_} and $a .= "$_=" . $isdn->{$_} . " " foreach qw(type protocol mem io io0 io1 irq);
	    $isdn->{driver} eq "hisax" and $a.="id=HiSax";
	    modules::set_options($isdn->{driver}, $a);
	}
	modules::add_alias("ippp0", $isdn->{driver});
	$::isStandalone and modules::write_conf($prefix);
	foreach my $f ('ioptions1B', 'ioptions2B') {
	    substInFile { s/^name .*\n//; $_ .= "name $isdn->{login}\n" if eof  } "$prefix/etc/ppp/$f";
	    chmod 0600, $f;
	}
	foreach my $f ('isdn1B.conf', 'isdn2B.conf') {
	    my $a=1;
	    substInFile {
		s/EAZ =.*/EAZ = $isdn->{phone_in}/;
		s/PHONE_OUT =.*/PHONE_OUT = $isdn->{phone_out}/;
		if (/NAME = ippp0/ .. /PPPBIND = 0/) {
		    s/HUPTIMEOUT =.*/HUPTIMEOUT = $isdn->{huptimeout}/;
		}
	    } "$prefix/etc/isdn/$f";
	    chmod 0600, $f;
	}
	my $bundle = $isdn->{speed} =~ /64/ ? "1B" : "2B";
	symlinkf("isdn" . $bundle . ".conf", "$prefix/etc/isdn/isdnctrl.conf");
	symlinkf("ioptions" . $bundle, "$prefix/etc/ppp/ioptions");
    } else {
	my $f = "$prefix/etc/isdn/profile/link/myisp";
	output ($f,
	  qq(
I4L_USERNAME="$isdn->{login}"
I4L_SYSNAME=""
I4L_LOCALMSN="$isdn->{phone_in}"
I4L_REMOTE_OUT="$isdn->{phone_out}"
I4L_DIALMODE="$isdn->{dialing_mode}"
) . if_($isdn->{speed} =~ /128/, 'SLAVE="ippp1"
'));
	chmod 0600, $f;

	output "$prefix/etc/isdn/profile/card/mycard",
	  qq(
I4L_MODULE="$isdn->{driver}"
I4L_TYPE="$isdn->{type}"
I4L_IRQ="$isdn->{irq}"
I4L_MEMBASE="$isdn->{mem}"
I4L_PORT="$isdn->{io}"
I4L_IO0="$isdn->{io0}"
I4L_IO1="$isdn->{io1}"
I4L_ID="HiSax"
I4L_FIRMWARE="$isdn->{firmware}"
);

	output "$prefix/etc/ppp/ioptions",
	  "lock
usepeerdns
defaultroute
";
	system "$prefix/etc/rc.d/init.d/isdn4linux restart";
    }

    substInFile { s/^FIRMWARE.*\n//; $_ .= qq(FIRMWARE="$isdn->{firmware}"\n) if eof  } "$prefix/etc/sysconfig/network-scripts/ifcfg-ippp0";

    write_secret_backend($isdn->{login}, $isdn->{passwd});

    write_cnx_script($netc, "isdn",
"/sbin/route del default
/sbin/ifup ippp0
/sbin/isdnctrl dial ippp0
" . if_($isdn->{speed} =~ /128/, "service ibod restart
"),
"/sbin/isdnctrl hangup ippp0
/sbin/ifdown ippp0
"  . if_($isdn->{speed} =~ /128/, "service ibod stop
"), $netc->{isdntype});
    1;
}

sub get_info_providers_backend {
    my ($isdn, $netc, $name, $file) = @_;
    $name eq 'Unlisted - edit manually' and return;
    foreach (catMaybeCompressed($file)) {
	chop;
	my ($name_, $phone, $real, $dns1, $dns2) = split '=>';
	if ($name eq $name_) {
	    @{$isdn}{qw(user_name phone_out DOMAINNAME2 dnsServer3 dnsServer2)} =
	               ((split(/\|/, $name_))[2], $phone, $real, $dns1, $dns2);
	}
    }
}

sub isdn_ask_info {
    my ($isdn, $netc) = @_;
    my $f = "$ENV{SHARE_PATH}/ldetect-lst/isdn.db";
    $f = "$prefix$f" if !-e $f;
    my $str= $in->ask_from_treelist( _("ISDN Configuration"), _("Select your provider.\n If it's not in the list, choose Unlisted"),
				     '|', ['Unlisted - edit manually',
					   read_providers_backend($f)], 'Unlisted - edit manually')
      or return;
    get_info_providers_backend($isdn, $netc, $str || 'Unlisted - edit manually', $f);
    $isdn->{huptimeout} = 180;
    $isdn->{$_} ||= '' foreach qw(phone_in phone_out dialing_mode login passwd passwd2 idl speed);
    add2hash($netc, { dnsServer2 => '', dnsServer3 => '', DOMAINNAME2 => '' });
    ask_info2($isdn, $netc);
}

sub isdn_ask_protocol {
    my @toto=(
	      { description => $::expert ? _("Europe protocol (EDSS1)") : _("Europe protocol"),
		protokol => 2},
	      { description => $::expert ? _("Protocol for the rest of the world \n no D-Channel (leased lines)") : _("Protocol for the rest of the world"),
		protokol => 3}
	     );
    my $e = $in->ask_from_listf(_("ISDN Configuration"),
				_("Which protocol do you want to use ?"),
				sub { $_[0]{description} },
				\@toto ) or return 0;
    $e->{protokol};
}

sub isdn_ask {
    my ($isdn, $netc, $label) = @_;
  isdn_ask_step_1:
    my $e = $in->ask_from_list_(_("ISDN Configuration"),
				$label . "\n" . _("What kind of card do you have?"),
				[ __("ISA / PCMCIA"), __("PCI"), __("I don't know") ]
			       ) or return;
    if ($e =~ /PCI/) {
	$isdn->{card_type} = 'pci';
    } else {
	$in->ask_from_list_(_("ISDN Configuration"),
			    _("
If you have an ISA card, the values on the next screen should be right.\n
If you have a PCMCIA card, you have to know the irq and io of your card.
"),
			    [ __("Continue"), __("Abort") ]) eq 'Continue' or goto isdn_ask_step_1;
	$isdn->{card_type} = 'isa';
    }

  isdn_ask_step_2:
    $e = $in->ask_from_listf(_("ISDN Configuration"),
			     _("Which is your ISDN card ?"),
			     sub { $_[0]{description} },
			     [ grep {$_->{card} eq $isdn->{card_type}; } @isdndata ] ) or goto isdn_ask_step_1;
    $e->{$_} and $isdn->{$_} = $e->{$_} foreach qw(driver type mem io io0 io1 irq firmware);

  isdn_ask_step_3:
    $isdn->{protocol} = isdn_ask_protocol() or goto isdn_ask_step_2;
  isdn_ask_step_4:
    isdn_ask_info($isdn, $netc) or goto isdn_ask_step_3;
    isdn_write_config($isdn, $netc) or goto isdn_ask_step_4;
    1;
}

sub isdn_detect {
    my ($isdn, $netc) = @_;
    if ($isdn->{id}) {
  	log::l("found isdn card : $isdn->{description}; vendor : $isdn->{vendor};id : $isdn->{id}; driver : $isdn->{driver}\n");
	$isdn->{description} =~ s/\|/ -- /;
	if ($isdn->{type} eq '') {
	    isdn_ask($isdn, $netc, _("I have detected an ISDN PCI Card, but I don't know the type. Please select one PCI card on the next screen.")) or return;
	} else {
	  isdn_detect_step_1:
	    $isdn->{protocol}=isdn_ask_protocol() or return;
	  isdn_detect_step_2:
	    isdn_ask_info($isdn, $netc) or goto isdn_detect_step_1;
	    isdn_write_config($isdn, $netc) or goto isdn_detect_step_2;
	}
    } else {
	isdn_ask($isdn, $netc, _("No ISDN PCI card found. Please select one on the next screen.")) or return;
    }
    $netc->{$_}='ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
    1;
}

sub isdn_detect_backend {
    my ($isdn) = @_;
    if (my ($c) = (modules::get_that_type('isdn'))) {
  	$isdn->{$_} = $c->{$_} foreach qw(description vendor id driver options firmware);
	$isdn->{$_} = sprintf("%0x", $isdn->{$_}) foreach ('vendor', 'id');
	$isdn->{card_type} = 'pci';
	($isdn->{type}) = $isdn->{options} =~ /type=(\d+)/;
#	$c->{options} !~ /id=HiSax/ && $isdn->{driver} eq "hisax" and $c->{options} .= " id=HiSax";
	if ($c->{options} !~ /protocol=/ && $isdn->{protocol} =~ /\d/) {
	    modules::set_options($c->{driver}, $c->{options} . " protocol=" . $isdn->{protocol});
	}
	$c->{options} =~ /protocol=(\d)/ and $isdn->{protocol} = $1;
    }
}

sub isdn_get_list {
    map { $_->{description} } @isdndata;
}

sub isdn_get_info {
    my ($desc) = @_;
    foreach (@isdndata) {
	return $_ if ($_->{description} eq $desc);
    }
}

1;
->{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) = @_; install_any::configure_pcmcia($o->{modules_conf}, $o->{pcmcia}) if $o->{pcmcia}; modules::load(modules::category2modules('disk/cdrom')); modules::load_category($o->{modules_conf}, 'bus/firewire'); modules::load_category($o->{modules_conf}, 'disk/ide|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 = fs::get::root_($o->{fstab}) || (first(install_any::find_root_parts($o->{fstab}, $o->{prefix})) || die)->{part}; $o->{migrate_device_names} = install_any::use_root_part($o->{all_hds}, $p); } } #------------------------------------------------------------------------------ sub doPartitionDisksBefore { my ($o) = @_; eval { eval { fs::umount("$o->{prefix}/sys") }; eval { fs::umount("$o->{prefix}/proc/bus/usb") }; 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::mount_options::set_all_default($o->{all_hds}, %$o, lang::fs_options($o->{locale})) if !$o->{isUpgrade}; $o->{fstab} = [ fs::get::fstab($o->{all_hds}) ]; fs::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/ && !fs::get::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/nfsimage| && !any { $_->{mntpoint} eq "/mnt/nfs" } @{$o->{all_hds}{nfss}} and push @{$o->{all_hds}{nfss}}, { fs_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}) { catch_cdie { fsedit::auto_allocate($o->{all_hds}, $o->{partitions}) } sub { 1 }; } } #------------------------------------------------------------------------------ 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 fs::type::set_fs_type($_, 'ext3') 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} }) if $_->{fs_type}; #- eg: don't set toFormat for isRawRAID (0xfd) $_->{$::recovery ? 'toFormat' : 'toFormatUnsure'} ||= member($_->{mntpoint}, '/', '/usr'); if (!$_->{toFormat}) { my $fs_type = fs::type::fs_type_from_magic($_); if (!$fs_type || $fs_type ne $_->{fs_type}) { log::l("setting toFormatUnsure for $_->{device} because <$_->{fs_type}> ne <$fs_type>"); $_->{toFormatUnsure} = 1; } } } } 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 deselectFoundMedia { my (undef, $hdlists) = @_; @$hdlists; } sub selectSupplMedia { '' } sub askSupplMirror { '' } 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->{rpmsrate_flags_chosen}, $o->{compssListLevel}, $availableCorrected); } $availableCorrected; } sub upgrading_redhat() { #- remove weird config files that bother Xconfig::* too much unlink "$::prefix/etc/X11/XF86Config"; unlink "$::prefix/etc/X11/XF86Config-4"; sub prefering_mdk { my ($lpkg, $rpkg_ver, $c) = @_; my $lpkg_ver = $lpkg->version . '-' . $lpkg->release; log::l($lpkg->name . ' ' . ': prefering ' . ($c == 1 ? "$lpkg_ver over $rpkg_ver" : "$rpkg_ver over $lpkg_ver")); } my $old_compare_pkg = \&URPM::Package::compare_pkg; undef *URPM::Package::compare_pkg; *URPM::Package::compare_pkg = sub { my ($lpkg, $rpkg) = @_; my $c = ($lpkg->release =~ /mdk$/ ? 1 : 0) - ($rpkg->release =~ /mdk$/ ? 1 : 0); if ($c) { prefering_mdk($lpkg, $rpkg->version . '-' . $rpkg->release, $c); $c; } else { &$old_compare_pkg; } }; my $old_compare = \&URPM::Package::compare; undef *URPM::Package::compare; *URPM::Package::compare = sub { my ($lpkg, $rpkg_ver) = @_; my $c = ($lpkg->release =~ /mdk$/ ? 1 : 0) - ($rpkg_ver =~ /mdk$/ ? 1 : 0); if ($c) { prefering_mdk($lpkg, $rpkg_ver, $c); return $c; } &$old_compare; }; } 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"; } } #- mainly for upgrading redhat packages, but it can help other my @should_not_be_dirs = qw(/usr/X11R6/lib/X11/xkb /usr/share/locale/zh_TW/LC_TIME /usr/include/GL); my @should_be_dirs = qw(/etc/X11/xkb); my @to_remove = ( (grep { !-l $_ && -d $_ } map { "$::prefix$_" } @should_not_be_dirs), (grep { -l $_ || !-d $_ && -e $_ } map { "$::prefix$_" } @should_be_dirs), ); rm_rf(@to_remove); if ($o->{isUpgrade} eq 'redhat') { upgrading_redhat(); } #- some packages need such files for proper installation. install_any::write_fstab($o); require network::network; network::network::add2hosts("$o->{prefix}/etc/hosts", "localhost", "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("install/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'); eval { run_program::rooted($o->{prefix}, 'gdk-pixbuf-query-loaders', '>', '/etc/gtk-2.0/gdk-pixbuf.loaders.' . (arch() =~ /64/ ? 'lib64' : 'lib')); run_program::rooted($o->{prefix}, 'gtk-query-immodules-2.0', '>', '/etc/gtk-2.0/gtk.immodules.' . (arch() =~ /64/ ? 'lib64' : 'lib')); run_program::rooted($o->{prefix}, 'pango-querymodules-' . (arch() =~ /64/ ? '64' : '32'), '>', '/etc/pango/' . (arch() =~ /i.86/ ? 'i386' : arch()) . '/pango.modules'); }; 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 media/main/*.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 }; require bootloader; bootloader::may_append_with_key($o->{bootloader}, devfs => $have_devfsd ? 'mount' : 'nomount'); #- generate /etc/lvmtab needed for rc.sysinit run_program::rooted($o->{prefix}, 'lvm2', 'vgscan') if -e '/etc/lvmtab'; #- configure PCMCIA services if needed. install_any::write_pcmcia($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($o->{isUpgrade} eq 'redhat'); #- 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->{updatemodules}) { $o->{updatemodules} = detect_devices::floppy() or die N("No floppy drive available"); $o->updateModulesFromFloppy; } } 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}); } } sub updateModulesFromFloppy { my ($o) = @_; return if $::testing; 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->{modules_conf}, $o->{prefix}, $o->{netc}, $o->{intf}); if ($o->{method} =~ /ftp|http|nfs/) { $o->{netcnx}{type} = 'lan'; $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) = @_; } #------------------------------------------------------------------------------ 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) = @_; eval { $o->do_pkgs->install('foomatic-filters', 'foomatic-db-engine', 'foomatic-db', 'printer-utils', 'printer-testpages', if_($o->do_pkgs->is_installed('gimp'), 'gimpprint')); }; if ($@ =~ /rpm not found/) { log::l("ERROR: $@"); if ($o->{printer}) { require printer::printerdrake; printer::printerdrake::final_cleanup($o->{printer}); } return; } 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->{security}, $o->do_pkgs); 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); } #------------------------------------------------------------------------------ sub addUser { my ($o) = @_; my $users = $o->{users} ||= []; if ($::prefix) { #- getpwnam, getgrnam, getgrid works symlinkf("$::prefix/etc/passwd", '/etc/passwd'); symlinkf("$::prefix/etc/group", '/etc/group'); } my (%uids, %gids); foreach (glob_("$::prefix/home")) { my ($u, $g) = (stat($_))[4,5]; $uids{$u} = 1; $gids{$g} = 1 } foreach (@$users) { $_->{home} ||= "/home/$_->{name}"; my $u = $_->{uid} || ($_->{oldu} = (stat("$::prefix$_->{home}"))[4]) || int getpwnam($_->{name}); my $g = $_->{gid} || ($_->{oldg} = (stat("$::prefix$_->{home}"))[5]) || int getgrnam($_->{name}); #- search for available uid above 501 else initscripts may fail to change language for KDE. if (!$u || getpwuid($u)) { for ($u = 501; getpwuid($u) || $uids{$u}; $u++) {} } if (!$g) { for ($g = 501; getgrgid($g) || $gids{$g}; $g++) {} } $_->{uid} = $u; $uids{$u} = 1; $_->{gid} = $g; $gids{$g} = 1; } any::write_passwd_user($_, $o->{authentication}{md5}) foreach @$users; append_to_file("$::prefix/etc/group", map { "$_->{name}:x:$_->{gid}:\n" } grep { ! getgrgid($_->{gid}) } @$users); foreach my $u (@$users) { if (! -d "$::prefix$u->{home}") { my $mode = $o->{security} < 2 ? 0755 : 0750; eval { cp_af("$::prefix/etc/skel", "$::prefix$u->{home}") };