Skip to content

Commit

Permalink
Cleanup repo code, support "empty:" urls for repo/dist
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Feb 25, 2021
1 parent 5f02a4c commit ae2035d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 0 additions & 2 deletions PBuild/Expand.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ sub configure_repos {
# code in expanddeps!
for my $repo (@$repos) {
my $bins = $repo->{'bins'} || [];
my $repono = $repo->{'repono'};
for my $bin (@$bins) {
my $n = $bin->{'name'};
next if $packs_done{$n};
Expand All @@ -62,7 +61,6 @@ sub configure_repos {
next if ($oarch eq 'noarch' || $arch ne 'noarch') && $oarch cmp $arch >= 0;
}
}
$bin->{'repono'} = $repono;
$packs{$n} = $bin;
}
%packs_done = %packs;
Expand Down
8 changes: 2 additions & 6 deletions PBuild/RemoteRepo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,10 @@ sub fetchbinaries {
die("downloaded binary $binname does not match repository metadata\n") unless is_matching_binary($bin, $q);
rename("$repodir/$tmpname", "$repodir/$binname") || die("rename $repodir/$tmpname $repodir/$binname\n");
$q->{'filename'} = $binname;
# inline replace!
$q->{'repono'} = $bin->{'repono'} if defined $bin->{'repono'};
%$bin = %$q;
%$bin = %$q; # inline replace!
}
# update _metadata
my $newbins = PBuild::Util::clone($repo->{'bins'});
delete $_->{'repono'} for @$newbins;
PBuild::Util::store("$repodir/._metadata.$$", "$repodir/_metadata", $newbins);
PBuild::Util::store("$repodir/._metadata.$$", "$repodir/_metadata", $repo->{'bins'});
}

1;
13 changes: 13 additions & 0 deletions PBuild/RepoMgr.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ sub create {
#
sub addremoterepo {
my ($repos, $bconf, $myarch, $builddir, $repourl, $buildtype, $opts) = @_;
return addemptyrepo($repos) if $repourl =~ /^empty:/;
my $id = Digest::MD5::md5_hex($repourl);
return $repos->{$id} if $repos->{$id};
my $repodir = "$builddir/.pbuild/_base/$id";
Expand Down Expand Up @@ -80,6 +81,18 @@ sub addlocalrepo {
return $repo;
}

#
# Add an emptt repository to the manager
#
sub addemptyrepo {
my ($repos) = @_;
my $id = 'empty';
return $repos->{$id} if $repos->{$id};
my $repo = { 'bins' => [], 'type' => 'empty', 'repoid' => $id };
$repos->{$id} = $repo;
return $repo;
}

#
# Update the local reposiory with new binary data
#
Expand Down
2 changes: 2 additions & 0 deletions pbuild
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ for my $dist (@{$opts->{'dist'} || []}) {
my ($obsconfigs, $obsrepos) = PBuild::OBS::fetch_all_configs($dist, $opts, $islast);
push @baseconfigs, reverse @$obsconfigs;
push @baseobsrepos, @$obsrepos;
} elsif ($dist =~ /^empty:/) {
next;
} elsif (-e "$dir/_configs/$opts->{'dist'}.conf") {
push @baseconfigs, PBuild::Util::readstr("$dir/_configs/$dist.conf");
} else {
Expand Down

0 comments on commit ae2035d

Please sign in to comment.