Skip to content

Commit

Permalink
[backend] now that we have a checker class, we can do xrpc/setchanged…
Browse files Browse the repository at this point in the history
… on the objects
  • Loading branch information
mlschroe committed Dec 15, 2015
1 parent a42919b commit 7899c6c
Show file tree
Hide file tree
Showing 10 changed files with 266 additions and 33 deletions.
58 changes: 58 additions & 0 deletions src/backend/BSSched/BuildJob.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,64 @@

package BSSched::BuildJob;

# gctx functions
# init_ourjobs
# purgejob
# killjob
# killscheduled
# killbuilding
# killunwantedjobs
# writejob
# add_crossmarker
# update_buildavg
# patchpackstatus
# addjobhist
# path2buildinfopath
#
# ectx functions
# jobfinished
#
# ctx functions
# fakejobfinished
# fakejobfinished_nouseforbuild
# nextbcnt
# create
# metacheck
#
# static functions
# jobname
# sortedmd5toreason
# diffsortedmd5
#
# gctx usage
# myjobsdir
# jobsdir
# arch
# buildavg
# changed_med
# projpacks
# reporoot
# prpsearchpath
# repounchanged
# obsname
# remoteprojs
#
# ctx usage
# gctx
# project
# repository
# gdst
# relsyncmax
# conf
# prpsearchpath
# sysbuild_$buildtype
# pool
# prp
#
# ectx usage
# gctx
# fullcache

use strict;
use warnings;

Expand Down
56 changes: 56 additions & 0 deletions src/backend/BSSched/BuildRepo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,62 @@
#
package BSSched::BuildRepo;

# fctx functions
# fctx_set_metaidmd5
# fctx_check_linkedmeta
# fctx_add_binary_to_full
# fctx_del_binary_from_full
# fctx_gbininfo2full
# fctx_rebuild_full
# fctx_migrate_full
# fctx_integrate_package_into_full
# fctx_integrate_package_into_full_old
# move_into_full
#
# gctx functions
# sync_fullcache
# checkuseforbuild
#
# ctx functions
# addrepo
# addrepo_alien
# addrepo_scan
#
# static functions
# writesolv
#
# fctx usage
# metaid
# metamd5
# lastmeta
# linkedmeta
# gdst
# packid
# meta
# dst
# oldids
# metacache
# metacache_ismerge
# dep2meta
# gctx
# prp
# filter
# olduseforbuild
# newuseforbuild
#
# gctx usage
# arch
# projpacks
# repodatas
# reporoot
# remoteprojs
# repodatas_alien
# prpnotready
#
# ctx usage
# gctx


=head1 NAME
BSSched::BuildRepo - create repository which is used for build
Expand Down
15 changes: 15 additions & 0 deletions src/backend/BSSched/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -920,4 +920,19 @@ sub publish {
return ($schedulerstate, $schedulerdetails);
}

sub xrpc {
my ($ctx, $resource, $param, @args) = @_;
return $ctx->{'gctx'}->{'rctx'}->xrpc($ctx, $resource, $param, @args);
}

sub setchanged {
my ($ctx, $handle) = @_;
my $gctx = $ctx->{'gctx'};
die("no gctx in ctx\n") unless $gctx;
my $changeprp = $handle->{'_changeprp'} || $ctx->{'changeprp'};
my $changetype = $handle->{'_changetype'} || $ctx->{'changetype'} || 'high';
my $changelevel = $handle->{'_changelevel'} || $ctx->{'changelevel'} || 1;
BSSched::Lookat::setchanged($gctx, $changeprp, $changetype, $changelevel);
}

1;
4 changes: 2 additions & 2 deletions src/backend/BSSched/DoD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ sub dodcheck {
sub dodfetch_resume {
my ($ctx, $handle, $error) = @_;
return if $error; # hmm
BSSched::Lookat::setchanged($ctx, $handle);
$ctx->setchanged($handle);
# drop cache
my $gctx = $ctx->{'gctx'};
my $myarch = $gctx->{'arch'};
Expand Down Expand Up @@ -182,7 +182,7 @@ sub dodfetch {
'_prpa' => $prpa,
},
};
$gctx->{'rctx'}->xrpc($ctx, "dodfetch/$prpa", $param, undef, "view=binaryversions", map {"binary=$_"} @pkgs);
$ctx->xrpc("dodfetch/$prpa", $param, undef, "view=binaryversions", map {"binary=$_"} @pkgs);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/backend/BSSched/Events.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use BSUtil;
use BSXML;
use BSConfiguration;
use BSSolv;
use BSSched::Checker;
use BSSched::BuildResult;
use BSSched::BuildRepo;
use BSSched::ProjPacks;
Expand Down Expand Up @@ -260,8 +261,9 @@ sub event_scanrepo {
my $prp = "$projid/$repoid";
print "reading packages of repository $projid/$repoid\n";
delete $gctx->{'repodatas'}->{$prp};
my $ctx = BSSched::Checker->new($gctx, $prp);
my $pool = BSSolv::pool->new();
BSSched::BuildRepo::addrepo({'gctx' => $gctx, 'prp' => $prp}, $pool, $prp);
BSSched::BuildRepo::addrepo($ctx, $pool, $prp);
undef $pool;
$changed_high->{$prp} = 2;
delete $gctx->{'repounchanged'}->{$prp};
Expand Down
12 changes: 4 additions & 8 deletions src/backend/BSSched/Lookat.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,18 @@ use warnings;
use BSUtil;


=head2 add a prp to the lookat queue and the dependent prps to the changed hashes
=head2 setchanged - add a prp to the lookat queue and the dependent prps to the changed hashes
TODO
=cut

sub setchanged {
my ($ctx, $handle) = @_;
my ($gctx, $changeprp, $changetype, $changelevel) = @_;

my $gctx = $ctx->{'gctx'};
die("no gctx in ctx\n") unless $gctx;

my $changeprp = $handle->{'_changeprp'} || $ctx->{'changeprp'};
my $changetype = $handle->{'_changetype'} || $ctx->{'changetype'} || 'high';
my $changelevel = $handle->{'_changelevel'} || $ctx->{'changelevel'} || 1;
return unless $changeprp;
$changetype ||= 'high';
$changelevel ||= 1;

my $changed = $gctx->{"changed_$changetype"};
my $changed_dirty = $gctx->{'changed_dirty'};
Expand Down
71 changes: 56 additions & 15 deletions src/backend/BSSched/ProjPacks.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,52 @@
#
package BSSched::ProjPacks;

# gctx functions
# checkbuildrepoid
# get_projpacks
# get_projpacks_resume
# update_projpacks
# update_project_meta
# update_project_meta_check
# update_project_meta_resume
# update_projpacks_meta
# clone_projpacks_part
# postprocess_needed_check
# get_projpacks_postprocess
# calc_projpacks_linked
# find_linked_sources
# expandsearchpath
# expandprojlink
# calc_prps
# do_delayedprojpackfetches
# do_fetchprojpacks
# getconfig
# update_prpcheckuseforbuild
#
# static functions
# orderpackids
#
# gctx usage
# reporoot
# arch
# projpacks
# rctx
# testmode
# remoteprojs
# delayedfetchprojpacks
# changed_high
# changed_med
# changed_low
# changed_dirty
# prps
# channeldata
# projpacks_linked
# prpsearchpath
# prpdeps
# prpnoleaf
# asyncmode
# prpcheckuseforbuild

use strict;
use warnings;

Expand Down Expand Up @@ -91,19 +137,18 @@ sub get_projpacks {
while (1) {
push @args, 'nopackages' if $testprojid && $projid ne $testprojid;
for my $tries (4, 3, 2, 1, 0) {
my $ctx = {'gctx' => $gctx, 'changeprp' => $projid, '_orderedrpcs' => 1};
my $param = {
'uri' => "$BSConfig::srcserver/getprojpack",
};
if ($doasync) {
$param->{'async'} = { %$doasync, '_resume' => \&get_projpacks_resume, '_projid' => $projid };
$param->{'async'} = { %$doasync, '_resume' => \&get_projpacks_resume, '_projid' => $projid, '_changeprp' => $projid };
$param->{'async'}->{'_packids'} = [ @packids ] if @packids;
}
eval {
if ($usestorableforprojpack) {
$projpacksin = $gctx->{'rctx'}->xrpc($ctx, $projid, $param, \&BSUtil::fromstorable, 'view=storable', 'withsrcmd5', 'withdeps', 'withrepos', 'withconfig', 'withremotemap', "arch=$myarch", @args);
$projpacksin = $gctx->{'rctx'}->xrpc($gctx, $projid, $param, \&BSUtil::fromstorable, 'view=storable', 'withsrcmd5', 'withdeps', 'withrepos', 'withconfig', 'withremotemap', "arch=$myarch", @args);
} else {
$projpacksin = $gctx->{'rctx'}->xrpc($ctx, $projid, $param, $BSXML::projpack, 'withsrcmd5', 'withdeps', 'withrepos', 'withconfig', 'withremotemap', "arch=$myarch", @args);
$projpacksin = $gctx->{'rctx'}->xrpc($gctx, $projid, $param, $BSXML::projpack, 'withsrcmd5', 'withdeps', 'withrepos', 'withconfig', 'withremotemap', "arch=$myarch", @args);
}
};
return 0 if !$@ && $projpacksin && $param->{'async'};
Expand Down Expand Up @@ -152,9 +197,7 @@ sub get_projpacks {
=cut

sub get_projpacks_resume {
my ($ctx, $handle, $error, $projpacksin) = @_;

my $gctx = $ctx->{'gctx'};
my ($gctx, $handle, $error, $projpacksin) = @_;

# what we asked about
my $projid = $handle->{'_projid'};
Expand Down Expand Up @@ -225,7 +268,7 @@ sub get_projpacks_resume {
# no need to call setchanged if this is a package source change event
# and the project does not exist (i.e. lives on another partition)
return if $packids && !$projpacks->{$projid};
BSSched::Lookat::setchanged($ctx, $handle);
BSSched::Lookat::setchanged($gctx, $projid, $handle->{'_changetype'}, $handle->{'_changelevel'});
}

=head2 update_projpacks - incorporate all the new data from projpacksin into our projpacks data
Expand Down Expand Up @@ -326,21 +369,20 @@ sub update_project_meta {
my ($gctx, $doasync, $projid) = @_;
print "updating meta for project '$projid' from $BSConfig::srcserver\n";

my $ctx = {'gctx' => $gctx, 'changeprp' => $projid, '_orderedrpcs' => 1};
my $myarch = $gctx->{'arch'};
my $projpacksin;
my $param = {
'uri' => "$BSConfig::srcserver/getprojpack",
};
if ($doasync) {
$param->{'async'} = { %$doasync, '_resume' => \&update_project_meta_resume, '_projid' => $projid };
$param->{'async'} = { %$doasync, '_resume' => \&update_project_meta_resume, '_projid' => $projid, '_changeprp' => $projid };
}
my @args;
push @args, "partition=$BSConfig::partition" if $BSConfig::partition;
push @args, "project=$projid";
eval {
# withsrcmd5 is needed for the patterns md5sum
$projpacksin = $gctx->{'rctx'}->xrpc($ctx, $projid, $param, $BSXML::projpack, 'nopackages', 'withrepos', 'withconfig', 'withsrcmd5', "arch=$myarch", @args);
$projpacksin = $gctx->{'rctx'}->xrpc($gctx, $projid, $param, $BSXML::projpack, 'nopackages', 'withrepos', 'withconfig', 'withsrcmd5', "arch=$myarch", @args);
};
if ($@ || !$projpacksin) {
print $@ if $@;
Expand Down Expand Up @@ -395,9 +437,8 @@ sub update_project_meta_check {
=cut
sub update_project_meta_resume {
my ($ctx, $handle, $error, $projpacksin) = @_;
my ($gctx, $handle, $error, $projpacksin) = @_;

my $gctx = $ctx->{'gctx'};
my $projid = $handle->{'_projid'};
if ($error || !update_project_meta_check($gctx, $projid, $projpacksin)) {
if ($error) {
Expand All @@ -423,12 +464,12 @@ sub update_project_meta_resume {
my $async = {'_dolink' => 2, '_changetype' => 'high', '_changelevel' => 1};
get_projpacks($gctx, $async, $projid, @$packids);
} else {
BSSched::Lookat::setchanged($ctx, $handle);
BSSched::Lookat::setchanged($gctx, $projid, $handle->{'_changetype'}, $handle->{'_changelevel'});
}
} else {
# project is gone!
delete $handle->{'_lpackids'};
get_projpacks_resume($ctx, $handle, $error, $projpacksin);
get_projpacks_resume($gctx, $handle, $error, $projpacksin);
}
}

Expand Down
22 changes: 22 additions & 0 deletions src/backend/BSSched/PublishRepo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@
#
package BSSched::PublishRepo;

# ctx functions
# prpfinished
# publishdelta
#
# static functions
# compile_publishfilter
# mkdeltaname
#
# ctx usage
# gctx
# gdst
# prp
# conf
# prpsearchpath
#
# gctx usage
# arch
# reporoot
# projpacks
# myjobsdir
# extrepodir

use strict;
use warnings;

Expand Down
Loading

0 comments on commit 7899c6c

Please sign in to comment.