From 994b1c073c35d48631ad1521773d762ff8a2331e Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 26 Jan 2004 16:23:46 +0000 Subject: get rid of pseudo global $prefix, just reuse global $::prefix :-) --- perl-install/network/adsl.pm | 26 +++++++++++++------------- perl-install/network/ethernet.pm | 8 ++++---- perl-install/network/isdn.pm | 18 +++++++++--------- perl-install/network/netconnect.pm | 29 ++++++++++++++--------------- perl-install/network/network.pm | 34 +++++++++++++++++----------------- perl-install/network/tools.pm | 16 ++++++++-------- 6 files changed, 65 insertions(+), 66 deletions(-) (limited to 'perl-install') diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm index b5cd82fed..7dc706cf1 100644 --- a/perl-install/network/adsl.pm +++ b/perl-install/network/adsl.pm @@ -6,7 +6,7 @@ use network::tools; use network::ethernet; use modules; use vars qw(@ISA @EXPORT); -use MDK::Common::Globals "network", qw($in $prefix); +use MDK::Common::Globals "network", qw($in); @ISA = qw(Exporter); @EXPORT = qw(adsl_conf_backend); @@ -90,17 +90,17 @@ If you don't know, choose 'use pppoe'"), sub adsl_probe_info { my ($adsl, $netc, $adsl_type, $adsl_modem) = @_; - my $pppoe_file = "$prefix/etc/ppp/pppoe.conf"; - my $pptp_file = "$prefix/etc/sysconfig/network-scripts/net_cnx_up"; + my $pppoe_file = "$::prefix/etc/ppp/pppoe.conf"; + my $pptp_file = "$::prefix/etc/sysconfig/network-scripts/net_cnx_up"; my %pppoe_conf; %pppoe_conf = getVarsFromSh($pppoe_file) if (! defined $adsl_type || $adsl_type =~ /pppoe/) && -f $pppoe_file; my $login = $pppoe_conf{USER}; foreach (qw(/etc/ppp/peers/adsl /etc/ppp/options /etc/ppp/options.adsl)) { - ($login) = map { if_(/^user\s+"([^"]+)"/, $1) } cat_("$prefix/$_") if !$login && -r "$prefix/$_"; + ($login) = map { if_(/^user\s+"([^"]+)"/, $1) } cat_("$::prefix/$_") if !$login && -r "$::prefix/$_"; } ($login) = map { if_(/\sname\s+([^ \n]+)/, $1) } cat_($pptp_file) if (! defined $adsl_type || $adsl_type =~ /pptp/) && -r $pptp_file; my $passwd = passwd_by_login($login); ($netc->{vpivci}) = - map { if_(/^.*-vpi\s+(\d+)\s+-vci\s+(\d+)/, "$1_$2") } cat_("$prefix/etc/ppp/peers/adsl") if $adsl_modem eq 'speedtouch'; + map { if_(/^.*-vpi\s+(\d+)\s+-vci\s+(\d+)/, "$1_$2") } cat_("$::prefix/etc/ppp/peers/adsl") if $adsl_modem eq 'speedtouch'; $pppoe_conf{DNS1} ||= ''; $pppoe_conf{DNS2} ||= ''; add2hash($netc, { dnsServer2 => $pppoe_conf{DNS1}, dnsServer3 => $pppoe_conf{DNS2}, DOMAINNAME2 => '' }); @@ -120,8 +120,8 @@ sub adsl_conf_backend { my ($adsl, $netc, $adsl_type, $o_netcnx) = @_; defined $o_netcnx and $netc->{adsltype} = $o_netcnx->{type}; $netc->{adsltype} ||= "adsl_$adsl_type"; - mkdir_p("$prefix/etc/ppp"); - output("$prefix/etc/ppp/options", + mkdir_p("$::prefix/etc/ppp"); + output("$::prefix/etc/ppp/options", 'lock noipdefault persist @@ -138,15 +138,15 @@ defaultroute s/USER=.*\n/USER=$adsl->{login}\n/; s/DNS1=.*\n/DNS1=$netc->{dnsServer2}\n/; s/DNS2=.*\n/DNS2=$netc->{dnsServer3}\n/; - } "$prefix/etc/ppp/pppoe.conf"; + } "$::prefix/etc/ppp/pppoe.conf"; } if ($adsl_type eq 'sagem') { substInFile { s/VCI=.*\n/VCI=00000023\n/; s/Encapsulation=.*\n/Encapsulation=00000006\n/; - } "$prefix/etc/analog/adiusbadsl"; - output("$prefix/etc/ppp/peers/adsl", + } "$::prefix/etc/analog/adiusbadsl"; + output("$::prefix/etc/ppp/peers/adsl", qq(noauth noipdefault pty "/usr/sbin/pppoa -I `/usr/sbin/adictrl -s; /usr/sbin/adictrl -i`" @@ -173,12 +173,12 @@ user "$adsl->{login}" substInFile { s/VCI=.*\n/VCI=00000024\n/; s/Encapsulation=.*\n/Encapsulation=00000004\n/; - } "$prefix/etc/analog/adiusbadsl"; + } "$::prefix/etc/analog/adiusbadsl"; } if ($adsl_type eq 'speedtouch') { my ($vpi, $vci) = $netc->{vpivci} =~ /(\d+)_(\d+)/ or return; - output("$prefix/etc/ppp/peers/adsl", + output("$::prefix/etc/ppp/peers/adsl", qq(noauth noipdefault pty "/usr/sbin/pppoa3 -e 1 -c -vpi $vpi -vci $vci" @@ -208,7 +208,7 @@ user "$adsl->{login}" if ($adsl_type eq 'eci') { my ($vpi, $vci) = $netc->{vpivci} =~ /(\d+)_(\d+)/ or return; - output("$prefix/etc/ppp/peers/adsl", + output("$::prefix/etc/ppp/peers/adsl", qq(debug kdebug 1 noipdefault diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm index 26a58a9af..fc9f8da44 100644 --- a/perl-install/network/ethernet.pm +++ b/perl-install/network/ethernet.pm @@ -10,7 +10,7 @@ use run_program; use network::tools; use vars qw(@ISA @EXPORT); -use MDK::Common::Globals "network", qw($in $prefix); +use MDK::Common::Globals "network", qw($in); @ISA = qw(Exporter); @EXPORT = qw(conf_network_card_backend); @@ -20,8 +20,8 @@ my (@cards, @ether_steps, $last, %last); sub ether_conf{ # my ($netcnx, $netc, $intf, $first_time) = @_; - my ($in, $prefix, $netc, $intf) = @_; - configureNetwork2($in, $prefix, $netc, $intf); + my ($in, $_prefix, $netc, $intf) = @_; + configureNetwork2($in, $::prefix, $netc, $intf); $netc->{NETWORKING} = "yes"; if ($netc->{GATEWAY} || any { $_->{BOOTPROTO} =~ /dhcp/ } values %$intf) { $netcnx->{type} = 'lan'; @@ -69,7 +69,7 @@ sub conf_network_card_backend { my @all_cards = detect_devices::getNet(); my @devs = detect_devices::pcmcia_probe(); - modules::mergein_conf("$prefix/etc/modules.conf"); + modules::mergein_conf("$::prefix/etc/modules.conf"); my $saved_driver; return map { my $interface = $_; diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm index 310aadc20..0e77ceea5 100644 --- a/perl-install/network/isdn.pm +++ b/perl-install/network/isdn.pm @@ -9,7 +9,7 @@ use run_program; use log; use network::tools; use vars qw(@ISA @EXPORT); -use MDK::Common::Globals "network", qw($in $prefix); +use MDK::Common::Globals "network", qw($in); use MDK::Common::File; @@ -28,7 +28,7 @@ sub isdn_write_config_backend { my ($isdn, $netc, $o_netcnx) = @_; defined $o_netcnx and $netc->{isdntype} = $o_netcnx->{type}; - output_with_perm("$prefix/etc/isdn/profile/link/myisp", 0600, + output_with_perm("$::prefix/etc/isdn/profile/link/myisp", 0600, qq( I4L_USERNAME="$isdn->{login}" I4L_SYSNAME="" @@ -37,7 +37,7 @@ I4L_REMOTE_OUT="$isdn->{phone_out}" I4L_DIALMODE="$isdn->{dialing_mode}" ) . if_($isdn->{speed} =~ /128/, 'SLAVE="ippp1" ')); - output "$prefix/etc/isdn/profile/card/mycard", + output "$::prefix/etc/isdn/profile/card/mycard", qq( I4L_MODULE="$isdn->{driver}" I4L_TYPE="$isdn->{type}" @@ -50,17 +50,17 @@ I4L_ID="HiSax" I4L_FIRMWARE="$isdn->{firmware}" ); - output "$prefix/etc/ppp/ioptions", + output "$::prefix/etc/ppp/ioptions", "lock usepeerdns defaultroute "; - system "$prefix/etc/rc.d/init.d/isdn4linux restart"; + system "$::prefix/etc/rc.d/init.d/isdn4linux restart"; - substInFile { s/^FIRMWARE.*\n//; $_ .= qq(FIRMWARE="$isdn->{firmware}"\n) if eof } "$prefix/etc/sysconfig/network-scripts/ifcfg-ippp0"; + substInFile { s/^FIRMWARE.*\n//; $_ .= qq(FIRMWARE="$isdn->{firmware}"\n) if eof } "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp0"; # we start the virtual interface at boot (we dial only on demand. - substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=yes\n) if eof } "$prefix/etc/sysconfig/network-scripts/ifcfg-ippp$isdn->{intf_id}"; + substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=yes\n) if eof } "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp$isdn->{intf_id}"; write_secret_backend($isdn->{login}, $isdn->{passwd}); @@ -93,7 +93,7 @@ sub isdn_read_config { I4L_IO1 => 'io1', I4L_FIRMWARE => 'firmware'); foreach ('link/myisp', 'card/mycard') { - my %conf = getVarsFromSh("$prefix/etc/isdn/profile/$_"); + my %conf = getVarsFromSh("$::prefix/etc/isdn/profile/$_"); foreach (keys %conf) { $isdn->{$match{$_}} = $conf{$_} if $match{$_}; } @@ -122,7 +122,7 @@ sub get_info_providers_backend { sub isdn_ask_info { my ($isdn, $netc) = @_; my $f = "$ENV{SHARE_PATH}/ldetect-lst/isdn.db"; - $f = "$prefix$f" if !-e $f; + $f = "$::prefix$f" if !-e $f; isdn_ask_info_step1: my $str = $in->ask_from_treelist(N("ISDN Configuration"), N("Select your provider.\nIf it isn't listed, choose Unlisted."), '|', ['Unlisted - edit manually', diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm index e2fe7b521..0213d76aa 100644 --- a/perl-install/network/netconnect.pm +++ b/perl-install/network/netconnect.pm @@ -10,7 +10,7 @@ use any; use mouse; use network::network; use network::tools; -use MDK::Common::Globals "network", qw($in $prefix $connect_file $disconnect_file $connect_prog); +use MDK::Common::Globals "network", qw($in $connect_file $disconnect_file $connect_prog); my %conf; @@ -39,10 +39,9 @@ sub detect { } sub init_globals { - my ($in, $prefix) = @_; + my ($in) = @_; MDK::Common::Globals::init( in => $in, - prefix => $prefix, connect_file => "/etc/sysconfig/network-scripts/net_cnx_up", disconnect_file => "/etc/sysconfig/network-scripts/net_cnx_down", connect_prog => "/etc/sysconfig/network-scripts/net_cnx_pg"); @@ -547,7 +546,7 @@ killall pppd if ($adsl_device eq 'speedtouch' && ! -r '/usr/share/speedtouch/mgmt.o' && !$::testing) { $in->do_pkgs->what_provides("speedtouch_mgmt") and $in->do_pkgs->install('speedtouch_mgmt', 'auto'); - return 'adsl_speedtouch_firmware' if ! -e "$prefix/usr/share/speedtouch/mgmt.o"; + return 'adsl_speedtouch_firmware' if ! -e "$::prefix/usr/share/speedtouch/mgmt.o"; } return 'adsl_provider' if $adsl_devices{$adsl_device}; return 'adsl_protocol'; @@ -584,7 +583,7 @@ or skip and do it later."), list => [ N("Use a floppy"), N("Use my Windows partition"), N("Do it later") ], } ], post => sub { - my $destination = "$prefix/usr/share/speedtouch/"; + my $destination = "$::prefix/usr/share/speedtouch/"; my ($file, $source, $mounted); if ($adsl_answer eq N("Use a floppy")) { $mounted = 1; @@ -1110,7 +1109,7 @@ else fi ); } - output_with_perm("$prefix$connect_prog", 0755, $connect_cmd) if $connect_cmd; + output_with_perm("$::prefix$connect_prog", 0755, $connect_cmd) if $connect_cmd; $netcnx->{$_} = $netc->{$_} foreach qw(NET_DEVICE NET_INTERFACE); $netcnx->{type} =~ /adsl/ or system("/sbin/chkconfig --del adsl 2> /dev/null"); @@ -1152,20 +1151,20 @@ sub get_profiles() { sub load_conf { my ($netcnx, $netc, $intf) = @_; - my $current = { getVarsFromSh("$prefix/etc/netprofile/current") }; + my $current = { getVarsFromSh("$::prefix/etc/netprofile/current") }; $netcnx->{PROFILE} = $current->{PROFILE} || 'default'; - network::network::read_all_conf($prefix, $netc, $intf); + network::network::read_all_conf($::prefix, $netc, $intf); } sub get_net_device() { my $connect_file = "/etc/sysconfig/network-scripts/net_cnx_up"; my $network_file = "/etc/sysconfig/network"; - if (cat_("$prefix$connect_file") =~ /ifup/) { + if (cat_("$::prefix$connect_file") =~ /ifup/) { if_(cat_($connect_file) =~ /^\s*ifup\s+(.*)/m, split(' ', $1)) - } elsif (cat_("$prefix$connect_file") =~ /network/) { - ${{ getVarsFromSh("$prefix$network_file") }}{GATEWAYDEV}; - } elsif (cat_("$prefix$connect_file") =~ /isdn/) { + } elsif (cat_("$::prefix$connect_file") =~ /network/) { + ${{ getVarsFromSh("$::prefix$network_file") }}{GATEWAYDEV}; + } elsif (cat_("$::prefix$connect_file") =~ /isdn/) { "ippp+"; } else { "ppp+"; @@ -1180,16 +1179,16 @@ sub read_net_conf { sub start_internet { my ($o) = @_; - init_globals($o, $o->{prefix}); + init_globals($o); #- give a chance for module to be loaded using kernel-BOOT modules... $::isStandalone or modules::load_category('network/main|gigabit|usb'); - run_program::rooted($prefix, $connect_file); + run_program::rooted($::prefix, $connect_file); } sub stop_internet { my ($o) = @_; init_globals($o, $o->{prefix}); - run_program::rooted($prefix, $disconnect_file); + run_program::rooted($::prefix, $disconnect_file); } 1; diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index e2c062355..51460d54b 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -147,11 +147,11 @@ sub write_resolv_conf { } sub write_interface_conf { - my ($file, $intf, $_netc, $prefix) = @_; + my ($file, $intf, $_netc, $_prefix) = @_; - if ($intf->{HWADDR} && -e "$prefix/sbin/ip") { + if ($intf->{HWADDR} && -e "$::prefix/sbin/ip") { $intf->{HWADDR} = undef; - if (my $s = `LC_ALL= LANG= $prefix/sbin/ip -o link show $intf->{DEVICE} 2>/dev/null`) { + if (my $s = `LC_ALL= LANG= $::prefix/sbin/ip -o link show $intf->{DEVICE} 2>/dev/null`) { if ($s =~ m|.*link/ether\s([0-9a-z:]+)\s|) { $intf->{HWADDR} = $1; } @@ -190,12 +190,12 @@ sub add2hosts { # The interface/gateway needs to be configured before this will work! sub guessHostname { - my ($prefix, $netc, $intf) = @_; + my ($_prefix, $netc, $intf) = @_; $intf->{isUp} && dnsServers($netc) or return 0; $netc->{HOSTNAME} && $netc->{DOMAINNAME} and return 1; - write_resolv_conf("$prefix/etc/resolv.conf", $netc); + write_resolv_conf("$::prefix/etc/resolv.conf", $netc); my $name = gethostbyaddr(Socket::inet_aton($intf->{IPADDR}), Socket::AF_INET()) or log::explanations("reverse name lookup failed"), return 0; @@ -333,28 +333,28 @@ sub proxy_configure { } sub read_all_conf { - my ($prefix, $netc, $intf, $o_netcnx) = @_; + my ($_prefix, $netc, $intf, $o_netcnx) = @_; $netc ||= {}; $intf ||= {}; my $netcnx = $o_netcnx || {}; - add2hash($netc, read_conf("$prefix/etc/sysconfig/network")) if -r "$prefix/etc/sysconfig/network"; + add2hash($netc, read_conf("$::prefix/etc/sysconfig/network")) if -r "$::prefix/etc/sysconfig/network"; add2hash($netc, read_resolv_conf()); - add2hash($netc, read_tmdns_conf("$prefix/etc/tmdns.conf")) if -r "$prefix/etc/tmdns.conf"; - foreach (all("$prefix/etc/sysconfig/network-scripts")) { + add2hash($netc, read_tmdns_conf("$::prefix/etc/tmdns.conf")) if -r "$::prefix/etc/tmdns.conf"; + foreach (all("$::prefix/etc/sysconfig/network-scripts")) { if (/^ifcfg-(\w+)$/ && $1 ne 'lo') { my $intf = findIntf($intf, $1); - add2hash($intf, { getVarsFromSh("$prefix/etc/sysconfig/network-scripts/$_") }); + add2hash($intf, { getVarsFromSh("$::prefix/etc/sysconfig/network-scripts/$_") }); } } - $netcnx->{type} or probe_netcnx_type($prefix, $netc, $intf, $netcnx); + $netcnx->{type} or probe_netcnx_type($::prefix, $netc, $intf, $netcnx); } sub probe_netcnx_type { - my ($prefix, $_netc, $intf, $netcnx) = @_; + my ($_prefix, $_netc, $intf, $netcnx) = @_; #- try to probe $netcnx->{type} which is used almost everywhere. unless ($netcnx->{type}) { #- ugly hack to determine network type (avoid saying not configured in summary). - -e "$prefix/etc/ppp/peers/adsl" and $netcnx->{type} ||= 'adsl'; # enough ? - -e "$prefix/etc/ppp/ioptions1B" || -e "$prefix/etc/ppp/ioptions2B" and $netcnx->{type} ||= 'isdn'; # enough ? + -e "$::prefix/etc/ppp/peers/adsl" and $netcnx->{type} ||= 'adsl'; # enough ? + -e "$::prefix/etc/ppp/ioptions1B" || -e "$::prefix/etc/ppp/ioptions2B" and $netcnx->{type} ||= 'isdn'; # enough ? $intf->{ppp0} and $netcnx->{type} ||= 'modem'; $intf->{eth0} and $netcnx->{type} ||= 'lan'; } @@ -409,13 +409,13 @@ sub easy_dhcp { #- $intf->{$device}{DEVICE} : DEVICE = $device #- $intf->{$device}{BOOTPROTO} : boot prototype : "bootp" or "dhcp" or "pump" or ... sub configureNetwork2 { - my ($in, $prefix, $netc, $intf) = @_; - my $etc = "$prefix/etc"; + my ($in, $_prefix, $netc, $intf) = @_; + my $etc = "$::prefix/etc"; if (!$::testing) { $netc->{wireless_eth} and $in->do_pkgs->ensure_is_installed('wireless-tools', '/sbin/iwconfig', 'auto'); write_conf("$etc/sysconfig/network", $netc); write_resolv_conf("$etc/resolv.conf", $netc) if ! $netc->{DHCP}; - write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_->{DEVICE}", $_, $netc, $prefix) foreach grep { $_->{DEVICE} ne 'ppp0' } values %$intf; + write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_->{DEVICE}", $_, $netc, $::prefix) foreach grep { $_->{DEVICE} ne 'ppp0' } values %$intf; add2hosts("$etc/hosts", $netc->{HOSTNAME}, map { $_->{IPADDR} } values %$intf) if $netc->{HOSTNAME} && !$netc->{DHCP}; add2hosts("$etc/hosts", "localhost", "127.0.0.1"); diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm index ec5169cf2..43dfff904 100644 --- a/perl-install/network/tools.pm +++ b/perl-install/network/tools.pm @@ -5,7 +5,7 @@ use common; use run_program; use c; use vars qw(@ISA @EXPORT @EXPORT_OK); -use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_prog $connect_file); +use MDK::Common::Globals "network", qw($in $disconnect_file $connect_prog $connect_file); use MDK::Common::System qw(getVarsFromSh); @ISA = qw(Exporter); @@ -19,7 +19,7 @@ sub write_cnx_script { $netc->{internet_cnx}{$o_type}{type} = $o_type2; } else { foreach ($connect_file, $disconnect_file) { - output_with_perm("$prefix$_", 0755, + output_with_perm("$::prefix$_", 0755, '#!/bin/bash ' . if_(!$netc->{at_boot}, 'if [ "x$1" == "x--boot_time" ]; then exit; fi ') . $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{$_}); @@ -29,7 +29,7 @@ sub write_cnx_script { sub write_secret_backend { my ($a, $b) = @_; - foreach my $i ("$prefix/etc/ppp/pap-secrets", "$prefix/etc/ppp/chap-secrets") { + foreach my $i ("$::prefix/etc/ppp/pap-secrets", "$::prefix/etc/ppp/chap-secrets") { substInFile { s/^'$a'.*\n//; $_ .= "\n'$a' * '$b' * \n" if eof } $i; #- restore access right to secrets file, just in case. chmod 0600, $i; @@ -44,7 +44,7 @@ sub unquotify { sub read_secret_backend() { my $conf = []; foreach my $i ("pap-secrets", "chap-secrets") { - foreach (cat_("$prefix/etc/ppp/$i")) { + foreach (cat_("$::prefix/etc/ppp/$i")) { my ($login, $server, $passwd) = split(' '); if ($login && $passwd) { unquotify \$passwd; @@ -69,9 +69,9 @@ sub passwd_by_login { } } -sub connect_backend() { run_program::rooted($prefix, "$connect_file &") } +sub connect_backend() { run_program::rooted($::prefix, "$connect_file &") } -sub disconnect_backend() { run_program::rooted($prefix, "$disconnect_file &") } +sub disconnect_backend() { run_program::rooted($::prefix, "$disconnect_file &") } sub read_providers_backend { my ($file) = @_; map { /(.*?)=>/ } catMaybeCompressed($file) } @@ -137,7 +137,7 @@ sub check_link_beat() { sub write_initscript() { $::testing and return; - output_with_perm("$prefix/etc/rc.d/init.d/internet", 0755, + output_with_perm("$::prefix/etc/rc.d/init.d/internet", 0755, sprintf(<<'EOF', $connect_file, $connect_file, $disconnect_file, $disconnect_file)); #!/bin/bash # @@ -183,7 +183,7 @@ esac exit 0 EOF $::isStandalone ? system("/sbin/chkconfig --add internet") : do { - symlinkf("../init.d/internet", "$prefix/etc/rc.d/rc$_") foreach + symlinkf("../init.d/internet", "$::prefix/etc/rc.d/rc$_") foreach '0.d/K11internet', '1.d/K11internet', '2.d/K11internet', '3.d/S89internet', '5.d/S89internet', '6.d/K11internet'; }; } -- cgit v1.2.1