Skip to content

Commit

Permalink
Rename "FromHost" to "OnlyNative"
Browse files Browse the repository at this point in the history
Add "AlsoNative" to specify that a package must be installed both
in the root and in the sysroot.

Add "#!NativeBuild" as new marker that this is to be a native
build instead of checking the package name.
  • Loading branch information
mlschroe committed Apr 26, 2021
1 parent 07ba4c6 commit 00e4922
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Build.pm
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ sub read_config {
$config->{'prefer'} = [];
$config->{'ignore'} = [];
$config->{'conflict'} = [];
$config->{'fromhost'} = [];
$config->{'alsonative'} = [];
$config->{'onlynative'} = [];
$config->{'substitute'} = {};
$config->{'substitute_vers'} = {};
$config->{'optflags'} = {};
Expand Down Expand Up @@ -414,7 +415,7 @@ sub read_config {
}
next;
}
if ($l0 eq 'preinstall:' || $l0 eq 'vminstall:' || $l0 eq 'required:' || $l0 eq 'support:' || $l0 eq 'keep:' || $l0 eq 'prefer:' || $l0 eq 'ignore:' || $l0 eq 'conflict:' || $l0 eq 'runscripts:' || $l0 eq 'expandflags:' || $l0 eq 'buildflags:' || $l0 eq 'publishflags:' || $l0 eq 'repourl:' || $l0 eq 'registryurl:' || $l0 eq 'assetsurl:' || $l0 eq 'fromhost:') {
if ($l0 eq 'preinstall:' || $l0 eq 'vminstall:' || $l0 eq 'required:' || $l0 eq 'support:' || $l0 eq 'keep:' || $l0 eq 'prefer:' || $l0 eq 'ignore:' || $l0 eq 'conflict:' || $l0 eq 'runscripts:' || $l0 eq 'expandflags:' || $l0 eq 'buildflags:' || $l0 eq 'publishflags:' || $l0 eq 'repourl:' || $l0 eq 'registryurl:' || $l0 eq 'assetsurl:' || $l0 eq 'onlynative:' || $l0 eq 'alsonative:') {
my $t = substr($l0, 0, -1);
for my $l (@l) {
if ($l eq '!*') {
Expand Down
19 changes: 14 additions & 5 deletions Build/Rpm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ sub parse {
my @subpacks;
my @packdeps;
my @prereqs;
my @fromhost;
my @alsonative;
my @onlynative;
my $hasnfb;
my $nfbline;
my %macros;
Expand Down Expand Up @@ -635,6 +636,9 @@ sub parse {
if ($preamble && $line =~ /^\#\!ForceMultiVersion\s*$/i) {
$ret->{'multiversion'} = 1;
}
if ($preamble && $line =~ /^\#\!NativeBuild\s*$/i) {
$ret->{'nativebuild'} = 1;
}
if ($preamble && $line =~ /^\#\!RemoteAsset(?::\s*([a-z0-9]+:[0-9a-f]+))?\s*$/i) {
$remoteasset = {};
$remoteasset->{'digest'} = $1 if $1;
Expand All @@ -658,7 +662,7 @@ sub parse {
}
next;
}
if ($preamble && ($line =~ /^(BuildRequires|BuildPrereq|BuildConflicts|\#\!BuildIgnore|\#\!BuildConflicts|\#\!BuildRequires|\#\!FromHost)\s*:\s*(\S.*)$/i)) {
if ($preamble && ($line =~ /^(BuildRequires|BuildPrereq|BuildConflicts|\#\!BuildIgnore|\#\!BuildConflicts|\#\!BuildRequires|\#\!AlsoNative|\#\!OnlyNative)\s*:\s*(\S.*)$/i)) {
my $what = $1;
my $deps = $2;
$ifdeps = 1 if $hasif;
Expand Down Expand Up @@ -706,8 +710,12 @@ sub parse {

$replace = 1 if grep {/^-/} @ndeps;
my $lcwhat = lc($what);
if ($lcwhat eq '#!fromhost') {
push @fromhost, @ndeps;
if ($lcwhat eq '#!alsonative') {
push @alsonative, @ndeps;
next;
}
if ($lcwhat eq '#!onlynative') {
push @onlynative, @ndeps;
next;
}
if ($lcwhat ne 'buildrequires' && $lcwhat ne 'buildprereq' && $lcwhat ne '#!buildrequires') {
Expand Down Expand Up @@ -804,7 +812,8 @@ sub parse {
$ret->{'badarch'} = $badarch if defined $badarch;
$ret->{'deps'} = \@packdeps;
$ret->{'prereqs'} = \@prereqs if @prereqs;
$ret->{'fromhost'} = \@fromhost if @fromhost;
$ret->{'onlynative'} = \@onlynative if @onlynative;
$ret->{'alsonative'} = \@alsonative if @alsonative;
$ret->{'configdependent'} = 1 if $ifdeps;
return $ret;
}
Expand Down
26 changes: 18 additions & 8 deletions PBuild/Recipe.pm
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ sub parse {
my $version = defined($d->{'version'}) ? $d->{'version'} : 'unknown';
$p->{'version'} = $version;
$p->{'name'} = $d->{'name'};
$p->{'native'} = 1 if $d->{'nativebuild'};
$p->{'dep'} = $d->{'deps'};
$p->{'fromhost'} = $d->{'fromhost'} if $d->{'fromhost'};
$p->{'onlynative'} = $d->{'onlynative'} if $d->{'onlynative'};
$p->{'alsonative'} = $d->{'alsonative'} if $d->{'alsonative'};
if ($d->{'prereqs'}) {
my %deps = map {$_ => 1} (@{$d->{'deps'} || []}, @{$d->{'subpacks'} || []});
my @prereqs = grep {!$deps{$_} && !/^%/} @{$d->{'prereqs'}};
Expand Down Expand Up @@ -142,19 +144,27 @@ sub split_hostdeps {
return if $p->{'buildtype'} eq 'kiwi' || $p->{'buildtype'} eq 'docker' || $p->{'buildtype'} eq 'fissile';
return if $p->{'native'};
return unless @{$p->{'dep'} || []};
my %fromhost = map {$_ => 1} @{$bconf->{'fromhost'} || []};
for (@{$p->{'fromhost'} || []}) {
my %onlynative = map {$_ => 1} @{$bconf->{'onlynative'} || []};
my %alsonative = map {$_ => 1} @{$bconf->{'alsonative'} || []};
for (@{$p->{'onlynative'} || []}) {
if (/^!(.*)/) {
delete $fromhost{$1};
delete $onlynative{$1};
} else {
$fromhost{$_} = 1;
$onlynative{$_} = 1;
}
}
return unless %fromhost;
my @hdep = grep {$fromhost{$_}} @{$p->{'dep'}};
for (@{$p->{'alsonative'} || []}) {
if (/^!(.*)/) {
delete $alsonative{$1};
} else {
$alsonative{$_} = 1;
}
}
return unless %onlynative || %alsonative;
my @hdep = grep {$onlynative{$_} || $alsonative{$_}} @{$p->{'dep'}};
return unless @hdep;
$p->{'dep_host'} = \@hdep;
$p->{'dep'} = [ grep {!$fromhost{$_}} @{$p->{'dep'}}];
$p->{'dep'} = [ grep {!$onlynative{$_}} @{$p->{'dep'}}] if %onlynative;
}

1;
1 change: 0 additions & 1 deletion pbuild
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ PBuild::Multibuild::expand_multibuilds(\%pkgsrc);
my @pkgs_target = @pkgs;
my @pkgs_native;
if ($cross) {
$pkgsrc{$_}->{'native'} = 1 for grep {/^native-/} @pkgs;
@pkgs_target = grep {!$pkgsrc{$_}->{'native'}} @pkgs;
@pkgs_native = grep {$pkgsrc{$_}->{'native'}} @pkgs;
}
Expand Down

0 comments on commit 00e4922

Please sign in to comment.