Skip to content

Commit dd4ae49

Browse files
committed
pbuils: do not set the location element in the OBS gbininfo
It is not needed and needs way too much space. We can generate it on the fly with the 'package' and 'fn' elements added by the Checker.
1 parent 1e39199 commit dd4ae49

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

PBuild/Checker.pm

+6-6
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,17 @@ sub genmeta_product {
322322
my @new_meta;
323323
for my $bin (@$edeps) {
324324
die("bad binary in genmeta_product (not a hash)\n") unless ref($bin) eq 'HASH';
325-
my $name = $bin->{'filename'};
326325
my $package = $bin->{'packid'};
326+
my $fn = $bin->{'filename'};
327327
if (!$package) {
328-
die("bad binary in genmeta_product (bad location)\n") unless $bin->{'location'} =~ /\/([^\/]+)\/([^\/]+)$/;
329-
$package = $1;
330-
$name = $2;
328+
die("bad binary in genmeta_product (bad data)\n") unless $bin->{'package'} && $bin->{'fn'};
329+
$package = $bin->{'package'};
330+
$fn = $bin->{'fn'};
331331
}
332332
if ($bin->{'hdrmd5'}) {
333-
push @new_meta, "$bin->{'hdrmd5'} $package/$name";
333+
push @new_meta, "$bin->{'hdrmd5'} $package/$fn";
334334
} elsif ($bin->{'md5sum'}) {
335-
push @new_meta, "$bin->{'md5sum'} $package/$name";
335+
push @new_meta, "$bin->{'md5sum'} $package/$fn";
336336
} else {
337337
die("bad binary in genmeta_product (no hrdmd5/md5sum)\n");
338338
}

PBuild/OBS.pm

+20-19
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,13 @@ sub fetch_repodata {
362362
}
363363
my @bins = grep {ref($_) eq 'HASH' && defined($_->{'name'})} values %{$rdata || {}};
364364
for (@bins) {
365-
if ($_->{'path'} =~ /^\.\.\/([^\/\.][^\/]*\/[^\/\.][^\/]*)$/s) {
366-
$_->{'location'} = "${baseurl}build/$prp/$arch/$1"; # obsbinlink to package
365+
my $path = $_->{'path'};
366+
if ($path =~ /^\.\.\/([^\/\.][^\/]*\/[^\/\.][^\/]*)$/s) {
367+
$_->{'location'} = "${baseurl}build/$prp/$arch/".PBuild::Util::urlencode($1); # obsbinlink to package
368+
} elsif ($path =~ /([\000-\040<>;\"#\?&\+=%[\177-\377])/s) {
369+
$_->{'location'} = "${baseurl}build/$prp/$arch/_repository/".PBuild::Util::urlencode($path);
367370
} else {
368-
$_->{'location'} = "${baseurl}build/$prp/$arch/_repository/$_->{'path'}";
371+
$_->{'location'} = "${baseurl}build/$prp/$arch/_repository/$path";
369372
}
370373
recode_deps($_); # recode deps from testcase format to rpm
371374
}
@@ -407,11 +410,6 @@ sub fetch_gbininfo {
407410
$bin->{'hdrmd5'} = $binary->{'hdrmd5'} if $binary->{'hdrmd5'};
408411
$bin->{'leadsigmd5'} = $binary->{'leadsigmd5'} if $binary->{'leadsigmd5'};
409412
$bin->{'md5sum'} = $binary->{'md5sum'} if $binary->{'md5sum'};
410-
if ($filename =~ /([\000-\040<>;\"#\?&\+=%[\177-\377])/s) {
411-
$bin->{'location'} = $location . PBuild::Util::urlencode($filename);
412-
} else {
413-
$bin->{'location'} = $location . $filename;
414-
}
415413
$bins{$filename} = $bin;
416414
}
417415
$gbininfo->{$binaryversionlist->{'package'}} = \%bins;
@@ -456,30 +454,33 @@ sub fetch_productbinaries_cpioextract {
456454
}
457455

458456
sub fetch_productbinaries {
459-
my ($url, $repodir, $bins, $callback) = @_;
457+
my ($url, $arch, $opts, $repodir, $bins, $callback) = @_;
458+
die("bad obs: reference\n") unless $url =~ /^obs:\/{1,3}([^\/]+\/[^\/]+)(?:\/([^\/]*))?$/;
459+
my $prp = $1;
460+
$arch = $2 if $2;
461+
die("please specify the build service url with the --obs option\n") unless $opts->{'obs'};
462+
my $baseurl = $opts->{'obs'};
463+
$baseurl .= '/' unless $baseurl =~ /\/$/;
464+
$baseurl .= "build/$prp/$arch/";
460465
# group by package
461466
my %packages;
462-
my $location;
463-
for my $bin (@$bins) {
464-
my $l = $bin->{'location'};
465-
die("fetch_productbinaries: missing location\n") unless $l;
466-
die("fetch_productbinaries: bad location $l\n") unless $l =~ /^(.+)\/([^\/]+)\/([^\/]+)$/;
467-
$location = $1 unless defined $location;
468-
die("fetch_productbinaries: location conflict\n") unless $1 eq $location;
469-
$packages{$bin->{'package'}}->{$bin->{'fn'}} = $bin;
470-
}
467+
$packages{$_->{'package'}}->{$_->{'fn'}} = $_ for @$bins;
471468
my $ua = create_ua();
472469
for my $packid (sort keys %packages) {
473470
my $files = $packages{$packid};
474471
die unless %$files;
475472
#print "downloading ".keys(%$files). " artifacts from $packid\n";
476-
my $requrl = "$location/".PBuild::Util::urlencode($packid).'?view=cpio';
473+
my $requrl = $baseurl.PBuild::Util::urlencode($packid).'?view=cpio';
477474
$requrl .= "&binary=".PBuild::Util::urlencode($_, 1) for sort keys %$files;
478475
my $tmpcpio = "$repodir/.$$.binaries.cpio";
479476
Build::Download::download($requrl, $tmpcpio, undef, 'ua' => $ua, 'retry' => 3);
480477
PBuild::Cpio::cpio_extract($tmpcpio, sub {fetch_productbinaries_cpioextract($_[0], $_[1], $repodir, $packid, $files, $callback)});
481478
unlink($tmpcpio);
482479
}
480+
# set location for all the binaries we missed
481+
for my $bin (@$bins) {
482+
$bin->{'location'} = $baseurl.PBuild::Util::urlencode("$bin->{'package'}/$bin->{'fn'}") unless $bin->{'filename'};
483+
}
483484
return $ua;
484485
}
485486

PBuild/RemoteRepo.pm

+3-3
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ sub fetchproductbinaries {
562562
my $repodir = $meta->{'repodir'};
563563
PBuild::Util::mkdir_p("$repodir/_gbins");
564564
my $ua;
565-
$ua = PBuild::OBS::fetch_productbinaries($meta->{'url'}, $repodir, $bins, \&fetchproductbinaries_replace);
565+
$ua = PBuild::OBS::fetch_productbinaries($meta->{'url'}, $meta->{'arch'}, $meta->{'opts'}, $repodir, $bins, \&fetchproductbinaries_replace);
566566
for my $bin (@$bins) {
567567
next if $bin->{'filename'};
568568
my $location = $bin->{'location'};
@@ -687,7 +687,7 @@ sub fetch_gbininfo {
687687
undef $oldmetadata unless $oldmetadata && ref($oldmetadata) eq 'HASH' && $oldmetadata->{'gbininfo'};
688688
$oldmetadata = undef if $oldmetadata && !replace_with_local_gbininfo($repodir, $oldmetadata->{'gbininfo'});
689689
if ($oldmetadata && $opts->{'no-repo-refresh'}) {
690-
my $meta = { 'metadata' => $oldmetadata, 'repodir' => $repodir, 'url' => $url, 'repotype' => $repotype};
690+
my $meta = { 'metadata' => $oldmetadata, 'repodir' => $repodir, 'url' => $url, 'repotype' => $repotype, 'arch' => $arch, 'opts' => $opts};
691691
return ($oldmetadata->{'gbininfo'}, $meta);
692692
}
693693
# fetch new meta data
@@ -705,7 +705,7 @@ sub fetch_gbininfo {
705705
replace_with_local_gbininfo($repodir, $metadata->{'gbininfo'}, $oldgbininfo) || die("replace_with_local_gbininfo failed\n");
706706
}
707707
# store new meta data
708-
my $meta = { 'metadata' => $metadata, 'repodir' => $repodir, 'url' => $url, 'repotype' => $repotype};
708+
my $meta = { 'metadata' => $metadata, 'repodir' => $repodir, 'url' => $url, 'repotype' => $repotype, 'arch' => $arch, 'opts' => $opts};
709709
PBuild::Util::store("$repodir/._gbininfo.$$", "$repodir/_gbininfo", $meta->{'metadata'});
710710
return ($metadata->{'gbininfo'}, $meta);
711711
}

0 commit comments

Comments
 (0)