X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=cdist;h=0e1df9f7c9abf6d3942daa4aad6ac7516ed75b1b;hb=714a5cf84cf08d53fb76ec42c5bec0296ac245a3;hp=cdc6acf6280cc24c853eb895357245d437113c91;hpb=0472bc3bab6557ff356b2cb313402b12b86c96e6;p=cdist.git diff --git a/cdist b/cdist index cdc6acf..0e1df9f 100755 --- a/cdist +++ b/cdist @@ -29,6 +29,7 @@ import os from pathlib import Path import platform import re +import signal import shlex import shutil import subprocess @@ -447,16 +448,16 @@ class Target(object): copyfile(p, os.path.join(output_dir, os.path.basename(devel_to_git(tree.commit, p)))) def package(self, project, checkout, output_dir, options, notarize): - tree = self.build(project, checkout, options) + tree = self.build(project, checkout, options, for_package=True) tree.add_defaults(options) p = self._cscript_package(tree, options) self._copy_packages(tree, p, output_dir) - def build(self, project, checkout, options): + def build(self, project, checkout, options, for_package=False): tree = globals.trees.get(project, checkout, self) if self.build_dependencies: tree.build_dependencies(options) - tree.build(options) + tree.build(options, for_package=for_package) return tree def test(self, project, checkout, target, test, options): @@ -543,12 +544,17 @@ class DockerTarget(Target): if self.privileged: opts += '--privileged=true ' if self.ccache: - opts += "-e CCACHE_DIR=/ccache/%s-%d --mount source=ccache,target=/ccache" % (self.image, os.getuid()) + opts += "-e CCACHE_DIR=/ccache/%s-%d --mount source=ccache,target=/ccache " % (self.image, os.getuid()) + opts += "--rm " tag = self.image if config.has('docker_hub_repository'): tag = '%s:%s' % (config.get('docker_hub_repository'), tag) + def signal_handler(signum, frame): + raise Error('Killed') + signal.signal(signal.SIGTERM, signal_handler) + self.container = command_and_read('%s run %s %s -itd %s /bin/bash' % (config.docker(), self._user_tag(), opts, tag))[0].strip() def command(self, cmd): @@ -855,7 +861,7 @@ class OSXSingleTarget(OSXTarget): self.set('CXX', '"ccache g++"') def package(self, project, checkout, output_dir, options, notarize): - tree = self.build(project, checkout, options) + tree = self.build(project, checkout, options, for_package=True) tree.add_defaults(options) self.unlock_keychain() p = self._cscript_package_and_notarize(tree, options, self.can_notarize and notarize) @@ -876,7 +882,7 @@ class OSXUniversalTarget(OSXTarget): for target in self.sub_targets: tree = globals.trees.get(project, checkout, target) tree.build_dependencies(options) - tree.build(options) + tree.build(options, for_package=True) self.unlock_keychain() tree = globals.trees.get(project, checkout, self) @@ -1109,7 +1115,7 @@ class Tree(object): for i in self.dependencies(options): i[0].build(i[1]) - def build(self, options): + def build(self, options, for_package=False): if self.built: return @@ -1121,7 +1127,10 @@ class Tree(object): self.add_defaults(options) if not globals.dry_run: - if len(inspect.getfullargspec(self.cscript['build']).args) == 2: + num_args = len(inspect.getfullargspec(self.cscript['build']).args) + if num_args == 3: + self.call('build', options, for_package) + elif num_args == 2: self.call('build', options) else: self.call('build') @@ -1238,8 +1247,8 @@ def main(): if args.target is None: raise Error('you must specify -t or --target') + target = target_factory(args) try: - target = target_factory(args) target.build(args.project, args.checkout, get_command_line_options(args)) finally: if not args.keep: