Skip to content

Commit

Permalink
Merge pull request #5187 from mlschroe/master
Browse files Browse the repository at this point in the history
Fix docker building with service generated files
  • Loading branch information
mlschroe committed Jun 22, 2018
2 parents 1aaf358 + 25acebc commit a8d0d8f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
21 changes: 13 additions & 8 deletions src/backend/BSSched/BuildJob.pm
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,12 @@ sub create {

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

my $kiwimode;
$kiwimode = $buildtype if $buildtype eq 'kiwi' || $buildtype eq 'docker' || $buildtype eq 'fissile';
$kiwimode = $buildtype if $buildtype eq 'kiwi-image' || $buildtype eq 'kiwi-product' || $buildtype eq 'docker' || $buildtype eq 'fissile';

my $syspath;
my $searchpath = path2buildinfopath($gctx, $ctx->{'prpsearchpath'});
Expand All @@ -904,18 +907,20 @@ sub create {
@btdeps = BSUtil::unify(@btdeps);
}

# calculate sysdeps (cannot cache in the kiwi case)
my @sysdeps;
if ($buildtype eq 'kiwi') {
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, @btdeps, @{$ctx->{'extradeps'} || []} ]);
# calculate sysdeps
my @sysdeps = @btdeps;
if ($buildtype eq 'kiwi-image' || $buildtype eq 'kiwi-product') {
unshift @sysdeps, grep {/^kiwi-.*:/} @{$info->{'dep'} || []};
push @sysdeps, @{$ctx->{'extradeps'} || []};
}
if (@sysdeps) {
@sysdeps = Build::get_sysbuild($bconf, $buildtype, [ @sysdeps ]); # cannot cache...
} else {
$ctx->{"sysbuild_$buildtype"} ||= [ Build::get_sysbuild($bconf, $buildtype) ];
@sysdeps = @{$ctx->{"sysbuild_$buildtype"}};
}
add_expanddebug($ctx,'sysdeps expansion') if $expanddebug && @sysdeps;
@btdeps = () if @sysdeps; # already included in sysdeps

# calculate packages needed for building
my @bdeps = grep {!/^\// || $bconf->{'fileprovides'}->{$_}} @{$info->{'prereq'} || []};
Expand Down
6 changes: 6 additions & 0 deletions src/backend/BSSched/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ sub wipeobsolete {
my $repoid = $ctx->{'repository'};
my $projpacks = $gctx->{'projpacks'};
my $myarch = $gctx->{'arch'};
my $repo = (grep {$_->{'name'} eq $repoid} @{$projpacks->{$projid}->{'repository'} || []})[0];
my $linkedbuild = $repo ? $repo->{'linkedbuild'} : 'all';
my $pdatas = $projpacks->{$projid}->{'package'} || {};
my $dstcache = { 'fullcache' => {}, 'bininfocache' => {} };
my $hadobsolete;
Expand All @@ -275,6 +277,10 @@ sub wipeobsolete {
if (($pdata->{'error'} || '') eq 'excluded') {
$reason = 'excluded';
} else {
if (exists($pdata->{'originproject'})) {
# package from project link
$reason = 'excluded' if !$linkedbuild || ($linkedbuild ne 'localdep' && $linkedbuild ne 'all');
}
my %info = map {$_->{'repository'} => $_} @{$pdata->{'info'} || []};
my $info = $info{$repoid};
$reason = 'excluded' if $info && ($info->{'error'} || '') eq 'excluded';
Expand Down
30 changes: 16 additions & 14 deletions src/backend/bs_worker
Original file line number Diff line number Diff line change
Expand Up @@ -2207,16 +2207,26 @@ sub getbinaries_buildenv {
return (); # no meta
}

sub getkiwimode {
my ($buildinfo) = @_;
my $file = $buildinfo->{'file'};
$file =~ s/^_service:.*://;
my $kiwimode;
$kiwimode = 'image' if $file =~ /\.kiwi$/;
$kiwimode = 'product' if $kiwimode && $buildinfo->{'imagetype'} && $buildinfo->{'imagetype'}->[0] eq 'product';
$kiwimode = 'docker' if $file eq 'Dockerfile';
$kiwimode = 'fissile' if $file eq 'fissile.yml';
return $kiwimode;
}

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

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

mkdir_p($dir);
my $kiwimode;
$kiwimode = 'image' if $buildinfo->{'file'} =~ /\.kiwi$/;
$kiwimode = 'docker' if $buildinfo->{'file'} eq 'Dockerfile';
$kiwimode = 'fissile' if $buildinfo->{'file'} eq 'fissile.yml';
my $recipefile = $buildinfo->{'file'};
my $kiwimode = getkiwimode($buildinfo);

# we need the Build package for queryhdrmd5
importbuild() unless defined &Build::queryhdrmd5;
Expand Down Expand Up @@ -2790,11 +2800,7 @@ sub dobuild {
my $repoid = $buildinfo->{'repository'};
my $arch = $buildinfo->{'arch'};
my $helperarch = $buildinfo->{'hostarch'} || $arch;
my $kiwimode;
$kiwimode = 'image' if $buildinfo->{'file'} =~ /\.kiwi$/;
$kiwimode = 'product' if $kiwimode && $buildinfo->{'imagetype'} && $buildinfo->{'imagetype'}->[0] eq 'product';
$kiwimode = 'docker' if $buildinfo->{'file'} eq 'Dockerfile';
$kiwimode = 'fissile' if $buildinfo->{'file'} eq 'fissile.yml';
my $kiwimode = getkiwimode($buildinfo);
my $kiwiorigins;
my $stats = {};
my $deltamode;
Expand Down Expand Up @@ -2881,11 +2887,7 @@ sub dobuild {
$buildinfo->{'rootforbuild'} = 1 if $buildinfo->{'file'} =~ /\.kiwi$/;
$buildinfo->{'file'} = $followupmode;
# recalc kiwimode as we changed the file
undef $kiwimode;
$kiwimode = 'image' if $buildinfo->{'file'} =~ /\.kiwi$/;
$kiwimode = 'product' if $kiwimode && $buildinfo->{'imagetype'} && $buildinfo->{'imagetype'}->[0] eq 'product';
$kiwimode = 'docker' if $buildinfo->{'file'} eq 'Dockerfile';
$kiwimode = 'fissile' if $buildinfo->{'file'} eq 'fissile.yml';
$kiwimode = getkiwimode($buildinfo);
@meta = split("\n", readstr("$srcdir/meta"));
} else {
$kiwiorigins = {} if $kiwimode; # always for kiwi
Expand Down

0 comments on commit a8d0d8f

Please sign in to comment.