Skip to content

Commit

Permalink
[backend] also track base container in packtrack data
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Oct 23, 2017
1 parent 0bc6f98 commit b11e8ac
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/backend/BSRepServer/Containerinfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ BSRepServer::Containerinfo

sub containerinfo2obsbinlnk {
my ($dir, $containerinfo, $packid) = @_;
my $d= readcontainerinfo($dir, $containerinfo);
my $d = readcontainerinfo($dir, $containerinfo);
return unless $d;
my $name = $d->{name};
my $lnk = {};
Expand All @@ -68,6 +68,7 @@ sub containerinfo2obsbinlnk {
return undef if $@;
my $annotation = {};
$annotation->{'repo'} = $d->{'repos'} if $d->{'repos'};
$annotation->{'disturl'} = $d->{'disturl'} if $d->{'disturl'};
if (%$annotation) {
eval { $lnk->{'annotation'} = BSUtil::toxml($annotation, $BSXML::binannotation) };
warn($@) if $@;
Expand Down Expand Up @@ -115,6 +116,7 @@ sub readcontainerinfo {
$d->{name} = $name;
my $file = $d->{'file'};
$d->{'file'} = $file = undef unless defined($file) && ref($file) eq '';
delete $d->{'disturl'} unless defined($d->{'disturl'}) && ref($d->{'disturl'}) eq '';
return undef unless defined($name) && defined($file);
eval {
BSVerify::verify_simple($file);
Expand Down
19 changes: 15 additions & 4 deletions src/backend/BSSched/BuildJob.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1242,10 +1242,21 @@ sub expandkiwipath {
sub getcontainerannotation {
my ($pool, $p, $bdep) = @_;
return undef unless defined &BSSolv::pool::pkg2annotation;
my $annotation_xml = $pool->pkg2annotation($p);
return undef unless $annotation_xml;
my $annotation = BSUtil::fromxml($annotation_xml, $BSXML::binannotation, 1);
$bdep->{'annotation'} = $annotation_xml if $bdep && $annotation;
my $annotation = $pool->pkg2annotation($p);
return undef unless $annotation;
$annotation = BSUtil::fromxml($annotation, $BSXML::binannotation, 1);
return undef unless $annotation;
if ($bdep) {
# add extra data from the package data
my $data = $pool->pkg2data($p);
$annotation->{'hdrmd5'} = $data->{'hdrmd5'} if $data->{'hdrmd5'};
$annotation->{'package'} = $1 if $data->{'path'} && $data->{'path'} =~ /^\.\.\/([^\/]+)\//;
$annotation->{'epoch'} = $data->{'epoch'} if $data->{'epoch'};
$annotation->{'version'} = $data->{'version'};
$annotation->{'release'} = $data->{'release'} if defined $data->{'release'};
$annotation->{'binaryarch'} = $data->{'arch'} if $data->{'arch'};
$bdep->{'annotation'} = BSUtil::toxml($annotation, $BSXML::binannotation);
}
return $annotation;
}

Expand Down
10 changes: 6 additions & 4 deletions src/backend/BSSched/BuildJob/Docker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,11 @@ sub build {
local *Build::expand = sub { $_[0] = $xp; goto &BSSolv::expander::expand; };
use warnings 'redefine';
$ctx = bless { %$ctx, 'conf' => $bconf, 'prpsearchpath' => [], 'pool' => $epool, 'dep2pkg' => $edep2pkg, 'realctx' => $ctx, 'expander' => $xp, 'unorderedrepos' => $unorderedrepos}, ref($ctx);
$ctx->{'extrabdeps'} = [ $cbdep ] if $cbdep;
$ctx->{'containerpath'} = [ $cprp ] if $cbdep && $cprp;
$ctx->{'containerannotation'} = delete $cbdep->{'annotation'} if $cbdep;
if ($cbdep) {
$ctx->{'extrabdeps'} = [ $cbdep ];
$ctx->{'containerpath'} = [ $cprp ] if $cprp;
$ctx->{'containerannotation'} = delete $cbdep->{'annotation'};
}
return BSSched::BuildJob::create($ctx, $packid, $pdata, $info, [], $edeps, $reason, 0);
}

Expand Down Expand Up @@ -355,7 +357,7 @@ sub build {
if ($cbdep) {
push @{$ctx->{'extrabdeps'}}, $cbdep;
$ctx->{'containerpath'} = [ $cprp ] if $cprp;
$ctx->{'containerannotation'} = delete $cbdep->{'annotation'} if $cbdep;
$ctx->{'containerannotation'} = delete $cbdep->{'annotation'};
}

# repo has a configured path, expand docker build system with it
Expand Down
8 changes: 6 additions & 2 deletions src/backend/BSSched/BuildJob/KiwiImage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,11 @@ sub build {
local *Build::expand = sub { $_[0] = $xp; goto &BSSolv::expander::expand; };
use warnings 'redefine';
$ctx = bless { %$ctx, 'conf' => $bconf, 'prpsearchpath' => [], 'pool' => $epool, 'dep2pkg' => $edep2pkg, 'realctx' => $ctx, 'expander' => $xp, 'unorderedrepos' => $unorderedrepos}, ref($ctx);
$ctx->{'extrabdeps'} = [ $cbdep ] if $cbdep;
$ctx->{'containerpath'} = [ $cprp ] if $cbdep && $cprp;
if ($cbdep) {
$ctx->{'extrabdeps'} = [ $cbdep ];
$ctx->{'containerpath'} = [ $cprp ] if $cprp;
$ctx->{'containerannotation'} = delete $cbdep->{'annotation'};
}
return BSSched::BuildJob::create($ctx, $packid, $pdata, $info, [], $edeps, $reason, 0);
}

Expand Down Expand Up @@ -339,6 +342,7 @@ sub build {
if ($cbdep) {
push @{$ctx->{'extrabdeps'}}, $cbdep;
$ctx->{'containerpath'} = [ $cprp ] if $cprp;
$ctx->{'containerannotation'} = delete $cbdep->{'annotation'};
}

# repo has a configured path, expand kiwi build system with it
Expand Down
6 changes: 5 additions & 1 deletion src/backend/BSXML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,11 @@ our $binannotation = [
'priority',
]],
'disturl',
'packid', # only in build job annotation
'package', # only in build job annotation
'epoch', # only in build job annotation
'version', # only in build job annotation
'release', # only in build job annotation
'binaryarch', # only in build job annotation
'hdrmd5', # only in build job annotation
];

Expand Down
19 changes: 18 additions & 1 deletion src/backend/bs_worker
Original file line number Diff line number Diff line change
Expand Up @@ -2328,6 +2328,21 @@ sub getbinaries {
die("getbinaries: missing packages: $bdep->{'name'}\n") unless @$res == 1;
push @{$buildinfo->{'containerurl'}}, "dir://./containers/$repo->{'project'}/$repo->{'repository'}/$res->[0]->{'name'}";
push @meta, "$res->[0]->{'md5'} $repo->{'project'}/$repo->{'repository'}/$bdep->{'name'}";
my $bin = {
'name' => $bdep->{'name'},
'project' => $repo->{'project'},
'repository' => $repo->{'repository'},
'arch' => $buildinfo->{'arch'},
};
if ($buildinfo->{'containerannotation'}) {
my $annotation = BSUtil::fromxml($buildinfo->{'containerannotation'}, $BSXML::binannotation, 1);
if ($annotation) {
for (qw{package version release binaryarch disturl}) {
$bin->{$_} = $annotation->{$_} if defined($annotation->{$_}) && $annotation->{$_} ne '';
}
}
}
push @{$kiwiorigins->{':basecontainers'}}, $bin;
}
if ($buildinfo->{'containerannotation'}) {
mkdir_p("$srcdir/containers");
Expand Down Expand Up @@ -2656,7 +2671,8 @@ sub createkiwireport {
my @bins;
while (<F>) {
my @s = split(/\|/, $_);
next unless @s < 6;
next if @s < 6;
next if $s[0] eq 'gpg-pubkey';
my $bin = {
'name' => $s[0],
'version' => $s[2],
Expand All @@ -2676,6 +2692,7 @@ sub createkiwireport {
push @bins, $bin;
}
close F;
push @bins, @{$kiwiorigins->{':basecontainers'} || []};
my $report = { 'binary' => \@bins };
my $reportfile = $file;
$reportfile =~ s/\.packages$/\.report/;
Expand Down

0 comments on commit b11e8ac

Please sign in to comment.