diff --git a/pyrex.ini b/pyrex.ini index cfe7cf8..3611b23 100644 --- a/pyrex.ini +++ b/pyrex.ini @@ -47,6 +47,11 @@ confversion = @CONFVERSION@ # repository %buildlocal = 0 +# If both buildlocal and norebuild are set to 1 pyrex will not attempt to +# rebuild and update an already built docker image. Useful if you are offline +# and your current image is good enough. +%norebuild = 0 + # A list of environment variables that should be imported as Pyrex # configuration variables in the "env" section, e.g. ${env:HOME}. Note that # environment variables accessed in this way must be set or an error will diff --git a/pyrex.py b/pyrex.py index a81f82f..61c690e 100755 --- a/pyrex.py +++ b/pyrex.py @@ -247,12 +247,14 @@ def build_image(config, build_config): .rstrip() ) else: - subprocess.check_call(engine_args, env=env) + if config["config"]["norebuild"] != "1": + subprocess.check_call(engine_args, env=env) build_config["build"]["buildid"] = get_image_id(config, tag) build_config["build"]["runid"] = build_config["build"]["buildid"] - except subprocess.CalledProcessError: + except subprocess.CalledProcessError as e: + print(e, file=sys.stderr) return None build_config["build"]["buildhash"] = get_build_hash(build_config) @@ -267,7 +269,8 @@ def build_image(config, build_config): subprocess.check_call(engine_args) build_config["build"]["buildid"] = get_image_id(config, tag) - except subprocess.CalledProcessError: + except subprocess.CalledProcessError as e: + print(e, file=sys.stderr) return None build_config["build"]["runid"] = tag