Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend] module builds: make sure that no selected modules conflict #11602

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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