diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-08-01 14:20:23 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-08-19 15:11:18 +0100 |
commit | 8401e38b28e64ab5e8303ba72ecc1b5588db274a (patch) | |
tree | 22f11b31390e8af23c5dc390e8f2f89a7591853e | |
parent | de581b4362278f1e958d083a12f7eed39b99e033 (diff) | |
download | morph-8401e38b28e64ab5e8303ba72ecc1b5588db274a.tar.gz |
Add 'rubygem' build mode
This build mode honours the new 'gem-url' field. It downloads the
Gem from the given URL
Including code from random servers on the internet in your builds might
mean that you can't reproduce what you build from source later on,
because the file or even the whole server might be gone. Morph does
nothing to prevent this, either for Git source code or Ruby Gems.
The Trove server provides a way of mirroring Git repos on local
infrastructure, so organisations can be certain they won't disappear
later on and so that they are quicker to access. Trove does not yet
provide a similar service for mirroring the required RubyGems.
-rw-r--r-- | morphlib/buildcommand.py | 4 | ||||
-rw-r--r-- | morphlib/builder2.py | 13 |
2 files changed, 13 insertions, 4 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py index 1cb0c4d9..e09b73b0 100644 --- a/morphlib/buildcommand.py +++ b/morphlib/buildcommand.py @@ -325,13 +325,13 @@ class BuildCommand(object): dep_prefix_set = artifact.get_dependency_prefix_set() extra_path = [os.path.join(d, 'bin') for d in dep_prefix_set] - if build_mode not in ['bootstrap', 'staging', 'test']: + if build_mode not in ['bootstrap', 'rubygem', 'staging', 'test']: logging.warning('Unknown build mode %s for chunk %s. ' 'Defaulting to staging mode.' % (build_mode, artifact.name)) build_mode = 'staging' - if build_mode == 'staging': + if build_mode in ['rubygem', 'staging']: use_chroot = True setup_mounts = True diff --git a/morphlib/builder2.py b/morphlib/builder2.py index c1a49221..fa0506cc 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -29,6 +29,7 @@ import traceback import subprocess import tempfile import gzip +import urllib2 import cliapp @@ -539,8 +540,16 @@ class ChunkBuilder(BuilderBase): return built_artifacts def get_sources(self, srcdir): # pragma: no cover - s = self.artifact.source - extract_sources(self.app, self.repo_cache, s.repo, s.sha1, srcdir) + if self.artifact.source.build_mode == 'rubygem': + gem_url = self.artifact.source.morphology['gem-url'] + self.app.status( + msg='Downloading %(url)s into build chroot', url=gem_url) + response = urllib2.urlopen(gem_url) + gem_filename = os.path.basename(gem_url) + self.staging_area.copy_file_to_build_dir(response, gem_filename) + else: + s = self.artifact.source + extract_sources(self.app, self.repo_cache, s.repo, s.sha1, srcdir) class StratumBuilder(BuilderBase): |