summaryrefslogtreecommitdiff
path: root/morphlib/buildcommand.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2013-02-25 15:17:49 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2013-07-30 11:22:06 +0000
commit3ec0ff49ee8a015dd472ede2ed0996009b015c33 (patch)
tree0eca9022d2ea3f271a93ce31801df9068c43b264 /morphlib/buildcommand.py
parentc3ec8559f4fe5f1a43002a197ad6316f752910d8 (diff)
downloadmorph-3ec0ff49ee8a015dd472ede2ed0996009b015c33.tar.gz
Add morph cross-bootstrap
Cross-bootstrap is a way to build baserock on an architecture that does not currently have Baserock. It can be used by `morph cross-bootstrap <ARCH> <REPO> <REF> <MORPH>`, and will build an artifact that can be used as a root filesystem with a basic build environment with a script named `native-bootstrap` which will build and install every chunk in the system. If done with a devel system, this will give you a suitable environment for building a proper Baserock system. This does not currently provide a kernel for the target architecture. Apart from adding the cross-bootstrap plugin, it also makes the following changes: * Moves the lit of valid_archs into morphlib (instead of locally-scoped in MorphologyFactory) * BuildCommand takes an extra argument, build_env * split BuildCommand's get_artifact_object into create_source_pool and resolve_artifacts (plus changes things that use get_artifact_object to use the new way) * setup_mounts finds out whether to do so by whether build_mode is 'staging', instead of by whether the setting 'staging-chroot' is true. * Makes ChunkBuilder's get_sources use the morphlib.builder2.extract_sources() method, and moved set_mtime_recursively into morphlib.builder2, since it's not currently used anywhere else. * moved ChunkBuilder's get_commands into the Morphology class (plus changes to anything that used get_commands)
Diffstat (limited to 'morphlib/buildcommand.py')
-rw-r--r--morphlib/buildcommand.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index bfc64edc..fe6e0721 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -32,7 +32,7 @@ class BuildCommand(object):
'''
- def __init__(self, app):
+ def __init__(self, app, build_env = None):
self.supports_local_build = True
self.app = app
@@ -47,8 +47,10 @@ class BuildCommand(object):
for repo_name, ref, filename in self.app.itertriplets(args):
self.app.status(msg='Building %(repo_name)s %(ref)s %(filename)s',
repo_name=repo_name, ref=ref, filename=filename)
- artifact = self.get_artifact_object(repo_name, ref, filename)
- self.build_in_order(artifact)
+ self.app.status(msg='Figuring out the right build order')
+ srcpool = self.create_source_pool(repo_name, ref, filename)
+ root_artifact = self.resolve_artifacts(srcpool)
+ self.build_in_order(root_artifact)
self.app.status(msg='Build ends successfully')
@@ -68,11 +70,14 @@ class BuildCommand(object):
return morphlib.buildenvironment.BuildEnvironment(self.app.settings,
arch)
- def get_artifact_object(self, repo_name, ref, filename):
- '''Create an Artifact object representing the given triplet.'''
-
- self.app.status(msg='Figuring out the right build order')
+ def create_source_pool(self, repo_name, ref, filename):
+ '''Find the source objects required for building a the given artifact
+
+ The SourcePool will contain every stratum and chunk dependency of the
+ given artifact (which must be a system) but will not take into account
+ any Git submodules which are required in the build.
+ '''
self.app.status(msg='Creating source pool', chatty=True)
srcpool = self.app.create_source_pool(
self.lrc, self.rrc, (repo_name, ref, filename))
@@ -81,6 +86,11 @@ class BuildCommand(object):
msg='Validating cross-morphology references', chatty=True)
self._validate_cross_morphology_references(srcpool)
+ return srcpool
+
+ def resolve_artifacts(self, srcpool):
+ '''Resolve the artifacts that will be built for a set of sources'''
+
self.app.status(msg='Creating artifact resolver', chatty=True)
ar = morphlib.artifactresolver.ArtifactResolver()
@@ -241,6 +251,7 @@ class BuildCommand(object):
deps = self.get_recursive_deps(artifact)
self.cache_artifacts_locally(deps)
+ use_chroot = False
setup_mounts = False
if artifact.source.morphology['kind'] == 'chunk':
build_mode = artifact.source.build_mode
@@ -255,7 +266,10 @@ class BuildCommand(object):
(build_mode, artifact.name))
build_mode = 'staging'
- use_chroot = build_mode=='staging'
+ if build_mode == 'staging':
+ use_chroot = True
+ setup_mounts = True
+
staging_area = self.create_staging_area(build_env,
use_chroot,
extra_env=extra_env,
@@ -404,7 +418,6 @@ class BuildCommand(object):
self.app.status(msg='Starting actual build: %(name)s '
'%(sha1)s',
name=artifact.name, sha1=artifact.source.sha1[:7])
- setup_mounts = self.app.settings['staging-chroot']
builder = morphlib.builder2.Builder(
self.app, staging_area, self.lac, self.rac, self.lrc,
self.app.settings['max-jobs'], setup_mounts)