Skip to content

Commit

Permalink
[backend] remove obsolete binary/pattern search routes
Browse files Browse the repository at this point in the history
We handle those in the source server since a couple of years.
  • Loading branch information
mlschroe committed Apr 26, 2022
1 parent 48f6ae4 commit 39a0b28
Showing 1 changed file with 0 additions and 122 deletions.
122 changes: 0 additions & 122 deletions src/backend/bs_repserver
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ use BSWatcher ':https';
use BSStdServer;
use BSXPath;
use BSXPathKeys;
use BSDB;
use BSDBIndex;
use BSNotify;
use BSUrlmapper;
use BSRegistryServer;
Expand Down Expand Up @@ -3576,124 +3574,6 @@ sub postrepo {
return {'value' => $v}, $BSXML::collection;
}

my %prp_to_repoinfo;

sub prp_to_repoinfo {
my ($prp) = @_;

my $repoinfo = $prp_to_repoinfo{$prp};
if (!$repoinfo) {
if (-s "$reporoot/$prp/:repoinfo") {
$repoinfo = BSUtil::retrieve("$reporoot/$prp/:repoinfo");
for (@{$repoinfo->{'prpsearchpath'} || []}) {
next if ref($_); # legacy
my ($p, $r) = split('/', $_, 2);
$_ = {'project' => $p, 'repository' => $r};
}
} else {
$repoinfo = {'binaryorigins' => {}};
}
$prp_to_repoinfo{$prp} = $repoinfo;
}
return $repoinfo;
}

sub binary_key_to_data {
my ($db, $key) = @_;
my @p = split('/', $key);
my $binary = pop(@p);
my $name = $binary;
my $version = '';
if ($name =~ s/-([^-]+-[^-]+)\.[^\.]+\.rpm$//) {
$version = $1;
} elsif ($name =~ s/_([^_]+)_[^_]+\.deb$//) {
$version = $1;
}
my $arch = pop(@p);
while (@p > 1 && $p[0] =~ /:$/) {
splice(@p, 0, 2, "$p[0]$p[1]");
}
my $project = shift(@p);
while (@p > 1 && $p[0] =~ /:$/) {
splice(@p, 0, 2, "$p[0]$p[1]");
}
my $repository = shift(@p);
my $prp = "$project/$repository";
my $repoinfo = $prp_to_repoinfo{$prp} || prp_to_repoinfo($prp);
my $type;
$type = 'rpm' if $binary =~ /\.rpm$/;
$type = 'deb' if $binary =~ /\.deb$/;
my $res = {
'name' => $name,
'version' => $version,
'arch' => $arch,
'type' => $type,
'project' => $project,
'repository' => $repository,
'filename' => $binary,
'filepath' => $key,
};
$res->{'path'} = $repoinfo->{'prpsearchpath'} if $repoinfo->{'prpsearchpath'};
$res->{'package'} = $repoinfo->{'binaryorigins'}->{"$arch/$binary"} if defined $repoinfo->{'binaryorigins'}->{"$arch/$binary"};
$res->{'baseproject'} = $res->{'path'}->[-1]->{'project'} if $res->{'path'};
return $res;
}

sub pattern_key_to_data {
my ($db, $key) = @_;
my @p = split('/', $key);
my $filename = pop(@p);
while (@p > 1 && $p[0] =~ /:$/) {
splice(@p, 0, 2, "$p[0]$p[1]");
}
my $project = shift(@p);
while (@p > 1 && $p[0] =~ /:$/) {
splice(@p, 0, 2, "$p[0]$p[1]");
}
my $repository = shift(@p);
my @v = BSDBIndex::getvalues($db, $db->{'table'}, $key);
return {} unless @v;
my $res = $v[0];
$res->{'baseproject'} = $res->{'path'}->[-1]->{'project'} if $res->{'path'};
$res->{'project'} = $project;
$res->{'repository'} = $repository;
$res->{'filename'} = $filename;
$res->{'filepath'} = $key;
return $res;
}

sub search_published_binary_id {
my ($cgi, $match) = @_;
my $binarydb = BSDB::opendb($extrepodb, 'binary');
$binarydb->{'allkeyspath'} = 'name';
$binarydb->{'noindex'} = {'arch' => 1, 'project' => 1, 'repository' => 1, 'package' => 1, 'type' => 1, 'path/project' => 1, 'path/repository' => 1};
$binarydb->{'fetch'} = \&binary_key_to_data;
$binarydb->{'cheapfetch'} = 1;
my $rootnode = BSXPathKeys::node($binarydb, '');
my $data = BSXPath::match($rootnode, $match) || [];
# epoch?
@$data = sort {Build::Rpm::verscmp($b->{'version'}, $a->{'version'}) || $a->{'name'} cmp $b->{'name'} || $a->{'arch'} cmp $b->{'arch'}} @$data;
delete $_->{'path'} for @$data;
my $res = {'binary' => $data};
return ($res, $BSXML::collection);
}

sub search_published_pattern_id {
my ($cgi, $match) = @_;
my $patterndb = BSDB::opendb($extrepodb, 'pattern');
$patterndb->{'noindex'} = {'project' => 1, 'repository' => 1};
$patterndb->{'fetch'} = \&pattern_key_to_data;
my $rootnode = BSXPathKeys::node($patterndb, '');
my $data = BSXPath::match($rootnode, $match) || [];
for (@$data) {
delete $_->{'path'};
delete $_->{'description'};
delete $_->{'summary'};
}
my $res = {'pattern' => $data};
return ($res, $BSXML::collection);
}

sub listpublished {
my ($dir, $fileok) = @_;
my @r;
Expand Down Expand Up @@ -4425,8 +4305,6 @@ my $dispatches = [
'/build/$project/$repository/$arch/$package:package_repository/$filename view:? module*' => \&getbinary,
'PUT:/build/$project/$repository/$arch/_repository/$filename ignoreolder:bool? wipe:bool?' => \&putbinary,
'DELETE:/build/$project/$repository/$arch/_repository/$filename' => \&delbinary,
'/search/published/binary/id $match:' => \&search_published_binary_id,
'/search/published/pattern/id $match:' => \&search_published_pattern_id,
'PUT:/build/_dispatchprios' => \&putdispatchprios,
'/build/_dispatchprios' => \&getdispatchprios,

Expand Down

0 comments on commit 39a0b28

Please sign in to comment.