summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-11-12 17:28:57 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-11-12 17:28:57 +0000
commit2ac6f661130322e63b8d2737145ea11d445aaa79 (patch)
treedd30179d22c09cc73898d7db6218e0d620d74ac8
parent19b16a2cc6d67871d0a4298354eb446ada136a8e (diff)
parenta5b913a83db94380fc91d15571f55cbf7b5c741b (diff)
downloaddefinitions-2ac6f661130322e63b8d2737145ea11d445aaa79.tar.gz
Merge branch 'samthursfield/build-without-push' of git://git.baserock.org/baserock/morph
-rwxr-xr-xmorphlib/app.py4
-rw-r--r--morphlib/buildcommand.py1
-rw-r--r--morphlib/cachedrepo.py7
-rw-r--r--morphlib/cachedrepo_tests.py6
-rw-r--r--morphlib/git.py7
-rw-r--r--morphlib/localrepocache.py10
-rw-r--r--morphlib/localrepocache_tests.py5
-rw-r--r--morphlib/plugins/branch_and_merge_plugin.py43
-rwxr-xr-xtests.as-root/build-with-external-strata.script62
-rwxr-xr-xtests.as-root/build-with-push.script39
-rwxr-xr-xtests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script6
-rw-r--r--tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.stdout30
-rwxr-xr-xtests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script14
-rw-r--r--tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.stdout9
-rwxr-xr-xtests.as-root/building-a-system-branch-works-anywhere.script7
-rw-r--r--tests.as-root/building-a-system-branch-works-anywhere.stdout10
-rw-r--r--tests.branching/branch-creates-new-system-branch-not-from-master.stdout1
-rw-r--r--tests.branching/branch-creates-new-system-branch.stdout1
-rw-r--r--tests.branching/branch-works-anywhere.stdout4
-rw-r--r--tests.branching/checkout-existing-branch.stdout1
-rw-r--r--tests.branching/checkout-works-anywhere.stdout2
-rw-r--r--tests.branching/edit-works-after-branch-root-was-renamed.stdout2
-rwxr-xr-xtests/update-gits-chunk.script23
-rwxr-xr-xtests/update-gits-stratum.script23
-rwxr-xr-xtests/update-gits-submodules.script24
25 files changed, 225 insertions, 116 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index 8769b41c..0a11c716 100755
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -139,6 +139,10 @@ class Morph(cliapp.Application):
'build chunks with prefix PREFIX',
metavar='PREFIX', default=defaults['prefix'],
group=group_build)
+ self.settings.boolean(['push-build-branches'],
+ 'always push temporary build branches to the '
+ 'remote repository',
+ group=group_build)
self.settings.boolean(['staging-chroot'],
'build things in an isolated chroot '
'(default: true)',
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index aa6c7d0e..95f3812e 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -38,6 +38,7 @@ class BuildCommand(object):
self.ckc = self.new_cache_key_computer(self.build_env)
self.lac, self.rac = self.new_artifact_caches()
self.lrc, self.rrc = self.new_repo_caches()
+ self.supports_local_build = True
def build(self, args):
'''Build triplets specified on command line.'''
diff --git a/morphlib/cachedrepo.py b/morphlib/cachedrepo.py
index c40cb657..0b5ce60f 100644
--- a/morphlib/cachedrepo.py
+++ b/morphlib/cachedrepo.py
@@ -102,6 +102,7 @@ class CachedRepo(object):
self.original_name = original_name
self.url = url
self.path = path
+ self.is_mirror = not url.startswith('file://')
def resolve_ref(self, ref):
'''Attempts to resolve a ref into its SHA1 and tree SHA1.
@@ -223,6 +224,9 @@ class CachedRepo(object):
'''
+ if not self.is_mirror:
+ return
+
try:
self._update()
except cliapp.AppException, e:
@@ -260,7 +264,8 @@ class CachedRepo(object):
def _copy_repository(self, source_dir, target_dir): # pragma: no cover
try:
- morphlib.git.copy_repository(self._runcmd, source_dir, target_dir)
+ morphlib.git.copy_repository(
+ self._runcmd, source_dir, target_dir, self.is_mirror)
except cliapp.AppException:
raise CopyError(self, target_dir)
diff --git a/morphlib/cachedrepo_tests.py b/morphlib/cachedrepo_tests.py
index 0ca0882f..81673880 100644
--- a/morphlib/cachedrepo_tests.py
+++ b/morphlib/cachedrepo_tests.py
@@ -246,6 +246,12 @@ class CachedRepoTests(unittest.TestCase):
self.repo._update = self.update_with_failure
self.assertRaises(cachedrepo.UpdateError, self.repo.update)
+ def test_no_update_if_local(self):
+ self.repo = cachedrepo.CachedRepo(
+ object(), 'local:repo', 'file:///local/repo/', '/local/repo/')
+ self.repo._update = self.update_with_failure
+ self.repo.update()
+
def test_clone_checkout(self):
self.repo.clone_checkout('master', '/.DOES_NOT_EXIST')
self.assertEqual(self.clone_target, '/.DOES_NOT_EXIST')
diff --git a/morphlib/git.py b/morphlib/git.py
index 973e4af7..7985b815 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -175,13 +175,18 @@ def set_remote(runcmd, gitdir, name, url):
return runcmd(['git', 'remote', 'set-url', name, url], cwd=gitdir)
-def copy_repository(runcmd, repo, destdir):
+def copy_repository(runcmd, repo, destdir, is_mirror=True):
'''Copies a cached repository into a directory using cp.
This also fixes up the repository afterwards, so that it can contain
code etc. It does not leave any given branch ready for use.
'''
+ if is_mirror == False:
+ runcmd(['cp', '-a', os.path.join(repo, '.git'),
+ os.path.join(destdir, '.git')])
+ return
+
runcmd(['cp', '-a', repo, os.path.join(destdir, '.git')])
# core.bare should be false so that git believes work trees are possible
runcmd(['git', 'config', 'core.bare', 'false'], cwd=destdir)
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py
index ae5fa655..465e9f03 100644
--- a/morphlib/localrepocache.py
+++ b/morphlib/localrepocache.py
@@ -193,9 +193,13 @@ class LocalRepoCache(object):
return quote_url(url)
def _cache_name(self, url):
- basename = self._escape(url)
- path = os.path.join(self._cachedir, basename)
- return path
+ scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
+ if scheme == 'file':
+ return path
+ else:
+ basename = self._escape(url)
+ path = os.path.join(self._cachedir, basename)
+ return path
def has_repo(self, reponame):
'''Have we already got a cache of a given repo?'''
diff --git a/morphlib/localrepocache_tests.py b/morphlib/localrepocache_tests.py
index 26a92616..6c5410ce 100644
--- a/morphlib/localrepocache_tests.py
+++ b/morphlib/localrepocache_tests.py
@@ -163,3 +163,8 @@ class LocalRepoCacheTests(unittest.TestCase):
def test_noremote_error_message_contains_repo_name(self):
e = morphlib.localrepocache.NoRemote(self.repourl, [])
self.assertTrue(self.repourl in str(e))
+
+ def test_avoids_caching_local_repo(self):
+ self.lrc.cache_repo('file:///local/repo')
+ cached = self.lrc.get_repo('file:///local/repo')
+ assert cached.path == '/local/repo'
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py
index 21a5970c..efaa8dfe 100644
--- a/morphlib/plugins/branch_and_merge_plugin.py
+++ b/morphlib/plugins/branch_and_merge_plugin.py
@@ -1126,6 +1126,11 @@ class BranchAndMergePlugin(cliapp.Plugin):
# Generate a UUID for the build.
build_uuid = uuid.uuid4().hex
+ build_command = morphlib.buildcommand.BuildCommand(self.app)
+ build_command = self.app.hookmgr.call('new-build-command',
+ build_command)
+ push = self.app.settings['push-build-branches']
+
self.app.status(msg='Starting build %(uuid)s', uuid=build_uuid)
self.app.status(msg='Collecting morphologies involved in '
@@ -1143,26 +1148,34 @@ class BranchAndMergePlugin(cliapp.Plugin):
# Create the build refs for all these repositories and commit
# all uncommitted changes to them, updating all references
# to system branch refs to point to the build refs instead.
- self.update_build_refs(build_repos, branch, build_uuid)
+ self.update_build_refs(build_repos, branch, build_uuid, push)
- # Push the temporary build refs.
- self.push_build_refs(build_repos)
+ if push:
+ self.push_build_refs(build_repos)
+ build_branch_root = branch_root
+ else:
+ dirname = build_repos[branch_root]['dirname']
+ build_branch_root = urlparse.urljoin('file://', dirname)
# Run the build.
- build_command = morphlib.buildcommand.BuildCommand(self.app)
- build_command = self.app.hookmgr.call('new-build-command',
- build_command)
- build_command.build([branch_root,
+ build_command.build([build_branch_root,
build_repos[branch_root]['build-ref'],
system_name])
- # Delete the temporary refs on the server.
- self.delete_remote_build_refs(build_repos)
+ if push:
+ self.delete_remote_build_refs(build_repos)
self.app.status(msg='Finished build %(uuid)s', uuid=build_uuid)
def get_system_build_repos(self, system_branch, branch_dir,
branch_root, system_name):
+ '''Map upstream repository URLs to their checkouts in the system branch
+
+ Also provides the list of morphologies stored in each repository,
+ grouped by kind.
+
+ '''
+
build_repos = {}
def prepare_repo_info(repo, dirname):
@@ -1205,7 +1218,7 @@ class BranchAndMergePlugin(cliapp.Plugin):
return build_repos
- def inject_build_refs(self, morphology, build_repos):
+ def inject_build_refs(self, morphology, build_repos, will_push):
# Starting from a system or stratum morphology, update all ref
# pointers of strata or chunks involved in a system build (represented
# by build_repos) to point to temporary build refs of the repos
@@ -1215,6 +1228,9 @@ class BranchAndMergePlugin(cliapp.Plugin):
info['morph'] in build_repos[info['repo']]['strata'] or
info['morph'] in build_repos[info['repo']]['chunks']):
info['ref'] = build_repos[info['repo']]['build-ref']
+ if not will_push:
+ dirname = build_repos[info['repo']]['dirname']
+ info['repo'] = urlparse.urljoin('file://', dirname)
if morphology['kind'] == 'system':
for info in morphology['strata']:
inject_build_ref(info)
@@ -1230,7 +1246,10 @@ class BranchAndMergePlugin(cliapp.Plugin):
branch_uuid, repo_uuid)
info['build-ref'] = build_ref
- def update_build_refs(self, build_repos, system_branch, build_uuid):
+ def update_build_refs(self, build_repos, system_branch, build_uuid,
+ will_push):
+ '''Update build branches for each repository with any local changes '''
+
# Define the committer.
committer_name = 'Morph (on behalf of %s)' % \
(morphlib.git.get_user_name(self.app.runcmd))
@@ -1282,7 +1301,7 @@ class BranchAndMergePlugin(cliapp.Plugin):
for filename in filenames:
# Inject temporary refs in the right places in each morphology.
morphology = self.load_morphology(repo_dir, filename)
- self.inject_build_refs(morphology, build_repos)
+ self.inject_build_refs(morphology, build_repos, will_push)
handle, tmpfile = tempfile.mkstemp(suffix='.morph')
self.save_morphology(repo_dir, tmpfile, morphology)
diff --git a/tests.as-root/build-with-external-strata.script b/tests.as-root/build-with-external-strata.script
new file mode 100755
index 00000000..affb28f5
--- /dev/null
+++ b/tests.as-root/build-with-external-strata.script
@@ -0,0 +1,62 @@
+#!/bin/bash
+# Copyright (C) 2012 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 build" with strata outside the branch root repository.
+
+set -eu
+
+# Disable test on versions of Python before 2.7.
+if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
+then
+ cat "$SRCDIR/tests.as-root/build-with-external-strata.stdout"
+ exit 0
+fi
+
+. "$SRCDIR/scripts/setup-3rd-party-strata"
+
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" branch test:morphs branch1
+
+# System will fail to build unless we add linux to it -- make the change but
+# don't commit it, in one of the external strata, as a challenge for
+# 'morph build'.
+cd "branch1"
+"$SRCDIR/scripts/test-morph" edit hello-system stratum2
+cd "test:external-strata"
+cat stratum2.morph | \
+ head -n $(expr $(wc -l < stratum2.morph) - 3) > stratum2.morph
+cat <<EOF >> stratum2.morph
+ },
+ {
+ "name": "linux",
+ "repo": "test:kernel-repo",
+ "ref": "master",
+ "build-depends": []
+ }
+ ]
+}
+EOF
+
+# Ignore Morph's output for now because it gives us:
+# 2012-11-07 16:26:12 Overlaps in system artifact hello-system-rootfs detected
+#
+# This is due to having a chunk named 'hello' in more than one stratum. It's
+# a bug that this generates overlaps (the chunk's .meta file needs to be called
+# $stratum.$chunk.meta rather than $chunk.meta to avoid the overlap) and the
+# redirection should be removed once this bug is fixed.
+"$SRCDIR/scripts/test-morph" build hello-system > /dev/null
+
+[ $("$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts" | wc -l) -eq 23 ]
diff --git a/tests.as-root/build-with-push.script b/tests.as-root/build-with-push.script
new file mode 100755
index 00000000..1c3fb3fd
--- /dev/null
+++ b/tests.as-root/build-with-push.script
@@ -0,0 +1,39 @@
+#!/bin/bash
+# Copyright (C) 2012 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 build' when build without push is disabled, i.e. everything is
+# built from the remote repositories instead of the local checkouts.
+
+set -eu
+
+# Disable test on versions of Python before 2.7.
+if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
+then
+ cat "$SRCDIR/tests.as-root/build-with-push.stdout"
+ exit 0
+fi
+
+source "$SRCDIR/tests.as-root/setup-build"
+
+cd "$DATADIR/workspace/branch1"
+"$SRCDIR/scripts/test-morph" --push-build-branches build linux-system
+
+# Test that the chunk was built from test:kernel-repo and not a local branch
+cd "$DATADIR/cache/artifacts"
+tar xf *.chunk.linux baserock/linux.meta
+grep -q "\"repo\": \"file://$DATADIR/kernel-repo\"" baserock/linux.meta
+
+
diff --git a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script
index ab84c431..9ccc3dee 100755
--- a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script
+++ b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script
@@ -32,14 +32,14 @@ source "$SRCDIR/tests.as-root/setup-build"
# Build once.
cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" build linux-system
-"$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts"
+ARTIFACT_COUNT="$(ls "$DATADIR/cache/artifacts" | wc -l)"
# Build twice.
cd "$DATADIR/workspace/branch1"
"$SRCDIR/scripts/test-morph" build linux-system
-"$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts"
+[ "$ARTIFACT_COUNT" -eq $(ls "$DATADIR/cache/artifacts" | wc -l) ]
# Build thrice, and that should be enough.
cd "$DATADIR/workspace/branch1/test:morphs"
"$SRCDIR/scripts/test-morph" build linux-system
-"$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts"
+[ "$ARTIFACT_COUNT" -eq $(ls "$DATADIR/cache/artifacts" | wc -l) ]
diff --git a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.stdout b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.stdout
deleted file mode 100644
index a02b977c..00000000
--- a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.stdout
+++ /dev/null
@@ -1,30 +0,0 @@
-d .
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.meta
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum.meta
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.build-log
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.chunk.linux
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.meta
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.meta
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-kernel
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-rootfs
-d .
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.meta
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum.meta
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.build-log
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.chunk.linux
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.meta
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.meta
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-kernel
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-rootfs
-d .
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.meta
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum.meta
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.build-log
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.chunk.linux
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.meta
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.meta
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-kernel
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-rootfs
diff --git a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script
index f959bb43..642093dc 100755
--- a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script
+++ b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script
@@ -34,14 +34,10 @@ cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" build linux-system
# Print tree SHA1s of the build ref of morphs and kernel.
-echo "Tree of morphs repo build branch after first build:"
cd "$DATADIR/workspace/branch1/test:morphs"
-git log -1 --format=%T baserock/builds/123456789/987654321
-echo "Tree of kernel repo build branch after first build:"
+MORPHS_SHA1="$(git rev-parse baserock/builds/123456789/987654321)"
cd "$DATADIR/workspace/branch1/test:kernel-repo"
-git log -1 --format=%T baserock/builds/123456789/AABBCCDDE
-
-echo
+KERNEL_SHA1="$(git rev-parse baserock/builds/123456789/AABBCCDDE)"
# Make an uncommitted change to the linux morphology.
cd "$DATADIR/workspace/branch1/test:kernel-repo"
@@ -55,9 +51,7 @@ cd "$DATADIR/workspace"
# This time the tree SHA1 of morphs should be the same
# but that of the kernel repo should be different because we
# made a change.
-echo "Tree of morphs repo build branch after second build:"
cd "$DATADIR/workspace/branch1/test:morphs"
-git log -1 --format=%T baserock/builds/123456789/987654321
-echo "Tree of kernel repo build branch after second build:"
+[ "$(git rev-parse baserock/builds/123456789/987654321)" != "$MORPHS_SHA1" ]
cd "$DATADIR/workspace/branch1/test:kernel-repo"
-git log -1 --format=%T baserock/builds/123456789/AABBCCDDE
+[ "$(git rev-parse baserock/builds/123456789/AABBCCDDE)" != "$KERNEL_SHA1" ]
diff --git a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.stdout b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.stdout
deleted file mode 100644
index d5758d78..00000000
--- a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.stdout
+++ /dev/null
@@ -1,9 +0,0 @@
-Tree of morphs repo build branch after first build:
-73b00844bfe028b01d2464727d703f1fcc1f8ef9
-Tree of kernel repo build branch after first build:
-83d99190fa36d14f1bd24d88ba0fbe2ce674dd7c
-
-Tree of morphs repo build branch after second build:
-73b00844bfe028b01d2464727d703f1fcc1f8ef9
-Tree of kernel repo build branch after second build:
-5b015689415c96cdd290834ba105a64be28a3cfb
diff --git a/tests.as-root/building-a-system-branch-works-anywhere.script b/tests.as-root/building-a-system-branch-works-anywhere.script
index 1ce59b0f..2bba83dc 100755
--- a/tests.as-root/building-a-system-branch-works-anywhere.script
+++ b/tests.as-root/building-a-system-branch-works-anywhere.script
@@ -52,11 +52,10 @@ cd "$DATADIR/workspace/branch1/test:kernel-repo"
"$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts" > "$DATADIR/output4"
rm -rf "$DATADIR/cache/artifacts"/*
-# Verify that we're always building the same and that we're building
-# the right things after all.
-cat "$DATADIR/output1"
+# Verify that we build the right number of artifacts
+[ $(wc < "$DATADIR/output1" -l) -eq 10 ]
-# Print diffs of the build results, all of which should be empty.
+# List of files in the artifact cache should be identical after each build
diff "$DATADIR/output1" "$DATADIR/output2"
diff "$DATADIR/output2" "$DATADIR/output3"
diff "$DATADIR/output3" "$DATADIR/output4"
diff --git a/tests.as-root/building-a-system-branch-works-anywhere.stdout b/tests.as-root/building-a-system-branch-works-anywhere.stdout
deleted file mode 100644
index 3bbb820f..00000000
--- a/tests.as-root/building-a-system-branch-works-anywhere.stdout
+++ /dev/null
@@ -1,10 +0,0 @@
-d .
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.meta
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum
-f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum.meta
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.build-log
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.chunk.linux
-f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.meta
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.meta
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-kernel
-f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-rootfs
diff --git a/tests.branching/branch-creates-new-system-branch-not-from-master.stdout b/tests.branching/branch-creates-new-system-branch-not-from-master.stdout
index 948c5d19..d80f81d7 100644
--- a/tests.branching/branch-creates-new-system-branch-not-from-master.stdout
+++ b/tests.branching/branch-creates-new-system-branch-not-from-master.stdout
@@ -3,7 +3,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_morphs
d ./newbranch
d ./newbranch/.morph-system-branch
d ./newbranch/test:morphs
diff --git a/tests.branching/branch-creates-new-system-branch.stdout b/tests.branching/branch-creates-new-system-branch.stdout
index bc4bf568..7c6b3065 100644
--- a/tests.branching/branch-creates-new-system-branch.stdout
+++ b/tests.branching/branch-creates-new-system-branch.stdout
@@ -3,7 +3,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_morphs
d ./newbranch
d ./newbranch/.morph-system-branch
d ./newbranch/test:morphs
diff --git a/tests.branching/branch-works-anywhere.stdout b/tests.branching/branch-works-anywhere.stdout
index 3470a804..41f30440 100644
--- a/tests.branching/branch-works-anywhere.stdout
+++ b/tests.branching/branch-works-anywhere.stdout
@@ -3,7 +3,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_morphs
d ./branch1
d ./branch1/.morph-system-branch
d ./branch1/test:morphs
@@ -16,7 +15,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_morphs
d ./branch1
d ./branch1/.morph-system-branch
d ./branch1/test:morphs
@@ -36,7 +34,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_morphs
d ./branch1
d ./branch1/.morph-system-branch
d ./branch1/test:morphs
@@ -63,7 +60,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_morphs
d ./branch1
d ./branch1/.morph-system-branch
d ./branch1/test:morphs
diff --git a/tests.branching/checkout-existing-branch.stdout b/tests.branching/checkout-existing-branch.stdout
index 60fca613..50bd01ab 100644
--- a/tests.branching/checkout-existing-branch.stdout
+++ b/tests.branching/checkout-existing-branch.stdout
@@ -3,7 +3,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_morphs
d ./master
d ./master/.morph-system-branch
d ./master/test:morphs
diff --git a/tests.branching/checkout-works-anywhere.stdout b/tests.branching/checkout-works-anywhere.stdout
index 6e82072a..15ae3686 100644
--- a/tests.branching/checkout-works-anywhere.stdout
+++ b/tests.branching/checkout-works-anywhere.stdout
@@ -3,7 +3,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_morphs
d ./master
d ./master/.morph-system-branch
d ./master/test:morphs
@@ -16,7 +15,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_morphs
d ./master
d ./master/.morph-system-branch
d ./master/test:morphs
diff --git a/tests.branching/edit-works-after-branch-root-was-renamed.stdout b/tests.branching/edit-works-after-branch-root-was-renamed.stdout
index 549c1c34..1436414d 100644
--- a/tests.branching/edit-works-after-branch-root-was-renamed.stdout
+++ b/tests.branching/edit-works-after-branch-root-was-renamed.stdout
@@ -2,8 +2,6 @@ d .
d ./.morph
d ./.morph/cache
d ./.morph/cache/gits
-d ./.morph/cache/gits/file_hello
-d ./.morph/cache/gits/file_morphs
d ./master
d ./master/.morph-system-branch
d ./master/my-renamed-morphs
diff --git a/tests/update-gits-chunk.script b/tests/update-gits-chunk.script
index 54a8d9ed..55bdebd0 100755
--- a/tests/update-gits-chunk.script
+++ b/tests/update-gits-chunk.script
@@ -1,7 +1,4 @@
-#!/bin/sh
-#
-# Test that 'morph update-gits' updates every chunk listed on the
-# command line
+#!/bin/bash
#
# Copyright (C) 2012 Codethink Limited
#
@@ -18,16 +15,28 @@
# 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 update-gits' updates every chunk listed on the
+# command line.
+
set -eu
-# create an empty commit in a chunk repository
+# Local repos do not get cached, so we need to fake some remote repositories
+git daemon --port=9419 --pid-file="$DATADIR/git.pid" --reuseaddr \
+ --export-all --base-path="$DATADIR" 2> /dev/null &
+trap 'kill $(cat "$DATADIR/git.pid")' INT TERM ERR
+REPO_ALIAS='test=git://localhost:9419/%s#git://localhost:9419/%s'
+
+# Create an empty commit in a chunk repository
cd "$DATADIR/chunk-repo"
git checkout --quiet farrokh
git commit --quiet --allow-empty --allow-empty-message -m ""
NEWREF="$(git show-ref --hash farrokh)"
-"$SRCDIR/scripts/test-morph" update-gits test:chunk-repo farrokh hello
+"$SRCDIR/scripts/test-morph" --repo-alias=$REPO_ALIAS update-gits \
+ test:chunk-repo farrokh hello
+
+kill $(cat "$DATADIR/git.pid")
-# check the top commit of the cached repo's farrokh branch
+# Check the top commit of the cached repo's farrokh branch
cd "$DATADIR/cache/gits/"*chunk?repo*
test "$(git show-ref --hash refs/heads/farrokh)" = "$NEWREF"
diff --git a/tests/update-gits-stratum.script b/tests/update-gits-stratum.script
index 718f2547..04511563 100755
--- a/tests/update-gits-stratum.script
+++ b/tests/update-gits-stratum.script
@@ -1,7 +1,4 @@
-#!/bin/sh
-#
-# Test that 'morph update-gits' updates every chunk that depends on the
-# strata listed on the command line
+#!/bin/bash
#
# Copyright (C) 2012 Codethink Limited
#
@@ -18,16 +15,28 @@
# 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 update-gits' updates every chunk that depends on the
+# strata listed on the command line.
+
set -eu
-# create an empty commit in a chunk repository
+# Local repos do not get cached, so we need to fake some remote repositories
+git daemon --port=9419 --pid-file="$DATADIR/git.pid" --reuseaddr \
+ --export-all --base-path="$DATADIR" 2> /dev/null &
+trap 'kill $(cat "$DATADIR/git.pid")' INT TERM ERR
+REPO_ALIAS='test=git://localhost:9419/%s#git://localhost:9419/%s'
+
+# Create an empty commit in a chunk repository
cd "$DATADIR/chunk-repo"
git checkout --quiet farrokh
git commit --quiet --allow-empty --allow-empty-message -m ""
NEWREF="$(git show-ref --hash farrokh)"
-"$SRCDIR/scripts/test-morph" update-gits test:morphs-repo master hello-stratum
+"$SRCDIR/scripts/test-morph" --repo-alias=$REPO_ALIAS update-gits \
+ test:morphs-repo master hello-stratum
+
+kill $(cat "$DATADIR/git.pid")
-# check the top commit of the cached repo's farrokh branch
+# Check the top commit of the cached repo's farrokh branch
cd "$DATADIR/cache/gits/"*chunk?repo*
test "$(git show-ref --hash refs/heads/farrokh)" = "$NEWREF"
diff --git a/tests/update-gits-submodules.script b/tests/update-gits-submodules.script
index 49f4de62..ad5f220c 100755
--- a/tests/update-gits-submodules.script
+++ b/tests/update-gits-submodules.script
@@ -1,7 +1,4 @@
-#!/bin/sh
-#
-# Test that 'morph update-gits' caches all the submodules needed by
-# a chunk.
+#!/bin/bash
#
# Copyright (C) 2012 Codethink Limited
#
@@ -18,22 +15,33 @@
# 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 update-gits' caches all the submodules needed by
+# a chunk.
+
set -eu
-# create a repo to use as a submodule
+# Local repos do not get cached, so we need to fake some remote repositories
+git daemon --port=9419 --pid-file="$DATADIR/git.pid" --reuseaddr \
+ --export-all --base-path="$DATADIR" 2> /dev/null &
+trap 'kill $(cat "$DATADIR/git.pid")' INT TERM ERR
+REPO_ALIAS='test=git://localhost:9419/%s#git://localhost:9419/%s'
+
+# Create a repo to use as a submodule
submodule="$DATADIR/submodule-repo"
"$SRCDIR/scripts/cmd-filter" git init --quiet "$submodule"
"$SRCDIR/scripts/run-git-in" "$submodule" commit --quiet --allow-empty \
--allow-empty-message -m ""
-
-# create an empty commit in a chunk repository
+# Create an empty commit in a chunk repository
chunkrepo="$DATADIR/chunk-repo"
"$SRCDIR/scripts/run-git-in" "$chunkrepo" checkout --quiet farrokh
"$SRCDIR/scripts/run-git-in" "$chunkrepo" submodule --quiet add "$submodule" \
> /dev/null
"$SRCDIR/scripts/run-git-in" "$chunkrepo" commit --quiet -m "add submodule"
-"$SRCDIR/scripts/test-morph" update-gits test:morphs-repo master hello-stratum
+"$SRCDIR/scripts/test-morph" --repo-alias=$REPO_ALIAS update-gits \
+ test:morphs-repo master hello-stratum
+
+kill $(cat "$DATADIR/git.pid")
test -d "$DATADIR/cache/gits/"*chunk?repo* && echo chunk-repo cached
test -d "$DATADIR/cache/gits/"*morphs?repo* && echo morphs-repo cached