summaryrefslogtreecommitdiffstats
path: root/perl-install/do_pkgs.pm
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mandriva.org>2009-02-11 14:24:13 +0000
committerPascal Terjan <pterjan@mandriva.org>2009-02-11 14:24:13 +0000
commit3dddd920e035b909143861e6fd5ab7a522966b24 (patch)
tree9eb5b647394755c3ec53477775f8b06f7bd6f810 /perl-install/do_pkgs.pm
parentea3d1d46d0537705ef5771bea985ed0cc63e45c2 (diff)
downloaddrakx-3dddd920e035b909143861e6fd5ab7a522966b24.tar
drakx-3dddd920e035b909143861e6fd5ab7a522966b24.tar.gz
drakx-3dddd920e035b909143861e6fd5ab7a522966b24.tar.bz2
drakx-3dddd920e035b909143861e6fd5ab7a522966b24.tar.xz
drakx-3dddd920e035b909143861e6fd5ab7a522966b24.zip
do_pkgs: add ensure_files_are_installed
Diffstat (limited to 'perl-install/do_pkgs.pm')
-rw-r--r--perl-install/do_pkgs.pm20
1 files changed, 20 insertions, 0 deletions
diff --git a/perl-install/do_pkgs.pm b/perl-install/do_pkgs.pm
index 1667d5cf5..a40eb66a7 100644
--- a/perl-install/do_pkgs.pm
+++ b/perl-install/do_pkgs.pm
@@ -68,6 +68,26 @@ sub ensure_binary_is_installed {
1;
}
+# takes a list of [ "package", "file" ] and installs package if file is not there
+sub ensure_files_are_installed {
+ my ($do, $pkgs, $b_auto) = @_;
+
+ my @not_installed = map { my ($package, $file) = @{$_}; -e "$::prefix$file"?():$package } @{$pkgs};
+
+ $do->in->ask_okcancel(N("Warning"), N("The following packages need to be installed:\n") . join(', ', @not_installed), 1)
+ or return if !$b_auto && $do->in;
+
+ if (!$do->install(@not_installed)) {
+ if ($do->in) {
+ $do->in->ask_warn(N("Error"), N("Could not install the %s package!", $not_installed[0]));
+ } else {
+ log::l("Could not install packages: " . join(' ', @not_installed));
+ }
+ return;
+ }
+ 1;
+}
+
sub ensure_is_installed_if_available {
my ($do, $pkg, $file) = @_;
if (-e "$::prefix$file" || $::testing) {