Skip to content

Commit

Permalink
[backend] add support for buildflags:obsgendiff for diff generation
Browse files Browse the repository at this point in the history
If the "obsgendiff" build flag is set and the repository has at
least one release target, we get all published files with the
suffix ".obsgendiff" from the first target.

It is up to the build job to do the diff and create new .obsgendiff
files.
  • Loading branch information
mlschroe committed Jan 29, 2020
1 parent 54325ba commit 8e2e74c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/backend/BSSched/BuildJob.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,9 @@ sub create {
my $genbuildreqs = ($ctx->{'genbuildreqs'} || {})->{$packid};
$binfo->{'logidlelimit'} = $bconf->{'buildflags:logidlelimit'} if $bconf->{'buildflags:logidlelimit'};
$binfo->{'genbuildreqs'} = $genbuildreqs->[0] if $genbuildreqs;
if ($bconf->{'buildflags:obsgendiff'} && @{$ctx->{'repo'}->{'releasetarget'} || []}) {
$binfo->{'obsgendiff'} = $ctx->{'repo'}->{'releasetarget'}->[0];
}
}
$ctx->writejob($job, $binfo, $reason);

Expand Down
4 changes: 4 additions & 0 deletions src/backend/BSXML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ our $buildinfo = [
'logidlelimit', # internal
'logsizelimit', # internal
'genbuildreqs', # internal
[ 'obsgendiff' =>
'project',
'package',
], # internal
[ 'dep' ],
[[ 'bdep' =>
'name',
Expand Down
12 changes: 12 additions & 0 deletions src/backend/bs_repserver
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,17 @@ sub getpreinstallimageinfos {
return ($answer, 'Content-Type: application/octet-stream');
}

sub getobsgendiffdata {
my ($cgi, $projid, $repoid, $arch) = @_;
my $dir = "$reporoot/$projid/$repoid/$arch/:repo";
my @files;
for my $f (grep {/[^\.].*\.obsgendiff$/} sort(ls($dir))) {
push @files, {'name' => $f, 'filename' => "$dir/$f"};
}
BSWatcher::reply_cpio(\@files);
return undef;
}

sub dirty {
my ($projid, $repoid, $arch) = @_;

Expand Down Expand Up @@ -4323,6 +4334,7 @@ my $dispatches = [
'!worker /getpackagebinaryversionlist $project $repository $arch $package* withcode:bool? workerid?' => \&getpackagebinaryversionlist,
'!worker /badpackagebinaryversionlist $project $repository $arch $package* workerid?' => \&badpackagebinaryversionlist,
'!worker /getpreinstallimageinfos $prpa+ match:? workerid?' => \&getpreinstallimageinfos,
'/getobsgendiffdata $project $repository $arch workerid?' => \&getobsgendiffdata,

# published files
'/published' => \&publisheddir,
Expand Down
14 changes: 14 additions & 0 deletions src/backend/bs_srcserver
Original file line number Diff line number Diff line change
Expand Up @@ -5403,6 +5403,19 @@ sub worker_getbinaryversions {
return ($bvl, $BSXML::binaryversionlist);
}

sub getobsgendiffdata {
my ($cgi, $projid, $repoid, $arch) = @_;
checkprojrepoarch($projid, $repoid, $arch);
my $reposerver = $BSConfig::partitioning ? BSSrcServer::Partition::projid2reposerver($projid) : $BSConfig::reposerver;
my $param = {
'uri' => "$reposerver/getobsgendiffdata",
'ignorestatus' => 1,
'receiver' => \&BSServer::reply_receiver,
};
BSWatcher::rpc($param, undef, BSRPC::args($cgi, 'project', 'repository', 'arch', 'workerid'));
return undef;
}

####################################################################

# this is shared for AJAX requests
Expand Down Expand Up @@ -6647,6 +6660,7 @@ my $dispatches = [
'/getsslcert $project autoextend:bool? workerid? signtype:?' => \&getsslcert,
'/getbinaries $project $repository $arch binaries: nometa:bool? workerid? module*' => \&worker_getbinaries,
'/getbinaryversions $project $repository $arch binaries: nometa:bool? workerid? module*' => \&worker_getbinaryversions,
'/getobsgendiffdata $project $repository $arch workerid?' => \&getobsgendiffdata,

# publisher/signer calls
'/getsignkey $project withpubkey:bool? autoextend:bool? withalgo:bool?' => \&getsignkey,
Expand Down
14 changes: 14 additions & 0 deletions src/backend/bs_worker
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,19 @@ sub getfollowupsources {
}, undef, "rev=$buildinfo->{'srcmd5'}");
}

sub getobsgendiffdata {
my ($buildinfo, $dir) = @_;
my $obsgendiff = $buildinfo->{'obsgendiff'};
return undef unless $obsgendiff;
my $server = $buildinfo->{'srcserver'} || $srcserver;
my $res = BSRPC::rpc({
'uri' => "$server/getobsgendiffdata",
'directory' => $dir,
'timeout' => $gettimeout,
}, $BSXML::dir, "project=$obsgendiff->{'project'}", "repository=$obsgendiff->{'repository'}", "arch=$buildinfo->{'arch'}", "jobid=$buildinfo->{'jobid'}");
return $res;
}

sub getsslcert {
my ($buildinfo, $dir, $signtype) = @_;
my $server = $buildinfo->{'srcserver'} || $srcserver;
Expand Down Expand Up @@ -3037,6 +3050,7 @@ sub dobuild {
close F;
}
}
getobsgendiffdata($buildinfo, $srcdir) if $buildinfo->{'obsgendiff'};
getsslcert($buildinfo, $srcdir, $needappxsslcert ? 'appx' : undef) if $needsslcert || $needappxsslcert;
readbuildenv($buildinfo, $srcdir);
print "packages, ";
Expand Down

0 comments on commit 8e2e74c

Please sign in to comment.