summaryrefslogtreecommitdiff
path: root/tests.build
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 /tests.build
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 'tests.build')
-rwxr-xr-xtests.build/bootstrap-mode.script119
-rw-r--r--tests.build/cross-bootstrap-only-to-supported-archs.exit1
-rwxr-xr-xtests.build/cross-bootstrap-only-to-supported-archs.script25
-rw-r--r--tests.build/cross-bootstrap-only-to-supported-archs.stderr1
-rwxr-xr-xtests.build/cross-bootstrap.script27
-rwxr-xr-xtests.build/setup-build-essential137
6 files changed, 192 insertions, 118 deletions
diff --git a/tests.build/bootstrap-mode.script b/tests.build/bootstrap-mode.script
index f4ff0a36..923fb21f 100755
--- a/tests.build/bootstrap-mode.script
+++ b/tests.build/bootstrap-mode.script
@@ -23,124 +23,7 @@
set -eu
# Create a fake 'compiler' chunk to go into build-essential stratum
-
-mkdir -p "$DATADIR/cc-repo"
-cd "$DATADIR/cc-repo"
-
-cat <<EOF > "morph-test-cc"
-#!/bin/sh
-echo "I'm a compiler!"
-EOF
-chmod +x morph-test-cc
-
-cat <<EOF > "stage1-cc.morph"
-{
- "name": "stage1-cc",
- "kind": "chunk",
- "install-commands": [
- "install -d \"\$DESTDIR\$PREFIX/bin\"",
- "install -m 755 morph-test-cc \"\$DESTDIR\$PREFIX/bin/morph-test-cc\""
- ]
-}
-EOF
-
-cat <<EOF > "cc.morph"
-{
- "name": "cc",
- "kind": "chunk",
- "configure-commands": [
- "[ -e ../tools/bin/morph-test-cc ]"
- ],
- "install-commands": [
- "install -d \"\$DESTDIR\$PREFIX/bin\"",
- "install -m 755 morph-test-cc \"\$DESTDIR\$PREFIX/bin/morph-test-cc\""
- ]
-}
-EOF
-
-git init -q
-git add morph-test-cc cc.morph stage1-cc.morph
-git commit -q -m "Create compiler chunk"
-
-# Require 'cc' in hello-chunk. We should have the second version available
-# but *not* the first one.
-cd "$DATADIR/chunk-repo"
-git checkout -q farrokh
-cat <<EOF > "hello.morph"
-{
- "name": "hello",
- "kind": "chunk",
- "configure-commands": [
- "[ ! -e ../tools/bin/morph-test-cc ]",
- "[ -e ../usr/bin/morph-test-cc ]"
- ],
- "build-commands": [
- "../usr/bin/morph-test-cc > hello"
- ],
- "install-commands": [
- "install -d \"\$DESTDIR\$PREFIX/bin\"",
- "install hello \"\$DESTDIR\$PREFIX/bin/hello\""
- ]
-}
-EOF
-git add hello.morph
-git commit -q -m "Make 'hello' require our mock compiler"
-
-# Add 'build-essential' stratum and make hello-stratum depend upon it. Only
-# the *second* 'cc' chunk should make it into the build-essential stratum
-# artifact, and neither should make it into the system.
-cd "$DATADIR/morphs-repo"
-cat <<EOF > "build-essential.morph"
-{
- "name": "build-essential",
- "kind": "stratum",
- "chunks": [
- {
- "name": "stage1-cc",
- "repo": "test:cc-repo",
- "ref": "master",
- "build-depends": [],
- "build-mode": "bootstrap",
- "prefix": "/tools"
- },
- {
- "name": "cc",
- "repo": "test:cc-repo",
- "ref": "master",
- "build-depends": [
- "stage1-cc"
- ],
- "build-mode": "test"
- }
- ]
-}
-EOF
-
-cat <<EOF > "hello-stratum.morph"
-{
- "name": "hello-stratum",
- "kind": "stratum",
- "build-depends": [
- {
- "morph": "build-essential",
- "repo": "test:morphs-repo",
- "ref": "master"
- }
- ],
- "chunks": [
- {
- "name": "hello",
- "repo": "test:chunk-repo",
- "ref": "farrokh",
- "build-depends": [],
- "build-mode": "test"
- }
- ]
-}
-EOF
-
-git add build-essential.morph hello-stratum.morph hello-system.morph
-git commit -q -m "Add fake build-essential stratum"
+"$SRCDIR/tests.build/setup-build-essential"
"$SRCDIR/scripts/test-morph" build-morphology \
test:morphs-repo master hello-system
diff --git a/tests.build/cross-bootstrap-only-to-supported-archs.exit b/tests.build/cross-bootstrap-only-to-supported-archs.exit
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/tests.build/cross-bootstrap-only-to-supported-archs.exit
@@ -0,0 +1 @@
+1
diff --git a/tests.build/cross-bootstrap-only-to-supported-archs.script b/tests.build/cross-bootstrap-only-to-supported-archs.script
new file mode 100755
index 00000000..872acd9f
--- /dev/null
+++ b/tests.build/cross-bootstrap-only-to-supported-archs.script
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# 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.
+
+
+# Test that "morph cross-bootstrap" works only for the architectures that
+# Morph explicitly supports.
+
+set -eu
+
+"$SRCDIR/scripts/test-morph" cross-bootstrap \
+ unknown-archicture test:morphs-repo master hello-system -v
diff --git a/tests.build/cross-bootstrap-only-to-supported-archs.stderr b/tests.build/cross-bootstrap-only-to-supported-archs.stderr
new file mode 100644
index 00000000..61c0fe0d
--- /dev/null
+++ b/tests.build/cross-bootstrap-only-to-supported-archs.stderr
@@ -0,0 +1 @@
+ERROR: Unsupported architecture "unknown-archicture"
diff --git a/tests.build/cross-bootstrap.script b/tests.build/cross-bootstrap.script
new file mode 100755
index 00000000..4de0f1ae
--- /dev/null
+++ b/tests.build/cross-bootstrap.script
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# 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.
+
+
+# Test "morph cross-bootstrap", up to the point of the tarball it generates
+# for the target
+
+set -eu
+
+"$SRCDIR/tests.build/setup-build-essential"
+
+"$SRCDIR/scripts/test-morph" cross-bootstrap \
+ x86_32 test:morphs-repo master hello-system
diff --git a/tests.build/setup-build-essential b/tests.build/setup-build-essential
new file mode 100755
index 00000000..778716f1
--- /dev/null
+++ b/tests.build/setup-build-essential
@@ -0,0 +1,137 @@
+#!/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.
+
+# Set up a stratum which resembles Baserock's 'build-essential' slightly. Used
+# for testing 'morph cross-bootstrap' and the 'bootstrap' build mode.
+
+mkdir -p "$DATADIR/cc-repo"
+cd "$DATADIR/cc-repo"
+
+cat <<EOF > "morph-test-cc"
+#!/bin/sh
+echo "I'm a compiler!"
+EOF
+chmod +x morph-test-cc
+
+cat <<EOF > "stage1-cc.morph"
+{
+ "name": "stage1-cc",
+ "kind": "chunk",
+ "install-commands": [
+ "install -d \"\$DESTDIR\$PREFIX/bin\"",
+ "install -m 755 morph-test-cc \"\$DESTDIR\$PREFIX/bin/morph-test-cc\""
+ ]
+}
+EOF
+
+cat <<EOF > "cc.morph"
+{
+ "name": "cc",
+ "kind": "chunk",
+ "configure-commands": [
+ "[ -e ../tools/bin/morph-test-cc ]"
+ ],
+ "install-commands": [
+ "install -d \"\$DESTDIR\$PREFIX/bin\"",
+ "install -m 755 morph-test-cc \"\$DESTDIR\$PREFIX/bin/morph-test-cc\""
+ ]
+}
+EOF
+
+git init -q
+git add morph-test-cc cc.morph stage1-cc.morph
+git commit -q -m "Create compiler chunk"
+
+# Require 'cc' in hello-chunk. We should have the second version available
+# but *not* the first one.
+cd "$DATADIR/chunk-repo"
+git checkout -q farrokh
+cat <<EOF > "hello.morph"
+{
+ "name": "hello",
+ "kind": "chunk",
+ "configure-commands": [
+ "[ ! -e ../tools/bin/morph-test-cc ]",
+ "[ -e ../usr/bin/morph-test-cc ]"
+ ],
+ "build-commands": [
+ "../usr/bin/morph-test-cc > hello"
+ ],
+ "install-commands": [
+ "install -d \"\$DESTDIR\$PREFIX/bin\"",
+ "install hello \"\$DESTDIR\$PREFIX/bin/hello\""
+ ]
+}
+EOF
+git add hello.morph
+git commit -q -m "Make 'hello' require our mock compiler"
+
+# Add 'build-essential' stratum and make hello-stratum depend upon it. Only
+# the *second* 'cc' chunk should make it into the build-essential stratum
+# artifact, and neither should make it into the system.
+cd "$DATADIR/morphs-repo"
+cat <<EOF > "build-essential.morph"
+{
+ "name": "build-essential",
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "stage1-cc",
+ "repo": "test:cc-repo",
+ "ref": "master",
+ "build-depends": [],
+ "build-mode": "bootstrap",
+ "prefix": "/tools"
+ },
+ {
+ "name": "cc",
+ "repo": "test:cc-repo",
+ "ref": "master",
+ "build-depends": [
+ "stage1-cc"
+ ],
+ "build-mode": "test"
+ }
+ ]
+}
+EOF
+
+cat <<EOF > "hello-stratum.morph"
+{
+ "name": "hello-stratum",
+ "kind": "stratum",
+ "build-depends": [
+ {
+ "morph": "build-essential",
+ "repo": "test:morphs-repo",
+ "ref": "master"
+ }
+ ],
+ "chunks": [
+ {
+ "name": "hello",
+ "repo": "test:chunk-repo",
+ "ref": "farrokh",
+ "build-depends": [],
+ "build-mode": "test"
+ }
+ ]
+}
+EOF
+
+git add build-essential.morph hello-stratum.morph hello-system.morph
+git commit -q -m "Add fake build-essential stratum"