From patchwork Wed Jun 8 16:35:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 69675 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2589367qgf; Wed, 8 Jun 2016 09:37:48 -0700 (PDT) X-Received: by 10.55.155.193 with SMTP id d184mr5847427qke.152.1465403868963; Wed, 08 Jun 2016 09:37:48 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v62si1134755qkh.41.2016.06.08.09.37.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Jun 2016 09:37:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAgUG-0003PK-EV for patch@linaro.org; Wed, 08 Jun 2016 12:37:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAgSN-0002Yg-TS for qemu-devel@nongnu.org; Wed, 08 Jun 2016 12:35:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAgSH-00060W-SC for qemu-devel@nongnu.org; Wed, 08 Jun 2016 12:35:50 -0400 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:35578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAgSH-0005z2-H9 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 12:35:45 -0400 Received: by mail-wm0-x231.google.com with SMTP id v199so71988972wmv.0 for ; Wed, 08 Jun 2016 09:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/pkU2yYCwVfiYySsveVMyBVfPmMPjNDoAAuxhbYy3uw=; b=WqnADYNXKDQZzIy9zpXrOWQqchuRD/fUuQAB24jMyGNDxFCwZ/c09SP5T1ECacoJvt V+PjIl0ZusNGJVmIFqBYeKwTnC157RW9ZE0gAjXMuLtvhhtZGVNN0Lr+KRWn6+U0Xc0g b916p5B8UoanjU5vSR9Qm2IOILCPDd2cMmO5Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/pkU2yYCwVfiYySsveVMyBVfPmMPjNDoAAuxhbYy3uw=; b=HdEuYN1ckcy21lPaKPzMtGsPPMiytk0w8yw3+0IiBS2/7PxyJ4in0xJ+i3BCvDEkWK mIhaVgwKfwTGcmGtKqcprgen4QBdSCBpaT3+cgwoY7jVjlUyfG+YsnlR4HDLNfEptUzI 82CiYY1TFcBKh27IXgaYE9Y0Vzl64nf4hHWUzzARNOsd7Fj/TglzE7r7/tni0QY9jiZZ O0yeUvKiqgJUMPuODTPNs+vyzOnmunIGLhJwvxwgXMsmKn9fa3cw7RIBWgqC5q43R5bC Oujw8PYkylh3hcRc5VeHUhRZyTq6YXVerggJ7hNMZ+51EjxbSbeRB3RO6uOMsIJ9/cUT lzYw== X-Gm-Message-State: ALyK8tLJkuBXFRoCpPdvfQQXV+fD9i12D/3DJDVKRszyEQMKKd1s3yq+xpLIVizMzl5k/X8P X-Received: by 10.28.96.10 with SMTP id u10mr9491813wmb.93.1465403742542; Wed, 08 Jun 2016 09:35:42 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b207sm25810484wmb.0.2016.06.08.09.35.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jun 2016 09:35:41 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id CA6F03E0664; Wed, 8 Jun 2016 17:35:55 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 17:35:52 +0100 Message-Id: <1465403752-30348-4-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1465403752-30348-1-git-send-email-alex.bennee@linaro.org> References: <1465403752-30348-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::231 Subject: [Qemu-devel] [PATCH v2 3/3] add debian-bootstrap.docker target (and pre script) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , riku.voipio@linaro.org, famz@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 diff --git a/tests/docker/docker.py b/tests/docker/docker.py index ed6fa45..43041eb 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -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, diff --git a/tests/docker/dockerfiles/debian-bootstrap.docker b/tests/docker/dockerfiles/debian-bootstrap.docker new file mode 100644 index 0000000..3a9125e --- /dev/null +++ b/tests/docker/dockerfiles/debian-bootstrap.docker @@ -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 diff --git a/tests/docker/dockerfiles/debian-bootstrap.pre b/tests/docker/dockerfiles/debian-bootstrap.pre new file mode 100755 index 0000000..6f42da6 --- /dev/null +++ b/tests/docker/dockerfiles/debian-bootstrap.pre @@ -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