summaryrefslogtreecommitdiff
path: root/morphlib/plugins
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-04-18 19:47:56 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-05-17 08:59:44 +0000
commit8bec47f4e087549c1b8d5e02b3aeb1df6ef20db9 (patch)
tree7bd8d6bbc485a30eb51ce82eab7061db2cf88ca5 /morphlib/plugins
parente5980ebf622e99925bc65f60634537c0951b48ca (diff)
downloadmorph-8bec47f4e087549c1b8d5e02b3aeb1df6ef20db9.tar.gz
Make `morph cross-bootstrap` work from definitions checkout
Change-Id: I9ae5a846e20c0d32047a3d4fd5892e2f632f0cbe
Diffstat (limited to 'morphlib/plugins')
-rw-r--r--morphlib/plugins/cross-bootstrap_plugin.py62
1 files changed, 35 insertions, 27 deletions
diff --git a/morphlib/plugins/cross-bootstrap_plugin.py b/morphlib/plugins/cross-bootstrap_plugin.py
index 7c1793f5..112e9133 100644
--- a/morphlib/plugins/cross-bootstrap_plugin.py
+++ b/morphlib/plugins/cross-bootstrap_plugin.py
@@ -18,6 +18,7 @@ import os.path
import re
import tarfile
import traceback
+import uuid
import morphlib
@@ -209,7 +210,7 @@ class CrossBootstrapPlugin(cliapp.Plugin):
def enable(self):
self.app.add_subcommand('cross-bootstrap',
self.cross_bootstrap,
- arg_synopsis='TARGET REPO REF SYSTEM-MORPH')
+ arg_synopsis='TARGET-ARCH SYSTEM-MORPH')
def disable(self):
pass
@@ -217,6 +218,32 @@ class CrossBootstrapPlugin(cliapp.Plugin):
def cross_bootstrap(self, args):
'''Cross-bootstrap a system from a different architecture.'''
+ MINARGS = 2
+
+ if len(args) != MINARGS:
+ raise cliapp.AppException(
+ 'cross-bootstrap requires 2 arguments: target archicture, and '
+ 'filename of the system morphology')
+
+ definitions_repo = morphlib.definitions_repo.open(
+ '.', search_for_root=True, app=self.app)
+
+ arch = args[0]
+ filename = args[1]
+
+ if arch not in morphlib.valid_archs:
+ raise morphlib.Error('Unsupported architecture "%s"' % arch)
+
+ filename = morphlib.util.sanitise_morphology_path(filename)
+ filename = definitions_repo.relative_path(filename, cwd='.')
+
+ source_pool_context = definitions_repo.source_pool(
+ definitions_repo.HEAD, filename)
+ with source_pool_context as source_pool:
+ self._cross_bootstrap(arch, source_pool)
+
+ def _cross_bootstrap(self, arch, srcpool):
+
# A brief overview of this process: the goal is to native build as much
# of the system as possible because that's easier, but in order to do
# so we need at least 'build-essential'. 'morph cross-bootstrap' will
@@ -233,32 +260,6 @@ class CrossBootstrapPlugin(cliapp.Plugin):
#
# This function is a variant of the BuildCommand() class in morphlib.
- # To do: make it work on a system branch instead of repo/ref/morph
- # triplet.
-
- if len(args) < 4:
- raise cliapp.AppException(
- 'cross-bootstrap requires 4 arguments: target archicture, and '
- 'repo, ref and and name of the system morphology')
-
- arch = args[0]
- root_repo, ref, system_name = args[1:4]
-
- if arch not in morphlib.valid_archs:
- raise morphlib.Error('Unsupported architecture "%s"' % arch)
-
- # Get system artifact
-
- build_env = morphlib.buildenvironment.BuildEnvironment(
- self.app.settings, arch)
- build_command = morphlib.buildcommand.BuildCommand(self.app, build_env)
-
- morph_name = morphlib.util.sanitise_morphology_path(system_name)
- srcpool = build_command.create_source_pool(
- root_repo, ref, [morph_name])
-
- definitions_version = srcpool.definitions_version
-
# FIXME: this is a quick fix in order to get it working for
# Baserock 13 release, it is not a reasonable fix
def validate(self, root_artifact):
@@ -272,6 +273,13 @@ class CrossBootstrapPlugin(cliapp.Plugin):
morphlib.buildcommand.BuildCommand._validate_architecture = validate
+ build_command = morphlib.buildcommand.BuildCommand(self.app)
+ build_command.validate_sources(srcpool)
+ build_command.srcpool = srcpool
+ root = build_command.resolve_artifacts(srcpool)
+ build_env = root.build_env
+ definitions_version = srcpool.definitions_version
+
system_artifact = build_command.resolve_artifacts(srcpool)
# Calculate build order