summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Dasmohapatra <vivek@collabora.co.uk>2014-05-16 15:24:58 (GMT)
committerVivek Dasmohapatra <vivek@collabora.co.uk>2014-05-16 15:24:58 (GMT)
commitceb593848706dba720e31cc7ed3442e69889908f (patch)
treee622654bf04e84f7e538711b3c478dd1c8909e93
parent51742e097de0d50267e0dcb7326b21b41189c8ae (diff)
downloadopen-build-service-per-repo-build-tweaks.tar.gz
open-build-service-per-repo-build-tweaks.tar.xz
Translate <buildenv>…</buildenv> entries into per-repo build env variablesper-repo-build-tweaks
-rwxr-xr-xsrc/backend/bs_worker42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/backend/bs_worker b/src/backend/bs_worker
index f03ec32..96d6bd4 100755
--- a/src/backend/bs_worker
+++ b/src/backend/bs_worker
@@ -1424,6 +1424,43 @@ sub patchkiwi {
writexml($kiwifile, undef, $kiwi, $BSKiwiXML::kiwidesc);
}
+sub write_repo_config ($$)
+{
+ my $xml = XML::Structured::XMLin( $BSXML::proj, $_[0] );
+ my $rid = $_[1];
+ my $repos = ( $xml && $xml->{repository} );
+ my $env = "$buildroot/.repo-env.sh";
+ my $done = 0;
+
+ $repos || return $done;
+
+ foreach my $r (grep { $_->{name} eq $rid } @$repos)
+ {
+ my $envars = $r->{ buildenv } || [];
+ my @envsh = ("repoid=$rid;", "export repoid;");
+
+ foreach my $var ( @$envars )
+ {
+ my $n = $var->{ name };
+ my $v = $var->{ _content };
+
+ # sanitise the name: alphanumeric_ only, must start with alpha_:
+ $n =~ s|[^A-Z0-9_]||ig;
+ $n =~ s|^([^A-Z_])|_$1|i;
+
+ # sanitise value: escape metacharacters + LF (but not \') and quote:
+ $v =~ s/([;<>\*\|`&\$!#\(\)\[\]\{\}:"\n\\])/\\$1/g;
+ push( @envsh, qq@$n="$v";@, "export $n;" );
+ }
+
+ writestr($env, undef, join("\n", @envsh, ''));
+ $done++;
+ last;
+ }
+
+ return $done;
+}
+
sub dobuild {
my ($buildinfo) = @_;
@@ -1493,7 +1530,12 @@ sub dobuild {
}
my $server = $buildinfo->{'srcserver'} || $srcserver;
my $config = BSRPC::rpc("$server/getconfig", undef, "project=$projid", "repository=$repoid", @configpath);
+ my $prjxml = BSRPC::rpc("$server/source/$projid/_meta", undef);
+
writestr("$buildroot/.build.config", undef, $config);
+ writestr("$buildroot/.project.xml", undef, $prjxml);
+ writestr("$buildroot/.repo", undef, $repoid);
+ write_repo_config($prjxml, $repoid);
my $release = $buildinfo->{'release'};
my $obsinstance = $BSConfig::obsname || '';