summaryrefslogtreecommitdiffstats
path: root/perl-install/Xconfig/xfree3.pm
blob: 9b69b3cb6596e863e0fa4fb3c98ef6233337c325 (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
package Xconfig::xfree3; # $Id$

use diagnostics;
use strict;

use common;
use Xconfig::parse;
use Xconfig::xfreeX;

our @ISA = 'Xconfig::xfreeX';

sub name { 'xfree3' }
sub config_file { '/etc/X11/XF86Config' }


sub get_keyboard_section {
    my ($raw_X) = @_;
    return $raw_X->get_Section('Keyboard') or die "no keyboard section";
}
sub new_keyboard_section {
    my ($raw_X) = @_;
    return $raw_X->add_Section('Keyboard', { Protocol => { val => 'Standard' } });
}

sub get_mouse_sections {
    my ($raw_X) = @_;
    my $main = $raw_X->get_Section('Pointer') or die "no mouse section";
    my $XInput = $raw_X->get_Section('XInput');    
    $main, if_($XInput, map { $_->{l} } @{$XInput->{Mouse} || []}); 
}

sub new_mouse_sections {
    my ($raw_X, $nb_new) = @_;

    $raw_X->remove_Section('Pointer');
    my $XInput = $raw_X->get_Section('XInput');
    delete $XInput->{Mouse} if $XInput;
    $raw_X->remove_Section('XInput') if $nb_new <= 1 && $XInput && !%$XInput;

    $nb_new or return;

    my $main = $raw_X->add_Section('Pointer', {});
    
    if ($nb_new == 1) {
	$main;
    } else {
	my @l = map { { AlwaysCore => {} } } (2 .. $nb_new);
	$XInput ||= $raw_X->add_Section('XInput', {});
	$XInput->{Mouse} = [ map { { l => $_ } } @l ];
	$main, @l;
    }
}

sub set_mice {
    my ($raw_X, @mice) = @_;
    @mice = map { 
	my %h = %$_;
	put_in_hash(\%h, { Protocol => 'IMPS/2', ZAxisMapping => '4 5' }) if $h{Protocol} eq 'ExplorerPS/2';
	\%h;
    } @mice;
    $raw_X->SUPER::set_mice(@mice);
}

sub set_wacoms {
    my ($raw_X, @wacoms) = @_;

    my %Modes = (Stylus => 'Absolute', Eraser => 'Absolute', Cursor => 'Relative');

    my $XInput = $raw_X->get_Section('XInput');
    if ($XInput) {
	delete $XInput->{"Wacom$_"} foreach keys %Modes;
	$raw_X->remove_Section('XInput') if !@wacoms && $XInput && !%$XInput;
    }
    #- only wacom is handled in XFree 3
    my ($wacom) = @wacoms or return;

    $XInput ||= $raw_X->add_Section('XInput', {});
    foreach (keys %Modes) {
	$XInput->{"Wacom$_"} = [ { l => { Port => { val => qq("$wacom->{Device}") }, 
					  Mode => { val => $Modes{$_} },
					  if_($wacom->{USB}, USB => {}),
					  AlwaysCore => {} } } ];
    }
}

sub depths { 8, 15, 16, 24, 32 }
sub set_resolution {
    my ($raw_X, $resolution, $Screen) = @_;

    $resolution = +{ %$resolution };
    if (my $Screen_ = $Screen || $raw_X->get_default_screen) {
	#- use framebuffer if Screen is
	$resolution->{fbdev} = 1 if val($Screen_->{Driver}) eq 'fbdev';
    }
    $raw_X->SUPER::set_resolution($resolution, $Screen);
}

sub get_device_section_fields {
    qw(VendorName BoardName Chipset VideoRam); #-);
}

sub default_ModeLine {
    my ($raw_X) = @_;
    $raw_X->SUPER::default_ModeLine . our $default_ModeLine;
}

sub new_device_sections {
    my ($raw_X, $nb_new) = @_;
    my @l = $raw_X->SUPER::new_device_sections($nb_new);
    $_->{power_saver} = { Option => 1 } foreach @l;
    @l;
}

sub set_Option {}


sub val {
    my ($ref) = @_;
    $ref && $ref->{val};
}

our $default_ModeLine = <<'END';
    # This is a set of standard mode timings. Modes that are out of monitor spec
    # are automatically deleted by the server (provided the HorizSync and
    # VertRefresh lines are correct), so there's no immediate need to
    # delete mode timings (unless particular mode timings don't work on your
    # monitor). With these modes, the best standard mode that your monitor
    # and video card can support for a given resolution is automatically
    # used.
    
    # 640x400 @ 70 Hz, 31.5 kHz hsync
    ModeLine "640x400"     25.175 640  664  760  800   400  409  411  450
    # 640x480 @ 60 Hz, 31.5 kHz hsync
    ModeLine "640x480"     25.175 640  664  760  800   480  491  493  525
    # 800x600 @ 56 Hz, 35.15 kHz hsync
    ModeLine "800x600"     36     800  824  896 1024   600  601  603  625
    # 1024x768 @ 87 Hz interlaced, 35.5 kHz hsync
    ModeLine "1024x768"    44.9  1024 1048 1208 1264   768  776  784  817 Interlace
    
    # 640x400 @ 85 Hz, 37.86 kHz hsync
    ModeLine "640x400"     31.5   640  672 736   832   400  401  404  445 -HSync +VSync
    # 640x480 @ 75 Hz, 37.50 kHz hsync
    ModeLine  "640x480"    31.5   640  656  720  840   480  481  484  500 -HSync -VSync
    # 800x600 @ 60 Hz, 37.8 kHz hsync
    ModeLine "800x600"     40     800  840  968 1056   600  601  605  628 +hsync +vsync
    
    # 640x480 @ 85 Hz, 43.27 kHz hsync
    ModeLine "640x480"     36     640  696  752  832   480  481  484  509 -HSync -VSync
    # 1152x864 @ 89 Hz interlaced, 44 kHz hsync
    ModeLine "1152x864"    65    1152 1168 1384 1480   864  865  875  985 Interlace
    
    # 800x600 @ 72 Hz, 48.0 kHz hsync
    ModeLine "800x600"     50     800  856  976 1040   600  637  643  666 +hsync +vsync
    # 1024x768 @ 60 Hz, 48.4 kHz hsync
    ModeLine "1024x768"    65    1024 1032 1176 1344   768  771  777  806 -hsync -vsync
    
    # 640x480 @ 100 Hz, 53.01 kHz hsync
    ModeLine "640x480"     45.8   640  672  768  864   480  488  494  530 -HSync -VSync
    # 1152x864 @ 60 Hz, 53.5 kHz hsync
    ModeLine  "1152x864"   89.9  1152 1216 1472 1680   864  868  876  892 -HSync -VSync
    # 800x600 @ 85 Hz, 55.84 kHz hsync
    ModeLine  "800x600"    60.75  800  864  928 1088   600  616  621  657 -HSync -VSync
    
    # 1024x768 @ 70 Hz, 56.5 kHz hsync
    ModeLine "1024x768"    75    1024 1048 1184 1328   768  771  777  806 -hsync -vsync
    # 1280x1024 @ 87 Hz interlaced, 51 kHz hsync
    ModeLine "1280x1024"   80    1280 1296 1512 1568  1024 1025 1037 1165 Interlace
    
    # 800x600 @ 100 Hz, 64.02 kHz hsync
    ModeLine  "800x600"    69.65  800  864  928 1088   600  604  610  640 -HSync -VSync
    # 1024x768 @ 76 Hz, 62.5 kHz hsync
    ModeLine "1024x768"    85    1024 1032 1152 1360   768  784  787  823
    # 1152x864 @ 70 Hz, 62.4 kHz hsync
    ModeLine  "1152x864"   92    1152 1208 1368 1474   864  865  875  895
    # 1280x1024 @ 61 Hz, 64.2 kHz hsync
    ModeLine "1280x1024"  110    1280 1328 1512 1712  1024 1025 1028 1054
    # 1400x1050 @ 60 Hz, 65.5 kHz
    ModeLine "1400x1050" 122.0 1400 1488 1640 1880   1050 1052 1064 1082 +HSync +VSync
    
    # 1024x768 @ 85 Hz, 70.24 kHz hsync
    ModeLine "1024x768"   98.9  1024 1056 1216 1408   768 782 788 822 -HSync -VSync
    # 1152x864 @ 78 Hz, 70.8 kHz hsync
    ModeLine "1152x864"   110   1152 1240 1324 1552   864  864  876  908
    
    # 1280x1024 @ 70 Hz, 74.59 kHz hsync
    ModeLine "1280x1024"  126.5 1280 1312 1472 1696  1024 1032 1040 1068 -HSync -VSync
    # 1600x1200 @ 60Hz, 75.00 kHz hsync
    ModeLine "1600x1200"  162   1600 1664 1856 2160  1200 1201 1204 1250 +HSync +VSync
    # 1152x864 @ 84 Hz, 76.0 kHz hsync
    ModeLine "1152x864"   135    1152 1464 1592 1776   864  864  876  908
    
    # 1280x1024 @ 75 Hz, 79.98 kHz hsync
    ModeLine "1280x1024"  135    1280 1296 1440 1688 1024 1025 1028 1066 +HSync +VSync
    
    # 1024x768 @ 100Hz, 80.21 kHz hsync
    ModeLine "1024x768"   115.5  1024 1056 1248 1440  768  771  781  802 -HSync -VSync
    # 1400x1050 @ 75 Hz, 82.2 kHz hsync
    ModeLine "1400x1050" 155.8   1400 1464 1784 1912  1050 1052 1064 1090 +HSync +VSync
    
    # 1600x1200 @ 70 Hz, 87.50 kHz hsync
    ModeLine "1600x1200"  189    1600 1664 1856 2160  1200 1201 1204 1250 -HSync -VSync
    # 1152x864 @ 100 Hz, 89.62 kHz hsync
    ModeLine "1152x864"   137.65 1152 1184 1312 1536   864  866  885  902 -HSync -VSync
    # 1280x1024 @ 85 Hz, 91.15 kHz hsync
    ModeLine "1280x1024"  157.5  1280 1344 1504 1728  1024 1025 1028 1072 +HSync +VSync
    # 1600x1200 @ 75 Hz, 93.75 kHz hsync
    ModeLine "1600x1200"  202.5  1600 1664 1856 2160  1200 1201 1204 1250 +HSync +VSync
    # 1600x1200 @ 85 Hz, 105.77 kHz hsync
    ModeLine "1600x1200"  220    1600 1616 1808 2080  1200 1204 1207 1244 +HSync +VSync
    # 1600x1200 @ 85 Hz, 106.3 kHz hsync
    ModeLine "1600x1200" 229.5   1600 1664 1856 2160  1200 1201 1204 1250 +HSync +VSync
    # 1280x1024 @ 100 Hz, 107.16 kHz hsync
    ModeLine "1280x1024"  181.75 1280 1312 1440 1696  1024 1031 1046 1072 -HSync -VSync
    
    # 1800x1440 @ 64Hz, 96.15 kHz hsync
    ModeLine "1800X1440"  230    1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync
    # 1800x1440 @ 70Hz, 104.52 kHz hsync
    ModeLine "1800X1440"  250    1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync
    
    # 1920x1440 @ 60 Hz, 90.0 kHz hsync
    ModeLine "1920x1440"  234.0  1920 2048 2256 2600 1440 1441 1444 1500 -HSync +VSync
    # 1920x1440 @ 75 Hz, 112.5kHz hsync
    ModeLine "1920x1440"  297.0  1920 2064 2288 2640 1440 1441 1444 1500 -HSync +VSync
    
    # 512x384 @ 78 Hz, 31.50 kHz hsync
    ModeLine "512x384"    20.160 512  528  592  640   384  385  388  404 -HSync -VSync
    # 512x384 @ 85 Hz, 34.38 kHz hsync
    ModeLine "512x384"    22     512  528  592  640   384  385  388  404 -HSync -VSync
    
    
    # Low-res Doublescan modes
    # If your chipset does not support doublescan, you get a 'squashed'
    # resolution like 320x400.
    
    # 320x200 @ 70 Hz, 31.5 kHz hsync, 8:5 aspect ratio
    ModeLine "320x200"     12.588 320  336  384  400   200  204  205  225 Doublescan
    # 320x240 @ 60 Hz, 31.5 kHz hsync, 4:3 aspect ratio
    ModeLine "320x240"     12.588 320  336  384  400   240  245  246  262 Doublescan
    # 320x240 @ 72 Hz, 36.5 kHz hsync
    ModeLine "320x240"     15.750 320  336  384  400   240  244  246  262 Doublescan
    # 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio
    ModeLine "400x300"     18     400  416  448  512   300  301  302  312 Doublescan
    # 400x300 @ 60 Hz, 37.8 kHz hsync
    ModeLine "400x300"     20     400  416  480  528   300  301  303  314 Doublescan
    # 400x300 @ 72 Hz, 48.0 kHz hsync
    ModeLine "400x300"     25     400  424  488  520   300  319  322  333 Doublescan
    # 480x300 @ 56 Hz, 35.2 kHz hsync, 8:5 aspect ratio
    ModeLine "480x300"     21.656 480  496  536  616   300  301  302  312 Doublescan
    # 480x300 @ 60 Hz, 37.8 kHz hsync
    ModeLine "480x300"     23.890 480  496  576  632   300  301  303  314 Doublescan
    # 480x300 @ 63 Hz, 39.6 kHz hsync
    ModeLine "480x300"     25     480  496  576  632   300  301  303  314 Doublescan
    # 480x300 @ 72 Hz, 48.0 kHz hsync
    ModeLine "480x300"     29.952 480  504  584  624   300  319  322  333 Doublescan
END

1;
">$o, $step) = @_; log::l("step `$step' finished"); if (-d "$o->{prefix}/root") { eval { commands::cp('-f', "/tmp/ddebug.log", "$o->{prefix}/root") }; install_any::g_auto_install(); } for (my $s = $o->{steps}{first}; $s; $s = $o->{steps}{$s}{next}) { #- 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(_("Error"), [ _("An error occurred, but I don't know how to handle it nicely. Continue at your own risk."), $@ ]) if $@; } } sub errorInStep($$) { print "error :(\n"; c::_exit(1) } sub kill_action {} sub set_help { 1 } #-###################################################################################### #- Steps Functions #-###################################################################################### #------------------------------------------------------------------------------ sub selectLanguage { my ($o) = @_; lang::set($o->{lang}); $o->{langs} ||= [ $o->{lang} ]; if ($o->{keyboard_unsafe} || !$o->{keyboard}) { $o->{keyboard_unsafe} = 1; $o->{keyboard} = keyboard::lang2keyboard($o->{lang}); selectKeyboard($o); } } #------------------------------------------------------------------------------ sub selectKeyboard { my ($o) = @_; keyboard::setup($o->{keyboard}); lang::set_langs($o->{langs}); } #------------------------------------------------------------------------------ sub selectPath {} #------------------------------------------------------------------------------ sub selectInstallClass($@) { my ($o) = @_; $o->{installClass} ||= $::corporate ? "corporate" : "normal"; $o->{security} ||= ${{ normal => 2, developer => 3, corporate => 3, server => 4, }}{$o->{installClass}}; } #------------------------------------------------------------------------------ sub setupSCSI { modules::load_ide(); modules::load_thiskind('scsi'); } #------------------------------------------------------------------------------ sub doPartitionDisks { my ($o, $hds) = @_; if ($o->{lnx4win}) { my @l = sort { $a->{device_windobe} cmp $b->{device_windobe} } grep { isFat($_) } fsedit::get_fstab(@{$o->{hds}}) or die "wow, lnx4win with no fat partitions! hard times :("; my $real_part = @l > 1 && $o->doPartitionDisksLnx4winDev(\@l) || $l[0]; my $handle = loopback::inspect($real_part, '', 'rw') or die _("This partition can't be used for loopback"); my $size = loopback::getFree($handle->{dir}, $real_part); my $max_linux = 1000 << 11; $max_linux *= 10 if $::expert; my $min_linux = 300 << 11; $min_linux /= 3 if $::expert; my $min_freewin = 100 << 11; $min_freewin /= 10 if $::expert; my $swap = { type => 0x82, loopback_file => '/lnx4win/swapfile', mntpoint => 'swap', size => 64 << 11, device => $real_part, notFormatted => 1 }; my $root = { type => 0x83, loopback_file => '/lnx4win/linuxsys.img', mntpoint => '/', size => 0, device => $real_part, notFormatted => 1 }; $root->{size} = min($size - $swap->{size} - $min_freewin, $max_linux); log::l("lnx4win $root->{size} <= $min_linux (minlinux), $size (minavail) - $swap->{size} (swapsize) - $min_freewin (minfreewin), $max_linux (maxlinux)"); $root->{size} > $min_linux or die "not enough room on that partition for lnx4win"; $o->doPartitionDisksLnx4winSize(\$root->{size}, \$swap->{size}, $size - 2 * $swap->{size}, 2 * $swap->{size}); unlink "$handle->{dir}$_" foreach "/lnx4win/swapfile", "/lnx4win/linuxsys.img"; push @{$real_part->{loopback}}, $root, $swap; } else { unless ($::testing) { partition_table::write($_) foreach @$hds; } } } sub doPartitionDisksLnx4winDev {} sub doPartitionDisksLnx4winSize {} #------------------------------------------------------------------------------ sub ask_mntpoint_s { my ($o, $fstab) = @_; #- TODO: set the mntpoints #- assure type is at least ext2 (fsedit::get_root($fstab) || {})->{type} = 0x83; my %m; foreach (@$fstab) { my $m = $_->{mntpoint}; next unless $m && $m ne 'swap'; #- there may be a lot of swap. $m{$m} and die _("Duplicate mount point %s", $m); $m{$m} = 1; #- in case the type does not correspond, force it to ext2 $_->{type} = 0x83 if $m =~ m|^/| && !isFat($_); } } 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 (!$_->{toFormat}) { my $t = isLoopback($_) ? eval { fsedit::typeOfPart($o->{prefix} . loopback::file($_)) } : fsedit::typeOfPart($_->{device}); $_->{toFormatUnsure} = $_->{mntpoint} eq "/" || #- if detected dos/win, it's not precise enough to just compare the types (too many of them) (isFat({ type => $t }) ? !isFat($_) : $t != $_->{type}); } } } sub formatMountPartitions { my ($o) = @_; fs::formatMount_all($o->{raid}, $o->{fstab}, $o->{prefix}); } #------------------------------------------------------------------------------ sub setPackages { my ($o) = @_; install_any::setPackages($o); } sub selectPackagesToUpgrade { my ($o) = @_; install_any::selectPackagesToUpgrade($o); } sub choosePackages { my ($o, $packages, $compss, $compssUsers, $compssUsersSorted, $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("available size $available (corrected $availableCorrected)"); foreach (values %{$packages->[0]}) { pkgs::packageSetFlagSkip($_, 0); pkgs::packageSetFlagUnskip($_, 0); } pkgs::unselectAllPackages($packages); pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, $_) || next) foreach @{$o->{default_packages}}; add2hash_($o, { compssListLevel => $::expert ? 90 : 80 }) unless $::auto_install; pkgs::setSelectedFromCompssList($o->{compssListLevels}, $packages, $o->{compssListLevel}, $availableCorrected, $o->{installClass}) if exists $o->{compssListLevel}; $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 { commands::cp("$o->{prefix}/$_", "$o->{prefix}/$_.mdkgisave") }; } } } #- some packages need such files for proper installation. install_any::write_ldsoconf($o->{prefix}); fs::write($o->{prefix}, $o->{fstab}, $o->{manualFstab}, $o->{useSupermount}); network::add2hosts("$o->{prefix}/etc/hosts", "localhost.localdomain", "127.0.0.1"); require pkgs; pkgs::init_db($o->{prefix}, $o->{isUpgrade}); } sub pkg_install { my ($o, @l) = @_; require pkgs; pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, $_) || die "$_ rpm not found") foreach @l; $o->installPackages; } sub installPackages($$) { #- complete REWORK, TODO and TOCHECK! my ($o) = @_; my $packages = $o->{packages}; if (@{$o->{toRemove} || []}) { #- hack to ensure proper upgrade of packages from other distribution, #- as release number are not mandrake based. this causes save of #- important files and restore them after. foreach (@{$o->{toSave} || []}) { if (-e "$o->{prefix}/$_") { unlink "$o->{prefix}/$_.mdkgisave"; eval { commands::cp("$o->{prefix}/$_", "$o->{prefix}/$_.mdkgisave") }; } } pkgs::remove($o->{prefix}, $o->{toRemove}); foreach (@{$o->{toSave} || []}) { if (-e "$o->{prefix}/$_.mdkgisave") { unlink "$o->{prefix}/$_"; rename "$o->{prefix}/$_.mdkgisave", "$o->{prefix}/$_"; } } $o->{toSave} = []; #- hack for compat-glibc to upgrade properly :-( if (pkgs::packageFlagSelected(pkgs::packageByName($packages, 'compat-glibc')) && !pkgs::packageFlagInstalled(pkgs::packageByName($packages, 'compat-glibc'))) { rename "$o->{prefix}/usr/i386-glibc20-linux", "$o->{prefix}/usr/i386-glibc20-linux.mdkgisave"; } } #- small transaction will be built based on this selection and depslist. my @toInstall = pkgs::packagesToInstall($packages); $ENV{DURING_INSTALL} = 1; pkgs::install($o->{prefix}, $o->{isUpgrade}, \@toInstall, $packages->[1], $packages->[2]); delete $ENV{DURING_INSTALL}; } sub afterInstallPackages($) { my ($o) = @_; return if $::g_auto_install; die _("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 grep { m|read failed: Input/output error| } cat_("$o->{prefix}/root/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"; } pkgs::done_db(); #- why not? cuz weather is nice today :-) [pixel] sync(); sync(); #- call ldconfig at the end of package installation run_program::rooted($o->{prefix}, "ldconfig"); #- configure PCMCIA services if needed. $o->pcmciaConfig(); #- for mandrake_firstime output "$o->{prefix}/var/lock/TMP_1ST", ""; #- remove the nasty acon... run_program::rooted($o->{prefix}, "chkconfig", "--del", "acon") unless $ENV{LANGUAGE} =~ /ar/; #- make the mdk fonts last in available fonts for buggy kde run_program::rooted($o->{prefix}, "chkfontpath", "--remove", "/usr/X11R6/lib/X11/fonts/mdk"); run_program::rooted($o->{prefix}, "chkfontpath", "--add", "/usr/X11R6/lib/X11/fonts/mdk"); #- call update-menus at the end of package installation run_program::rooted($o->{prefix}, "update-menus"); #- mainly for auto_install's run_program::rooted($o->{prefix}, "sh", "-c", $o->{postInstall}) if $o->{postInstall}; #- create /etc/sysconfig/desktop file according to user choice and presence of /usr/bin/kdm or /usr/bin/gdm. my $f = "$o->{prefix}/etc/sysconfig/desktop"; if ($o->{compssUsersChoice}{KDE} && -x "$o->{prefix}/usr/bin/kdm") { output($f, "KDE\n"); } elsif ($o->{compssUsersChoice}{Gnome} && -x "$o->{prefix}/usr/bin/gdm") { output($f, "GNOME\n"); } if ($o->{pcmcia}) { substInFile { s/.*(TaskBarShowAPMStatus).*/$1=1/ } "$o->{prefix}/usr/lib/X11/icewm/preferences"; eval { commands::cp("$o->{prefix}/usr/share/applnk/System/kapm.kdelnk", "$o->{prefix}/etc/skel/Desktop/Autostart/kapm.kdelnk") }; } my $msec = "$o->{prefix}/etc/security/msec"; substInFile { s/^audio\n//; $_ .= "audio\n" if eof } "$msec/group.conf" if -d $msec; substInFile { s/^cdrom\n//; $_ .= "cdrom\n" if eof } "$msec/group.conf" if -d $msec; substInFile { s/^xgrp\n//; $_ .= "xgrp\n" if eof } "$msec/group.conf" if -d $msec; my $pkg = pkgs::packageByName($o->{packages}, 'urpmi'); if ($pkg && pkgs::packageFlagSelected($pkg)) { install_any::install_urpmi($o->{prefix}, $o->{method}, $o->{packages}[2]); substInFile { s/^urpmi\n//; $_ .= "urpmi\n" if eof } "$msec/group.conf" if -d $msec; } #- update language and icons for KDE. log::l("updating language for kde"); install_any::kdelang_postinstall($o->{prefix}); log::l("updating kde icons according to available devices"); install_any::kdeicons_postinstall($o->{prefix}); my $welcome = _("Welcome to %s", "[HOSTNAME]"); substInFile { s/^(GreetString)=.*/$1=$welcome/ } "$o->{prefix}/usr/share/config/kdmrc"; substInFile { s/^(UserView)=false/$1=true/ } "$o->{prefix}/usr/share/config/kdmrc" if $o->{security} < 3; run_program::rooted($o->{prefix}, "kdeDesktopCleanup"); #- konsole and gnome-terminal are lamers in exotic languages, link them to something better if ($o->{lang} =~ /ja|ko|zh/) { foreach ("konsole", "gnome-terminal") { my $f = "$o->{prefix}/usr/bin/$_"; symlinkf("X11/rxvt.sh", $f) if -e $f; } } #- my $hasttf; #- my $dest = "/usr/X11R6/lib/X11/fonts/drakfont"; #- foreach my $d (map { $_->{mntpoint} } grep { isFat($_) } @{$o->{fstab}}) { #- foreach my $D (map { "$d/$_" } grep { m|^win|i } all("$o->{prefix}$d")) { #- $D .= "/fonts"; #- -d "$o->{prefix}$D" or next; #- log::l("found win font dir $D"); #- if (!$hasttf) { #- $hasttf = $o->ask_okcancel('', #-_("Some true type fonts from windows have been found on your computer. #-Do you want to use them? Be sure you have the right to use them under Linux."), 1) or goto nottf; #- mkdir "$o->{prefix}$dest", 0755; #- } #- /(.*)\.ttf/i and symlink "$D/$_", "$o->{prefix}$dest/$1.ttf" foreach grep { /\.ttf/i } all("$o->{prefix}$D"); #- } #- } #- nottf: #- if ($hasttf) { #- run_program::rooted($o->{prefix}, "ttmkfdir", "-d", $dest, "-o", "$dest/fonts.dir"); #- run_program::rooted($o->{prefix}, "chkfontpath", "--add", $dest); #- } foreach (install_any::list_skels()) { my $found; substInFile { $found ||= /KFM Misc Defaults/; $_ .= "[KFM Misc Defaults] GridWidth=85 GridHeight=70 " if eof && !$found; } "$o->{prefix}$_/.kde/share/config/kfmrc" } #- move some file after an upgrade that may be seriously annoying. #- and rename saved files to .mdkgiorig. if ($o->{isUpgrade}) { log::l("moving previous desktop files that have been updated to Trash of each user"); install_any::move_desktop_file($o->{prefix}); foreach (@filesToSaveForUpgrade) { if (-e "$o->{prefix}$_.mdkgisave") { unlink "$o->{prefix}$_.mdkgiorig"; rename "$o->{prefix}/$_.mdkgisave", "$o->{prefix}/$_.mdkgiorig"; } } } } #------------------------------------------------------------------------------ sub selectMouse($) { my ($o) = @_; } #------------------------------------------------------------------------------ sub configureNetwork($) { my ($o) = @_; my $etc = "$o->{prefix}/etc"; network::write_conf("$etc/sysconfig/network", $o->{netc}); network::write_resolv_conf("$etc/resolv.conf", $o->{netc}); network::write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_->{DEVICE}", $_) foreach @{$o->{intf}}; network::add2hosts("$etc/hosts", $o->{netc}{HOSTNAME}, map { $_->{IPADDR} } @{$o->{intf}}); network::sethostname($o->{netc}) unless $::testing; network::addDefaultRoute($o->{netc}) unless $::testing; $o->pkg_install("dhcpcd") if grep { $_->{BOOTPROTO} =~ /^(dhcp)$/ } @{$o->{intf}}; # Handle also pump (this is still in initscripts no?) $o->pkg_install("pump") if grep { $_->{BOOTPROTO} =~ /^(pump|bootp)$/ } @{$o->{intf}}; #-res_init(); #- reinit the resolver so DNS changes take affect miscellaneousNetwork($o); } #------------------------------------------------------------------------------ sub pppConfig { my ($o) = @_; $o->{modem} or return; symlinkf($o->{modem}{device}, "$o->{prefix}/dev/modem") or log::l("creation of $o->{prefix}/dev/modem failed"); $o->pkg_install("ppp") unless $::testing; my %toreplace; $toreplace{$_} = $o->{modem}{$_} foreach qw(connection phone login passwd auth domain dns1 dns2); $toreplace{kpppauth} = ${{ 'Script-based' => 0, 'PAP' => 1, 'Terminal-based' => 2, 'CHAP' => 3, }}{$o->{modem}{auth}}; $toreplace{phone} =~ s/\D//g; $toreplace{dnsserver} = join ',', map { $o->{modem}{$_} } "dns1", "dns2"; $toreplace{dnsserver} .= $toreplace{dnsserver} && ','; #- using peerdns or dns1,dns2 avoid writing a /etc/resolv.conf file. $toreplace{peerdns} = "yes"; $toreplace{connection} ||= 'DialupConnection'; $toreplace{domain} ||= 'localdomain'; $toreplace{intf} ||= 'ppp0'; $toreplace{papname} = $o->{modem}{auth} eq 'PAP' && $toreplace{login}; #- build ifcfg-ppp0. my $ifcfg = "$o->{prefix}/etc/sysconfig/network-scripts/ifcfg-ppp0"; local *IFCFG; open IFCFG, ">$ifcfg" or die "Can't open $ifcfg"; print IFCFG <<END; DEVICE="$toreplace{intf}" ONBOOT="no" USERCTL="no" MODEMPORT="/dev/modem" LINESPEED="115200" PERSIST="yes" DEFABORT="yes" DEBUG="yes" INITSTRING="ATZ" DEFROUTE="yes" HARDFLOWCTL="yes" ESCAPECHARS="no" PPPOPTIONS="" PAPNAME="$toreplace{papname}" REMIP="" NETMASK="" IPADDR="" MRU="" MTU="" DISCONNECTTIMEOUT="5" RETRYTIMEOUT="60" BOOTPROTO="none" PEERDNS="$toreplace{peerdns}" END foreach (1..2) { if ($toreplace{"dns$_"}) { print IFCFG <<END; DNS$_=$toreplace{"dns$_"} END } } close IFCFG; #- build chat-ppp0. my $chat = "$o->{prefix}/etc/sysconfig/network-scripts/chat-ppp0"; local *CHAT; open CHAT, ">$chat" or die "Can't open $chat"; print CHAT <<END; 'ABORT' 'BUSY' 'ABORT' 'ERROR' 'ABORT' 'NO CARRIER' 'ABORT' 'NO DIALTONE' 'ABORT' 'Invalid Login' 'ABORT' 'Login incorrect' '' 'ATZ' 'OK' 'ATDT$toreplace{phone}' 'CONNECT' '' END if ($o->{modem}{auth} eq 'Terminal-based' || $o->{modem}{auth} eq 'Script-based') { print CHAT <<END; 'ogin:' '$toreplace{login}' 'ord:' '$toreplace{passwd}' END } print CHAT <<END; 'TIMEOUT' '5' '~--' '' END close CHAT; if ($o->{modem}{auth} eq 'PAP') { #- need to create a secrets file for the connection. my $secrets = "$o->{prefix}/etc/ppp/" . lc($o->{modem}{auth}) . "-secrets"; my @l = cat_($secrets); my $replaced = 0; do { $replaced ||= 1 if s/^\s*"?$toreplace{login}"?\s+ppp0\s+(\S+)/"$toreplace{login}" ppp0 "$toreplace{passwd}"/; } foreach @l; if ($replaced) { local *F; open F, ">$secrets" or die "Can't open $secrets: $!"; print F @l; } else { local *F; open F, ">>$secrets" or die "Can't open $secrets: $!"; print F "$toreplace{login} ppp0 \"$toreplace{passwd}\"\n"; } #- restore access right to secrets file, just in case. chmod 0600, $secrets; } #- CHAP is not supported by initscripts, need patching before doing more on that here! #-install_any::template2userfile($o->{prefix}, "$ENV{SHARE_PATH}/kppprc.in", ".kde/share/config/kppprc", 1, %toreplace); commands::mkdir_("-p", "$o->{prefix}/usr/share/config"); template2file("$ENV{SHARE_PATH}/kppprc.in", "$o->{prefix}/usr/share/config/kppprc", %toreplace); miscellaneousNetwork($o); } #------------------------------------------------------------------------------ sub installCrypto { my ($o) = @_; my $u = $o->{crypto} or return; $u->{mirror} && $u->{packages} or return; $o->upNetwork; require crypto; my @crypto_packages = crypto::getPackages($o->{prefix}, $o->{packages}, $u->{mirror}); my $oldGetFile = \&install_any::getFile; local *install_any::getFile = sub { my ($rpmfile) = @_; if ($rpmfile =~ /^(.*)-[^-]*-[^-]*$/ && member($1, @crypto_packages)) { log::l("crypto::getFile $rpmfile"); crypto::getFile($rpmfile, $u->{mirror}); } else { #- use previous getFile typically if non cryptographic packages #- have been selected by dependancies. log::l("normal getFile $rpmfile"); &$oldGetFile($rpmfile); } }; $o->pkg_install(@{$u->{packages}}); } #------------------------------------------------------------------------------ sub pcmciaConfig($) { my ($o) = @_; my $t = $o->{pcmcia}; #- should be set after installing the package above else the file will be renamed. setVarsInSh("$o->{prefix}/etc/sysconfig/pcmcia", { PCMCIA => $t ? "yes" : "no", PCIC => $t, PCIC_OPTS => "", CORE_OPTS => "", }); } #------------------------------------------------------------------------------ sub timeConfig { my ($o, $f) = @_; require timezone; timezone::write($o->{prefix}, $o->{timezone}, $f); } #------------------------------------------------------------------------------ sub servicesConfig {} #------------------------------------------------------------------------------ sub printerConfig { my($o) = @_; if ($o->{printer}{configured}) { require pkgs; pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, 'rhs-printfilters')); $o->installPackages($o->{packages}); require printer; foreach (keys %{$o->{printer}{configured} || {}}) { log::l("configuring printer queue $_->{queue}"); printer::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::configure_queue($o->{printer}); } } } #------------------------------------------------------------------------------ my @etc_pass_fields = qw(name pw uid gid realname home shell); sub setRootPassword($) { my ($o) = @_; my $p = $o->{prefix}; my $u = $o->{superuser} ||= {}; $u->{pw} ||= $u->{password} && install_any::crypt($u->{password}); my @lines = cat_(my $f = "$p/etc/passwd") or log::l("missing passwd file"), return; local *F; open F, "> $f" or die "failed to write file $f: $!\n"; foreach (@lines) { if (/^root:/) { chomp; my %l; @l{@etc_pass_fields} = split ':'; add2hash($u, \%l); $_ = join(':', @$u{@etc_pass_fields}) . "\n"; } print F $_; } } #------------------------------------------------------------------------------ sub addUser($) { my ($o) = @_; my $p = $o->{prefix}; my (%uids, %gids); foreach (glob_("$p/home")) { my ($u, $g) = (stat($_))[4,5]; $uids{$u} = 1; $gids{$g} = 1; } my %done; my @l = grep { if (!$_->{name} || getpwnam($_->{name}) || $done{$_->{name}}) { 0; } else { $_->{home} ||= "/home/$_->{name}"; my $u = $_->{uid} || ($_->{oldu} = (stat("$p$_->{home}"))[4]); my $g = $_->{gid} || ($_->{oldg} = (stat("$p$_->{home}"))[5]); #- 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 || getgrgid($g)) { for ($g = 501; getgrgid($g) || $gids{$g}; $g++) {} } $_->{uid} = $u; $uids{$u} = 1; $_->{gid} = $g; $gids{$g} = 1; $_->{pw} ||= $_->{password} && install_any::crypt($_->{password}); $_->{shell} ||= "/bin/bash"; $done{$_->{name}} = 1; } } @{$o->{users} || []}; my @passwd = cat_("$p/etc/passwd");; local *F; open F, ">> $p/etc/passwd" or die "can't append to passwd file: $!"; print F join(':', @$_{@etc_pass_fields}), "\n" foreach @l; open F, ">> $p/etc/group" or die "can't append to group file: $!"; print F "$_->{name}:x:$_->{gid}:\n" foreach @l; foreach my $u (@l) { if (! -d "$p$u->{home}") { my $mode = $o->{security} < 2 ? 0755 : 0750; eval { commands::cp("-f", "$p/etc/skel", "$p$u->{home}") }; if ($@) { log::l("copying of skel failed: $@"); mkdir("$p$u->{home}", $mode); } else { chmod $mode, "$p$u->{home}"; } } eval { commands::chown_("-r", "$u->{uid}.$u->{gid}", "$p$u->{home}") } if $u->{uid} != $u->{oldu} || $u->{gid} != $u->{oldg}; } require any;