Skip to content

Commit

Permalink
Support artifact-less modulemd data
Browse files Browse the repository at this point in the history
We do no filtering for those.
  • Loading branch information
mlschroe committed Sep 27, 2021
1 parent 8a7e645 commit e179006
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions writemodulemd
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,19 @@ if (@ARGV && $ARGV[0] eq '--filter') {
$outmds{$ns} = $md;
next;
}
# check if we have this md in the rpms
next unless $mdd->{'artifacts'};
my @have = grep {exists $rpms{$_}} @{$mdd->{'artifacts'} && $mdd->{'artifacts'}->{'rpms'} || []};
next unless @have;
my @have;
if ($mdd->{'artifacts'}) {
# check if we have this md in the rpms
@have = grep {exists $rpms{$_}} @{$mdd->{'artifacts'} && $mdd->{'artifacts'}->{'rpms'} || []};
next unless @have;
}

# filter artifacts and licenses
my %licenses;
for (@have) {
$licenses{$rpms{$_}} = 1 if defined $rpms{$_};
}
$mdd->{'artifacts'}->{'rpms'} = \@have;
$mdd->{'artifacts'}->{'rpms'} = \@have if @have;
delete $mdd->{'license'}->{'content'} if $mdd->{'license'} && $mdd->{'license'}->{'content'};
$mdd->{'license'}->{'content'} = [ sort keys %licenses ] if %licenses;

Expand All @@ -139,10 +141,16 @@ if (@ARGV && $ARGV[0] eq '--filter') {
# merge with existing entry
my $omdd = $omd->{'data'};
($md, $omd, $mdd, $omdd) = ($omd, $md, $omdd, $mdd) if $omdd->{'version'} > $mdd->{'version'};
$mdd->{'artifacts'}->{'rpms'} = unifyandsort(@{$mdd->{'artifacts'}->{'rpms'}}, @{$omdd->{'artifacts'}->{'rpms'}});
my $licenses = unifyandsort(@{$mdd->{'license'}->{'content'}}, @{$omdd->{'license'}->{'content'}});
delete $mdd->{'license'}->{'content'};
$mdd->{'license'}->{'content'} = $licenses if @$licenses;
if ($mdd->{'artifacts'} || $omdd->{'artifacts'}) {
my $artifacts = unifyandsort(@{$mdd->{'artifacts'}->{'rpms'} || []}, @{$omdd->{'artifacts'}->{'rpms'} || []});
delete $mdd->{'artifacts'}->{'rpms'};
$mdd->{'artifacts'}->{'rpms'} = $artifacts if @$artifacts;
}
if ($mdd->{'license'} || $omdd->{'license'}) {
my $licenses = unifyandsort(@{$mdd->{'license'}->{'content'} || []}, @{$omdd->{'license'}->{'content'} || []});
delete $mdd->{'license'}->{'content'};
$mdd->{'license'}->{'content'} = $licenses if @$licenses;
}
}
$outmds{$nsca} = $md;
}
Expand Down

0 comments on commit e179006

Please sign in to comment.