new data structures to keep track of dups
This commit is contained in:
parent
eb5169ddad
commit
d22ab2d47a
@ -29,20 +29,29 @@ $compress =~ s/["' ]//g;
|
|||||||
|
|
||||||
$prtget .= " --no-std-config --config-set=\"prtdir $prtdir\"" if ($prtdir);
|
$prtget .= " --no-std-config --config-set=\"prtdir $prtdir\"" if ($prtdir);
|
||||||
|
|
||||||
my @dirlist = glob("*#*.pkg.tar.$compress"); my @packages;
|
my @dirlist = glob("*#*.pkg.tar.$compress");
|
||||||
|
my @packages; my %isDup;
|
||||||
|
|
||||||
if ($#ARGV >= 0) { # single packages
|
if ($#ARGV >= 0) { # single packages
|
||||||
foreach my $name (sort @ARGV) {
|
foreach my $name (sort @ARGV) {
|
||||||
my @hits = glob("$name#*.pkg.tar.$compress");
|
my @hits = glob("$name#*.pkg.tar.$compress");
|
||||||
push(@packages,@hits);
|
push(@packages,@hits);
|
||||||
|
$isDup{$name} = 1 if ($#hits > 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@packages = @dirlist;
|
@packages = @dirlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
# A hash to determine quickly whether a package is a dup
|
# hashes to determine the package name ...
|
||||||
our %pname = map { $_ => $_ } @packages;
|
our %pname = map { $_ => $_ } @packages;
|
||||||
foreach my $p (@packages) { $pname{$p} =~ s/\#.*//; }
|
foreach my $p (@packages) { $pname{$p} =~ s/\#.*//; }
|
||||||
|
|
||||||
|
# ... or to look up the successor when merging old metadata files
|
||||||
|
my %followR; my %followH; my @queue = @packages;
|
||||||
|
while (my $q = shift @queue) {
|
||||||
|
($#queue < 0) or ($pname{$q} ne $pname{$queue[0]}) or $isDup{$q} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
# Populate some other hashes using a single run of prt-get
|
# Populate some other hashes using a single run of prt-get
|
||||||
our %path; our %depends; our %descrip; our %flags;
|
our %path; our %depends; our %descrip; our %flags;
|
||||||
my @validkeys = @dirlist;
|
my @validkeys = @dirlist;
|
||||||
@ -91,7 +100,6 @@ sub pkg_single {
|
|||||||
|
|
||||||
while (my $p =shift @packages) {
|
while (my $p =shift @packages) {
|
||||||
my ($pver, $url, $du, $md5, $desc, $ppr, $pdeps, $date) = metadata($p);
|
my ($pver, $url, $du, $md5, $desc, $ppr, $pdeps, $date) = metadata($p);
|
||||||
my $isDup = ((@packages) and ($pname{$packages[0]} eq $pname{$p})) ? 1 : 0;
|
|
||||||
|
|
||||||
($firstrun{"PKGREPO"}==0) or printf $nR "%-s:%-s:%-s:%-s:%-s\n",
|
($firstrun{"PKGREPO"}==0) or printf $nR "%-s:%-s:%-s:%-s:%-s\n",
|
||||||
$p, $du, $md5, $desc, $ppr;
|
$p, $du, $md5, $desc, $ppr;
|
||||||
@ -99,7 +107,7 @@ sub pkg_single {
|
|||||||
or printf $nD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
or printf $nD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
||||||
if ($firstrun{"index.html"} == 1) {
|
if ($firstrun{"index.html"} == 1) {
|
||||||
$count++;
|
$count++;
|
||||||
htmlrow($nH,$parity{($count % 2)},$pname{$p},$url,$pver,$desc,$date);
|
htmlrow($nH,$count,$pname{$p},$url,$pver,$desc,$date);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pop entries from the old repository until we reach an entry
|
# Pop entries from the old repository until we reach an entry
|
||||||
@ -107,7 +115,7 @@ sub pkg_single {
|
|||||||
while ( ($firstrun{"PKGREPO"}==0) and $oline = <$oR> ) {
|
while ( ($firstrun{"PKGREPO"}==0) and $oline = <$oR> ) {
|
||||||
chomp($oline); $oname = $oline;
|
chomp($oline); $oname = $oline;
|
||||||
$oname =~ s/\#.*//;
|
$oname =~ s/\#.*//;
|
||||||
print $nR "$oline\n" if ($oname lt $pname{$p});
|
print $nR "$oline\n" if ($oname lt $pname{$p});
|
||||||
|
|
||||||
# before breaking out of the loop, either overwrite the old
|
# before breaking out of the loop, either overwrite the old
|
||||||
# entry in the repository, or insert the requested package
|
# entry in the repository, or insert the requested package
|
||||||
@ -115,10 +123,8 @@ sub pkg_single {
|
|||||||
printf $nR "%-s:%-s:%-s:%-s:%-s\n", $p, $du, $md5, $desc, $ppr
|
printf $nR "%-s:%-s:%-s:%-s:%-s\n", $p, $du, $md5, $desc, $ppr
|
||||||
if ($oname ge $pname{$p});
|
if ($oname ge $pname{$p});
|
||||||
|
|
||||||
# in case the current package is the last in a sequence of dups, or
|
# save what got popped from the repository, in case of dups
|
||||||
# the last in the queue, make sure we don't lose what got popped
|
$followR{$pname{$p}} = $oline if ($oname gt $pname{$p});
|
||||||
# from the repository
|
|
||||||
print $nR $oline if (($oname gt $pname{$p}) and (! $isDup));
|
|
||||||
|
|
||||||
# stop reading the repository, at least until the next package
|
# stop reading the repository, at least until the next package
|
||||||
last if ($oname ge $pname{$p});
|
last if ($oname ge $pname{$p});
|
||||||
@ -135,25 +141,28 @@ sub pkg_single {
|
|||||||
$oname =~ s/.*a href="(.*)"/$1/;
|
$oname =~ s/.*a href="(.*)"/$1/;
|
||||||
$oname =~ s/\%23.*//;
|
$oname =~ s/\%23.*//;
|
||||||
|
|
||||||
print $nH "$oline\n" if ($oname lt $pname{$p});
|
print $nH "$oline\n" if ($oname lt $pname{$p});
|
||||||
htmlrow($nH,$parity{($count % 2)},$pname{$p},$url,$pver,$desc,$date)
|
htmlrow($nH,$count,$pname{$p},$url,
|
||||||
if ($oname ge $pname{$p});
|
$pver,$desc,$date) if ($oname ge $pname{$p});
|
||||||
|
$followH{$pname{$p}} = $oline if ($oname gt $pname{$p});
|
||||||
if ( ($oname gt $pname{$p}) and (! $isDup) ) {
|
|
||||||
$count++;
|
|
||||||
$oline =~ s/class="(even|odd)"/class="$parity{($count %2)}"/;
|
|
||||||
print $nH "$oline\n";
|
|
||||||
}
|
|
||||||
last if ($oname ge $pname{$p});
|
last if ($oname ge $pname{$p});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( (! $isDup{$p}) and ($isDup{$pname{$p}}) ) {
|
||||||
|
$count++;
|
||||||
|
(! $followH{$pname{$p}}) or $followH{$pname{$p}} =~
|
||||||
|
s/class="(even|odd)"/class="$parity{($count %2)}"/;
|
||||||
|
(! $followH{$pname{$p}}) or print $nH $followH{$pname{$p}};
|
||||||
|
(! $followR{$pname{$p}}) or print $nR $followR{$pname{$p}};
|
||||||
|
}
|
||||||
|
|
||||||
# Likewise for the dependency map, but avoid creating duplicate entries
|
# Likewise for the dependency map, but avoid creating duplicate entries
|
||||||
while ($firstrun{"PKGDEPS"}==0 and $oline = <$oD>) {
|
while ($firstrun{"PKGDEPS"}==0 and $oline = <$oD>) {
|
||||||
chomp($oline); $oname = $oline;
|
chomp($oline); $oname = $oline;
|
||||||
$oname =~ s/\s*\:.*//;
|
$oname =~ s/\s*\:.*//;
|
||||||
if ($oname lt $pname{$p}) {
|
if ($oname lt $pname{$p}) {
|
||||||
print $nD "$oline\n";
|
print $nD "$oline\n";
|
||||||
} elsif ( ($pdeps ne "") and (! $isDup) ) {
|
} elsif ( ($pdeps ne "") and (! $isDup{$p}) ) {
|
||||||
printf $nD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
printf $nD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
||||||
}
|
}
|
||||||
printf $nD "$oline\n" if ($oname gt $pname{$p});
|
printf $nD "$oline\n" if ($oname gt $pname{$p});
|
||||||
@ -193,15 +202,14 @@ sub pkg_dir {
|
|||||||
printheader(0);
|
printheader(0);
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
open (my $ih, '>>index.html');
|
open (my $ih, '>>index.html');
|
||||||
while (my $p =shift @packages) {
|
foreach my $p (@packages) {
|
||||||
chomp($p);
|
chomp($p);
|
||||||
$count++;
|
$count++;
|
||||||
my ($pver, $url, $du, $md5, $desc, $ppr, $pdeps, $date) = metadata($p);
|
my ($pver, $url, $du, $md5, $desc, $ppr, $pdeps, $date) = metadata($p);
|
||||||
($pdeps eq "") or
|
($pdeps eq "") or ($isDup{$p}) or (! $isDup{$pname{$p}})
|
||||||
( (@packages) and ($pname{$p} eq $pname{$packages[0]}) )
|
or printf $iD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
||||||
or printf $iD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
|
||||||
printf $iR "%-s:%-s:%-s:%-s:%-s\n", $p,$du,$md5,$desc,$ppr;
|
printf $iR "%-s:%-s:%-s:%-s:%-s\n", $p,$du,$md5,$desc,$ppr;
|
||||||
htmlrow($ih,$parity{($count % 2)},$pname{$p},$url,$pver,$desc,$date);
|
htmlrow($ih,$count,$pname{$p},$url,$pver,$desc,$date);
|
||||||
}
|
}
|
||||||
close($ih);
|
close($ih);
|
||||||
printfooter($count);
|
printfooter($count);
|
||||||
@ -321,8 +329,8 @@ EOH
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub htmlrow {
|
sub htmlrow {
|
||||||
my ($ih, $odd, $name, $url, $version, $desc, $date) = @_;
|
my ($ih, $count, $name, $url, $version, $desc, $date) = @_;
|
||||||
print $ih "<tr class=\"$odd\"><td>$name</td>";
|
print $ih "<tr class=\"$parity{($count % 2)}\"><td>$name</td>";
|
||||||
print $ih "<td><a href=\"$url\">$version</a></td>";
|
print $ih "<td><a href=\"$url\">$version</a></td>";
|
||||||
print $ih "<td>$desc</td><td>$date</td></tr>\n";
|
print $ih "<td>$desc</td><td>$date</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user