From ffda35dfebb9125a08d494e099fe1f48769d2efb Mon Sep 17 00:00:00 2001 From: Olivier Thauvin Date: Fri, 28 Dec 2007 18:21:53 +0000 Subject: - ensure rpm exists when comparing it to hdlist content (glob find also broken link) --- lib/MDV/Distribconf/Utils.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/MDV') diff --git a/lib/MDV/Distribconf/Utils.pm b/lib/MDV/Distribconf/Utils.pm index ecdb7ce..1551789 100644 --- a/lib/MDV/Distribconf/Utils.pm +++ b/lib/MDV/Distribconf/Utils.pm @@ -4,6 +4,7 @@ use strict; use warnings; use MDV::Packdrakeng; use Digest::MD5; +use Devel::Peek; our ($VERSION) = (qq$Revision$ =~ /(\d+)/)[0]; @@ -28,29 +29,30 @@ sub hdlist_vs_dir { my (@only_pack, @only_dir); my @rpms; foreach my $dir (@dir) { - push(@rpms, glob("$dir/*.rpm")); + push(@rpms, grep { -e $_ } glob("$dir/*.rpm")); } - @rpms = sort { ($b =~ m:.*/+(.*):)[0] cmp ($a =~ m:.*/+(.*):)[0] } @rpms; + @rpms = sort { ($b =~ m:.*/+(.*):)[0] cmp ($a =~ m:([^/]+)$:)[0] } @rpms; if (-f $hdlist and my $pack = MDV::Packdrakeng->open(archive => $hdlist)) { my $hdlisttime = (stat($hdlist))[9]; my (undef, $files, undef) = $pack->getcontent(); my @hdrs = sort { $b cmp $a } map { "$_.rpm" } @{$files || []}; my ($r, $h) = ("", ""); do { - my $comp = (($r =~ m:.*/+(.*):)[0] || '') cmp $h; - # print "< $r - $h > $comp\n"; + my $base_r = ($r =~ m:([^/]+)$:)[0] || ''; + my $comp = ($base_r cmp $h); + my $st_d = (stat($r))[9] if ($r); if ($comp < 0) { push(@only_pack, $h); } - elsif ($comp > 0) { push(@only_dir, ($r =~ m:.*/+(.*):)[0]); } - elsif ($r && (stat($r))[9] > $hdlisttime) { + elsif ($comp > 0) { push(@only_dir, $base_r); } + elsif ($r && (!defined($st_d) || $st_d > $hdlisttime)) { push(@only_pack, $h); push(@only_dir, ($r =~ m:.*/+(.*):)[0]); } if ($comp <= 0) { - $h = shift(@hdrs) || ""; + $h = shift(@hdrs) || ''; } if ($comp >= 0) { - $r = shift(@rpms) || ""; + $r = shift(@rpms) || ''; } } while (scalar(@rpms) || scalar(@hdrs)); } else { -- cgit v1.2.1