Skip to content

Commit

Permalink
[backend] start package tracking for kiwi image builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Oct 12, 2017
1 parent 17d3aff commit f75c35d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/backend/bs_publish
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,11 @@ sub publish {
$kiwimedium{$p} = $1 if $bin =~ /(.+)\.iso$/;
} elsif ($bin =~ /\.raw(?:\.install)?(?:\.(?:gz|bz2|xz))?(?:\.sha256)?$/) {
$p = "$bin";
} elsif ($bin =~ /-Build\d.*\.(?:tbz|tgz|tar|tar\.gz|tar\.bz2|tar\.xz)(?:\.sha256)?$/) {
} elsif ($bin =~ /(.*-Build\d.*)\.(?:tbz|tgz|tar|tar\.gz|tar\.bz2|tar\.xz)(\.sha256)?$/) {
$kiwimedium{$p} = $1 if !$2 && -e "$r/$1.packages";
$p = "$bin";
} elsif ($bin =~ /\.tar(?:\.(?:gz|bz2|xz))?(?:\.sha256)?$/) {
} elsif ($bin =~ /(.*)\.tar(?:\.(?:gz|bz2|xz))?(\.sha256)?$/) {
$kiwimedium{$p} = $1 if !$2 && -e "$r/$1.packages";
$p = "$bin";
} elsif ($bin =~ /\.(?:tgz|zip)?(?:\.sha256)?$/) {
# esp. for Go builds
Expand Down
49 changes: 46 additions & 3 deletions src/backend/bs_worker
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ sub getbinaries_buildenv {
}

sub getbinaries {
my ($buildinfo, $dir, $srcdir, $preinstallimagedata) = @_;
my ($buildinfo, $dir, $srcdir, $preinstallimagedata, $kiwiorigins) = @_;

return getbinaries_buildenv($buildinfo, $dir, $srcdir) if $buildinfo->{'hasbuildenv'};

Expand Down Expand Up @@ -2291,6 +2291,8 @@ sub getbinaries {
if (!$bdep_notmeta{$n}) {
my $id = Build::queryhdrmd5("$ddir/$f->{'name'}") || "deaddeaddeaddeaddeaddeaddeaddead";
push @meta, "$id $repoprp/$n";
# sigh, no package information available yet...
$kiwiorigins->{$n} = "$repoprp/$buildinfo->{'arch'}" if $kiwiorigins;
}
if (!$buildinfo->{'syspath'} && !$bdep_noinstall{$n}) {
if (!-e "$dir/$f->{'name'}") {
Expand Down Expand Up @@ -2543,7 +2545,8 @@ sub xmlescape {
return $d;
}

# parse all .report file and create a channel file from them
# parse all .report files and create a channel file from them
# also update the data in the .report files with the binary origins
sub createchannel {
my ($dir, $kiwiorigins) = @_;
my @reports = grep {/\.report$/} ls($dir);
Expand Down Expand Up @@ -2643,6 +2646,43 @@ sub createchannel {
writestr("$dir/._channel", "$dir/_channel", $c);
}

# create a kiwi .report file from a kiwi .packages file by adding binary origin information
sub createkiwireport {
my ($dir, $kiwiorigins) = @_;

local *F;
for my $file (grep {/\.packages$/} sort(ls($dir))) {
next unless open(F, '<', "$dir/$file");
my @bins;
while (<F>) {
my @s = split(/\|/, $_);
next unless @s < 6;
my $bin = {
'name' => $s[0],
'version' => $s[2],
'release' => $s[3],
'binaryarch' => $s[4],
'disturl' => $s[5],
};
$bin->{'epoch'} = $s[1] if $s[1] ne '(none)';
my $prpap = $kiwiorigins->{$s[0]};
if ($prpap) {
my ($projid, $repoid, $arch, $packid) = split('/', $prpap, 4);
$bin->{'project'} = $projid;
$bin->{'repository'} = $repoid;
$bin->{'arch'} = $arch;
$bin->{'package'} = $packid if $packid;
}
push @bins, $bin;
}
close F;
my $report = { 'binary' => \@bins };
my $reportfile = $file;
$reportfile =~ s/\.packages$/\.report/;
writexml("$dir/.$reportfile", "$dir/$reportfile", $report, $BSXML::report);
}
}

$Build::Kiwi::urlmapper = sub {return '_obsrepositories'} unless $Build::Kiwi::urlmapper;

sub dobuild {
Expand Down Expand Up @@ -2778,7 +2818,7 @@ sub dobuild {
}
push @meta, getbinaries_kiwiproduct($buildinfo, $pkgdir, $srcdir, $kiwiorigins);
} else {
push @meta, getbinaries($buildinfo, $pkgdir, $srcdir, $preinstallimagedata);
push @meta, getbinaries($buildinfo, $pkgdir, $srcdir, $preinstallimagedata, $kiwiorigins);
}
}
$preinstallimagedata ||= {};
Expand Down Expand Up @@ -3022,6 +3062,9 @@ sub dobuild {
if (($kiwimode || '') eq 'product' && !$followupmode) {
createchannel("$buildroot/.build.packages/OTHER", $kiwiorigins);
}
if ($kiwimode && $kiwimode ne 'product' && !$followupmode) {
createkiwireport("$buildroot/.build.packages/KIWI", $kiwiorigins);
}
if ($followupmode && %$kiwiorigins) {
writestr("$buildroot/.build.packages/OTHER/$_", undef, $kiwiorigins->{$_}) for keys %$kiwiorigins;
}
Expand Down

0 comments on commit f75c35d

Please sign in to comment.