summaryrefslogtreecommitdiffstats
path: root/urpm.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2002-12-13 13:27:45 +0000
committerFrancois Pons <fpons@mandriva.com>2002-12-13 13:27:45 +0000
commit90116b81b7e4ce0b99be4c1235ac96702202beaf (patch)
tree978d05d4f83e595595b2be5ca24e71906d81e467 /urpm.pm
parentb147827046fbaede65f06b1b15b8729afc758399 (diff)
downloadurpmi-90116b81b7e4ce0b99be4c1235ac96702202beaf.tar
urpmi-90116b81b7e4ce0b99be4c1235ac96702202beaf.tar.gz
urpmi-90116b81b7e4ce0b99be4c1235ac96702202beaf.tar.bz2
urpmi-90116b81b7e4ce0b99be4c1235ac96702202beaf.tar.xz
urpmi-90116b81b7e4ce0b99be4c1235ac96702202beaf.zip
4.1-18mdk
Diffstat (limited to 'urpm.pm')
-rw-r--r--urpm.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/urpm.pm b/urpm.pm
index 43a7f1f7..ff42826e 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -2007,6 +2007,15 @@ sub download_source_packages {
$urpm->{error}(_("incoherent medium \"%s\" marked removable but not really", $medium->{name}));
}
};
+
+ #- avoid putting a require on Fcntl ':flock' (which is perl and not perl-base).
+ my ($LOCK_EX, $LOCK_UN) = (2, 8);
+
+ #- lock urpmi database, but keep lock to wait for an urpmi.update to finish.
+ local (*LOCK_FILE);
+ open LOCK_FILE, $urpm->{statedir};
+ flock LOCK_FILE, $LOCK_EX or $urpm->{fatal}(7, _("urpmi database locked"));
+
foreach (0..$#$list) {
values %{$list->[$_]} or next;
my $medium = $urpm->{media}[$_];
@@ -2085,7 +2094,6 @@ sub download_source_packages {
};
if ($@) {
$urpm->{log}(_("...retrieving failed: %s", $@));
- #delete @sources{keys %distant_sources};
}
#- clean files that have not been downloaded, but keep mind there
#- has been problem downloading them at least once, this is
@@ -2100,6 +2108,13 @@ sub download_source_packages {
#- clean failed download which have succeeded.
delete @error_sources{keys %sources};
+ #- now everything is finished.
+ system("sync");
+
+ #- release lock on database.
+ flock LOCK_FILE, $LOCK_UN;
+ close LOCK_FILE;
+
#- return the hash of rpm file that have to be installed, they are all local now.
%$local_sources, %sources, %error_sources;
}