Skip to content

Commit

Permalink
Add a updatelocalgbininfo RepoMgr method
Browse files Browse the repository at this point in the history
Also drop the builddir parameter, as it is part of the
repo data structure.
  • Loading branch information
mlschroe committed Oct 16, 2024
1 parent 3e5bdc9 commit 7eb09b4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
17 changes: 15 additions & 2 deletions PBuild/RepoMgr.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package PBuild::RepoMgr;
use strict;

use PBuild::Util;
use PBuild::LocalRepo;
use PBuild::RemoteRepo;
use PBuild::RemoteRegistry;
use PBuild::Verify;
Expand Down Expand Up @@ -99,11 +100,11 @@ sub addemptyrepo {
# Update the local reposiory with new binary data
#
sub updatelocalrepo {
my ($repos, $bconf, $myarch, $builddir, $pkgsrc, $pkgs) = @_;
my ($repos, $bconf, $myarch, $pkgsrc, $pkgs) = @_;
my $id = "$myarch/local";
my $repo = $repos->{$id};
die("local repo does not exist\n") unless $repo;
my $bins = PBuild::LocalRepo::fetchrepo($bconf, $myarch, $builddir, $pkgsrc, $pkgs);
my $bins = PBuild::LocalRepo::fetchrepo($bconf, $myarch, $repo->{'dir'}, $pkgsrc, $pkgs);
$_->{'repoid'} = $id for @$bins;
$repo->{'bins'} = $bins;
}
Expand Down Expand Up @@ -263,4 +264,16 @@ sub get_gbininfo {
return $gbininfo;
}

#
# Update the local reposiory with the artifact information of a succeeded build
#
sub updatelocalgbininfo {
my ($repos, $myarch, $pkg, $bininfo) = @_;
my $id = "$myarch/local";
my $repo = $repos->{$id};
die("local repo does not exist\n") unless $repo;
PBuild::LocalRepo::update_gbininfo($repo->{'dir'}, $pkg, $bininfo);
delete $repo->{'gbininfo'}; # flush our cache
}

1;
8 changes: 6 additions & 2 deletions PBuild/Result.pm
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ sub print_result {
return $found_failures;
}

sub has_failed_code {
my ($opts, $code) = @_;
return $code_failures{$code || 'unknown'} ? 1 : 0;
}

sub has_failed {
my ($opts, $builddir, $pkg) = @_;
my $r = PBuild::Util::retrieve("$builddir/.pbuild/_result", 1);
die("pbuild has not run yet for $builddir\n") unless $r;
my $code = $r->{$pkg}->{'code'} || 'unknown';
return $code_failures{$code} ? 1 : 0;
return has_failed_code($opts, $r->{$pkg}->{'code'});
}

1;
9 changes: 4 additions & 5 deletions pbuild
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ while (1) {
$details = ": $result->{$pkg}->{'details'}" if $result->{$pkg}->{'details'};
}
print "$pkg: $code$details\n";
exit($code eq 'broken' || $code eq 'failed' || $code eq 'unresolvable' ? 1 : 0);
exit PBuild::Result::has_failed_code($opts, $code);
}

# mix in old result from other packages if in single package mode
Expand Down Expand Up @@ -571,14 +571,13 @@ while (1) {

# if the build was successful, update artifact information and the local repo
if ($bininfo) {
PBuild::LocalRepo::update_gbininfo($builddir, $p->{'pkg'}, $bininfo);
delete $repos[0]->{'gbininfo'};
$repomgr->updatelocalgbininfo($myarch, $p->{'pkg'}, $bininfo);
if ($p->{'useforbuildenabled'}) {
# update with new local bin information
if ($p->{'native'}) {
$repomgr->updatelocalrepo($bconf, $hostarch, $builddir, \%pkgsrc, \@pkgs_native);
$repomgr->updatelocalrepo($bconf, $hostarch, \%pkgsrc, \@pkgs_native);
} else {
$repomgr->updatelocalrepo($bconf, $myarch, $builddir, \%pkgsrc, \@pkgs_target);
$repomgr->updatelocalrepo($bconf, $myarch, \%pkgsrc, \@pkgs_target);
}
# we also need a new checker
undef $ctx;
Expand Down

0 comments on commit 7eb09b4

Please sign in to comment.