Skip to content

Commit

Permalink
[backend] refactor: split update_projpacks from get_projpacks
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe authored and adrianschroeter committed Feb 21, 2013
1 parent 7c20877 commit d38cc15
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions src/backend/bs_sched
Expand Up @@ -2201,22 +2201,38 @@ sub get_projpacks {
last;
}

# Be sure that this is the right source server for my binary packages
checkbuildrepoid($projpacksin);
update_projpacks($projpacksin, $projid, \@packids);

if ($testprojid) {
my $proj = $projpacks->{$projid};
for my $repo (@{$proj->{'repository'} || []}) {
for my $path (@{$repo->{'path'} || []}) {
next if $path->{'project'} eq $testprojid;
next if $projid ne $testprojid && $projpacks->{$path->{'project'}};
get_projpacks($path->{'project'});
}
}
}
}

# incorporate all the new data from projpacksin into our projpacks data
sub update_projpacks {
my ($projpacksin, $projid, $packids) = @_;

checkbuildrepoid($projpacksin);
for my $proj (@{$projpacksin->{'project'} || []}) {
if (@packids) {
if ($packids && @$packids) {
die("bad projpack answer\n") unless $proj->{'name'} eq $projid;
if ($projpacks->{$projid}) {
# use all packages/configs from old projpacks
my $opackage = $projpacks->{$projid}->{'package'} || {};
for (keys %$opackage) {
$opackage->{$_}->{'name'} = $_;
push @{$proj->{'package'}}, $opackage->{$_};
}
# use all packages/configs from old projpacks
my $opackage = $projpacks->{$projid}->{'package'} || {};
for (keys %$opackage) {
$opackage->{$_}->{'name'} = $_;
push @{$proj->{'package'}}, $opackage->{$_};
}
if (!$proj->{'patternmd5'} && $projpacks->{$projid}->{'patternmd5'}) {
$proj->{'patternmd5'} = $projpacks->{$projid}->{'patternmd5'} unless grep {$_ eq '_pattern'} @packids;
}
$proj->{'patternmd5'} = $projpacks->{$projid}->{'patternmd5'} unless grep {$_ eq '_pattern'} @$packids;
}
}
}
$projpacks->{$proj->{'name'}} = $proj;
Expand All @@ -2232,16 +2248,6 @@ sub get_projpacks {
delete $proj->{'package'};
}
}
if ($testprojid) {
my $proj = $projpacks->{$projid};
for my $repo (@{$proj->{'repository'} || []}) {
for my $path (@{$repo->{'path'} || []}) {
next if $path->{'project'} eq $testprojid;
next if $projid ne $testprojid && $projpacks->{$path->{'project'}};
get_projpacks($path->{'project'});
}
}
}
}

# -> BSUtil
Expand Down

0 comments on commit d38cc15

Please sign in to comment.