From 1996511a162e6b4ee7c4b4a2e325100e483f5519 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 8 Jul 2008 16:49:03 +0000 Subject: create cachedir_rpms() out of _selected2local_and_ids() --- urpm/get_pkgs.pm | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'urpm/get_pkgs.pm') diff --git a/urpm/get_pkgs.pm b/urpm/get_pkgs.pm index 0312321a..71336da0 100644 --- a/urpm/get_pkgs.pm +++ b/urpm/get_pkgs.pm @@ -17,6 +17,25 @@ sub clean_all_cache { urpm::sys::empty_dir("$urpm->{cachedir}/rpms"); } +sub cachedir_rpms { + my ($urpm) = @_; + + #- examine the local repository, which is trusted (no gpg or pgp signature check but md5 is now done). + my %fn2file; + foreach my $filepath (glob("$urpm->{cachedir}/rpms/*")) { + next if -d $filepath; + + if (! -s $filepath) { + unlink $filepath; #- this file should be removed or is already empty. + } else { + my $filename = basename($filepath); + my ($fullname) = $filename =~ /(.*)\.rpm$/ or next; + $fn2file{$fullname} = $filepath; + } + } + \%fn2file; +} + #- select sources for selected packages, #- according to keys of the packages hash. #- returns a list of lists containing the source description for each rpm, @@ -39,20 +58,16 @@ sub _selected2local_and_ids { } #- examine the local repository, which is trusted (no gpg or pgp signature check but md5 is now done). - foreach my $filepath (glob("$urpm->{cachedir}/rpms/*")) { - next if -d $filepath; + my $cachedir_rpms = cachedir_rpms($urpm); + + foreach my $fullname (keys %$cachedir_rpms) { + my $filepath = $cachedir_rpms->{$fullname}; - if (! -s $filepath) { - unlink $filepath; #- this file should be removed or is already empty. - } else { - my $filename = basename($filepath); - my ($fullname) = $filename =~ /(.*)\.rpm$/ or next; if (my $id = delete $fullname2id{$fullname}) { $local_sources{$id} = $filepath; } else { $options{clean_other} && ! exists $protected_files{$filepath} and unlink $filepath; } - } } my %id2ids; -- cgit v1.2.1