summaryrefslogtreecommitdiffstats
path: root/perl-install/network/ethernet.pm
blob: fc87f5b3ad5bb6fc2c40729690e15306b0e99f2b (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
package network::ethernet; # $Id$


use network::network;
use modules;
use modules::interactive;
use detect_devices;
use common;
use run_program;
use network::tools;
use vars qw(@ISA @EXPORT);

use MDK::Common::Globals "network", qw($in $prefix);

@ISA = qw(Exporter);
@EXPORT = qw(configureNetwork conf_network_card conf_network_card_backend go_ethernet);

sub configure_cable {
    my ($netcnx, $netc, $intf, $first_time) = @_;
    $::isInstall and $in->set_help('configureNetworkCable');
    $netcnx->{type} = 'cable';

    if ($::expert) {
	my @m = (
	       { description => "dhcp-client",
		 c => 1 },
	       { description => "dhcpcd",
		 c => 3 },
	       { description => "dhcpxd",
		 c => 4 },
	      );
	if (my $f = $in->ask_from_listf(N("Connect to the Internet"),
					N("Which dhcp client do you want to use?
Default is dhcp-client."),
					sub { $_[0]{description} },
					\@m)) {
	    $f->{c} == 3 and $netcnx->{dhcp_client} = "dhcpcd" and $in->do_pkgs->install(qw(dhcpcd));
	    $f->{c} == 4 and $netcnx->{dhcp_client} = "dhcpxd" and $in->do_pkgs->install(qw(dhcpxd));
	    $f->{c} == 1 and $netcnx->{dhcp_client} = "dhcp-client" and $in->do_pkgs->install(qw(dhcp-client));
	}
    } else {
	$in->do_pkgs->install(qw(dhcp-client));
    }
    go_ethernet($netc, $intf, 'dhcp', '', '', $first_time);
    write_cnx_script($netc, "cable",
qq(
/sbin/ifup $netc->{NET_DEVICE}
),
qq(
/sbin/ifdown $netc->{NET_DEVICE}
), $netcnx->{type});
    1;
}

sub configure_lan {
    my ($netcnx, $netc, $intf, $first_time) = @_;
    $::isInstall and $in->set_help('configureNetworkIP');
    configureNetwork($netc, $intf, $first_time) or return;
    configureNetwork2($in, $prefix, $netc, $intf);
    $netc->{NETWORKING} = "yes";
    if ($netc->{GATEWAY} || any { $_->{BOOTPROTO} =~ /dhcp/ } values %$intf) {
	$netcnx->{type} = 'lan';
	$netcnx->{NET_DEVICE} = $netc->{NET_DEVICE} = '';
	$netcnx->{NET_INTERFACE} = 'lan'; #$netc->{NET_INTERFACE};
        write_cnx_script($netc, "local network",
qq(
/etc/rc.d/init.d/network restart
),
qq(
/etc/rc.d/init.d/network stop
/sbin/ifup lo
), $netcnx->{type});
    }
    $::isStandalone and modules::write_conf($prefix);
    1;
}

sub conf_network_card {
    my ($netc, $intf, $type, $ipadr, $netadr) = @_;
    #-type =static or dhcp
    modules::interactive::load_category($in, 'network/main|gigabit|usb', !$::expert, 1);
    my @all_cards = conf_network_card_backend($netc, $intf, $type, undef, $ipadr, $netadr);
    my $interface;
    @all_cards == () and $in->ask_warn('', N("No ethernet network adapter has been detected on your system.
I cannot set up this connection type.")) and return;
    @all_cards == 1 and $interface = $all_cards[0][0];
    while (!$interface) {
	$interface = $in->ask_from_list(N("Choose the network interface"),
					N("Please choose which network adapter you want to use to connect to Internet."),
					[ map { $_->[0] . ($_->[1] ? " (using module $_->[1])" : "") } @all_cards ]
				       ) or return;
    }
    $::isStandalone and modules::write_conf($prefix);

    my $_device = conf_network_card_backend($netc, $intf, $type, $interface, $ipadr, $netadr, $interface);
#      if ( $::isStandalone and !($type eq "dhcp")) {
#  	$in->ask_yesorno(N("Network interface"),
#  			  N("I'm about to restart the network device:\n") . $device . N("\nDo you agree?"), 1) and configureNetwork2($in, $prefix, $netc, $intf) and system("$prefix/sbin/ifdown $device;$prefix/sbin/ifup $device");
#      }
    1;
}

#- conf_network_card_backend : configure the network cards and return the list of them, or configure one specified interface : WARNING, you have to setup the ethernet cards, by calling load_category($in, 'network/main|gigabit|usb', !$::expert, 1) or load_category_backend before calling this function. Basically, you call this function in 2 times.
#- input
#-  $prefix
#-  $netc
#-  $intf
#-  $type : type of interface, must be given if $interface is : string : "static" or "dhcp"
#-  $interface : facultative, if given, set this interface and return it in a proper form. If not, return @all_cards
#-  $ipadr : facultative, ip address of the interface : string
#-  $netadr : facultative, netaddress of the interface : string
#- when $interface is given, informations are written in $intf and $netc. If not, @all_cards is returned.
#- $intf output: $device is the result of
#-  $intf->{$device}->{DEVICE} : which device is concerned : $device is the result of $interface =~ /(eth[0-9]+)/; my $device = $1;;
#-  $intf->{$device}->{BOOTPROTO} : $type
#-  $intf->{$device}->{NETMASK} : '255.255.255.0'
#-  $intf->{$device}->{NETWORK} : $netadr
#-  $intf->{$device}->{ONBOOT} : "yes"
#- $netc output:
#-  $netc->{NET_DEVICE} : this is used to indicate that this eth card is used to connect to internet : $device
#- output:
#-  $all_cards : a list of a list ( [eth1, module1], ... , [ethn, modulen]). Pass the ethx as $interface in further call.
#-  $device : only returned in case $interface was given it's $interface, but filtered by /eth[0-9+]/ : string : /eth[0-9+]/
sub conf_network_card_backend {
    my ($netc, $intf, $type, $interface, $ipadr, $netadr) = @_;
    #-type =static or dhcp
    if (!$interface) {
	my @all_cards = detect_devices::getNet();
	my @unconfigured_interfaces = qw(ADIModem);

	my @devs = detect_devices::pcmcia_probe();
	modules::mergein_conf("$prefix/etc/modules.conf");
	my $saved_driver;
	return map {
	    my $interface = $_;
	    my $a = modules::get_alias($interface);
	    my $b;
	    foreach (@devs) {
		$_->{device} eq $interface and $b = $_->{driver};
	    }
	    $a ||= $b;
	    $a and $saved_driver = $a;
	    if_(!member($interface, @unconfigured_interfaces) || $a, [$interface, $saved_driver]);
	} @all_cards, @unconfigured_interfaces;
    }
    my ($device) = $interface =~ /(ADIModem|eth[0-9]+)/ or die("the interface is not an ethx or other (like ADIModem)");
    $netc->{NET_DEVICE} = $device; #- one consider that there is only ONE Internet connection device..

    @{$intf->{$device}}{qw(DEVICE BOOTPROTO   NETMASK     NETWORK ONBOOT)} = ($device, $type, '255.255.255.0', $netadr, 'yes');

    $intf->{$device}{IPADDR} = $ipadr if $ipadr;
    $device;
}

sub go_ethernet {
    my ($netc, $intf, $type, $ipadr, $netadr, $first_time) = @_;
    conf_network_card($netc, $intf, $type, $ipadr, $netadr) or return;
    $netc->{NET_INTERFACE} = $netc->{NET_DEVICE};
    configureNetwork($netc, $intf, $first_time) or return;
    1;
}

sub configureNetwork {
    my ($netc, $intf, $_first_time) = @_;
    local $_;
    modules::interactive::load_category($in, 'network/main|gigabit|usb|pcmcia', !$::expert, 1) or return;
    my @l = detect_devices::getNet() or die N("no network card found");
    my @all_cards = conf_network_card_backend($netc, $intf, undef, undef, undef, undef);

  configureNetwork_step_1:
    my $n_card = 0;
    $netc ||= {};
    my $last; foreach (@l) {
	my $intf2 = findIntf($intf ||= {}, $_);
	add2hash($intf2, $last);
	add2hash($intf2, { NETMASK => '255.255.255.0' });
	configureNetworkIntf($netc, $in, $intf2, $netc->{NET_DEVICE}, 0, $all_cards[$n_card][1]) or return;

	$last = $intf2;
	$n_card++;
    }
    $last or return;
    
    if ($last->{BOOTPROTO} !~ /static/) {
	$netc->{minus_one} = 1;
	$::isInstall and $in->set_help('configureNetworkHostDHCP');
	$in->ask_from(N("Configuring network"),
N("Please enter your host name if you know it.
Some DHCP servers require the hostname to work.
Your host name should be a fully-qualified host name,
such as ``mybox.mylab.myco.com''.") . N("

Enter a Zeroconf host name without any dot if you don't
want to use the default host name."),
		      [ { label => N("Host name"), val => \$netc->{HOSTNAME} },
			{ label => N("Zeroconf Host name"), val => \$netc->{ZEROCONF_HOSTNAME} },
		      ],
		      complete => sub {
			  if ($netc->{ZEROCONF_HOSTNAME} and $netc->{ZEROCONF_HOSTNAME} =~ /\./) {
			      $in->ask_warn('', N("Zeroconf host name must not contain a ."));
			      return 1;
			  }
			  0;
		      }
		      ) or goto configureNetwork_step_1;
    } else {
	configureNetworkNet($in, $netc, $last ||= {}, @l) or goto configureNetwork_step_1;
    }
    network::network::miscellaneous_choose($in, $::o->{miscellaneous} ||= {}) or goto configureNetwork_step_1;
    1;
}

1;
/span> installStepsCall($o, $auto, 'doPartitionDisks'); installStepsCall($o, $auto, 'doPartitionDisksAfter'); } sub formatPartitions { my ($auto) = @_; $o->{steps}{choosePackages}{done} = 0; installStepsCall($o, $auto, 'choosePartitionsToFormat') if !$o->{isUpgrade} && !$::local_install; my $want_root_formated = fs::get::root($o->{fstab})->{toFormat}; if ($want_root_formated) { foreach ('/usr') { my $part = fs::get::mntpoint2part($_, $o->{fstab}) or next; $part->{toFormat} or die N("You must also format %s", $_); } } installStepsCall($o, $auto, 'formatMountPartitions') if !$::testing; if ($want_root_formated) { #- we formatted /, ensure /var/lib/rpm is cleaned otherwise bad things can happen #- (especially when /var is *not* formatted) eval { rm_rf("$::prefix/var/lib/rpm") }; } fs::any::prepare_minimal_root(); install::any::screenshot_dir__and_move(); install::any::move_compressed_image_to_disk($o); any::rotate_logs($::prefix); require raid; raid::write_conf($o->{all_hds}{raids}); } #------------------------------------------------------------------------------ sub choosePackages { my ($auto) = @_; require install::pkgs; #- always setPackages as it may have to copy hdlist and synthesis files. installStepsCall($o, $auto, 'setPackages'); installStepsCall($o, $auto, 'choosePackages'); my @flags = map_each { if_($::b, $::a) } %{$o->{rpmsrate_flags_chosen}}; log::l("rpmsrate_flags_chosen's: ", join(' ', sort @flags)); #- check pre-condition that basesystem package must be selected. install::pkgs::packageByName($o->{packages}, 'basesystem')->flag_available or die "basesystem package not selected"; #- check if there are packages that need installation. $o->{steps}{installPackages}{done} = 0 if $o->{steps}{installPackages}{done} && install::pkgs::packagesToInstall($o->{packages}) > 0; } #------------------------------------------------------------------------------ sub installPackages { my ($auto) = @_; installStepsCall($o, $auto, 'beforeInstallPackages'); installStepsCall($o, $auto, 'installPackages'); installStepsCall($o, $auto, 'afterInstallPackages'); } #------------------------------------------------------------------------------ sub miscellaneous { my ($auto) = @_; installStepsCall($o, $auto, 'miscellaneousBefore'); installStepsCall($o, $auto, 'miscellaneous'); installStepsCall($o, $auto, 'miscellaneousAfter'); } #------------------------------------------------------------------------------ sub summary { my ($auto) = @_; installStepsCall($o, $auto, 'summaryBefore') if $o->{steps}{summary}{entered} == 1; installStepsCall($o, $auto, 'summary'); installStepsCall($o, $auto, 'summaryAfter'); } #------------------------------------------------------------------------------ sub configureNetwork { my ($auto) = @_; #- get current configuration of network device. require network::network; eval { network::network::read_net_conf($o->{net}) }; modules::load_category($o->{modules_conf}, list_modules::ethernet_categories()); require network::connection::ethernet; if (!$o->{isUpgrade}) { installStepsCall($o, $auto, 'configureNetwork'); } else { network::connection::ethernet::configure_eth_aliases($o->{modules_conf}); } } #------------------------------------------------------------------------------ sub installUpdates { my ($auto) = @_; installStepsCall($o, $auto, 'installUpdates'); } #------------------------------------------------------------------------------ sub configureServices { my ($auto) = @_; installStepsCall($o, $auto, 'configureServices'); } #------------------------------------------------------------------------------ sub setRootPassword_addUser { my ($auto) = @_; installStepsCall($o, $auto, 'setRootPassword_addUser') if !$o->{isUpgrade}; } #------------------------------------------------------------------------------ sub setupBootloader { my ($auto) = @_; return if $::local_install; $o->{modules_conf}->write; installStepsCall($o, $auto, 'setupBootloaderBefore'); installStepsCall($o, $auto, 'setupBootloader'); } #------------------------------------------------------------------------------ sub configureX { my ($auto) = @_; #- done here and also at the end of install2.pm, just in case... install::any::write_fstab($o); $o->{modules_conf}->write; require install::pkgs; installStepsCall($o, $auto, 'configureX') if !$::testing && eval { install::pkgs::packageByName($o->{packages}, 'task-x11')->flag_installed } && !$o->{X}{disabled}; } #------------------------------------------------------------------------------ sub exitInstall { my ($auto) = @_; installStepsCall($o, $auto, 'exitInstall', getNextStep($::o) eq 'exitInstall'); } #-###################################################################################### #- Udev Functions #-###################################################################################### sub start_udev() { # Ensure /run is mounted mkdir("/run", 0755); run_program::run("mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run"); # Fake dracut boot (due to checks employed when running dracut during install) # as we know that we'll have the needed metadata in udevadm db due to us # starting udev nice and early here. mkdir_p("/run/initramfs"); # Start up udev and trigger cold plugs run_program::run("mount", "-t", "devtmpfs", "-o", "mode=0755,nosuid", "devtmpfs", "/dev"); mkdir("/dev/$_", 0755) foreach qw(pts shm); run_program::run("mount", "-t", "devpts", "-o", "gid=5,mode=620,noexec,nosuid", "devpts", "/dev/pts"); run_program::run("mount", "-t", "tmpfs", "-o", "mode=1777,nosuid,nodev", "tmpfs", "/dev/shm"); mkdir_p("/run/udev/rules.d"); $ENV{UDEVRULESD} = "/run/udev/rules.d"; run_program::run("/lib/udev/udevd", "--daemon", "--resolve-names=never"); run_program::run("udevadm", "trigger", "--type=subsystems", "--action=add"); run_program::run("udevadm", "trigger", "--type=devices", "--action=add"); } sub stop_udev() { kill 15, fuzzy_pidofs('udevd'); sleep(2); require fs::mount; fs::mount::umount($_) foreach '/dev/pts', '/dev/shm', '/run'; } #-###################################################################################### #- Other Functions #-###################################################################################### sub init_local_install { my ($o) = @_; push @::auto_steps, # 'selectLanguage', 'selectKeyboard', 'miscellaneous', 'selectInstallClass', 'doPartitionDisks', 'formatPartitions'; fs::mount::usbfs(''); #- do it now so that when_load doesn't do it $o->{nomouseprobe} = 1; $o->{mouse} = mouse::fullname2mouse('Universal|Any PS/2 & USB mice'); } sub pre_init_brltty() { if (my ($s) = cat_("/proc/cmdline") =~ /brltty=(\S*)/) { my ($driver, $device, $table) = split(',', $s); $table = "text.$table.tbl" if $table !~ /\.tbl$/; log::l("brltty option $driver $device $table"); $o->{brltty} = { driver => $driver, device => $device, table => $table }; $o->{interactive} = 'curses'; $o->{nomouseprobe} = 1; } } sub init_brltty() { symlink "/tmp/stage2/$_", $_ foreach "/etc/brltty"; devices::make($_) foreach $o->{brltty}{device} ? $o->{brltty}{device} : qw(ttyS0 ttyS1); devices::make("vcsa"); run_program::run("brltty"); } sub step_init { my ($o) = @_; my $o_; while (1) { $o_ = $::auto_install ? install::steps_auto_install->new($o) : $o->{interactive} eq "stdio" ? install::steps_stdio->new($o) : $o->{interactive} eq "curses" ? install::steps_curses->new($o) : $o->{interactive} eq "gtk" ? install::steps_gtk->new($o) : die "unknown install type"; $o_ and last; log::l("$o->{interactive} failed, trying again with curses"); $o->{interactive} = "curses"; require install::steps_curses; } $o; } sub read_product_id() { my $product_id = cat__(install::any::getFile_($o->{stage2_phys_medium}, "product.id")); log::l('product_id: ' . chomp_($product_id)); $o->{product_id} = common::parse_LDAP_namespace_structure($product_id); $o->{meta_class} ||= { One => 'desktop', Free => 'download', Powerpack => 'powerpack', }->{$o->{product_id}{product}} || 'download'; } sub sig_segv_handler() { my $msg = "segmentation fault: install crashed (maybe memory is missing?)\n" . backtrace(); log::l("$msg\n"); # perl_checker: require UNIVERSAL UNIVERSAL::can($o, 'ask_warn') and $o->ask_warn('', $msg); setVirtual(1); require install::steps_auto_install; install::steps_auto_install_non_interactive::errorInStep($o, $msg); } sub read_stage1_net_conf() { require network::network; #- get stage1 network configuration if any. log::l('found /tmp/network'); add2hash($o->{net}{network} ||= {}, network::network::read_conf('/tmp/network')); if (my ($file) = glob_('/tmp/ifcfg-*')) { log::l("found network config file $file"); my $l = network::network::read_interface_conf($file); $o->{net}{ifcfg}{$l->{DEVICE}} ||= $l; } my $dsl_device = find { $_->{BOOTPROTO} eq 'adsl_pppoe' } values %{$o->{net}{ifcfg}}; if ($dsl_device) { $o->{net}{type} = 'adsl'; $o->{net}{net_interface} = $dsl_device->{DEVICE}; $o->{net}{adsl} = { method => 'pppoe', device => $dsl_device->{DEVICE}, ethernet_device => $dsl_device->{DEVICE}, login => $dsl_device->{USER}, password => $dsl_device->{PASS}, }; %$dsl_device = (); } else { $o->{net}{type} = 'lan'; $o->{net}{net_interface} = first(values %{$o->{net}{ifcfg}}); } } sub parse_args { my ($cfg, $patch); my %cmdline = map { my ($n, $v) = split /=/; $n => defined($v) ? $v : 1; } split ' ', cat_("/proc/cmdline"); my $opt; foreach (@_) { if (/^--?(.*)/) { $cmdline{$opt} = 1 if $opt; $opt = $1; } else { $cmdline{$opt} = $_ if $opt; $opt = ''; } } $cmdline{$opt} = 1 if $opt; #- from stage1 put_in_hash(\%ENV, { getVarsFromSh('/tmp/env') }); exists $ENV{$_} and $cmdline{lc($_)} = $ENV{$_} foreach qw(METHOD PCMCIA KICKSTART); map_each { my ($n, $v) = @_; my $f = ${{ lang => sub { $o->{lang} = $v }, flang => sub { $o->{lang} = $v; push @::auto_steps, 'selectLanguage' }, langs => sub { $o->{locale}{langs} = +{ map { $_ => 1 } split(':', $v) } }, method => sub { $o->{method} = $v }, pcmcia => sub { $o->{pcmcia} = $v }, vga16 => sub { $o->{vga16} = $v }, vga => sub { $o->{vga} = $v =~ /0x/ ? hex($v) : $v }, step => sub { $o->{steps}{first} = $v }, meta_class => sub { $o->{meta_class} = $v }, freedriver => sub { $o->{freedriver} = $v }, no_bad_drives => sub { $o->{partitioning}{no_bad_drives} = 1 }, nodmraid => sub { $o->{partitioning}{nodmraid} = 1 }, debug_urpmi => sub { $o->{debug_urpmi} = 1 }, readonly => sub { $o->{partitioning}{readonly} = $v ne "0" }, display => sub { $o->{display} = $v }, askdisplay => sub { print "Please enter the X11 display to perform the install on ? "; $o->{display} = chomp_(scalar(<STDIN>)) }, security => sub { $o->{security} = $v }, noauto => sub { $::noauto = 1 }, testing => sub { $::testing = 1 }, patch => sub { $patch = 1 }, defcfg => sub { $cfg = $v }, newt => sub { $o->{interactive} = "curses" }, text => sub { $o->{interactive} = "curses" }, stdio => sub { $o->{interactive} = "stdio" }, use_uuid => sub { $::no_uuid_by_default = !$v }, kickstart => sub { $::auto_install = $v }, local_install => sub { $::local_install = 1 }, uml_install => sub { $::uml_install = $::local_install = 1 }, auto_install => sub { $::auto_install = $v }, simple_themes => sub { $o->{simple_themes} = 1 }, theme => sub { $o->{theme} = $v }, doc => sub { $o->{doc} = 1 }, #- will be used to know that we're running for the doc team, #- e.g. we want screenshots with a good B&W contrast useless_thing_accepted => sub { $o->{useless_thing_accepted} = 1 }, alawindows => sub { $o->{security} = 0; $o->{partitioning}{clearall} = 1; $o->{bootloader}{crushMbr} = 1 }, fdisk => sub { $o->{partitioning}{fdisk} = 1 }, nomouseprobe => sub { $o->{nomouseprobe} = $v }, updatemodules => sub { $o->{updatemodules} = 1 }, suppl => sub { $o->{supplmedia} = $v }, askmedia => sub { $o->{askmedia} = 1 }, restore => sub { $::isRestore = 1 }, compsslistlevel => sub { $o->{compssListLevel} = $v }, }}{lc $n}; &$f if $f; } %cmdline; ($cfg, $patch); } sub init_env_share() { if ($::testing) { $ENV{SHARE_PATH} ||= "/export/install/stage2/live/usr/share"; $ENV{SHARE_PATH} = "/usr/share" if !-e $ENV{SHARE_PATH}; } else { $ENV{SHARE_PATH} ||= "/usr/share"; } } sub process_auto_steps() { foreach (@::auto_steps) { if (my $s = $o->{steps}{/::(.*)/ ? $1 : $_}) { $s->{auto} = $s->{hidden} = 1; } else { log::l("ERROR: unknown step $_ in auto_steps"); } } } #-###################################################################################### #- MAIN #-###################################################################################### sub main { $SIG{SEGV} = \&sig_segv_handler; $ENV{PERL_BADLANG} = 1; delete $ENV{TERMINFO}; umask 022; $::isWizard = 1; $::no_ugtk_init = 1; push @::textdomains, 'DrakX', 'drakx-net', 'drakx-kbd-mouse-x11'; my ($cfg, $patch) = parse_args(@_); init_env_share(); undef $::auto_install if $cfg; $o->{stage2_phys_medium} = install::media::stage2_phys_medium($o->{method}); log::l("second stage install running (", install::any::drakx_version($o), ")"); eval { output('/proc/sys/kernel/modprobe', "\n") } if !$::local_install && !$::testing; #- disable kmod eval { fs::mount::mount('none', '/sys', 'sysfs', 1) }; eval { touch('/root/non-chrooted-marker.DrakX') }; #- helps distinguishing /root and /mnt/root when we don't know if we are chrooted if ($::local_install) { init_local_install($o); } else { start_udev(); } $o->{prefix} = $::prefix = $::testing ? "/tmp/test-perl-install" : "/mnt"; mkdir $::prefix, 0755; #- make sure we do not pick up any gunk from the outside world my $remote_path = "$::prefix/sbin:$::prefix/bin:$::prefix/usr/sbin:$::prefix/usr/bin:$::prefix/usr/X11R6/bin"; $ENV{PATH} = "/usr/bin:/bin:/sbin:/usr/sbin:/usr/X11R6/bin:$remote_path"; eval { install::any::spawnShell() }; list_modules::load_default_moddeps(); require modules::any_conf; require modules::modules_conf; $o->{modules_conf} = modules::modules_conf::read(modules::any_conf::vnew(), '/tmp/modules.conf'); modules::read_already_loaded($o->{modules_conf}); #- done before auto_install is called to allow the -IP feature on auto_install file name read_stage1_net_conf() if -e '/tmp/network'; #- done after module dependencies are loaded for "vfat depends on fat" if ($::auto_install) { if ($::auto_install =~ /-IP(\.pl)?$/) { my ($ip) = cat_('/tmp/stage1.log') =~ /configuring device (?!lo)\S+ ip: (\S+)/; my $normalized_ip = join('', map { sprintf "%02X", $_ } split('\.', $ip)); $::auto_install =~ s/-IP(\.pl)?$/-$normalized_ip$1/; } require install::steps_auto_install; eval { $o = $::o = install::any::loadO($o, $::auto_install) }; if ($@) { if ($o->{useless_thing_accepted}) { #- Pixel's hack to be able to fail through log::l("error using auto_install, continuing"); undef $::auto_install; } else { install::steps_auto_install_non_interactive::errorInStep($o, "Error using auto_install\n" . formatError($@)); } } else { log::l("auto install config file loaded successfully"); #- normalize for people not using our special scheme foreach (@{$o->{manualFstab} || []}) { $_->{device} =~ s!^/dev/!!; } } } $o->{interactive} ||= 'gtk' if !$::auto_install; if ($o->{interactive} eq "gtk" && availableMemory() < 22 * 1024) { log::l("switching to curses install cuz not enough memory"); $o->{interactive} = "curses"; } pre_init_brltty(); # perl_checker: require install::steps_gtk # perl_checker: require install::steps_curses # perl_checker: require install::steps_stdio require "install/steps_$o->{interactive}.pm" if $o->{interactive}; #- needed before accessing floppy (in case of usb floppy) modules::load_category($o->{modules_conf}, 'bus/usb'); #- oem patch should be read before to still allow patch or defcfg. eval { $o = $::o = install::any::loadO($o, "install/patch-oem.pl"); log::l("successfully read oem patch") }; #- patch should be read after defcfg in order to take precedance. eval { $o = $::o = install::any::loadO($o, $cfg); log::l("successfully read default configuration: $cfg") } if $cfg; eval { $o = $::o = install::any::loadO($o, "patch"); log::l("successfully read patch") } if $patch; eval { modules::load("af_packet") }; require harddrake::sound; harddrake::sound::configure_sound_slots($o->{modules_conf}); #- need to be after oo-izing $o init_brltty() if $o->{brltty}; devices::make('tty') if $o->{interactive} eq "curses"; #- needed very early for install::steps_gtk if (!$::testing) { eval { $o->{mouse} = mouse::detect($o->{modules_conf}) } if !$o->{mouse} && !$o->{nomouseprobe}; mouse::load_modules($o->{mouse}); } #- for auto_install compatibility with old $o->{lang}, #- and also for --lang and --flang if ($o->{lang}) { put_in_hash($o->{locale}, lang::lang_to_ourlocale($o->{lang})); } lang::set($o->{locale}); # keep the result otherwise monitor-edid does not return good results afterwards eval { any::monitor_full_edid() }; $o->{allowFB} = listlength(cat_("/proc/fb")); read_product_id() if !$::testing; log::l("META_CLASS=$o->{meta_class}"); $ENV{META_CLASS} = $o->{meta_class}; #- for Ia Ora process_auto_steps(); $ENV{COLUMNS} ||= 80; $ENV{LINES} ||= 25; $::o = $o = step_init($o); eval { output('/proc/splash', "verbose\n") }; real_main(); finish_install(); } sub real_main() { #-the main cycle MAIN: for ($o->{step} = $o->{steps}{first};; $o->{step} = getNextStep($o)) { $o->{steps}{$o->{step}}{entered}++; $o->enteringStep($o->{step}); eval { &{$install::install2::{$o->{step}}}($o->{steps}{$o->{step}}{auto}); }; my $err = $@; $o->kill_action; if ($err) { local $_ = $err; $o->kill_action; if (!/^already displayed/) { eval { $o->errorInStep($_) }; $o->{steps}{$o->{step}}{auto} = 0; $err = $@; $err and next; } $o->{step} = $o->{steps}{$o->{step}}{onError}; next MAIN unless $o->{steps}{$o->{step}}{reachable}; #- sanity check: avoid a step not reachable on error. redo MAIN; } $o->{steps}{$o->{step}}{done} = 1; $o->leavingStep($o->{step}); last if $o->{step} eq 'exitInstall'; } } sub finish_install() { unlink $install::any::compressed_image_on_disk; install::media::clean_postinstall_rpms(); install::media::log_sizes(); install::any::remove_advertising(); install::any::write_fstab($o); $o->{modules_conf}->write; detect_devices::install_addons($::prefix); install::any::adjust_files_mtime_to_timezone(); #- make sure failed upgrade will not hurt too much. install::steps::cleanIfFailedUpgrade($o); -e "$::prefix/usr/sbin/urpmi.update" or eval { rm_rf("$::prefix/var/lib/urpmi") }; system("chroot", $::prefix, "bash", "-c", $o->{postInstallBeforeReboot}) if $o->{postInstallBeforeReboot}; #- copy latest log files eval { cp_af("/tmp/$_", "$::prefix/root/drakx") foreach qw(ddebug.log stage1.log) }; #- ala pixel? :-) [fpons] common::sync(); common::sync(); stop_udev() if !$::local_install; log::l("installation complete, leaving"); log::l("files still open by install2: ", readlink($_)) foreach glob_("/proc/self/fd/*"); print "\n" x 80 if !$::local_install; } 1;