Skip to content

Commit

Permalink
[backend] support annotation extension in a compatible way
Browse files Browse the repository at this point in the history
We now export both the old limited xml annotation and the complete
annotation as perl data.
  • Loading branch information
mlschroe committed Jun 6, 2018
1 parent c9247d0 commit 9229594
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/backend/BSRepServer/Remote.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sub addrepo_remote {
delete $_->{'path'};
delete $_->{'id'};
# import annotations
$_->{'annotation'} = import_annotation($_->{'annotation'}) if $_->{'annotation'};
$_->{'annotation'} = import_annotation($_->{'annotationdata'} || $_->{'annotation'}) if $_->{'annotation'};
}
delete $cache->{'/external/'};
delete $cache->{'/url'};
Expand Down
2 changes: 1 addition & 1 deletion src/backend/BSSched/Remote.pm
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ sub addrepo_remote_unpackcpio {
delete $_->{'path'};
delete $_->{'id'};
# import annotations
$_->{'annotation'} = import_annotation($_->{'annotation'}) if $_->{'annotation'};
$_->{'annotation'} = import_annotation($_->{'annotationdata'} || $_->{'annotation'}) if $_->{'annotation'};
}
# add special "havedod" marker
$cache->{'/dodcookie'} = 'remote repository with dod packages' if $havedod;
Expand Down
21 changes: 17 additions & 4 deletions src/backend/bs_repserver
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ sub processavailable {
sub export_annotation {
my ($annotation_xml) = @_;
my $annotation = BSUtil::fromxml($annotation_xml, $BSXML::binannotation, 1);
return undef unless $annotation;
return $annotation_xml unless $annotation->{'repo'}; # nothing to map
return $annotation unless $annotation && $annotation->{'repo'};
# map repositories
for my $r (@{$annotation->{'repo'}}) {
my $url = $r->{'url'};
next unless $url;
Expand All @@ -553,7 +553,17 @@ sub export_annotation {
}
($r->{'project'}, $r->{'repository'}) = split('/', $urlprp, 2) if $urlprp;
}
return BSUtil::toxml($annotation, $BSXML::binannotation);
return $annotation;
}

# create legacy xml from annotation subset
sub create_legacy_annotation {
my ($annotation) = @_;
return undef unless $annotation;
my %a;
$a{'repo'} = $annotation->{'repo'} if $annotation->{'repo'};
$a{'disturl'} = $annotation->{'disturl'} if $annotation->{'disturl'};
return BSUtil::toxml(\%a, $BSXML::binannotation);
}

sub getbinarylist_repository {
Expand Down Expand Up @@ -642,7 +652,10 @@ sub getbinarylist_repository {
my %data = $repo->pkgnames();
for my $p (values %data) {
$p = $pool->pkg2data($p);
$p->{'annotation'} = export_annotation($p->{'annotation'}) if $p->{'annotation'};
if ($p->{'annotation'}) {
$p->{'annotationdata'} = export_annotation($p->{'annotation'});
$p->{'annotation'} = create_legacy_annotation($p->{'annotationdata'});
}
}
if (keys(%data) < 100 && $s[7] < 10000) {
# small repo, feed from memory
Expand Down

0 comments on commit 9229594

Please sign in to comment.