Skip to content

Commit

Permalink
[backend] add new "ismedium" element to packtrack data
Browse files Browse the repository at this point in the history
The "ismedium" element is set for binaries that contain other
binaries, like products, images, or containers. It contains
the same string as the "medium" element of the contained binaries,
thus it can be used to lookup the medium binary.
  • Loading branch information
mlschroe committed Apr 26, 2018
1 parent 9b64cf5 commit f78a068
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
25 changes: 19 additions & 6 deletions src/backend/BSRepServer/Containerinfo.pm
Expand Up @@ -36,6 +36,24 @@ BSRepServer::Containerinfo
=cut

=head2 containerinfo2nevra - convert a containerinfo file to name/epoch/version/release/arch
input: $containerinfo - containerinfo filename in $dir
output: hash containting name/epoch/...
=cut

sub containerinfo2nevra {
my ($d) = @_;
my $lnk = {};
$lnk->{'name'} = "container:$d->{'name'}";
$lnk->{'version'} = defined($d->{'version'}) ? $d->{'version'} : '0';
$lnk->{'release'} = defined($d->{'release'}) ? $d->{'release'} : '0';
$lnk->{'arch'} = defined($d->{'arch'}) ? $d->{'arch'} : 'noarch';
return $lnk;
}

=head2 containerinfo2obsbinlnk - convert a containerinfo file to an obsbinlnk
input: $dir - directory of the built container
Expand All @@ -50,12 +68,7 @@ sub containerinfo2obsbinlnk {
my ($dir, $containerinfo, $packid) = @_;
my $d = readcontainerinfo($dir, $containerinfo);
return unless $d;
my $name = $d->{name};
my $lnk = {};
$lnk->{'name'} = "container:$name";
$lnk->{'version'} = defined($d->{'version'}) ? $d->{'version'} : '0';
$lnk->{'release'} = defined($d->{'release'}) ? $d->{'release'} : '0';
$lnk->{'arch'} = defined($d->{'arch'}) ? $d->{'arch'} : 'noarch';
my $lnk = containerinfo2nevra($d);
# need to have a source so that it goes into the :full tree
$lnk->{'source'} = $lnk->{'name'};
# add self-provides
Expand Down
25 changes: 16 additions & 9 deletions src/backend/bs_publish
Expand Up @@ -2036,27 +2036,32 @@ sub publish {

# track containers
if ($containers{$bin}) {
my $containerinfo = $containers{$bin};
my $containerinfo = $containers{$bin};
my $medium = $bin;
$medium =~ s/.*\///; # basename
my $lnk = BSRepServer::Containerinfo::containerinfo2nevra($containerinfo);
my $pt = { 'project' => $projid, 'repository' => $repoid };
$pt->{'arch'} = $containerinfo->{'arch'};
for (qw{name epoch version release arch}) {
$pt->{$_} = $lnk->{$_} if defined $lnk->{$_};
}
$pt->{'package'} = $binaryorigins->{$bin} if $binaryorigins->{$bin};
for (qw{name version release disturl buildtime}) {
for (qw{disturl buildtime}) {
$pt->{$_} = $containerinfo->{$_} if defined $containerinfo->{$_};
}
# this overwrites the name for kiwi containers
$pt->{'name'} = $bin;
$pt->{'name'} =~ s/.*\///; # basename
$pt->{'ismedium'} = $medium;
$packtrack->{$bin} = $pt;
}

# track kiwi images and kiwi products
if (!$containers{$bin} && $kiwireport{$kiwimedium{$bin}}) {
my $medium = $bin;
$medium =~ s/.*\///; # basename
my $pt = { 'project' => $projid, 'repository' => $repoid };
$pt->{'arch'} = (split('/', $kiwimedium{$bin}, 2))[0];
$pt->{'arch'} = (split('/', $kiwimedium{$bin}, 2))[0];
$pt->{'package'} = $binaryorigins->{$bin} if $binaryorigins->{$bin};
$pt->{'name'} = $bin;
$pt->{'name'} =~ s/.*\///; # basename
$pt->{'name'} = $medium; # hmm...
# need a way to get disturl and buildtime...
$pt->{'ismedium'} = $medium;
$packtrack->{$bin} = $pt;
}

Expand All @@ -2066,6 +2071,8 @@ sub publish {
if ($kiwireport{$reportfile}) {
my $medium = $bin;
$medium =~ s/.*\///; # basename
# make sure ismedium is set in the binary
$packtrack->{$bin}->{'ismedium'} = $medium if $packtrack->{$bin};
for my $kb (@{$kiwireport{$reportfile}->{'binary'} || []}) {
my $pt = { %$kb };
delete $pt->{'_content'};
Expand Down

0 comments on commit f78a068

Please sign in to comment.