aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Iurt/Urpmi.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-08-30 16:58:48 +0000
committerOlivier Blin <oblin@mandriva.com>2007-08-30 16:58:48 +0000
commitd595e0aa090d03e73532efe32263b451651afb52 (patch)
tree825a0f5bbdc1b134a7523ed17bbc562e1bf7b831 /lib/Iurt/Urpmi.pm
parente1e1f78a9e1effad3ec62cc33f31a0fecae36655 (diff)
downloadiurt-d595e0aa090d03e73532efe32263b451651afb52.tar
iurt-d595e0aa090d03e73532efe32263b451651afb52.tar.gz
iurt-d595e0aa090d03e73532efe32263b451651afb52.tar.bz2
iurt-d595e0aa090d03e73532efe32263b451651afb52.tar.xz
iurt-d595e0aa090d03e73532efe32263b451651afb52.zip
factorize packages installation check code in a are_installed() function
Diffstat (limited to 'lib/Iurt/Urpmi.pm')
-rw-r--r--lib/Iurt/Urpmi.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Iurt/Urpmi.pm b/lib/Iurt/Urpmi.pm
index 86ac52d..51d9022 100644
--- a/lib/Iurt/Urpmi.pm
+++ b/lib/Iurt/Urpmi.pm
@@ -381,6 +381,11 @@ sub install_packages_old {
1;
}
+sub are_installed {
+ my ($chroot, @pkgs) = @_;
+ system("sudo chroot $chroot rpm -q @pkgs") == 0;
+}
+
sub install_packages {
my ($self, $title, $chroot_tmp, $local_spool, $pack_provide, $log, $error, $opt, @packages) = @_;
@@ -411,7 +416,7 @@ sub install_packages {
my $try_urpmi = 1;
my @rpm = grep { !/\.src\.rpm$/ } @to_install;
- return 1 if ($opt->{check} && -f "$chroot_tmp/bin/rpm" && @rpm && !system("sudo chroot $chroot_tmp rpm -q @to_install"));
+ return 1 if ($opt->{check} && -f "$chroot_tmp/bin/rpm" && @rpm && are_installed($chroot_tmp, @to_install));
if ($try_urpmi) {
foreach my $try (
@@ -514,7 +519,7 @@ sub install_packages {
}
$unsatisfied and last;
} else {
- if (!@rpm || !system("sudo chroot $chroot_tmp rpm -q @rpm")) {
+ if (!@rpm || are_installed($chroot_tmp, @rpm)) {
plog("installation successful");
$ok = 1;
}
@@ -538,7 +543,7 @@ sub install_packages {
last if $ok == 1;
}
}
- if (!-f "$chroot_tmp/bin/rpm" || @rpm && system("sudo chroot $chroot_tmp rpm -q @to_install")) {
+ if (!-f "$chroot_tmp/bin/rpm" || @rpm && !are_installed($chroot_tmp, @to_install)) {
plog(1, "ERROR: urpmi is not working, doing it manually");
my $root = "$config->{repository}/$run->{distro}/$run->{my_arch}";
my $depslist = "$root/media/media_info/depslist.ordered";