summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--morphlib/buildcommand.py7
-rwxr-xr-xtests.build/only-build-systems.script29
-rw-r--r--tests.build/only-build-systems.stderr2
3 files changed, 37 insertions, 1 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index 27fec4da..b9ded140 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -80,7 +80,12 @@ class BuildCommand(object):
self.app.status(msg='Creating source pool', chatty=True)
srcpool = self.app.create_source_pool(
self.lrc, self.rrc, (repo_name, ref, filename))
-
+
+ root_kind = srcpool.lookup(repo_name, ref, filename).morphology['kind']
+ if root_kind != 'system':
+ raise morphlib.Error(
+ 'Building a %s directly is not supported' % root_kind)
+
self.app.status(
msg='Validating cross-morphology references', chatty=True)
self._validate_cross_morphology_references(srcpool)
diff --git a/tests.build/only-build-systems.script b/tests.build/only-build-systems.script
new file mode 100755
index 00000000..635a218f
--- /dev/null
+++ b/tests.build/only-build-systems.script
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 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
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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.
+
+
+## Morph should refuse build a chunk or a stratum out of the context. Only
+## system morphologies can be built.
+
+set -eu
+
+"$SRCDIR/scripts/test-morph" build-morphology \
+ test:morphs-repo master hello-stratum || true
+
+"$SRCDIR/scripts/test-morph" build-morphology \
+ test:chunk-repo farrokh hello || true
+
diff --git a/tests.build/only-build-systems.stderr b/tests.build/only-build-systems.stderr
new file mode 100644
index 00000000..ba7339d2
--- /dev/null
+++ b/tests.build/only-build-systems.stderr
@@ -0,0 +1,2 @@
+ERROR: Building a stratum directly is not supported
+ERROR: Building a chunk directly is not supported