From edca7c0913473d846ea9f242364959e03ab17679 Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Wed, 6 May 2020 00:26:09 +0200 Subject: [PATCH] Added --squeeze switch to focker compose build. --- focker/compose.py | 11 +++++++---- focker/focker.py | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/focker/compose.py b/focker/compose.py index ecffb71..c69fcdc 100644 --- a/focker/compose.py +++ b/focker/compose.py @@ -48,11 +48,14 @@ def build_volumes(spec): zfs_set_props(name, params['zfs']) -def build_images(spec, path): +def build_images(spec, path, args): # print('build_images(): NotImplementedError') for (tag, focker_dir) in spec.items(): - res = subprocess.run(['focker', 'image', 'build', - os.path.join(path, focker_dir), '-t', tag]) + cmd = ['focker', 'image', 'build', + os.path.join(path, focker_dir), '-t', tag] + if args.squeeze: + cmd.append('--squeeze') + res = subprocess.run(cmd) if res.returncode != 0: raise RuntimeError('Image build failed: ' + str(res.returncode)) @@ -97,7 +100,7 @@ def command_compose_build(args): if 'volumes' in spec: build_volumes(spec['volumes']) if 'images' in spec: - build_images(spec['images'], path) + build_images(spec['images'], path, args) if 'jails' in spec: build_jails(spec['jails']) diff --git a/focker/focker.py b/focker/focker.py index 8c517fa..15c8034 100644 --- a/focker/focker.py +++ b/focker/focker.py @@ -192,6 +192,7 @@ def create_parser(): parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['build', 'bld', 'b']]) parser.set_defaults(func=command_compose_build) parser.add_argument('filename', type=str) + parser.add_argument('--squeeze', '-s', action='store_true') parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['run', 'r']]) parser.set_defaults(func=command_compose_run)