Skip to content

Commit

Permalink
Merge pull request #11587 from mlschroe/master
Browse files Browse the repository at this point in the history
[backend] use macros defined in the modulemd data when parsing packages
  • Loading branch information
mlschroe committed Sep 8, 2021
2 parents b36fc16 + b5ebbc2 commit 652e612
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/backend/BSRepServer/BuildInfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ sub getmodulemddata {
push @args, "package=$buildinfo->{'modularity_package'}";
push @args, "srcmd5=$buildinfo->{'modularity_srcmd5'}";
push @args, "arch=$buildinfo->{'arch'}";
push @args, map {"module=$_"} @{$buildinfo->{'module'}};
push @args, map {"module=$_"} @{$buildinfo->{'module'} || []};
push @args, "modularityplatform=$buildinfo->{'modularity_platform'}";
push @args, "modularitylabel=$buildinfo->{'modularity_label'}";
push @args, "view=yaml";
Expand Down
2 changes: 1 addition & 1 deletion src/backend/BSRepServer/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ sub setup_modulemd {
my $modulemd = $pdata->{'modulemd'};
die("$modulemdpackid: not a modulemd package\n") unless $modulemd;
my $bconf = $ctx->{'conf'};
my $dependency = BSSched::Modulemd::select_dependency($bconf, $modulemd) || {};
my $dependency = BSSched::Modulemd::select_dependency($bconf, $modulemd);
die("cannot build this module\n") unless $dependency;
my $errors = BSSched::Modulemd::extend_modules($bconf, $dependency->{'buildrequires'} || []);
die(join(', ', @$errors)."\n") if $errors;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/BSSched/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ sub setup {
if ($pdatas->{'modulemd'} && $pdatas->{'modulemd'}->{'modulemd'}) {
my $pdata = $pdatas->{'modulemd'};
my $modulemd = $pdata->{'modulemd'};
my $dependency = BSSched::Modulemd::select_dependency($bconf, $modulemd) || {};
my $dependency = BSSched::Modulemd::select_dependency($bconf, $modulemd);
return ('broken', 'cannot build this module') unless $dependency;
my $errors = BSSched::Modulemd::extend_modules($bconf, $dependency->{'buildrequires'} || []);
return ('broken', join(', ', @$errors)) if $errors;
Expand Down
13 changes: 10 additions & 3 deletions src/backend/BSSrcServer/Modulemd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ sub parse_modulemd {
my $rd = {};
$rd->{'buildrequires'} = parse_deps($dd->{'buildrequires'}) if $dd->{'buildrequires'};
$rd->{'requires'} = parse_deps($dd->{'requires'}) if $dd->{'requires'};
push @{$r->{'dependency'}}, $rd if %$rd;
push @{$r->{'dependencies'}}, $rd if %$rd;
}
my $buildopts = $d->{'buildopts'};
if ($buildopts && ref($buildopts) eq 'HASH') {
Expand Down Expand Up @@ -113,7 +113,7 @@ sub tostream {
}
$md = $md->{'data'};
my ($versionprefix, $distprefix, @distprovides) = split(':', $modularityplatform);
my %distprovides = map {$_ => 1} @distprovides;
my %distprovides = map {$_ => $_} @distprovides;
for (@distprovides) {
$distprovides{"$1-*"} = $_ if /^(.*)-/;
}
Expand All @@ -133,7 +133,13 @@ sub tostream {
last unless $good;
}
next unless $good;
my @newbuildrequires;

# add modules data to provides
for (@{$modules || []}) {
$distprovides{$_} = $_;
$distprovides{"$1-*"} = $_ if /^(.*)-/;
}

my %brmap;
for my $br (@$buildrequires) {
my ($n, @v) = split(':', $br);
Expand Down Expand Up @@ -166,6 +172,7 @@ sub tostream {
my ($n, @v) = split(':', $_);
$newdeps->{'buildrequires'}->{$n} = \@v;
}
last;
}
die("could not select dependency block\n") unless $newdeps;
$md->{'dependencies'} = [ $newdeps ];
Expand Down
2 changes: 1 addition & 1 deletion src/backend/BSXML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ our $modulemd = [
'distindex',
[],
'macros',
[[ 'dependency' =>
[[ 'dependencies' =>
[ 'buildrequires' ],
[ 'requires' ],
]],
Expand Down
30 changes: 25 additions & 5 deletions src/backend/bs_srcserver
Original file line number Diff line number Diff line change
Expand Up @@ -1290,13 +1290,27 @@ sub getprojpack {
}
}

if ($cgi->{'buildinfo'} && @packages && !grep {$_ eq 'modulemd'} @packages) {
if (readpackage($projid, $proj, 'modulemd', undef, 1)) {
push @packages, 'modulemd';
$packids->{'modulemd'} = 1 if $packids;
# check if we have modulemd data
my $modulemd_packid;
my $modulemd_macros;
if (@packages) {
if (!$cgi->{'package'}) {
$modulemd_packid = 'modulemd' if grep {$_ eq 'modulemd'} @packages;
} else {
$modulemd_packid = 'modulemd' if readpackage($projid, $proj, 'modulemd', undef, 1);
if ($modulemd_packid && !grep {$_ eq $modulemd_packid} @packages) {
push @packages, $modulemd_packid;
$packids->{$modulemd_packid} = 1 if $packids;
}
}
}

# bring modulemd packages to the front (we need to parse them early)
if ($modulemd_packid && @packages && $packages[0] ne $modulemd_packid) {
@packages = grep {$_ ne $modulemd_packid} @packages;
unshift @packages, $modulemd_packid;
}

my %packages_multibuild;
for my $packid (@packages) {
next unless $packid =~ /(?<!^_product)(?<!^_patchinfo):./ && $packid =~ /^(.*):/;
Expand Down Expand Up @@ -1608,6 +1622,7 @@ sub getprojpack {
$pinfo->{'error'} = "_modulemd.yaml: $err";
next;
}
$modulemd_macros = $d->{'macros'} if $packid eq $modulemd_packid;
$pinfo->{'modulemd'} = $d;
next;
} elsif ($cgi->{'withdeps'}) {
Expand Down Expand Up @@ -1650,6 +1665,7 @@ sub getprojpack {
eval {
die($path) unless ref $path;
my $c = concatconfigs($projid, $repoid, $remotemap, @$path);
$c = Build::combine_configs($c, "Macros:\n$modulemd_macros") if $modulemd_macros;
$bconfs{$repoid} = Build::read_config($arch, [ split("\n", $c) ]);
};
if ($@) {
Expand Down Expand Up @@ -1685,6 +1701,7 @@ sub getprojpack {
if (!$bconfs{"$repoid/$arch"}) {
eval {
my $c = concatconfigs($projid, $repoid, $remotemap, @$path);
$c = Build::combine_configs($c, "Macros:\n$modulemd_macros") if $modulemd_macros;
$bconfs{"$repoid/$arch"} = Build::read_config($arch, [ split("\n", $c) ]);
};
if ($@) {
Expand Down Expand Up @@ -1837,6 +1854,9 @@ sub getprojpack {
}
}
}
if ($cgi->{'buildinfo'} && $modulemd_packid && $cgi->{'package'} && $cgi->{'package'}->[0] ne $modulemd_packid) {
push @pinfo, shift @pinfo if @pinfo && $pinfo[0]->{'name'} eq $modulemd_packid;
}
$jinfo->{'package'} = \@pinfo;
push @res, $jinfo;
}
Expand Down Expand Up @@ -5896,7 +5916,7 @@ sub getmodulemd {
my $mds = BSSrcServer::Modulemd::read_modulemds($yaml);
for my $md (@$mds) {
next unless $md->{'document'} eq 'modulemd';
BSSrcServer::Modulemd::tostream($md, $cgi->{'modules'} || [], $cgi->{'modularitylabel'}, $cgi->{'modularityplatform'});
BSSrcServer::Modulemd::tostream($md, $cgi->{'module'} || [], $cgi->{'modularitylabel'}, $cgi->{'modularityplatform'});
$md->{'data'}->{'arch'} = $cgi->{'arch'} if $cgi->{'arch'};
}
my $view = $cgi->{'view'} || 'storable';
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bs_worker
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ sub getmodulemddata {
my ($buildinfo, $dir) = @_;
my $server = $buildinfo->{'srcserver'} || $srcserver;
my @args;
push @args, map {"module=$_"} @{$buildinfo->{'module'}};
push @args, map {"module=$_"} @{$buildinfo->{'module'} || []};
push @args, "modularityplatform=$buildinfo->{'modularity_platform'}";
push @args, "modularitylabel=$buildinfo->{'modularity_label'}";
my $mds = BSRPC::rpc({
Expand Down

0 comments on commit 652e612

Please sign in to comment.