Skip to content

Commit

Permalink
[backend] bring back buildinfo 'add' and 'debug' options
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Jul 13, 2016
1 parent 9896d94 commit ea92c69
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/backend/BSRepServer/BuildInfo.pm
Expand Up @@ -35,6 +35,9 @@ sub new {

$self->{ctx} = $ctx;
$ctx->{'dobuildinfo'} = 1 unless $opts{'internal'};
$ctx->{'extradeps'} = $opts{'add'} if $opts{'add'};
my $debugoutput = '';
$ctx->{'expanddebug'} = \$debugoutput if $opts{'debug'};

bless($self, $class);

Expand Down Expand Up @@ -143,6 +146,7 @@ sub fixupbuildinfo {
$binfo->{'debuginfo'} ||= 0; # XXX: why?
my %preimghdrmd5s = map {delete($_->{'preimghdrmd5'}) => 1} grep {$_->{'preimghdrmd5'}} @{$binfo->{'bdep'}};
addpreinstallimg($ctx, $binfo, \%preimghdrmd5s);
$binfo->{'expanddebug'} = ${$ctx->{'expanddebug'}} if $ctx->{'expanddebug'};
}

sub getbuildinfo {
Expand Down
6 changes: 6 additions & 0 deletions src/backend/BSRepServer/Checker.pm
Expand Up @@ -22,6 +22,7 @@ use Build;

use strict;

use BSSched::BuildJob;
use BSSched::BuildJob::Package;
use BSSched::BuildJob::KiwiImage;
use BSSched::BuildJob::KiwiProduct;
Expand Down Expand Up @@ -112,7 +113,11 @@ sub preparepool {
# see checkpks in BSSched::Checker
sub buildinfo {
my ($ctx, $packid, $pdata, $info) = @_;

my $expanddebug = $ctx->{'expanddebug'};
local $Build::expand_dbg = 1 if $expanddebug;
my $xp = BSSolv::expander->new($ctx->{'pool'}, $ctx->{'conf'});
$ctx->{'expander'} = $xp;
no warnings 'redefine';
local *Build::expand = sub { $_[0] = $xp; goto &BSSolv::expander::expand; };
use warnings 'redefine';
Expand All @@ -125,6 +130,7 @@ sub buildinfo {
die("$pdata->{'error'}\n") if $pdata->{'error'};
die("$info->{'error'}\n") if $info->{'error'};
my ($eok, @edeps) = $handler->expand($bconf, $ctx->{'subpacks'}->{$info->{'name'}}, @{$info->{'dep'} || []});
BSSched::BuildJob::add_expanddebug($ctx, 'meta deps expansion') if $expanddebug;
die("unresolvable: ".join(", ", @edeps)."\n") unless $eok;
$info->{'edeps'} = \@edeps;
my ($status, $error) = $handler->check($ctx, $packid, $pdata, $info, $bconf->{'type'});
Expand Down
38 changes: 34 additions & 4 deletions src/backend/BSSched/BuildJob.pm
Expand Up @@ -788,6 +788,31 @@ sub create_jobdata {
return $binfo;
}

=head2 add_expanddebug - add debug data from the expander
input: $ctx - prp context
$type - expandsion type information
$xp - expander (optional)
=cut

sub add_expanddebug {
my ($ctx, $type, $xp) = @_;
my $expanddebug = $ctx->{'expanddebug'};
return unless ref($expanddebug);
$xp ||= $ctx->{'expander'};
return unless $xp;
return unless defined &BSSolv::expander::debugstr;
my $dbg = $xp->debugstr();
return unless $dbg;
$dbg = substr($dbg, $ctx->{"xp_cut_hack$xp"}) if $ctx->{"xp_cut_hack$xp"};
return unless $dbg;
$$expanddebug .= "\n" if $$expanddebug;
$$expanddebug .= "=== $type\n";
$$expanddebug .= $dbg;
$dbg = $xp->debugstr();
$ctx->{"xp_cut_hack$xp"} = length($dbg) if $dbg; # sigh
}

=head2 create - create a new build job
Expand Down Expand Up @@ -840,8 +865,6 @@ sub create {

# a new one. expand usedforbuild. write info file.
my $buildtype = $pdata->{'buildtype'} || Build::recipe2buildtype($info->{'file'});
my $kiwitype = '';
$kiwitype = $info->{'imagetype'} && $info->{'imagetype'}->[0] eq 'product' ? 'product' : 'image' if $buildtype eq 'kiwi';

my $syspath;
my $searchpath = path2buildinfopath($gctx, $ctx->{'prpsearchpath'});
Expand All @@ -852,24 +875,31 @@ sub create {
}

# calculate sysdeps (cannot cache in the kiwi case)
my $expanddebug = $ctx->{'expanddebug'};

my @sysdeps;
if ($buildtype eq 'kiwi') {
@sysdeps = Build::get_sysbuild($bconf, "kiwi-$kiwitype", [ grep {/^kiwi-.*:/} @{$info->{'dep'} || []} ]);
my $kiwitype = '';
$kiwitype = $info->{'imagetype'} && $info->{'imagetype'}->[0] eq 'product' ? 'kiwi-product' : 'kiwi-image';
@sysdeps = grep {/^kiwi-.*:/} @{$info->{'dep'} || []};
@sysdeps = Build::get_sysbuild($bconf, $kiwitype, [ @sysdeps, @{$ctx->{'extradeps'} || []} ]);
} else {
$ctx->{"sysbuild_$buildtype"} ||= [ Build::get_sysbuild($bconf, $buildtype) ];
@sysdeps = @{$ctx->{"sysbuild_$buildtype"}};
}
add_expanddebug($ctx,'sysdeps expansion') if $expanddebug && @sysdeps;

# calculate packages needed for building
my @bdeps = grep {!/^\// || $bconf->{'fileprovides'}->{$_}} @{$info->{'prereq'} || []};
unshift @bdeps, '--directdepsend--' if @bdeps;
unshift @bdeps, @{$info->{'dep'} || []};
unshift @bdeps, @{$info->{'dep'} || []}, @{$ctx->{'extradeps'} || []};
push @bdeps, '--ignoreignore--' if @sysdeps;

if ($buildtype eq 'kiwi' || $buildtype eq 'buildenv') {
@bdeps = (1, @$edeps); # reuse edeps packages, no need to expand again
} else {
@bdeps = Build::get_build($bconf, $subpacks, @bdeps);
add_expanddebug($ctx, 'build expansion') if $expanddebug;
}
if (!shift(@bdeps)) {
if ($ctx->{'verbose'}) {
Expand Down
5 changes: 4 additions & 1 deletion src/backend/BSSched/BuildJob/KiwiImage.pm
Expand Up @@ -132,11 +132,14 @@ sub check {
delete $bconf->{'ignoreh'};

my @deps = @{$info->{'dep'} || []};
my $expanddebug = $ctx->{'expanddebug'};
local $Build::expand_dbg = 1 if $expanddebug;
my $xp = BSSolv::expander->new($pool, $bconf);
no warnings 'redefine';
local *Build::expand = sub { $_[0] = $xp; goto &BSSolv::expander::expand; };
use warnings 'redefine';
my ($eok, @edeps) = Build::get_build($bconf, [], @deps, '--ignoreignore--');
BSSched::BuildJob::add_expanddebug($ctx, 'kiwi image expansion', $xp) if $expanddebug;
if (!$eok) {
if ($ctx->{'verbose'}) {
print " - $packid (kiwi-image)\n";
Expand Down Expand Up @@ -223,7 +226,7 @@ sub build {
no warnings 'redefine';
local *Build::expand = sub { $_[0] = $xp; goto &BSSolv::expander::expand; };
use warnings 'redefine';
my $nctx = bless { %$ctx, 'conf' => $bconf, 'prpsearchpath' => [], 'pool' => $epool, 'dep2pkg' => $edep2pkg, 'realctx' => $ctx}, ref($ctx);
my $nctx = bless { %$ctx, 'conf' => $bconf, 'prpsearchpath' => [], 'pool' => $epool, 'dep2pkg' => $edep2pkg, 'realctx' => $ctx, 'expander' => $xp}, ref($ctx);
return BSSched::BuildJob::create($nctx, $packid, $pdata, $info, [], $edeps, $reason, 0);
}
if ($ctx->{'dobuildinfo'}) {
Expand Down
9 changes: 3 additions & 6 deletions src/backend/BSSched/BuildJob/KiwiProduct.pm
Expand Up @@ -183,6 +183,7 @@ sub check {
use warnings 'redefine';
my ($eok, @kdeps) = Build::get_sysbuild($bconf, 'kiwi-product', [ grep {/^kiwi-.*:/} @{$info->{'dep'} || []} ]);
if (!$eok) {
BSSched::BuildJob::add_expanddebug($ctx, 'kiwi sysdeps expansion', $xp) if $ctx->{'expanddebug'};
if ($ctx->{'verbose'}) {
print " - $packid (kiwi-product)\n";
print " unresolvable for sysbuild:\n";
Expand Down Expand Up @@ -457,11 +458,7 @@ sub build {
my $remoteprojs = $gctx->{'remoteprojs'};
my $gdst = $ctx->{'gdst'};

my $bconf = $data->[0];
my $rpms = $data->[1];
my $pool = $data->[2];
my $dep2pkg = $data->[3];
my $reason = $data->[4];
my ($bconf, $rpms, $pool, $dep2pkg, $reason) = @$data;
my $prp = "$projid/$repoid";

my $dobuildinfo = $ctx->{'dobuildinfo'};
Expand Down Expand Up @@ -508,7 +505,7 @@ sub build {
local *Build::expand = sub { $_[0] = $xp; goto &BSSolv::expander::expand; };
use warnings 'redefine';

my $nctx = bless { %$ctx, 'prpsearchpath' => $prpsearchpath, 'conf' => $bconf, 'pool' => $pool, 'dep2pkg' => $dep2pkg, 'extrabdeps' => \@bdeps, 'realctx' => $ctx}, ref($ctx);
my $nctx = bless { %$ctx, 'prpsearchpath' => $prpsearchpath, 'conf' => $bconf, 'pool' => $pool, 'dep2pkg' => $dep2pkg, 'extrabdeps' => \@bdeps, 'realctx' => $ctx, 'expander' => $xp}, ref($ctx);
return BSSched::BuildJob::create($nctx, $packid, $pdata, $info, [], [], $reason, 0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/backend/BSSched/BuildRepo.pm
Expand Up @@ -298,7 +298,7 @@ sub fctx_gbininfo2full {
my $or = $full{$r->{'name'}};
$full{$r->{'name'}} = $r if $or && $or->{'packid'} eq '_volatile' && volatile_cmp($r, $or);
}
$full{$r->{'name'}} ||= $r;
$full{$r->{'name'}} ||= $r; # first one wins
}
}
delete $gbininfo->{$oldpackid} if defined($oldpackid) && !$hadoldpackid;
Expand Down

0 comments on commit ea92c69

Please sign in to comment.