[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 23/25] tests/docker: remove FROM qemu/ support from docker.py
From: |
Alex Bennée |
Subject: |
[PATCH v1 23/25] tests/docker: remove FROM qemu/ support from docker.py |
Date: |
Fri, 26 Aug 2022 18:21:26 +0100 |
We want to migrate from docker.py to building our images directly with
docker/podman. Before we get there we need to make sure we don't
re-introduce our layered builds so bug out if we see FROM qemu/ in a
Dockerfile.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tests/docker/docker.py | 38 ++++++++++----------------------------
1 file changed, 10 insertions(+), 28 deletions(-)
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index d0af2861b8..3a1ed7cb18 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -205,22 +205,17 @@ def _read_qemu_dockerfile(img_name):
return _read_dockerfile(df)
-def _dockerfile_preprocess(df):
- out = ""
+def _dockerfile_verify_flat(df):
+ "Verify we do not include other qemu/ layers"
for l in df.splitlines():
if len(l.strip()) == 0 or l.startswith("#"):
continue
from_pref = "FROM qemu/"
if l.startswith(from_pref):
- # TODO: Alternatively we could replace this line with "FROM $ID"
- # where $ID is the image's hex id obtained with
- # $ docker images $IMAGE --format="{{.Id}}"
- # but unfortunately that's not supported by RHEL 7.
- inlining = _read_qemu_dockerfile(l[len(from_pref):])
- out += _dockerfile_preprocess(inlining)
- continue
- out += l + "\n"
- return out
+ print("We no longer support multiple QEMU layers.")
+ print("Dockerfiles should be flat, ideally created by lcitool")
+ return False
+ return True
class Docker(object):
@@ -309,23 +304,10 @@ def build_image(self, tag, docker_dir, dockerfile,
if argv is None:
argv = []
- # pre-calculate the docker checksum before any
- # substitutions we make for caching
- checksum = _text_checksum(_dockerfile_preprocess(dockerfile))
+ if not _dockerfile_verify_flat(dockerfile):
+ return -1
- if registry is not None:
- sources = re.findall("FROM qemu\/(.*)", dockerfile)
- # Fetch any cache layers we can, may fail
- for s in sources:
- pull_args = ["pull", "%s/qemu/%s" % (registry, s)]
- if self._do(pull_args, quiet=quiet) != 0:
- registry = None
- break
- # Make substitutions
- if registry is not None:
- dockerfile = dockerfile.replace("FROM qemu/",
- "FROM %s/qemu/" %
- (registry))
+ checksum = _text_checksum(dockerfile)
tmp_df = tempfile.NamedTemporaryFile(mode="w+t",
encoding='utf-8',
@@ -371,7 +353,7 @@ def image_matches_dockerfile(self, tag, dockerfile):
checksum = self.get_image_dockerfile_checksum(tag)
except Exception:
return False
- return checksum == _text_checksum(_dockerfile_preprocess(dockerfile))
+ return checksum == _text_checksum(dockerfile)
def run(self, cmd, keep, quiet, as_user=False):
label = uuid.uuid4().hex
--
2.30.2
- [PATCH v1 22/25] tests/docker: update and flatten debian-toolchain, (continued)
- [PATCH v1 22/25] tests/docker: update and flatten debian-toolchain, Alex Bennée, 2022/08/26
- [PATCH v1 21/25] tests/docker: update and flatten debian-hexagon-cross, Alex Bennée, 2022/08/26
- [PATCH v1 25/25] gitlab-ci: Only use one process in Windows jobs for compilation, Alex Bennée, 2022/08/26
- [PATCH v1 20/25] tests/docker: update and flatten debian-loongarch-cross, Alex Bennée, 2022/08/26
- [PATCH v1 19/25] tests/docker: update and flatten debian-amd64-cross, Alex Bennée, 2022/08/26
- [PATCH v1 23/25] tests/docker: remove FROM qemu/ support from docker.py,
Alex Bennée <=
- [PATCH v1 16/25] tests/docker: flatten debian-riscv64-test-cross, Alex Bennée, 2022/08/26