Skip to content

Commit

Permalink
[backend] fix macro block handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Jun 3, 2013
1 parent d10c0cb commit 8dc64c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
6 changes: 5 additions & 1 deletion src/backend/bs_sched
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,11 @@ sub getconfig {
next unless defined $c;
$config .= "\n### from $p\n";
$config .= "%define _repository $r\n";
$c = defined($1) ? $1 : '' if $c =~ /^(.*\n)?\s*macros:[^\n]*\n/si;
# get rid of the Macros sections
my $s1 = '^\s*macros:\s*$.*?^\s*:macros\s*$';
my $s2 = '^\s*macros:\s*$.*\Z';
$c =~ s/$s1//gmsi;
$c =~ s/$s2//gmsi;
$config .= $c;
}
# it's an error if we have no config at all
Expand Down
27 changes: 15 additions & 12 deletions src/backend/bs_srcserver
Original file line number Diff line number Diff line change
Expand Up @@ -2644,17 +2644,10 @@ sub getprojpack {
if ($cgi->{'withconfig'}) {
my $config = readstr("$projectsdir/$projid.conf", 1);
if ($config) {
# strip away macro blocks
while ($config =~ /^(.*?\n)?\s*(macros:[^\n]*\n.*)/si) {
my ($c1, $c2) = ($1, $2);
$c1 = '' unless defined $c1;
if ($c2 =~ /^(?:.*?\n)?\s*:macros\s*\n(.*)$/si) {
$config = "$c1$1";
} else {
$config = $c1;
last;
}
}
my $s1 = '^\s*macros:\s*$.*?^\s*:macros\s*$';
my $s2 = '^\s*macros:\s*$.*\Z';
$config =~ s/$s1//gmsi;
$config =~ s/$s2//gmsi;
$jinfo->{'config'} = $config unless $config =~ /^\s*$/s;
}
}
Expand Down Expand Up @@ -3993,7 +3986,17 @@ sub concatconfigs {
next unless defined $c;
$config .= "\n### from $p\n";
$config .= "%define _repository $r\n";
if ($c =~ /^(.*\n)?\s*macros:[^\n]*\n(.*)/si) {

if ($c =~ /^\s*:macros\s*$/im) {
# probably some multiple macro sections with %if statements
# flush out macros
$macros .= "\n### from $p\n";
$macros .= "\n%_repository $r\n";
$config .= "\nMacros:\n$macros:Macros\n\n";
$macros = '';
$lastr = $r;
} elsif ($c =~ /^(.*\n)?\s*macros:[^\n]*\n(.*)/si) {
# single macro section. cumulate
$c = defined($1) ? $1 : '';
$macros .= "\n### from $p\n";
$macros .= "%_repository $r\n";
Expand Down

0 comments on commit 8dc64c1

Please sign in to comment.