summaryrefslogtreecommitdiff
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
parente5980ebf622e99925bc65f60634537c0951b48ca (diff)
downloadmorph-8bec47f4e087549c1b8d5e02b3aeb1df6ef20db9.tar.gz
Make `morph cross-bootstrap` work from definitions checkout
Change-Id: I9ae5a846e20c0d32047a3d4fd5892e2f632f0cbe
-rw-r--r--morphlib/plugins/cross-bootstrap_plugin.py62
-rw-r--r--yarns/architecture.yarn4
-rw-r--r--yarns/implementations.yarn4
3 files changed, 39 insertions, 31 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
diff --git a/yarns/architecture.yarn b/yarns/architecture.yarn
index d8b1182c..080776f8 100644
--- a/yarns/architecture.yarn
+++ b/yarns/architecture.yarn
@@ -14,7 +14,7 @@ Morph Architecture Tests
GIVEN a git server
AND a system called base-system-testarch.morph for the test architecture in the git server
WHEN the user clones definitions
- AND the user attempts to cross-bootstrap the system base-system-testarch.morph in branch master of repo test:definitions to the arch testarch
+ AND the user attempts to cross-bootstrap the system base-system-testarch.morph in branch master to the arch testarch
THEN morph succeeded
FINALLY the git server is shut down
@@ -22,7 +22,7 @@ Morph Architecture Tests
GIVEN a git server
AND a system called base-system-testarch.morph for the test architecture in the git server
WHEN the user clones definitions
- AND the user attempts to cross-bootstrap the system base-system-testarch.morph in branch master of repo test:definitions to the arch unknown-archicture
+ AND the user attempts to cross-bootstrap the system base-system-testarch.morph in branch master to the arch unknown-archicture
THEN morph failed
AND the cross-bootstrap error message includes the string "Unsupported architecture "unknown-archicture"
FINALLY the git server is shut down
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index 186fe316..eab162b3 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -660,10 +660,10 @@ Implementation sections for building
Implementation sections for cross-bootstrapping
===============================================
- IMPLEMENTS WHEN the user (attempts to )?cross-bootstraps? the system (\S+) in branch (\S+) of repo (\S+) to the arch (\S+)
+ IMPLEMENTS WHEN the user (attempts to )?cross-bootstraps? the system (\S+) in branch (\S+) to the arch (\S+)
cd "$DATADIR/definitions"
git checkout "$MATCH_3"
- set -- cross-bootstrap "$MATCH_5" "$MATCH_4" "$MATCH_3" "$MATCH_2"
+ set -- cross-bootstrap "$MATCH_4" "$MATCH_2"
if [ "$MATCH_1" != "attempts to " ]; then run_morph "$@"
else attempt_morph "$@"; fi
echo $@ >&2