diff options
Diffstat (limited to 'morphlib/plugins/distbuild_plugin.py')
-rw-r--r-- | morphlib/plugins/distbuild_plugin.py | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/morphlib/plugins/distbuild_plugin.py b/morphlib/plugins/distbuild_plugin.py index 66d86dcf..1900b1bd 100644 --- a/morphlib/plugins/distbuild_plugin.py +++ b/morphlib/plugins/distbuild_plugin.py @@ -1,6 +1,6 @@ # distbuild_plugin.py -- Morph distributed build plugin # -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -12,8 +12,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.. +# with this program. If not, see <http://www.gnu.org/licenses/>. import cliapp @@ -72,7 +71,9 @@ class SerialiseArtifactPlugin(cliapp.Plugin): srcpool = build_command.create_source_pool( repo_name, ref, filename, original_ref=original_ref) artifact = build_command.resolve_artifacts(srcpool) - self.app.output.write(distbuild.serialise_artifact(artifact)) + self.app.output.write(distbuild.serialise_artifact(artifact, + repo_name, + ref)) self.app.output.write('\n') @@ -96,9 +97,14 @@ class WorkerBuild(cliapp.Plugin): distbuild.add_crash_conditions(self.app.settings['crash-condition']) serialized = sys.stdin.readline() - artifact = distbuild.deserialise_artifact(serialized) - + artifact_reference = distbuild.deserialise_artifact(serialized) + bc = morphlib.buildcommand.BuildCommand(self.app) + source_pool = bc.create_source_pool(artifact_reference.repo, + artifact_reference.ref, + artifact_reference.root_filename) + + root = bc.resolve_artifacts(source_pool) # Now, before we start the build, we garbage collect the caches # to ensure we have room. First we remove all system artifacts @@ -111,8 +117,21 @@ class WorkerBuild(cliapp.Plugin): self.app.subcommands['gc']([]) - arch = artifact.arch - bc.build_source(artifact.source, bc.new_build_env(arch)) + source = self.find_source(source_pool, artifact_reference) + build_env = bc.new_build_env(artifact_reference.arch) + bc.build_source(source, build_env) + + def find_source(self, source_pool, artifact_reference): + for s in source_pool.lookup(artifact_reference.source_repo, + artifact_reference.source_ref, + artifact_reference.filename): + if s.cache_key == artifact_reference.cache_key: + return s + for s in source_pool.lookup(artifact_reference.source_repo, + artifact_reference.source_sha1, + artifact_reference.filename): + if s.cache_key == artifact_reference.cache_key: + return s def is_system_artifact(self, filename): return re.match(r'^[0-9a-fA-F]{64}\.system\.', filename) @@ -180,7 +199,6 @@ class ControllerDaemon(cliapp.Plugin): self.app.settings.string( ['initiator-step-output-dir'], 'write build output to files in DIR', - default='.', group=group_distbuild) self.app.settings.string( @@ -238,6 +256,11 @@ class ControllerDaemon(cliapp.Plugin): distbuild.add_crash_conditions(self.app.settings['crash-condition']) + if not self.app.settings['worker']: + raise cliapp.AppException( + 'Distbuild controller has no workers configured. Refusing to ' + 'start.') + artifact_cache_server = ( self.app.settings['artifact-cache-server'] or self.app.settings['cache-server']) |