diff options
author | Olivier Thauvin <nanardon@mandriva.org> | 2007-12-28 18:21:53 +0000 |
---|---|---|
committer | Olivier Thauvin <nanardon@mandriva.org> | 2007-12-28 18:21:53 +0000 |
commit | ffda35dfebb9125a08d494e099fe1f48769d2efb (patch) | |
tree | 00208390fbc83204a27ab3f4a8f8af4eab668316 /lib/MDV | |
parent | 79cdaa2dc6c736fb10f85c914e58f2ac8da06782 (diff) | |
download | perl-MDV-Distribconf-ffda35dfebb9125a08d494e099fe1f48769d2efb.tar perl-MDV-Distribconf-ffda35dfebb9125a08d494e099fe1f48769d2efb.tar.gz perl-MDV-Distribconf-ffda35dfebb9125a08d494e099fe1f48769d2efb.tar.bz2 perl-MDV-Distribconf-ffda35dfebb9125a08d494e099fe1f48769d2efb.tar.xz perl-MDV-Distribconf-ffda35dfebb9125a08d494e099fe1f48769d2efb.zip |
- ensure rpm exists when comparing it to hdlist content (glob find also broken link)
Diffstat (limited to 'lib/MDV')
-rw-r--r-- | lib/MDV/Distribconf/Utils.pm | 18 |
1 files changed, 10 insertions, 8 deletions
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 { |