When building "foo.docker", if a "foo.pre" script exists, it will be
executed in the building context before "docker build" is invoked.

Signed-off-by: Fam Zheng <f...@redhat.com>
---
 tests/docker/docker.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 0151362..7b8f022 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -99,6 +99,12 @@ class Docker(object):
         tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s" %
                      _text_checksum(dockerfile))
         tmp_df.flush()
+        pre_path = os.path.abspath(df_path[:-len(".docker")] + ".pre")
+        if os.path.isfile(pre_path):
+            if quiet:
+                subprocess.check_output([pre_path], cwd=tmp_dir)
+            else:
+                subprocess.check_call([pre_path], cwd=tmp_dir)
         self._do(["build", "-t", tag, "-f", tmp_df.name] + argv + \
                  [tmp_dir],
                  quiet=quiet)
-- 
2.8.2


Reply via email to