diff --git a/lib/tamarin.py b/lib/tamarin.py index de1bfb8..0d9d150 100644 --- a/lib/tamarin.py +++ b/lib/tamarin.py @@ -52,8 +52,9 @@ def get_workspace_subdir(subdir): def run(cmd, captureOutput=False, pty=False, debug=False, **kwargs): """Execute an arbitrary command on the system""" if debug: - print(" ".join(cmd)) + print(" ".join(cmd) if isinstance(cmd, list) else cmd) stdin=subprocess.PIPE + kwargs['shell'] = False if isinstance(cmd, list) else True if pty: kwargs['stdin'] = sys.stdin if captureOutput: @@ -62,4 +63,8 @@ def run(cmd, captureOutput=False, pty=False, debug=False, **kwargs): return subprocess.check_call(cmd, **kwargs) def run_docker(args, captureOutput=False, **kwargs): - return run(["docker"] + args, captureOutput=captureOutput, **kwargs) + if isinstance(args, list): + cmd = ["docker"] + args + else: + cmd = "docker " + args + return run(cmd, captureOutput=captureOutput, **kwargs) diff --git a/package b/package index e6ce889..5a47719 100755 --- a/package +++ b/package @@ -21,7 +21,7 @@ def create_args_parser(): parser.add_argument("--rebuild", help="Ignore cache and rebuild container's image", action="store_true", default=False) parser.add_argument("--debug", help="Will add extra output and start the container in interactive mode", action="store_true", default=False) parser.add_argument("--cleanup", help="Clear the workspace and remove obsolete Docker images before build", action="store_true", default=False) - parser.add_argument("--override-docker-args", help="Override all 'docker run' arguments. You can use this flag multiple times to add custom arguments", default=[], action='append') + parser.add_argument("--override-docker-args", help="Override all 'docker run' arguments. Use '[IMAGE_TAG]' to insert the generated image's name.", default="") return parser @@ -89,9 +89,8 @@ if __name__ == "__main__": docker_args = [] # Append custom arguments - if len(args.override_docker_args) > 0: - docker_args += args.override_docker_args - docker_args = [a.replace('[IMAGE_TAG]', image_tag) for a in docker_args] + if args.override_docker_args != "": + docker_args = args.override_docker_args.replace('[IMAGE_TAG]', image_tag) else: docker_args += [ "run", "--rm" ]