summaryrefslogtreecommitdiff
path: root/morphlib/buildcommand.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-12-18 18:33:58 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2014-01-10 11:47:18 +0000
commita49bae2710fcacd0301d45966c641b9bbe77810f (patch)
treeb5f5939b972996b5daea774ac609b220f3733156 /morphlib/buildcommand.py
parent5f5a4669161be1ca571796ef4902883b17e8d86c (diff)
downloadmorph-a49bae2710fcacd0301d45966c641b9bbe77810f.tar.gz
BuildCommand: Validate multiple root morphologies
When you attempt to build a stratum or chunk, the ArtifactResolver can return multiple root artifacts, since the root source produces multiple artifacts. Rather than having the BuildCommand complain that there's mutiple root artifacts, it now validates all the produced artifacts too, since that will validate the kinds of artifacts produced, and give a more useful error message, that you're trying to build a Stratum or Chunk directly. If all the produced artifacts validate, then an Exception is raised to signal that it got multiple artifacts, when it only expected one.
Diffstat (limited to 'morphlib/buildcommand.py')
-rw-r--r--morphlib/buildcommand.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index 4b3b2108..882c8d9e 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2013 Codethink Limited
+# Copyright (C) 2011-2014 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
@@ -22,6 +22,13 @@ import tempfile
import morphlib
+class MultipleRootArtifactsError(morphlib.Error):
+ def __init__(self, artifacts):
+ self.msg = ('System build has multiple root artifacts: %r'
+ % [a.name for a in artifacts])
+ self.artifacts = artifacts
+
+
class BuildCommand(object):
'''High level logic for building.
@@ -142,7 +149,14 @@ class BuildCommand(object):
artifacts = ar.resolve_artifacts(srcpool)
self.app.status(msg='Computing build order', chatty=True)
- root_artifact = self._find_root_artifact(artifacts)
+ try:
+ root_artifact = self._find_root_artifact(artifacts)
+ except MultipleRootArtifactsError as e:
+ # Validate root artifacts, since we may get a more useful
+ # error out of it.
+ for root_artifact in e.artifacts:
+ self._validate_root_artifact(root_artifact)
+ raise
# Validate the root artifact here, since it's a costly function
# to finalise it, so any pre finalisation validation is better
@@ -245,7 +259,8 @@ class BuildCommand(object):
for dep in a.dependencies:
if dep in maybe:
maybe.remove(dep)
- assert len(maybe) == 1
+ if len(maybe) != 1:
+ raise MultipleRootArtifactsError(maybe)
return maybe.pop()
def build_in_order(self, root_artifact):