2021-03-25 10:27:58 +00:00
|
|
|
package modularity;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use base 'Exporter';
|
|
|
|
use Exporter;
|
|
|
|
use lockapi;
|
|
|
|
use testapi;
|
|
|
|
use utils;
|
|
|
|
|
|
|
|
our @EXPORT = qw(parse_module_list is_listed);
|
|
|
|
|
|
|
|
# This subroutine takes the output from the dnf module list command
|
2023-02-12 22:59:37 +00:00
|
|
|
# and deletes all unnecessary stuff and returns an array of hash
|
2021-03-25 10:27:58 +00:00
|
|
|
# references where each hash consists of (module, stream, profile).
|
|
|
|
# The subroutine only recognizes one profile but it is enough
|
|
|
|
# for the sake of the modularity testing.
|
|
|
|
|
|
|
|
sub parse_module_list {
|
|
|
|
my $output = shift;
|
|
|
|
my @output_lines = split(/\n/, $output);
|
|
|
|
my @parsed_list;
|
|
|
|
|
|
|
|
foreach my $line (@output_lines) {
|
|
|
|
my ($module, $stream, $profile) = split(/\s+/, $line);
|
2021-09-23 23:04:25 +00:00
|
|
|
unless ($module =~ /Rocky|Last|Hint|Name|^$/) {
|
2021-03-25 10:27:58 +00:00
|
|
|
$profile =~ s/,$//;
|
|
|
|
my %module = ("module" => $module, "stream" => $stream, "profile" => $profile);
|
|
|
|
push(@parsed_list, \%module);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return @parsed_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
# This subroutine iterates over the given list of module hashes and returns True
|
|
|
|
# if it finds it in the list.
|
|
|
|
sub is_listed {
|
|
|
|
my ($module, $stream, $listref) = @_;
|
|
|
|
my $found = 0;
|
2023-02-12 22:59:37 +00:00
|
|
|
foreach (@{$listref}) {
|
2021-03-25 10:27:58 +00:00
|
|
|
if ($_->{module} eq $module and $_->{stream} eq $stream) {
|
|
|
|
$found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $found;
|
|
|
|
}
|