@@ -205,6 +205,11 @@ class BuildCommand(SubCommand):
# Create a docker context directory for the build
docker_dir = tempfile.mkdtemp(prefix="docker_build")
+ # Is there a .pre file to run in the build context?
+ docker_pre = os.path.splitext(args.dockerfile)[0]+".pre"
+ if os.path.exists(docker_pre):
+ subprocess.call(os.path.realpath(docker_pre), cwd=docker_dir)
+
# Do we include a extra binary?
if args.include_executable:
_copy_binary_with_libs(args.include_executable,
new file mode 100644
@@ -0,0 +1,21 @@
+# Create Debian Bootstrap Image
+#
+# This is intended to be pre-poluated by:
+# - a first stage debootstrap (see debian-bootstrap.pre)
+# - a native qemu-$arch that binfmt_misc will run
+FROM scratch
+
+# Add everything from the context into the container
+ADD . /
+
+# Patch all mounts as docker already has stuff set up
+RUN sed -i 's/in_target mount/echo not for docker in_target mount/g' /debootstrap/functions
+
+# Run stage 2
+RUN /debootstrap/debootstrap --second-stage
+
+# At this point we can install additional packages if we want
+# Duplicate deb line as deb-src
+RUN cat /etc/apt/sources.list | sed "s/deb/deb-src/" >> /etc/apt/sources.list
+RUN apt-get update
+RUN apt-get -y build-dep qemu
new file mode 100755
@@ -0,0 +1,5 @@
+#!/bin/sh
+#
+# Simple wrapper for debootstrap, run in the docker build context
+#
+fakeroot debootstrap --variant=buildd --foreign --arch=$DEB_ARCH $DEB_TYPE . http://httpredir.debian.org/debian
Together with the debian-bootstrap.pre script can now build an arbitrary architecture of Debian using debootstrap. The docker script will now search for an associated $dockerfile.pre script which gets run in the same build context as the dockerfile will be. This allows debootstrap to set up its first stage before the container is built. To build a container you need a command line like: DEB_ARCH=armhf DEB_TYPE=testing \ ./tests/docker/docker.py build \ --include-executable=arm-linux-user/qemu-arm debian:armhf \ ./tests/docker/dockerfiles/debian-bootstrap.docker Signed-off-by: Alex Bennée <alex.bennee@linaro.org> --- v2 - use .pre script instead of embedded HOST_CMD - make default image include all QEMU build-deps --- tests/docker/docker.py | 5 +++++ tests/docker/dockerfiles/debian-bootstrap.docker | 21 +++++++++++++++++++++ tests/docker/dockerfiles/debian-bootstrap.pre | 5 +++++ 3 files changed, 31 insertions(+) create mode 100644 tests/docker/dockerfiles/debian-bootstrap.docker create mode 100755 tests/docker/dockerfiles/debian-bootstrap.pre -- 2.7.4