Skip to content

Commit

Permalink
Merge pull request #11602 from mlschroe/master
Browse files Browse the repository at this point in the history
[backend] module builds: make sure that no selected modules conflict
  • Loading branch information
mlschroe committed Sep 13, 2021
2 parents e400f08 + 6160079 commit bec6330
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/backend/BSSched/Modulemd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -87,36 +87,47 @@ sub select_dependency {
return undef;
}

sub check_conflicting_modules {
my ($bconf) = @_;
return undef unless @{$bconf->{'modules'} || []} > 1;
my %modules = map {$_ => 1} @{$bconf->{'modules'} || []};
my %streams;
for (sort keys %modules) {
push @{$streams{$1}}, $_ if /^(.*)-/;
}
my @errors;
for (sort keys %streams) {
push @errors, "conflicting module streams for $_: ".join(" | ", @{$streams{$_}}) if @{$streams{$_}} > 1;
}
return @errors ? \@errors : undef;
}

sub extend_modules {
my ($bconf, $buildrequires) = @_;
my $pfdata = $bconf->{'buildflags:modulemdplatform'};
return [ "buildflags:modulemdplatform is not set" ] unless $pfdata;
my ($versionprefix, $distprefix, @distprovides) = split(':', $pfdata);
my %distprovides = map {$_ => 1} @distprovides;
my @needed;
my @have = @{$bconf->{'modules'} || []};
push @have, @distprovides;
my @errors = @{ check_conflicting_modules($bconf) || [] };
my @have = (@{$bconf->{'modules'} || []}, @distprovides);
my %have = map {$_ => 1} @have;
my @errors;
for (@have) {
$have{"$1-*"} = $_ if /^(.*)-/;
}
my @ambiguous;
my @needed;
for my $br (@{$buildrequires || []}) {
my ($n, @v) = split(':', $br);
next if $n =~ /^-/;
next if @v && grep {$have{"$n-$_"}} @v;
if ($have{"$n-*"}) {
next if !@v || grep {$have{"$n-$_"}} @v;
next if !@v; # just need any version
push @errors, "modulemd requires ".join(" | ", map {"$n-$_"} @v)." instead of ".$have{"$n-*"};
next;
}
next if @v && grep {$have{"$n-$_"}} @v;
if (@v == 1) {
push @needed, "$n-$v[0]";
next;
}
if (!@v) {
push @errors, "modulemd requires any stream version of $n";
} elsif (@v == 1) {
push @needed, "$n-$v[0]";
} else {
push @errors, "modulemd requires ".join(" | ", map {"$n-$_"} @v);
}
Expand Down

0 comments on commit bec6330

Please sign in to comment.