Skip to content

Commit

Permalink
pbuils: do not set the location element in the OBS gbininfo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mlschroe committed Feb 5, 2024
1 parent 1e39199 commit dd4ae49
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
12 changes: 6 additions & 6 deletions PBuild/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -322,17 +322,17 @@ sub genmeta_product {
my @new_meta;
for my $bin (@$edeps) {
die("bad binary in genmeta_product (not a hash)\n") unless ref($bin) eq 'HASH';
my $name = $bin->{'filename'};
my $package = $bin->{'packid'};
my $fn = $bin->{'filename'};
if (!$package) {
die("bad binary in genmeta_product (bad location)\n") unless $bin->{'location'} =~ /\/([^\/]+)\/([^\/]+)$/;
$package = $1;
$name = $2;
die("bad binary in genmeta_product (bad data)\n") unless $bin->{'package'} && $bin->{'fn'};
$package = $bin->{'package'};
$fn = $bin->{'fn'};
}
if ($bin->{'hdrmd5'}) {
push @new_meta, "$bin->{'hdrmd5'} $package/$name";
push @new_meta, "$bin->{'hdrmd5'} $package/$fn";
} elsif ($bin->{'md5sum'}) {
push @new_meta, "$bin->{'md5sum'} $package/$name";
push @new_meta, "$bin->{'md5sum'} $package/$fn";
} else {
die("bad binary in genmeta_product (no hrdmd5/md5sum)\n");
}
Expand Down
39 changes: 20 additions & 19 deletions PBuild/OBS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,13 @@ sub fetch_repodata {
}
my @bins = grep {ref($_) eq 'HASH' && defined($_->{'name'})} values %{$rdata || {}};
for (@bins) {
if ($_->{'path'} =~ /^\.\.\/([^\/\.][^\/]*\/[^\/\.][^\/]*)$/s) {
$_->{'location'} = "${baseurl}build/$prp/$arch/$1"; # obsbinlink to package
my $path = $_->{'path'};
if ($path =~ /^\.\.\/([^\/\.][^\/]*\/[^\/\.][^\/]*)$/s) {
$_->{'location'} = "${baseurl}build/$prp/$arch/".PBuild::Util::urlencode($1); # obsbinlink to package
} elsif ($path =~ /([\000-\040<>;\"#\?&\+=%[\177-\377])/s) {
$_->{'location'} = "${baseurl}build/$prp/$arch/_repository/".PBuild::Util::urlencode($path);
} else {
$_->{'location'} = "${baseurl}build/$prp/$arch/_repository/$_->{'path'}";
$_->{'location'} = "${baseurl}build/$prp/$arch/_repository/$path";
}
recode_deps($_); # recode deps from testcase format to rpm
}
Expand Down Expand Up @@ -407,11 +410,6 @@ sub fetch_gbininfo {
$bin->{'hdrmd5'} = $binary->{'hdrmd5'} if $binary->{'hdrmd5'};
$bin->{'leadsigmd5'} = $binary->{'leadsigmd5'} if $binary->{'leadsigmd5'};
$bin->{'md5sum'} = $binary->{'md5sum'} if $binary->{'md5sum'};
if ($filename =~ /([\000-\040<>;\"#\?&\+=%[\177-\377])/s) {
$bin->{'location'} = $location . PBuild::Util::urlencode($filename);
} else {
$bin->{'location'} = $location . $filename;
}
$bins{$filename} = $bin;
}
$gbininfo->{$binaryversionlist->{'package'}} = \%bins;
Expand Down Expand Up @@ -456,30 +454,33 @@ sub fetch_productbinaries_cpioextract {
}

sub fetch_productbinaries {
my ($url, $repodir, $bins, $callback) = @_;
my ($url, $arch, $opts, $repodir, $bins, $callback) = @_;
die("bad obs: reference\n") unless $url =~ /^obs:\/{1,3}([^\/]+\/[^\/]+)(?:\/([^\/]*))?$/;
my $prp = $1;
$arch = $2 if $2;
die("please specify the build service url with the --obs option\n") unless $opts->{'obs'};
my $baseurl = $opts->{'obs'};
$baseurl .= '/' unless $baseurl =~ /\/$/;
$baseurl .= "build/$prp/$arch/";
# group by package
my %packages;
my $location;
for my $bin (@$bins) {
my $l = $bin->{'location'};
die("fetch_productbinaries: missing location\n") unless $l;
die("fetch_productbinaries: bad location $l\n") unless $l =~ /^(.+)\/([^\/]+)\/([^\/]+)$/;
$location = $1 unless defined $location;
die("fetch_productbinaries: location conflict\n") unless $1 eq $location;
$packages{$bin->{'package'}}->{$bin->{'fn'}} = $bin;
}
$packages{$_->{'package'}}->{$_->{'fn'}} = $_ for @$bins;
my $ua = create_ua();
for my $packid (sort keys %packages) {
my $files = $packages{$packid};
die unless %$files;
#print "downloading ".keys(%$files). " artifacts from $packid\n";
my $requrl = "$location/".PBuild::Util::urlencode($packid).'?view=cpio';
my $requrl = $baseurl.PBuild::Util::urlencode($packid).'?view=cpio';
$requrl .= "&binary=".PBuild::Util::urlencode($_, 1) for sort keys %$files;
my $tmpcpio = "$repodir/.$$.binaries.cpio";
Build::Download::download($requrl, $tmpcpio, undef, 'ua' => $ua, 'retry' => 3);
PBuild::Cpio::cpio_extract($tmpcpio, sub {fetch_productbinaries_cpioextract($_[0], $_[1], $repodir, $packid, $files, $callback)});
unlink($tmpcpio);
}
# set location for all the binaries we missed
for my $bin (@$bins) {
$bin->{'location'} = $baseurl.PBuild::Util::urlencode("$bin->{'package'}/$bin->{'fn'}") unless $bin->{'filename'};
}
return $ua;
}

Expand Down
6 changes: 3 additions & 3 deletions PBuild/RemoteRepo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ sub fetchproductbinaries {
my $repodir = $meta->{'repodir'};
PBuild::Util::mkdir_p("$repodir/_gbins");
my $ua;
$ua = PBuild::OBS::fetch_productbinaries($meta->{'url'}, $repodir, $bins, \&fetchproductbinaries_replace);
$ua = PBuild::OBS::fetch_productbinaries($meta->{'url'}, $meta->{'arch'}, $meta->{'opts'}, $repodir, $bins, \&fetchproductbinaries_replace);
for my $bin (@$bins) {
next if $bin->{'filename'};
my $location = $bin->{'location'};
Expand Down Expand Up @@ -687,7 +687,7 @@ sub fetch_gbininfo {
undef $oldmetadata unless $oldmetadata && ref($oldmetadata) eq 'HASH' && $oldmetadata->{'gbininfo'};
$oldmetadata = undef if $oldmetadata && !replace_with_local_gbininfo($repodir, $oldmetadata->{'gbininfo'});
if ($oldmetadata && $opts->{'no-repo-refresh'}) {
my $meta = { 'metadata' => $oldmetadata, 'repodir' => $repodir, 'url' => $url, 'repotype' => $repotype};
my $meta = { 'metadata' => $oldmetadata, 'repodir' => $repodir, 'url' => $url, 'repotype' => $repotype, 'arch' => $arch, 'opts' => $opts};
return ($oldmetadata->{'gbininfo'}, $meta);
}
# fetch new meta data
Expand All @@ -705,7 +705,7 @@ sub fetch_gbininfo {
replace_with_local_gbininfo($repodir, $metadata->{'gbininfo'}, $oldgbininfo) || die("replace_with_local_gbininfo failed\n");
}
# store new meta data
my $meta = { 'metadata' => $metadata, 'repodir' => $repodir, 'url' => $url, 'repotype' => $repotype};
my $meta = { 'metadata' => $metadata, 'repodir' => $repodir, 'url' => $url, 'repotype' => $repotype, 'arch' => $arch, 'opts' => $opts};
PBuild::Util::store("$repodir/._gbininfo.$$", "$repodir/_gbininfo", $meta->{'metadata'});
return ($metadata->{'gbininfo'}, $meta);
}
Expand Down

0 comments on commit dd4ae49

Please sign in to comment.