From: Iain Arnell <iarnell@epo.org> This patch adds support for patterns to standard yum-based distros such as Fedora, Red Hat, and CentOS. Once applied, setting Patterntype to 'comps' in prjconf will enable generation of groups.xml file and allow users of these distros to "yum groupinstall <patternname>". --- src/backend/BSXML.pm | 23 +++++++++++++++++ src/backend/bs_publish | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 0 deletions(-) diff --git a/src/backend/BSXML.pm b/src/backend/BSXML.pm index 8630f29..7e745ab 100644 --- a/src/backend/BSXML.pm +++ b/src/backend/BSXML.pm @@ -988,5 +988,28 @@ our $person = [ ], ]; +our $comps = [ + 'comps' => + [], + [[ 'group' => + [], + 'id', + [[ 'description' => + 'xml:lang', + '_content', + ]], + [[ 'name' => + 'xml:lang', + '_content', + ]], + [ 'packagelist' => + [[ 'packagereq' => + 'type', + [], + '_content', + ]], + ], + ]], +]; 1; diff --git a/src/backend/bs_publish b/src/backend/bs_publish index 15f8bf1..fbd5fb3 100755 --- a/src/backend/bs_publish +++ b/src/backend/bs_publish @@ -525,6 +525,64 @@ sub deletepatterns_rpmmd { } } +sub createpatterns_comps { + my ($extrep, $projid, $repoid, $signargs, $pubkey, $repoinfo, $patterns) = @_; + + deletepatterns_comps($extrep); + return unless @{$patterns || []}; + + # create comps data structure + my @grps; + for my $pattern (@$patterns) { + my $pat = XMLin($BSXML::pattern, $pattern->{'data'}); + (my $name = $pattern->{name}) =~ s/\.xml$//; + my $grp = { + id => $name, + }; + for ( @{$pat->{summary}} ) { + my $el = { '_content' => $_->{_content} }; + $el->{'xml:lang'} = $_->{lang} if $_->{lang}; + push @{$grp->{name}}, $el; + } + for ( @{$pat->{description}} ) { + my $el = { '_content' => $_->{_content} }; + $el->{'xml:lang'} = $_->{lang} if $_->{lang}; + push @{$grp->{description}}, $el; + } + for ( @{ $pat->{'rpm:requires'}->{'rpm:entry'} } ) { + push @{ $grp->{packagelist}->{packagereq} }, { _content => $_->{name}, type => 'mandatory' }; + } + for ( @{ $pat->{'rpm:recommends'}->{'rpm:entry'} } ) { + push @{ $grp->{packagelist}->{packagereq} }, { _content => $_->{name}, type => 'default' }; + } + for ( @{ $pat->{'rpm:suggests'}->{'rpm:entry'} } ) { + push @{ $grp->{packagelist}->{packagereq} }, { _content => $_->{name}, type => 'optional' }; + } + push @grps, $grp; + } + print " adding comps to repodata\n"; + my $comps = {'group' => \@grps}; + writexml("$extrep/repodata/group.xml", undef, $comps, $BSXML::comps); + qsystem('modifyrepo', "$extrep/repodata/group.xml", "$extrep/repodata") && print(" modifyrepo failed: $?\n"); + unlink("$extrep/repodata/group.xml"); + + # re-sign changed repomd.xml file + if ($BSConfig::sign && -e "$extrep/repodata/repomd.xml") { + my @signargs; + push @signargs, '--project', $projid if $BSConfig::sign_project; + push @signargs, @$signargs; + qsystem($BSConfig::sign, @signargs, '-d', "$extrep/repodata/repomd.xml") && print(" sign failed: $?\n"); + } +} + +sub deletepatterns_comps { + my ($extrep) = @_; + for my $pat (ls("$extrep/repodata")) { + next unless $pat =~ /^group/; + unlink("$extrep/repodata/$pat"); + } +} + sub createpatterns_ymp { my ($extrep, $projid, $repoid, $signargs, $pubkey, $repoinfo, $patterns) = @_; @@ -1086,6 +1144,11 @@ sub publish { } else { deletepatterns_rpmmd($extrep, $projid, $repoid, $signargs, $pubkey); } + if ($patterntype{'comps'}) { + createpatterns_comps($extrep, $projid, $repoid, $signargs, $pubkey, $repoinfo, $patterns); + } else { + deletepatterns_comps($extrep, $projid, $repoid, $signargs, $pubkey); + } publishprog_done: unlink("$uploaddir/publisher.$$") if $signkey; -- 1.6.6.1 -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org