diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-03-19 09:34:58 +0000 |
---|---|---|
committer | Morph (on behalf of Adam Coldrick) <adam.coldrick@codethink.co.uk> | 2015-03-19 09:34:58 +0000 |
commit | 7db4ee53fb5398dd8f4ae8f56778735fe6531178 (patch) | |
tree | 01513d77326acd03b2da356ec2cd7f4761901b6b /morphlib/buildcommand.py | |
parent | 211d6317d22bace089da58875d280ae5e54d5d54 (diff) | |
download | morph-7db4ee53fb5398dd8f4ae8f56778735fe6531178.tar.gz |
Morph build 2ee8190abe87461992f5b7ed85fe2ee9
System branch: master
Diffstat (limited to 'morphlib/buildcommand.py')
-rw-r--r-- | morphlib/buildcommand.py | 84 |
1 files changed, 36 insertions, 48 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py index 438badb3..be8a1507 100644 --- a/morphlib/buildcommand.py +++ b/morphlib/buildcommand.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2014 Codethink Limited +# Copyright (C) 2011-2015 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 @@ -10,8 +10,7 @@ # 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. +# with this program. If not, see <http://www.gnu.org/licenses/>. import itertools @@ -94,10 +93,12 @@ class BuildCommand(object): ''' self.app.status(msg='Creating source pool', chatty=True) - srcpool = self.app.create_source_pool( + srcpool = morphlib.sourceresolver.create_source_pool( self.lrc, self.rrc, repo_name, ref, filename, - original_ref=original_ref) - + cachedir=self.app.settings['cachedir'], + original_ref=original_ref, + update_repos=not self.app.settings['no-git-update'], + status_cb=self.app.status) return srcpool def validate_sources(self, srcpool): @@ -125,11 +126,21 @@ class BuildCommand(object): root_arch = root_artifact.source.morphology['arch'] host_arch = morphlib.util.get_host_architecture() - if root_arch != host_arch: - raise morphlib.Error( - 'Are you trying to cross-build? ' - 'Host architecture is %s but target is %s' - % (host_arch, root_arch)) + + if root_arch == host_arch: + return + + # Since the armv8 instruction set is nearly entirely armv7 compatible, + # and since the incompatibilities are appropriately trapped in the + # kernel, we can safely run any armv7 toolchain natively on armv8. + if host_arch == 'armv8l' and root_arch in ('armv7l', 'armv7lhf'): + return + if host_arch == 'armv8b' and root_arch in ('armv7b', 'armv7bhf'): + return + + raise morphlib.Error( + 'Are you trying to cross-build? Host architecture is %s but ' + 'target is %s' % (host_arch, root_arch)) @staticmethod def _validate_has_non_bootstrap_chunks(srcpool): @@ -260,7 +271,7 @@ class BuildCommand(object): def build_in_order(self, root_artifact): '''Build everything specified in a build order.''' - self.app.status(msg='Building a set of sources', chatty=True) + self.app.status(msg='Building a set of sources') build_env = root_artifact.build_env ordered_sources = list(self.get_ordered_sources(root_artifact.walk())) old_prefix = self.app.status_prefix @@ -375,39 +386,8 @@ class BuildCommand(object): '''Update the local git repository cache with the sources.''' repo_name = source.repo_name - if self.app.settings['no-git-update']: - self.app.status(msg='Not updating existing git repository ' - '%(repo_name)s ' - 'because of no-git-update being set', - chatty=True, - repo_name=repo_name) - source.repo = self.lrc.get_repo(repo_name) - return - - if self.lrc.has_repo(repo_name): - source.repo = self.lrc.get_repo(repo_name) - try: - sha1 = source.sha1 - source.repo.resolve_ref(sha1) - self.app.status(msg='Not updating git repository ' - '%(repo_name)s because it ' - 'already contains sha1 %(sha1)s', - chatty=True, repo_name=repo_name, - sha1=sha1) - except morphlib.cachedrepo.InvalidReferenceError: - self.app.status(msg='Updating %(repo_name)s', - repo_name=repo_name) - source.repo.update() - else: - self.app.status(msg='Cloning %(repo_name)s', - repo_name=repo_name) - source.repo = self.lrc.cache_repo(repo_name) - - # Update submodules. - done = set() - self.app.cache_repo_and_submodules( - self.lrc, source.repo.url, - source.sha1, done) + source.repo = self.lrc.get_updated_repo(repo_name, ref=source.sha1) + self.lrc.ensure_submodules(source.repo, source.sha1) def cache_artifacts_locally(self, artifacts): '''Get artifacts missing from local cache from remote cache.''' @@ -517,7 +497,7 @@ class BuildCommand(object): staging_area.install_artifact(handle) if target_source.build_mode == 'staging': - morphlib.builder2.ldconfig(self.app.runcmd, staging_area.dirname) + morphlib.builder.ldconfig(self.app.runcmd, staging_area.dirname) def build_and_cache(self, staging_area, source, setup_mounts): '''Build a source and put its artifacts into the local cache.''' @@ -525,7 +505,7 @@ class BuildCommand(object): self.app.status(msg='Starting actual build: %(name)s ' '%(sha1)s', name=source.name, sha1=source.sha1[:7]) - builder = morphlib.builder2.Builder( + builder = morphlib.builder.Builder( self.app, staging_area, self.lac, self.rac, self.lrc, self.app.settings['max-jobs'], setup_mounts) return builder.build_and_cache(source) @@ -563,4 +543,12 @@ class InitiatorBuildCommand(BuildCommand): self.MAX_RETRIES) loop.add_state_machine(cm) - loop.run() + try: + loop.run() + except KeyboardInterrupt: + # This will run if the user presses Ctrl+C or sends SIGINT during + # the build. It won't trigger on SIGTERM, SIGKILL or unhandled + # Python exceptions. + logging.info('Received KeyboardInterrupt, aborting.') + for initiator in loop.state_machines_of_type(distbuild.Initiator): + initiator.handle_cancel() |