Skip to content

Commit

Permalink
Merge pull request #5172 from mlschroe/master
Browse files Browse the repository at this point in the history
Fix container building and other changes
  • Loading branch information
mlschroe committed Jun 21, 2018
2 parents 2b05d09 + dc49b99 commit 3e40561
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/backend/BSTar.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ my @headnames = qw{name mode uid gid size mtime chksum tartype linkname magic ve

sub parsetarhead {
my ($tarhead) = @_;
my @head = unpack('A100A8A8A8A12A12A8A1A100a6a2A32A32A8A8A155x12', $tarhead);
/^([^\0]*)/ && ($_ = $1) for @head;
$head[7] = '0' if $head[7] eq '';
my @head = unpack('A100A8A8A8A12A12A8a1A100a6a2A32A32A8A8A155x12', $tarhead);
/^([^\0]*)/s && ($_ = $1) for @head;
$head[7] = '0' if $head[7] eq ''; # map old \0 type to 0
$head[$_] = oct($head[$_]) for (1, 2, 3, 5, 6, 13, 14);
my $pad;
if (substr($tarhead, 124, 1) eq "\x80") {
Expand Down
40 changes: 30 additions & 10 deletions src/backend/bs_repserver
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use Data::Dumper;
use Digest::MD5 ();
use List::Util;
use Symbol;
use Encode;

use BSConfiguration;
use BSRPC ':https';
Expand Down Expand Up @@ -537,9 +538,31 @@ sub processavailable {
return \@res;
}

sub utf8_off {
my ($x) = @_;
return undef unless defined($x);
my $r = ref($x);
if ($r eq '') {
Encode::_utf8_off($x);
return $x;
} elsif ($r eq 'ARRAY') {
return [ map { utf8_off($_) } @$x ];
} elsif ($r eq 'HASH') {
my %h;
for my $k (keys %$x) {
Encode::_utf8_off($k);
$h{$k} = utf8_off($x->{$k});
}
return \%h;
} else {
return $x; # hope for the best
}
}

sub export_annotation {
my ($annotation_xml) = @_;
my $annotation = BSUtil::fromxml($annotation_xml, $BSXML::binannotation, 1);
$annotation = utf8_off($annotation); # work around XML::Structured bug
return $annotation unless $annotation && $annotation->{'repo'};
# map repositories
for my $r (@{$annotation->{'repo'}}) {
Expand Down Expand Up @@ -809,17 +832,14 @@ sub getbinarylist_repository {
my $n = $bin;
if ($bin =~ /^container:/ && $path =~ /(\.tar(?:\..+)?)$/) {
$n .= $1;
if ($1 eq '.tar' && ! -e $path) {
my @s = BSRepServer::Containertar::stat_container($path);
if (@s) {
my $r = {'filename' => $view eq 'names' ? $n : $path, 'mtime' => $s[9], 'size' => $s[7] };
push @res, $r;
next;
}
}
} else {
$n .= ".$1" if $path =~ /\.($binsufsre)$/;
my $r = {'filename' => $view eq 'names' ? $n : $path };
my @s = stat("$reporoot/$prp/$arch/:full/$path");
@s = BSRepServer::Containertar::stat_container("$reporoot/$prp/$arch/:full/$path") if $1 eq '.tar' && !@s;
($r->{'mtime'}, $r->{'size'}) = ($s[9], $s[7]) if @s;
push @res, $r;
next;
}
$n .= ".$1" if $path =~ /\.($binsufsre)$/;
my $r = {'filename' => $view eq 'names' ? $n : $path };
my $id = $pool->pkg2bsid($p);
if ($id && $bin !~ /^container:/) {
Expand Down
11 changes: 9 additions & 2 deletions src/backend/bs_srcserver
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,15 @@ sub getprojpack {
}
}
if ($BSConfig::limit_projects && $BSConfig::limit_projects->{$arch}) {
my %limit_projids = map {$_ => 1} @{$BSConfig::limit_projects->{$arch}};
$projids = [ grep {$limit_projids{$_}} @$projids ];
my $limit = $BSConfig::limit_projects->{$arch};
if ($BSConfig::limit_projects_use_regex || $BSConfig::limit_projects_use_regex) {
for my $projid (splice @$projids) {
push @$projids, $projid if grep {$projid =~ /^$_$/} @$limit;
}
} else {
my %limit_projids = map {$_ => 1} @$limit;
$projids = [ grep {$limit_projids{$_}} @$projids ];
}
}
$repoids = { map {$_ => 1} @$repoids } if $repoids;
$packids = { map {$_ => 1} @$packids } if $packids;
Expand Down

0 comments on commit 3e40561

Please sign in to comment.