Skip to content

Commit

Permalink
[backend] support Debian's Multi-Arch indicator for cross build
Browse files Browse the repository at this point in the history
Also remove duplicated code by moving the sysroot expansion from
the Checker to BuildJob/Package.
  • Loading branch information
mlschroe committed Mar 22, 2022
1 parent 67f43e2 commit 0427faa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 59 deletions.
31 changes: 2 additions & 29 deletions src/backend/BSRepServer/Checker.pm
Expand Up @@ -210,32 +210,6 @@ sub preparepool {
}
}

sub split_hostdeps {
my ($ctx, $bconf, $info) = @_;
my $dep = $info->{'dep'} || [];
return ($dep, []) unless @$dep;
my %onlynative = map {$_ => 1} @{$bconf->{'onlynative'} || []};
my %alsonative = map {$_ => 1} @{$bconf->{'alsonative'} || []};
for (@{$info->{'onlynative'} || []}) {
if (/^!(.*)/) {
delete $onlynative{$1};
} else {
$onlynative{$_} = 1;
}
}
for (@{$info->{'alsonative'} || []}) {
if (/^!(.*)/) {
delete $alsonative{$1};
} else {
$alsonative{$_} = 1;
}
}
return ($dep, []) unless %onlynative || %alsonative;
my @hdep = grep {$onlynative{$_} || $alsonative{$_}} @$dep;
return ($dep, \@hdep) if !@hdep || !%onlynative;
return ([ grep {!$onlynative{$_}} @$dep ], \@hdep)
}

# see checkpks in BSSched::Checker
sub buildinfo {
my ($ctx, $packid, $pdata, $info) = @_;
Expand All @@ -259,9 +233,8 @@ sub buildinfo {
my ($eok, @edeps);
if ($cross && !$handler) {
$handler ||= $handlers{default};
my @splitdeps = split_hostdeps($ctx, $bconf, $info);
$info->{'split_hostdeps'} = \@splitdeps;
($eok, @edeps) = Build::get_sysroot($bconf, $ctx->{'subpacks'}->{$info->{'name'}}, @{$splitdeps[0]});
my ($splitdeps, $eok, @edeps) = BSSched::BuildJob::Package::expand_sysroot($bconf, $ctx->{'subpacks'}->{$info->{'name'}}, $info);
$info->{'split_hostdeps'} = $splitdeps;
} else {
$handler ||= $handlers{default};
($eok, @edeps) = $handler->expand($bconf, $ctx->{'subpacks'}->{$info->{'name'}}, @{$info->{'dep'} || []});
Expand Down
43 changes: 42 additions & 1 deletion src/backend/BSSched/BuildJob/Package.pm
Expand Up @@ -130,7 +130,7 @@ sub check {
$split_hostdeps ||= ($ctx->{'split_hostdeps'} || {})->{$packid} if $packid;
return ('broken', 'missing split_hostdeps entry') unless $split_hostdeps;
my $subpacks = $ctx->{'subpacks'};
$hdeps = [ @{$split_hostdeps->[1]} ];
$hdeps = [ @{$split_hostdeps->[1]}, @{$split_hostdeps->[2] || []} ];
my $xp = BSSolv::expander->new($ctx->{'pool_host'}, $ctx->{'conf_host'});
no warnings 'redefine';
local *Build::expand = sub { $_[0] = $xp; goto &BSSolv::expander::expand; };
Expand Down Expand Up @@ -392,4 +392,45 @@ sub build {
return ($state, $job);
}

sub split_hostdeps {
my ($bconf, $info) = @_;
my $dep = $info->{'dep'} || [];
return ($dep, []) unless @$dep;
my %onlynative = map {$_ => 1} @{$bconf->{'onlynative'} || []};
my %alsonative = map {$_ => 1} @{$bconf->{'alsonative'} || []};
for (@{$info->{'onlynative'} || []}) {
if (/^!(.*)/) {
delete $onlynative{$1};
} else {
$onlynative{$_} = 1;
}
}
for (@{$info->{'alsonative'} || []}) {
if (/^!(.*)/) {
delete $alsonative{$1};
} else {
$alsonative{$_} = 1;
}
}
return ($dep, []) unless %onlynative || %alsonative;
my @hdep = grep {$onlynative{$_} || $alsonative{$_}} @$dep;
return ($dep, \@hdep) if !@hdep || !%onlynative;
return ([ grep {!$onlynative{$_}} @$dep ], \@hdep)
}

# split build dependencies and expand the sysroot
sub expand_sysroot {
my ($bconf, $subpacks, $info) = @_;
my @splitdeps = split_hostdeps($bconf, $info);
my @n;
my @edeps;
if ($bconf->{'binarytype'} eq 'deb') {
@edeps = Build::get_sysroot($bconf, $subpacks, '--extractnative--', \@n, @{$splitdeps[0]});
} else {
@edeps = Build::get_sysroot($bconf, $subpacks, @{$splitdeps[0]});
}
$splitdeps[2] = \@n if @n;
return \@splitdeps, @edeps;
}

1;
31 changes: 2 additions & 29 deletions src/backend/BSSched/Checker.pm
Expand Up @@ -643,32 +643,6 @@ sub emulate_depsort2 {
return BSSolv::depsort(\%pkgdeps, undef, $cycles, @packs);
}

sub split_hostdeps {
my ($ctx, $bconf, $info) = @_;
my $dep = $info->{'dep'} || [];
return ($dep, []) unless @$dep;
my %onlynative = map {$_ => 1} @{$bconf->{'onlynative'} || []};
my %alsonative = map {$_ => 1} @{$bconf->{'alsonative'} || []};
for (@{$info->{'onlynative'} || []}) {
if (/^!(.*)/) {
delete $onlynative{$1};
} else {
$onlynative{$_} = 1;
}
}
for (@{$info->{'alsonative'} || []}) {
if (/^!(.*)/) {
delete $alsonative{$1};
} else {
$alsonative{$_} = 1;
}
}
return ($dep, []) unless %onlynative || %alsonative;
my @hdep = grep {$onlynative{$_} || $alsonative{$_}} @$dep;
return ($dep, \@hdep) if !@hdep || !%onlynative;
return ([ grep {!$onlynative{$_}} @$dep ], \@hdep)
}

sub expandandsort {
my ($ctx) = @_;

Expand Down Expand Up @@ -795,9 +769,8 @@ sub expandandsort {
my ($eok, @edeps);
my $handler = $handlers{$buildtype};
if ($cross && !$handler) {
my @splitdeps = split_hostdeps($ctx, $bconf, $info);
$ctx->{'split_hostdeps'}->{$packid} = \@splitdeps;
($eok, @edeps) = Build::get_sysroot($bconf, $subpacks->{$info->{'name'}}, @{$splitdeps[0]});
my ($splitdeps, $eok, @edeps) = BSSched::BuildJob::Package::expand_sysroot($bconf, $subpacks->{$info->{'name'}}, $info);
$ctx->{'split_hostdeps'}->{$packid} = $splitdeps;
} else {
$handler ||= $handlers{default};
($eok, @edeps) = $handler->expand($bconf, $subpacks->{$info->{'name'}}, @deps);
Expand Down

0 comments on commit 0427faa

Please sign in to comment.