summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/harddrake2
blob: 9afdcf78a0cd9a9c6585b58477dbf7d77818b2e3 (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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
#!/usr/bin/perl

use strict;
use diagnostics;
use lib qw(/usr/lib/libDrakX);
use standalone;
use common;

use ugtk2 qw(:create :helpers :wrappers);
use interactive;
use harddrake::data;  #- needs to stay after use-ugtk2 as long as this module defines globals containing some N()
use POSIX qw(:sys_wait_h);


# { field => [ short_translation, full_description] }
my %fields = 
    (
     "alternative_drivers" => [ N("Alternative drivers"),
                                N("the list of alternative drivers for this sound card") ],
     "bus" => 
     [ N("Bus"), 
       N("this is the physical bus on which the device is plugged (eg: PCI, USB, ...)") ],
     "channel" => [ N("Channel"), N("EIDE/SCSI channel") ],
     "bogomips" => [ N("Bogomips"), N("the GNU/Linux kernel needs to run a calculation loop at boot time to initialize a timer counter.  Its result is stored as bogomips as a way to \"benchmark\" the cpu.") ],
     "bus_id" => 
     [ N("Bus identification"), 
       N("- PCI and USB devices: this lists the vendor, device, subvendor and subdevice PCI/USB ids") ],
     "bus_location" => 
     [ N("Location on the bus"), 
       N("- pci devices: this gives the PCI slot, device and function of this card
- eide devices: the device is either a slave or a master device
- scsi devices: the scsi bus and the scsi device ids") ],
     "cache size" => [ N("Cache size"), N("size of the (second level) cpu cache") ],
     "capacity" => [ N("Drive capacity"), N("special capacities of the driver (burning ability and or DVD support)") ],
#-PO Translators, here "comas" is the medical coma, not the lexical coma!!
     "coma_bug" => [ N("Coma bug"), N("whether this cpu has the Cyrix 6x86 Coma bug") ],
     "cpu family" => [ N("Cpuid family"), N("family of the cpu (eg: 6 for i686 class)") ],
     "cpuid level" => [ N("Cpuid level"), N("information level that can be obtained through the cpuid instruction") ],
     "cpu MHz" => [ N("Frequency (MHz)"), N("the CPU frequency in MHz (Megahertz which in first approximation may be coarsely assimilated to number of instructions the cpu is able to execute per second)") ],
     "description" => [ N("Description"), N("this field describes the device") ],
     "device" => [ N("Old device file"),
                   N("old static device name used in dev package") ],
     "devfs_device" => [ N("New devfs device"),  
                         N("new dynamic device name generated by core kernel devfs") ],
#-PO Translators, here "module" is the "jargon term" for a kernel driver
     "driver" => [ N("Module"), N("the module of the GNU/Linux kernel that handles the device") ],
     "flags" => [ N("Flags"), N("CPU flags reported by the kernel") ],
     "fdiv_bug" => [ N("Fdiv bug"), 
                     N("Early Intel Pentium chips manufactured have a bug in their floating point processor which did not achieve the required precision when performing a Floating point DIVision (FDIV)") ],
     "fpu" => [ N("Is FPU present"), N("yes means the processor has an arithmetic coprocessor") ],
     "fpu_exception" => [ N("Whether the FPU has an irq vector"), N("yes means the arithmetic coprocessor has an exception vector attached") ],
     "f00f_bug" => [N("F00f bug"), N("early pentiums were buggy and freezed when decoding the F00F bytecode")],
     "hlt_bug" => [ N("Halt bug"), 
                    N("Some of the early i486DX-100 chips cannot reliably return to operating mode after the \"halt\" instruction is used") ],

     "info" => [N("Floppy format"), N("format of floppies supported by the drive")],
     "level" => [N("Level"), N("sub generation of the cpu")],
     "media_type" => [ N("Media class"), N("class of hardware device") ],
     "Model" => [N("Model"), N("hard disk model")],
     "model" => [N("Model"), N("generation of the cpu (eg: 8 for PentiumIII, ...)")],
     "model name" => [N("Model name"), N("official vendor name of the cpu")],
     "nbuttons" => [ N("Number of buttons"), N("the number of buttons the mouse has") ],
     "name" => [ N("Name"), N("the name of the CPU") ],
     "port" => [N("Port"), N("network printer port")],
     "processor" => [ N("Processor ID"), N("the number of the processor") ],
     "stepping" => [ N("Model stepping"), N("stepping of the cpu (sub model (generation) number)") ],
     "type" => [ N("Type"), N("the type of bus on which the mouse is connected") ],
     "Vendor" => [ N("Vendor"), N("the vendor name of the device") ],
     "vendor_id" => [ N("Vendor"), N("the vendor name of the processor") ],
     "wp" => [ N("Write protection"), N("the WP flag in the CR0 register of the cpu enforce write proctection at the memory page level, thus enabling the processor to prevent unchecked kernel accesses to user memory (aka this is a bug guard)") ],
     );


my ($in, $pid, $w);

my (%options, %check_boxes);
my $conffile = "/etc/sysconfig/harddrake2/ui.conf";

my ($current_device, $current_configurator);


#-PO Translators, please keep all "/" charaters !!!
my %menus = (
             'options' => N("/_Options"),
             'help' => N("/_Help")
             );

my %menu_options = (
                    'PRINTERS_DETECTION' => [ $menus{options}, N("/Autodetect _printers") ],
                    'MODEMS_DETECTION' => [ $menus{options}, N("/Autodetect _modems") ],
                    'JAZZ_DETECTION' => [ $menus{options}, N("/Autodetect _jaz drives") ],
                    );


my @menu_items = 
    (
     [ N("/_File"), undef, undef, undef, '<Branch>' ],
     [ N("/_File").N("/_Quit"), N("<control>Q"), \&quit_global, undef, '<StockItem>', 'gtk-quit' ],
     [ join('', @{$menu_options{PRINTERS_DETECTION}}), undef, 
       sub { $options{PRINTERS_DETECTION} = $check_boxes{PRINTERS_DETECTION}->get_active }, undef, '<CheckItem>' ],
     [ join('', @{$menu_options{MODEMS_DETECTION}}), undef,
       sub { $options{MODEMS_DETECTION} = $check_boxes{MODEMS_DETECTION}->get_active }, undef, '<CheckItem>' ],
     [ join('', @{$menu_options{JAZZ_DETECTION}}), undef,
       sub { $options{JAZZ_DETECTION} = $check_boxes{JAZZ_DETECTION}->get_active }, undef, '<CheckItem>' ],
     [ $menus{help}, undef, undef, undef, '<Branch>' ],
     [ $menus{help}.N("/_Help"), undef, sub { unless (fork()) { exec("drakhelp --id harddrake") } }, undef, '<Item>' ],
     [ $menus{help}.N("/_Fields description"), undef, sub {
           if ($current_device) {
               create_dialog(N("Harddrake help"), 
                             N("Description of the fields:\n\n")
#-PO Do not alter the <span ..> and </span> tags
                             . join("\n\n", map { if_($fields{$_}[0], formatAlaTeX(qq(<span foreground="royalblue3">$fields{$_}[0]:</span> $fields{$_}[1]))) } sort keys %$current_device), { use_markup => 1, if_(!$::isEmbedded, transient => $w->{window}), height => 400, scroll => 1 })

           } else {
               create_dialog(N("Select a device !"), N("Once you've selected a device, you'll be able to see the device information in fields displayed on the right frame (\"Information\")"), { if_(!$::isEmbedded, transient => $w->{window}) })
           }
       },
       undef, '<Item>'
     ],
     [ $menus{help}.N("/_Report Bug"), undef, sub { unless (fork()) { exec("drakbug --report harddrake2 &") } }, undef, '<Item>' ],
     [ $menus{help}.N("/_About..."), undef, sub {
           create_dialog(N("About Harddrake"), 
#-PO Do not alter the <span ..> and </span> tags
                         N("This is HardDrake, a Mandrake hardware configuration tool.\n<span foreground=\"royalblue3\">Version:</span> %s
<span foreground=\"royalblue3\">Author:</span> Thierry Vignaud &lt;tvignaud\@mandrakesoft.com&gt;\n\n", $harddrake::data::version) . "\n" .
                         formatAlaTeX($::license), { use_markup => 1, if_(!$::isEmbedded, transient => $w->{window}) });
       }, undef, '<Item>'
     ]
    );

$ugtk2::wm_icon = "harddrake";
$in = 'interactive'->vnew('su'); #require_root_capability();

my $wait = $in->wait_message(N("Please wait"), N("Detection in progress"));
gtkflush();

%options = getVarsFromSh($conffile);

# Build the gui
add_icon_path('/usr/share/pixmaps/harddrake2/');
$w = ugtk2->new(N("Harddrake2 version %s", $harddrake::data::version));
local $::main_window;   # fake diagnostics pragma
my ($menubar, $factory, $opt_menu, $help_menu);
if ($::isEmbedded) {
    ($menubar, $factory) = create_factory_popup_menu($::Plug, @menu_items);
    $opt_menu = $factory->get_widget("<main>" . strip_first_underscore($menus{options}));
    $help_menu = $factory->get_widget("<main>" . strip_first_underscore($menus{help}));
} else {
    $::main_window = $w->{rwindow};
    ($menubar, $factory) = create_factory_menu($w->{rwindow}, @menu_items);
    $w->{window}->set_size_request(805, 550);
}

my $tree_model = Gtk2::TreeStore->new("Gtk2::Gdk::Pixbuf", "Glib::String", "Glib::Int");
$w->{window}->add(gtkpack_(0, Gtk2::VBox->new(0, 0),
                           if_(!$::isEmbedded, 0, $menubar),
                           1, create_hpaned(gtkadd(Gtk2::Frame->new(N("Detected hardware")), 
                                                   create_scrolled_window(gtkset_size_request(my $tree = Gtk2::TreeView->new_with_model($tree_model), $::isEmbedded ? 250 : 350, -1), ['automatic', 'automatic'])),
                                            gtkpack_(0, Gtk2::VBox->new(0, 0),
                                                     1, gtkadd(my $frame = Gtk2::Frame->new(N("Information")),
                                                               create_scrolled_window(my $text = Gtk2::TextView->new)),
                                                     0, my $module_cfg_button = gtksignal_connect(Gtk2::Button->new(N("Configure module")),
                                                                                                  clicked => sub {
                                                                                                      local $SIG{CHLD} = undef;
                                                                                                      require modules::interactive;
                                                                                                      modules::interactive::config_window($in, $current_device);
                                                                                                      gtkset_mousecursor_normal();
                                                                                                  }),
                                                     0, my $config_button = gtksignal_connect(Gtk2::Button->new(N("Run config tool")),
                                                                                              # we've a configurator, let's add a button for it and show it
                                                                                              clicked => sub {
                                                                                                  return 1 if defined $pid;
                                                                                                  if ($pid = fork()) {
                                                                                                  } else {
                                                                                                      exec($current_configurator) or die "$current_configurator missing\n";
                                                                                                  }
                                                                                              })
                                                     ),
                                            ),
                           if_($::isEmbedded, 
                               0, 
                               gtkpack(Gtk2::HBox->new,
                                       gtkpack(create_hbox('start'),
                                               gtksignal_connect(Gtk2::Button->new(N("Help")), event => popup_menu($help_menu), $menubar),
                                               gtksignal_connect(Gtk2::Button->new(N("Options")), event => popup_menu($opt_menu), $menubar),
                                              ),
                                       gtkpack(create_hbox('end'),
                                               gtksignal_connect(Gtk2::Button->new(N("Quit")), clicked => \&quit_global),
                                              ),
                                      ),
                              )
                          )
                 );

$text->set_wrap_mode('word');
$frame->set_size_request(300, 450) unless $::isEmbedded;
#    $tree->set_column_auto_resize(0, 1);
my (@data, @configurators);
$tree->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererPixbuf->new, 'pixbuf' => 0));
$tree->append_column(my $textcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 1));
$tree->set_headers_visible(0);
$tree->get_selection->signal_connect('changed' => sub {
    my ($select) = @_;
    my ($model, $iter) = $select->get_selected;
    if ($model) {
        my $idx = $model->get($iter, 2);
        $current_device = $data[$idx];
        
        if ($idx ne -1) {
            use Gtk2::Pango;
            gtktext_insert($text, [ map  {
                # The U+200E character is to force LTR display, as what what follows the colon is always in LTR (device names, paths, etc),
                # this ensures proper displaying of names like /dev/fd0 (otherwise it gets 'dev/fd0/').
                # it must come *after* the space, as the space must follow the colon following the direction of writting.
                if_($_ && $fields{$_}[0], [ $fields{$_}[0] . ": \x{200e}", { 'foreground' => 'royalblue3', 'weight' => Gtk2::Pango->PANGO_WEIGHT_BOLD } ],
                    [ ($current_device->{$_} =~ /^(unknown)/ ? N("unknown") :
                       $current_device->{$_} =~ /^(Unknown)/ ? N("Unknown") : 
                       $current_device->{$_} eq 'yes' ? N("Yes") : 
                       $current_device->{$_} eq 'no'  ? N("No") : 
                       $current_device->{$_}) . "\n\n", if_($_ eq 'driver' && $current_device->{$_} =~ /^unknown|^Bad:/, { foreground => 'indian red' }) ])
                } sort keys %$current_device ]);

            foreach (keys %$current_device) {
                print qq(Warning: skip "$_" field => "$current_device->{$_}"\n\n) unless $fields{$_}[0];
            };
            
            # if we've valid driver, let's offer to configure it, else hide buttons 
            show_hide(defined($current_device->{driver}) && $current_device->{driver} !~ /^unknown|^Bad|^Card|^Hsf|^Removable:|\|/, $module_cfg_button);
            
            $current_configurator = $configurators[$idx];
            show_hide(-x first(split /\s+/, $current_configurator), $config_button);  # strip arguments for -x test
            return 1;
        }
    }
    $text->get_buffer->set_text(N("Click on a device in the left tree in order to display its information here."));
    undef $current_device;
    $config_button->hide;
    $module_cfg_button->hide;
});

my $index = 0;

my @classes;

# Fill the graphic devices tree with a "tree branch" widget per device category
foreach my $hw_class (@harddrake::data::tree) {
    my ($Ident, $title, $icon, $configurator, $detector) = @$hw_class{qw(class string icon configurator detector)};
    next if ref($detector) ne "CODE"; #skip class witouth detector
    # blacklist agp controllers b/c string is not yet translated:
    next if $Ident eq 'AGP';
    next if $Ident =~ /(MODEM|PRINTER)/ && $::testing;
    next if $Ident =~ /JAZZ/ && !$options{JAZZ_DETECTION};
    next if $Ident =~ /MODEM/ && !$options{MODEMS_DETECTION};
    next if $Ident =~ /PRINTER/ && !$options{PRINTERS_DETECTION};

    my @devices = &$detector;
    next unless @devices; # Skip empty class (no devices)
    push @classes, [ $Ident, $title, $icon, $configurator, @devices ];
}

# Fill the graphic devices tree with a "tree branch" widget per device category
foreach (@classes) {
    my ($Ident, $title, $icon, $configurator, @devices) = @$_;

    my $parent_iter = $tree_model->append_set(undef, [ 0 => gtkcreate_pixbuf($icon), 1 => $title, 2 => -1 ]);

    # Fill the graphic tree with a "tree leaf" widget per device
    foreach (@devices) {
        # we really should test for $title there:
        if ($_->{bus} && $_->{bus} eq "PCI") {
            my $i = $_;
            $_->{bus_id} = join ':', map { if_($i->{$_} ne "65535",  sprintf("%lx", $i->{$_})) } qw(vendor id subvendor subid);
            $_->{bus_location} = join ':', map { sprintf("%lx", $i->{$_}) } qw(pci_bus pci_device pci_function);
            # do not display unknown driver for system bridges that're managed by kernel core:
            delete $_->{driver} if $_->{driver} eq "unknown" && ($Ident =~ /^ATA_STORAGE|BRIDGE|SMB_CONTROLLER$/ || $_->{description} =~ /3Com.*5610/);
        }
        # split description into manufacturer/description
        ($_->{Vendor}, $_->{description}) = split(/\|/, $_->{description}) if $_->{description};

        if ($_->{val}) { # Scanner ?
            my $val = $_->{val};
            ($_->{Vendor}, $_->{description}) = split(/\|/, $val->{DESCRIPTION});
        }
        # EIDE detection incoherency:
        if ($_->{bus} && $_->{bus} eq 'ide') {
            $_->{channel} = $_->{channel} ? N("secondary") : N("primary");
            delete $_->{info};
        } elsif ($_->{bus} && $_->{bus} !~ /USB|PCI/) {
            # SCSI detection incoherency:
            my $i = $_;
            $_->{bus_location} = join ':', map { sprintf("%lx", $i->{$_}) } qw(channel id lun);
        }
        if (defined $_->{capacity}) {
            my ($burner, $dvd) = (N("burner"), N("DVD"));
            $_->{capacity} =~ s/burner/$burner/;
            $_->{capacity} =~ s/DVD/$dvd/;
        }
        $configurator .= harddrake::data::set_removable_configurator($Ident, $_);
        if ($Ident eq "AUDIO") {
            require harddrake::sound;
            my $alter = harddrake::sound::get_alternative($_->{driver});
            my $alternative_drivers = join(':', @$alter) if $alter->[0] ne 'unknown';
            $_->{alternative_drivers} = $alternative_drivers if $alternative_drivers;
        }
        rename_field($_, 'usb_description', 'description');
        rename_field($_, 'vendor_name', 'Vendor');
        rename_field($_, 'usb_driver', 'driver');
        rename_field($_, 'usb_media_type', 'media_type');
        foreach my $i (qw(EMULATEWHEEL MOUSETYPE XMOUSETYPE auxmouse devfs_prefix id pci_bus pci_device pci_function subid subvendor unsafe usb_bus usb_pci_bus usb_pci_device usb_vendor val vendor wacom)) { delete $_->{$i} };

        my $custom_id = harddrake::data::custom_id($_, $title);
        foreach my $field (qw(devfs_device device)) {
            $_->{$field} = '/dev/'.$_->{$field} if $_->{$field};
        }
        $tree_model->append_set($parent_iter, [ 1 => $custom_id, 2 => $index++ ]);
        push @data, $_;
        push @configurators, $configurator;
    }
    $tree->expand_row($tree_model->get_path($parent_iter), 1) unless $title eq N("Unknown/Others");
}

$SIG{CHLD} = sub {
    undef $pid;
    # reap zombies
    my $child_pid;
    do { $child_pid = waitpid(-1, POSIX::WNOHANG) } until $child_pid > 0;
};

$w->{rwindow}->signal_connect(delete_event => \&quit_global);
$w->{rwindow}->set_position('center') unless $::isEmbedded;

foreach (keys %menu_options) {
    my $title = strip_first_underscore(@{$menu_options{$_}});
    $options{$_} = 0 unless defined($options{$_}); # force detection by default
    $check_boxes{$_} = $factory->get_widget("<main>" . $title);
    $check_boxes{$_}->set_active($options{$_});    # restore saved values
}

$textcolumn->set_min_width(350);
#$textcolumn->set_minmax_width(400);
$textcolumn->set_sizing('GTK_TREE_VIEW_COLUMN_AUTOSIZE');#GROW_ONLY
#$tree->columns_autosize();
$tree->signal_connect(realize => sub { $tree->get_selection->select_path(Gtk2::TreePath->new_first) });
$w->{rwindow}->show_all;
undef $wait;
gtkset_mousecursor_normal();
$_->hide foreach $module_cfg_button, $config_button; # hide buttons while no device
$w->main;


sub quit_global() {
    kill(15, $pid) if $pid;
    setVarsInSh($conffile, \%options) if !$::testing;
    ugtk2->exit(0);
}

sub show_hide {
    my ($bool, $button) = @_;
    if ($bool) { $button->show } else { $button->hide }
}


sub strip_first_underscore {
    join '', map { s/_//; $_ } @_;
}

sub rename_field {
    my ($dev, $field, $new_field) = @_;
    if ($dev->{$field}) {
        if ($dev->{$new_field}) {
            $dev->{$new_field} .= " ($dev->{$field})";
        } else {
            $dev->{$new_field} = $dev->{$field};
        }
        delete $dev->{$field};
    }
}

sub popup_menu {
    my ($menu) = @_;
    sub { my (undef, $event) = @_;
          if ($event->type eq 'button-press') {
              $menu->popup(undef, undef, undef, undef, $event->button, $event->time);
              # Tell calling code that we have handled this event; the buck stops here.
              return 1;
          }
          # Tell calling code that we have not handled this event; pass it on.
          return 0;
      }
}
n>->{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 { my ($o) = @_; modules::configure_pcmcia($o->{pcmcia}); modules::load_ide(); modules::load_thiskind('scsi|disk'); } #------------------------------------------------------------------------------ sub doPartitionDisksBefore { my ($o) = @_; if (cat_("/proc/mounts") =~ m|/\w+/(\S+)\s+/tmp/hdimage\s+(\S+)| && !$o->{partitioning}{readonly}) { $o->{stage1_hd} = { device => $1, type => $2 }; install_any::getFile("XXX"); #- close still opened filehandle eval { fs::umount("/tmp/hdimage") }; } eval { fs::umount_all($o->{fstab}, $o->{prefix}) } if $o->{fstab} && !$::testing && !$::live; $o->{raid} ||= {}; } #------------------------------------------------------------------------------ sub doPartitionDisksAfter { my ($o) = @_; unless ($::testing) { partition_table::write($_) foreach @{$o->{hds}}; $_->{rebootNeeded} and $o->rebootNeeded foreach @{$o->{hds}}; } $o->{fstab} = [ fsedit::get_fstab(@{$o->{hds}}, $o->{raid}) ]; fsedit::get_root($o->{fstab}) or die "Oops, no root partition"; if (my $s = delete $o->{stage1_hd}) { my ($part) = grep { $_->{device} eq $s->{device} } @{$o->{fstab}}; $part->{isMounted} ? do { rmdir "/tmp/hdimage" ; symlinkf("$o->{prefix}$part->{mntpoint}", "/tmp/hdimage") } : eval { fs::mount($s->{device}, "/tmp/hdimage", $s->{type}); $part->{isMounted} = 1; }; } cat_("/proc/mounts") =~ m|(\S+)\s+/tmp/rhimage nfs| && !grep { $_->{mntpoint} eq "/mnt/nfs" } @{$o->{manualFstab} || []} and push @{$o->{manualFstab}}, { type => "nfs", mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,rsize=8192,wsize=8192" }; } #------------------------------------------------------------------------------ sub doPartitionDisks { my ($o) = @_; install_any::getHds($o); if ($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->{hds}, $o->{prefix})) or die; install_any::use_root_part($o->{fstab}, $p, $o->{prefix}); } elsif ($o->{partitioning}{auto_allocate}) { fsedit::auto_allocate($o->{hds}, $o->{partitions}); } } #------------------------------------------------------------------------------ sub ask_mntpoint_s { my ($o, $fstab) = @_; #- TODO: set the mntpoints 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($_) && !isTrueFS($_); } 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 (!$_->{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) (!$t || isOtherAvailableFS({ type => $t }) ? !isOtherAvailableFS($_) : $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) = @_; pkgs::selectPackagesToUpgrade($o->{packages}, $o->{prefix}, $o->{base}, $o->{toRemove}, $o->{toSave}); } 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); } #- avoid destroying user selection of packages. TOCHECK if ($first_time) { 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) = @_; log::l("before install packages"); #- 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") }; } } } log::l("before install packages, after copy"); #- some packages need such files for proper installation. any::writeandclean_ldsoconf($o->{prefix}); log::l("before install packages, after writing ld.so.conf"); $::live or fs::write($o->{prefix}, $o->{fstab}, $o->{manualFstab}, $o->{useSupermount}); log::l("before install packages, after adding localhost in hosts"); require network; network::add2hosts("$o->{prefix}/etc/hosts", "localhost.localdomain", "127.0.0.1"); log::l("before openning database"); require pkgs; pkgs::init_db($o->{prefix}, $o->{isUpgrade}); log::l("initialized database"); } sub pkg_install { my ($o, @l) = @_; log::l("selecting packages"); require pkgs; 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; foreach (@l) { my %newSelection; my $pkg = pkgs::packageByName($o->{packages}, $_) || die "$_ rpm not found"; pkgs::selectPackage($o->{packages}, $pkg, 0, \%newSelection); scalar(keys %newSelection) == 1 and pkgs::selectPackage($o->{packages}, $pkg); } $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); my $time = time; $ENV{DURING_INSTALL} = 1; pkgs::install($o->{prefix}, $o->{isUpgrade}, \@toInstall, $packages->[1], $packages->[2]); delete $ENV{DURING_INSTALL}; run_program::rooted($o->{prefix}, 'ldconfig') or die "ldconfig failed!"; log::l("Install took: ", formatTimeRaw(time - $time)); } 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(); #- configure PCMCIA services if needed. modules::write_pcmcia($o->{prefix}, $o->{pcmcia}); #- for mandrake_firstime touch "$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"); #- 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") { log::l("setting desktop to KDE"); output($f, "KDE\n"); } elsif ($o->{compssUsersChoice}{Gnome} && -x "$o->{prefix}/usr/bin/gdm") { log::l("setting desktop to GNOME"); 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/^xgrp\n//; $_ .= "xgrp\n" if eof } "$msec/group.conf" if -d $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/^cdwriter\n//; $_ .= "cdwriter\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. update_userkderc($o->{prefix}, 'Locale', Language => ""); 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 (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}) { log::l("moving previous desktop files that have been updated to Trash of each user"); install_any::kdemove_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) = @_; require network; network::configureNetwork2($o->{prefix}, $o->{netc}, $o->{intf}, sub { $o->pkg_install(@_) }); } #------------------------------------------------------------------------------ sub installCrypto { my ($o) = @_; my $u = $o->{crypto} or return; $u->{mirror} && $u->{packages} or return; upNetwork($o); require crypto; my @crypto_packages = crypto::getPackages($o->{prefix}, $o->{packages}, $u->{mirror}); $o->pkg_install(@{$u->{packages}}); } #------------------------------------------------------------------------------ sub configureTimezone { my ($o, $f) = @_; require timezone; timezone::write($o->{prefix}, $o->{timezone}, $f); } #------------------------------------------------------------------------------ sub configureServices { my ($o) = @_; require services; services::doit($o, $o->{services}, $o->{prefix}) if $o->{services}; } #------------------------------------------------------------------------------ sub configurePrinter { my($o) = @_; my ($use_cups, $use_lpr) = (0, 0); foreach (values %{$o->{printer}{configured} || {}}) { for ($_->{mode}) { /cups/ and $use_cups++; /lpr/ and $use_lpr++; } } #- if at least one queue is configured, configure it. if ($use_cups || $use_lpr) { $o->pkg_install(($use_cups ? ('cups-drivers') : ()), ($use_lpr ? ('rhs-printfilters') : ())); require printer; eval { add2hash($o->{printer}, printer::getinfo($o->{prefix})) }; #- get existing configuration. $use_cups and printer::poll_ppd_base(); $use_lpr and printer::read_printer_db(); foreach (keys %{$o->{printer}{configured} || {}}) { log::l("configuring printer queue $_->{queue} for $_->{mode}"); 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} && any::crypt($u->{password}, $o->{authentication}{md5}); 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} && any::crypt($_->{password}, $o->{authentication}{md5}); $_->{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}"; } } require commands; eval { commands::chown_("-r", "$u->{uid}.$u->{gid}", "$p$u->{home}") } if $u->{uid} != $u->{oldu} || $u->{gid} != $u->{oldg}; } require any; any::addUsers($o->{prefix}, @l); } #------------------------------------------------------------------------------ sub createBootdisk($) { my ($o) = @_; my $dev = $o->{mkbootdisk} or return; my @l = detect_devices::floppies(); $dev = shift @l || die _("No floppy drive available") if $dev eq "1"; #- special case meaning autochoose return if $::testing; require bootloader; bootloader::mkbootdisk($o->{prefix}, install_any::kernelVersion($o), $dev, $o->{bootloader}{perImageAppend}); $o->{mkbootdisk} = $dev; } #------------------------------------------------------------------------------ sub readBootloaderConfigBeforeInstall { my ($o) = @_; my ($image, $v); require bootloader; add2hash($o->{bootloader} ||= {}, bootloader::read($o->{prefix}, arch() =~ /sparc/ ? "/etc/silo.conf" : "/etc/lilo.conf")); #- since kernel or kernel-smp may not be upgraded, it should be checked #- if there is a need to update existing lilo.conf entries by following #- symlinks before kernel or other packages get installed. foreach my $e (@{$o->{bootloader}{entries}}) { while (my $v = readlink "$o->{prefix}/$e->{kernel_or_dev}") { $v = "/boot/$v" if $v !~ m|^/|; log::l("testing for presence of file $o->{prefix}$v"); -e "$o->{prefix}$v" or last; log::l("renaming /boot/$e->{kernel_or_dev} entry by $v"); $e->{kernel_or_dev} = $v; } } } sub setupBootloaderBefore { my ($o) = @_; if (arch() =~ /alpha/) { if (my $dev = fsedit::get_root($o->{fstab})) { $o->{bootloader}{boot} ||= "/dev/$dev->{rootDevice}"; $o->{bootloader}{root} ||= "/dev/$dev->{device}"; $o->{bootloader}{part_nb} ||= first($dev->{device} =~ /(\d+)/); } } else { require bootloader; #- propose the default fb mode for kernel fb, if aurora is installed too. bootloader::suggest($o->{prefix}, $o->{bootloader}, $o->{hds}, $o->{fstab}, install_any::kernelVersion($o), pkgs::packageFlagInstalled(pkgs::packageByName($o->{packages}, 'Aurora') || {}) && ($o->{vga} || 785)); if ($o->{miscellaneous}{profiles}) { my $e = bootloader::get_label("linux", $o->{bootloader}); push @{$o->{bootloader}{entries}}, { %$e, label => "office", append => "$e->{append} prof=Office" }; $e->{append} .= " prof=Home"; } bootloader::suggest_floppy($o->{bootloader}) if $o->{security} <= 3; $o->{bootloader}{keytable} ||= keyboard::keyboard2kmap($o->{keyboard}); } } sub setupBootloader($) { my ($o) = @_; return if $::g_auto_install; if (arch() =~ /alpha/) { return if $::testing; my $b = $o->{bootloader}; $b->{boot} or $o->ask_warn('', "Can't install aboot, not a bsd disklabel"), return; run_program::rooted($o->{prefix}, "swriteboot", $b->{boot}, "/boot/bootlx") or do { cdie "swriteboot failed"; run_program::rooted($o->{prefix}, "swriteboot", "-f1", $b->{boot}, "/boot/bootlx"); }; run_program::rooted($o->{prefix}, "abootconf", $b->{boot}, $b->{part_nb}); modules::load('loop'); output "$o->{prefix}/etc/aboot.conf", map_index { -e "$o->{prefix}/boot/initrd-$_->[1]" ? "$::i:$b->{part_nb}$_->[0] root=$b->{root} initrd=/boot/initrd-$_->[1] $b->{perImageAppend}\n" : "$::i:$b->{part_nb}$_->[0] root=$b->{root} $b->{perImageAppend}\n" } map { run_program::rooted($o->{prefix}, "mkinitrd", "-f", "/boot/initrd-$_->[1]", "--ifneeded", $_->[1]) ;#or #unlink "$o->{prefix}/boot/initrd-$_->[1]";$_ } grep { $_->[0] && $_->[1] } $_ } grep { $_->[0] && $_->[1] } map { [ m|$o->{prefix}(/boot/vmlinux-(.*))| ] } glob_("$o->{prefix}/boot/vmlinux-*"); # output "$o->{prefix}/etc/aboot.conf", # map_index { "$::i:$b->{part_nb}$_ root=$b->{root} $b->{perImageAppend}\n" } # map { /$o->{prefix}(.*)/ } eval { glob_("$o->{prefix}/boot/vmlinux*") }; } else { require bootloader; bootloader::install($o->{prefix}, $o->{bootloader}, $o->{fstab}, $o->{hds}); } } #------------------------------------------------------------------------------ sub configureXBefore { my ($o) = @_; my $xkb = $o->{X}{keyboard}{xkb_keymap} || keyboard::keyboard2xkb($o->{keyboard}); if (!-e "$o->{prefix}/usr/X11R6/lib/X11/xkb/symbols/$xkb" && (my $f = keyboard::xmodmap_file($o->{keyboard}))) { require commands; commands::cp("-f", $f, "$o->{prefix}/etc/X11/xinit/Xmodmap"); $xkb = ''; } $o->{X}{keyboard}{xkb_keymap} = $xkb; $o->{X}{mouse} = $o->{mouse}; $o->{X}{wacom} = $o->{wacom}; require Xconfig; Xconfig::getinfoFromDDC($o->{X}); #- keep this here if the package has to be updated. $o->pkg_install("XFree86"); } sub configureX { my ($o) = @_; $o->configureXBefore; require Xconfigurator; require class_discard; { local $::testing = 0; #- unset testing local $::auto = 1; $o->{X}{skiptest} = 1; Xconfigurator::main($o->{prefix}, $o->{X}, class_discard->new, $o->{allowFB}, bool($o->{pcmcia}), sub { my ($server, @l) = @_; $o->pkg_install("XFree86-$server", @l); }); } $o->configureXAfter; } sub configureXAfter { my ($o) = @_; if ($o->{X}{card}{server} eq 'FBDev') { unless (install_any::setupFB($o, Xconfigurator::getVGAMode($o->{X}))) { log::l("disabling automatic start-up of X11 if any as setup framebuffer failed"); Xconfigurator::rewriteInittab(3) unless $::testing; #- disable automatic start-up of X11 on error. } } if ($o->{X}{default_depth} >= 16 && $o->{X}{card}{default_wres} >= 1024) { log::l("setting large icon style for kde"); install_any::kderc_largedisplay($o->{prefix}); } } #------------------------------------------------------------------------------ sub miscellaneousBefore { my ($o) = @_; my %s = getVarsFromSh("$o->{prefix}/etc/sysconfig/system"); $o->{miscellaneous}{HDPARM} ||= $s{HDPARM} if exists $s{HDPARM}; $o->{miscellaneous}{CLEAN_TMP} ||= $s{CLEAN_TMP} if exists $s{CLEAN_TMP}; $o->{security} ||= $s{SECURITY} if exists $s{SECURITY}; $ENV{SECURE_LEVEL} = $o->{security}; add2hash_ $o, { useSupermount => $o->{security} < 4 && arch() !~ /sparc/ && $o->{installClass} !~ /corporate|server/ }; cat_("/proc/cmdline") =~ /.mem=(\S+)/; #- if /^mem/, it means that's the value grub gave add2hash_($o->{miscellaneous} ||= {}, { numlock => !$o->{pcmcia}, $1 ? (memsize => $1) : () }); } sub miscellaneous { my ($o) = @_; local $_ = $o->{bootloader}{perImageAppend}; $o->{miscellaneous}{memsize} ||= availableRamMB() . 'M' if $o->{lnx4win}; if (my $ramsize = $o->{miscellaneous}{memsize} and !/mem=/) { $_ .= " mem=$ramsize"; } if (my @l = detect_devices::getIDEBurners() and !/ide-scsi/) { $_ .= " " . join(" ", (map { "$_=ide-scsi" } @l), map { "$_->{device}=ide-floppy" } detect_devices::ide_zips()); } if ($o->{miscellaneous}{HDPARM}) { $_ .= join('', map { " $_=autotune" } grep { /ide.*/ } all("/proc/ide")) if !/ide.=autotune/; } if (my $m = detect_devices::hasUltra66()) { $_ .= " $m" if !/ide.=0x/; } #- keep some given parameters #-TODO log::l("perImageAppend: $_"); $o->{bootloader}{perImageAppend} = $_; } #------------------------------------------------------------------------------ sub generateAutoInstFloppy($) { my ($o) = @_; } #------------------------------------------------------------------------------ sub exitInstall { install_any::unlockCdrom } #------------------------------------------------------------------------------ sub hasNetwork { my ($o) = @_; $o->{intf} && $o->{netc}{NETWORKING} ne 'false' || $o->{netcnx}{modem}; } #------------------------------------------------------------------------------ sub upNetwork { my ($o, $pppAvoided) = @_; foreach (qw(resolv.conf protocols services)) { symlinkf("$o->{prefix}/etc/$_", "/etc/$_"); } modules::write_conf($o->{prefix}); if ($o->{intf} && $o->{netc}{NETWORKING} ne 'false') { network::up_it($o->{prefix}, $o->{intf}); } elsif (!$pppAvoided && $o->{netcnx}{modem} && !$o->{netcnx}{modem}{isUp}) { eval { modules::load_multi(qw(serial ppp bsd_comp ppp_deflate)) }; run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "start"); run_program::rooted($o->{prefix}, "ifup", "ppp0"); $o->{netcnx}{modem}{isUp} = 1; } else { $::testing or return; } 1; } #------------------------------------------------------------------------------ sub downNetwork { my ($o, $pppOnly) = @_; modules::write_conf($o->{prefix}); if (!$pppOnly && $o->{intf} && $o->{netc}{NETWORKING} ne 'false') { network::down_it($o->{prefix}, $o->{intf}); } elsif ($o->{netcnx}{modem} && $o->{netcnx}{modem}{isUp}) { run_program::rooted($o->{prefix}, "ifdown", "ppp0"); run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "stop"); eval { modules::unload($_) foreach qw(ppp_deflate bsd_comp ppp serial) }; $o->{netcnx}{modem}{isUp} = 0; } else { $::testing or return; } 1; } #------------------------------------------------------------------------------ sub cleanIfFailedUpgrade($) { my ($o) = @_; #- if an upgrade has failed, there should be .mdkgisave files around. if ($o->{isUpgrade}) { foreach (@filesToSaveForUpgrade) { if (-e "$o->{prefix}/$_" && -e "$o->{prefix}/$_.mdkgisave") { rename "$o->{prefix}/$_", "$o->{prefix}/$_.mdkginew"; #- keep new files around in case ! rename "$o->{prefix}/$_.mdkgisave", "$o->{prefix}/$_"; } } } } #-###################################################################################### #- Wonderful perl :( #-###################################################################################### 1;