From 48df454d604810ab006d7f3ce1b545c83df1e540 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 21 Aug 2002 20:43:06 +0000 Subject: - add do_pkgs->are_installed - add an auto parameter to ensure_is_installed - implement do_pkgs->ensure_is_installed during install --- perl-install/install_any.pm | 23 +++++++++++++++++++++++ perl-install/standalone.pm | 13 +++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index c5abc334b..8edbe0573 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -1173,6 +1173,21 @@ sub install { $do->{o}->pkg_install(@l); } +sub ensure_is_installed { + my ($do, $pkg, $file, $auto) = @_; + + if (! -e $file) { + $do->{o}->ask_okcancel('', _("The package %s needs to be installed. Do you want to install it?", $pkg), 1) + or return if !$auto; + $do->{o}->do_pkgs->install($pkg); + } + if (! -e $file) { + $do->{o}->ask_warn('', _("Mandatory package %s is missing", $pkg)); + return; + } + 1; +} + sub what_provides { my ($do, $name) = @_; map { $do->{o}{packages}{depslist}[$_]->name } keys %{$do->{o}{packages}{provides}{$name} || {}}; @@ -1187,6 +1202,14 @@ sub is_installed { 1; } +sub are_installed { + my ($do, @l) = @_; + grep { + my $p = pkgs::packageByName($do->{o}{packages}, $_); + $p && $p->flag_selected; + } @l; +} + sub remove { my ($do, @l) = @_; diff --git a/perl-install/standalone.pm b/perl-install/standalone.pm index 54205dc7b..e3463df10 100644 --- a/perl-install/standalone.pm +++ b/perl-install/standalone.pm @@ -21,6 +21,7 @@ foreach (@ARGV) { package pkgs_interactive; use run_program; +use common; sub interactive::do_pkgs { @@ -51,10 +52,11 @@ sub install { } sub ensure_is_installed { - my ($o, $pkg, $file) = @_; + my ($o, $pkg, $file, $auto) = @_; if (! -e $file) { - $o->{in}->ask_okcancel('', _("The package %s needs to be installed. Do you want to install it?", $pkg), 1) or return; + $o->{in}->ask_okcancel('', _("The package %s needs to be installed. Do you want to install it?", $pkg), 1) + or return if !$auto; $o->{in}->do_pkgs->install($pkg); } if (! -e $file) { @@ -75,6 +77,13 @@ sub is_installed { run_program::run('rpm', '>', '/dev/null', '-q', @l); } +sub are_installed { + my ($o, @l) = @_; + my @l2; + run_program::run('rpm', '>', \@l2, '-q', '--qf', "%{name}\n", @l); + intersection(\@l, [ map { chomp_($_) } @l2 ]); +} + sub remove { my ($o, @l) = @_; $o->{in}->suspend; -- cgit v1.2.1