diff --git a/src/backend/BSRepServer/BuildInfo.pm b/src/backend/BSRepServer/BuildInfo.pm index b90a444d588..61da9369713 100644 --- a/src/backend/BSRepServer/BuildInfo.pm +++ b/src/backend/BSRepServer/BuildInfo.pm @@ -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); @@ -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 { diff --git a/src/backend/BSRepServer/Checker.pm b/src/backend/BSRepServer/Checker.pm index 1af540a07fd..c54df4beec5 100644 --- a/src/backend/BSRepServer/Checker.pm +++ b/src/backend/BSRepServer/Checker.pm @@ -22,6 +22,7 @@ use Build; use strict; +use BSSched::BuildJob; use BSSched::BuildJob::Package; use BSSched::BuildJob::KiwiImage; use BSSched::BuildJob::KiwiProduct; @@ -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'; @@ -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'}); diff --git a/src/backend/BSSched/BuildJob.pm b/src/backend/BSSched/BuildJob.pm index 3d4a23e6cd2..8ba2b5d3123 100644 --- a/src/backend/BSSched/BuildJob.pm +++ b/src/backend/BSSched/BuildJob.pm @@ -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 @@ -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'}); @@ -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'}) { diff --git a/src/backend/BSSched/BuildJob/KiwiImage.pm b/src/backend/BSSched/BuildJob/KiwiImage.pm index 31fe93e3e46..862b64edfa2 100644 --- a/src/backend/BSSched/BuildJob/KiwiImage.pm +++ b/src/backend/BSSched/BuildJob/KiwiImage.pm @@ -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"; @@ -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'}) { diff --git a/src/backend/BSSched/BuildJob/KiwiProduct.pm b/src/backend/BSSched/BuildJob/KiwiProduct.pm index e0ae060d407..07fc794a4e1 100644 --- a/src/backend/BSSched/BuildJob/KiwiProduct.pm +++ b/src/backend/BSSched/BuildJob/KiwiProduct.pm @@ -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"; @@ -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'}; @@ -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); } diff --git a/src/backend/BSSched/BuildRepo.pm b/src/backend/BSSched/BuildRepo.pm index 4956eb30841..a7680324d23 100644 --- a/src/backend/BSSched/BuildRepo.pm +++ b/src/backend/BSSched/BuildRepo.pm @@ -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;