Skip to content

Commit

Permalink
[backend] fix cpeid handling in the tracker cache
Browse files Browse the repository at this point in the history
The current code could not work as the cpeid was never
written into the tracker cache.
  • Loading branch information
mlschroe committed Nov 7, 2019
1 parent 82ca59d commit 2204bb2
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/backend/bs_publish
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ my $binsufsre = join('|', map {"\Q$_\E"} @binsufs);
my @binsufsrsync = map {"--include=*.$_"} @binsufs;
my $binarchs = join("|", keys(%BSCando::knownarch));

my $trackercacheversion = 2;

my $testmode;

# convert hooks with filenames to real code refs
Expand Down Expand Up @@ -2321,7 +2323,7 @@ sub publish {
my $packtrackcache;
if (-s "$reporoot/$prp/:repoinfo") {
$oldrepoinfo = BSUtil::retrieve("$reporoot/$prp/:repoinfo");
$packtrackcache = $oldrepoinfo->{'trackercache'} if $oldrepoinfo->{'trackercache'} && ($oldrepoinfo->{'trackercacheversion'} || '') eq '1';
$packtrackcache = $oldrepoinfo->{'trackercache'} if $oldrepoinfo->{'trackercache'} && ($oldrepoinfo->{'trackercacheversion'} || '') eq $trackercacheversion;
$publishid = $oldrepoinfo->{'publishid'} + 1 if $oldrepoinfo->{'publishid'};
}
$publishid ||= $starttime;
Expand Down Expand Up @@ -2383,7 +2385,7 @@ sub publish {
next unless @s;
my $c = $cache{"$bin/$s[9]/$s[7]/$s[1]"};
if ($c) {
my @d = qw{arch name epoch version release disturl buildtime provides};
my @d = qw{arch name epoch version release disturl buildtime cpeid};
$res = {};
for (@$c) {
my $dd = shift @d;
Expand All @@ -2394,6 +2396,12 @@ sub publish {
$res = Build::query("$extrep/$bin", 'evra' => 1, 'buildtime' => 1, 'disturl' => 1);
};
next unless $res;
# catch provided product cpeid strings
my ($cpeid) = grep {/^product-cpeid\(\)/} @{$res->{'provides'} || []};
if ($cpeid) {
$cpeid =~ s/.* = //;
$res->{'cpeid'} = BSHTTP::urldecode($cpeid);
}
}
my $pt = { 'project' => $projid, 'repository' => $repoid };
$pt->{'arch'} = $1 if $bins{$bin} =~ /^\Q$reporoot\E\/\Q$prp\E\/([^\/]+)\//;
Expand All @@ -2404,11 +2412,7 @@ sub publish {
$pt->{'binaryarch'} = $res->{'arch'} if defined $res->{'arch'};
$pt->{'binaryid'} = $res->{'hdrmd5'} if defined $res->{'hdrmd5'};
$pt->{'id'} = "$bin/$s[9]/$s[7]/$s[1]";
# catch provided product cpeid strings
if (my ($cpeid) = grep {$_ =~ m/^product-cpeid\(\)/} @{$res->{"provides"}}) {
$cpeid =~ s/.* = //;
$pt->{'cpeid'} = BSHTTP::urldecode($cpeid);
}
$pt->{'cpeid'} = $res->{'cpeid'} if $res->{'cpeid'};
$packtrack->{$bin} = $pt;
if ($pt->{'arch'}) {
$reportfile = $bin;
Expand Down Expand Up @@ -2779,12 +2783,12 @@ publishprog_done:
my @newcache;
for my $pt (values %$packtrack) {
my $id = delete $pt->{'id'};
push @newcache, $id, [ map {$pt->{$_ eq 'arch' ? 'binaryarch' : $_}} qw{arch name epoch version release disturl buildtime} ] if $id;
push @newcache, $id, [ map {$pt->{$_ eq 'arch' ? 'binaryarch' : $_}} qw{arch name epoch version release disturl buildtime cpeid} ] if $id;
}
$repoinfo = BSUtil::retrieve("$reporoot/$prp/:repoinfo", 1) || {};
if (%$repoinfo) {
$repoinfo->{'trackercache'} = \@newcache;
$repoinfo->{'trackercacheversion'} = '1';
$repoinfo->{'trackercacheversion'} = $trackercacheversion;
BSUtil::store("$reporoot/$prp/.:repoinfo", "$reporoot/$prp/:repoinfo", $repoinfo);
@newcache = (); # free mem
undef $repoinfo; # free mem
Expand Down

0 comments on commit 2204bb2

Please sign in to comment.