From d911fb62181f1f8b6bf2ca500b8838410615055b Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 4 Dec 2003 10:16:44 +0000 Subject: - use do_pkgs->ensure_is_installed instead of do_pkgs->install where it's easy to do so - do_pkgs->install won't do anything when $::testing we need a ensure_are_installed we also need to share more package pkgs_interactive code which is hosted in install_any and standalone --- perl-install/install_any.pm | 7 ++++++- perl-install/network/adsl.pm | 13 +++++++------ perl-install/network/network.pm | 6 +++--- perl-install/standalone.pm | 5 +++++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index bfb568b2f..607659ef8 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -1123,7 +1123,12 @@ sub install_steps::do_pkgs { sub install { my ($do, @l) = @_; - $do->{o}->pkg_install(@l); + if ($::testing) { + log::l("i would install packages " . join(' ', @l)); + return 1; + } else { + $do->{o}->pkg_install(@l); + } } sub ensure_is_installed { diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm index 191e81ea9..02520011e 100644 --- a/perl-install/network/adsl.pm +++ b/perl-install/network/adsl.pm @@ -33,26 +33,27 @@ If you don't know, choose 'use pppoe'"), ) or return; $type = find { $l{$_} eq $type } keys %l; if ($type eq 'pppoe') { - $in->do_pkgs->install("rp-$type") if !$::testing; + $in->do_pkgs->install("rp-$type"); $netcnx->{type} = "adsl_$type"; adsl_conf($netcnx->{"adsl_$type"}, $netc, $intf, $type) or goto conf_adsl_step1; } elsif ($type eq 'dhcp') { - $in->do_pkgs->install(qw(dhcpcd)) if !$::testing; + $in->do_pkgs->ensure_is_installed('dhcpcd', '/sbin/dhcpcd', 'auto'); go_ethernet($netc, $intf, 'dhcp', '', '', $first_time) or goto conf_adsl_step1; } elsif ($type eq 'pptp') { - $in->do_pkgs->install(qw(pptp-adsl)) if !$::testing; + $in->do_pkgs->ensure_is_installed('pptp-adsl', '/usr/bin/pptp', 'auto'); $netcnx->{type} = "adsl_$type"; $netcnx->{"adsl_$type"} = {}; adsl_conf($netcnx->{"adsl_$type"}, $netc, $intf, $type) or goto conf_adsl_step1; } elsif ($type =~ /sagem/) { $type = 'sagem' . ($type =~ /dhcp/ ? "_dhcp" : ""); - $in->do_pkgs->install(qw(adiusbadsl), if_($type =~ /dhcp/, qw(dhcpcd))) if !$::testing; + $in->do_pkgs->ensure_is_installed('adiusbadsl', '/usr/sbin/adictrl', 'auto'); + $in->do_pkgs->ensure_is_installed('dhcpcd', '/sbin/dhcpcd', 'auto') if $type =~ /dhcp/; $netcnx->{type} = "adsl_$type"; $netcnx->{"adsl_$type"} = {}; adsl_conf($netcnx->{"adsl_$type"}, $netc, $intf, $type) or goto conf_adsl_step1; } elsif ($type =~ /speedtouch/) { $type = 'speedtouch'; - $in->do_pkgs->install(qw(speedtouch)) if !$::testing; + $in->do_pkgs->ensure_is_installed('speedtouch', '/usr/sbin/pppoa3', 'auto'); $netcnx->{type} = "adsl_$type"; $netcnx->{"adsl_$type"} = {}; $netcnx->{"adsl_$type"}{vpivci} = ''; @@ -204,7 +205,7 @@ user "$adsl->{login}" ['ppp-compress-24', 'ppp_deflate'], ['ppp-compress-26', 'ppp_deflate']; $::isStandalone and modules::write_conf($prefix); - $in->do_pkgs->what_provides("speedtouch_mgmt") and $in->do_pkgs->install('speedtouch_mgmt'); + $in->do_pkgs->what_provides("speedtouch_mgmt") and $in->do_pkgs->ensure_is_installed('speedtouch_mgmt', '/usr/share/speedtouch/mgmt.o', 'auto'); -e "$prefix/usr/share/speedtouch/mgmt.o" and goto end_firmware; firmware: diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index 4f9dcfbe9..15109a9f1 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -549,7 +549,7 @@ sub configureNetwork2 { my ($in, $prefix, $netc, $intf) = @_; my $etc = "$prefix/etc"; if (!$::testing) { - $netc->{wireless_eth} and $in->do_pkgs->install(qw(wireless-tools)); + $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; @@ -557,8 +557,8 @@ sub configureNetwork2 { add2hosts("$etc/hosts", "localhost", "127.0.0.1"); any { $_->{BOOTPROTO} eq "dhcp" } values %$intf and $in->do_pkgs->install($netc->{dhcp_client} || 'dhcp-client'); - $in->do_pkgs->install(qw(tmdns)) if !$in->do_pkgs->is_installed('bind'); - $in->do_pkgs->install(qw(zcip)); + $in->do_pkgs->ensure_is_installed('tmdns', '/sbin/tmdns', 'auto') if !$in->do_pkgs->is_installed('bind'); + $in->do_pkgs->ensure_is_installed('zcip', '/sbin/zcip', 'auto'); $netc->{ZEROCONF_HOSTNAME} and write_zeroconf("$etc/tmdns.conf", $netc->{ZEROCONF_HOSTNAME}); any { $_->{BOOTPROTO} =~ /^(pump|bootp)$/ } values %$intf and $in->do_pkgs->install('pump'); } diff --git a/perl-install/standalone.pm b/perl-install/standalone.pm index 84e9d1b2e..b05301b5f 100644 --- a/perl-install/standalone.pm +++ b/perl-install/standalone.pm @@ -164,6 +164,11 @@ sub install { return 1 if is_installed($o, @l); + if ($::testing) { + log::l("i would install packages " . join(' ', @l)); + return 1; + } + my $wait; if ($o->{in}->isa('interactive::newt')) { $o->{in}->suspend; -- cgit v1.2.1