Skip to content

Commit

Permalink
[backend] use macros defined in the modulemd data when parsing packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Sep 7, 2021
1 parent 9837301 commit a0d4002
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 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

0 comments on commit a0d4002

Please sign in to comment.