From patchwork Tue Feb 16 12:39:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 62009 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1643760lbl; Tue, 16 Feb 2016 04:51:26 -0800 (PST) X-Received: by 10.140.156.212 with SMTP id c203mr28764661qhc.96.1455627086096; Tue, 16 Feb 2016 04:51:26 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d8si40484592qgd.69.2016.02.16.04.51.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 16 Feb 2016 04:51:26 -0800 (PST) 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; 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 Received: from localhost ([::1]:45381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVf6D-0000xK-Ma for patch@linaro.org; Tue, 16 Feb 2016 07:51:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVewL-0001y9-G7 for qemu-devel@nongnu.org; Tue, 16 Feb 2016 07:41:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVewK-0003Sh-Fi for qemu-devel@nongnu.org; Tue, 16 Feb 2016 07:41:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVewK-0003Sc-AJ for qemu-devel@nongnu.org; Tue, 16 Feb 2016 07:41:12 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E57FEC0023B5; Tue, 16 Feb 2016 12:41:11 +0000 (UTC) Received: from fam-t430.redhat.com (vpn1-7-134.pek2.redhat.com [10.72.7.134]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1GCdxbQ024209; Tue, 16 Feb 2016 07:41:08 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 16 Feb 2016 20:39:59 +0800 Message-Id: <1455626399-7111-16-git-send-email-famz@redhat.com> In-Reply-To: <1455626399-7111-1-git-send-email-famz@redhat.com> References: <1455626399-7111-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, peter.maydell@linaro.org, jsnow@redhat.com, stefanha@redhat.com, sw@weilnetz.de, Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , david@gibson.dropbear.id.au Subject: [Qemu-devel] [PATCH v2 15/15] tests/docker/Makefile.include: snapshot the src for docker X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée Instead of providing a live version of the source tree to the docker container we snapshot it with git-archive. This ensure the tree is in a pristine state for whatever operations the container is going to run on them. Uncommitted changes known to files known by the git index will be included in the snapshot if there are any. Signed-off-by: Alex Bennée [Generate an unique directory under /tmp/ - Fam Zheng] Signed-off-by: Fam Zheng --- tests/docker/Makefile.include | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) -- 2.4.3 diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include index aaf7d23..7cc2130 100644 --- a/tests/docker/Makefile.include +++ b/tests/docker/Makefile.include @@ -2,7 +2,7 @@ $(if $(quiet-command),,$(eval include $(SRC_PATH)/rules.mak)) -.PHONY: docker docker-test docker-clean docker-image +.PHONY: docker docker-test docker-clean docker-image docker-qemu-src DOCKER_SUFFIX := .docker @@ -16,6 +16,21 @@ DOCKER_TOOLS := travis TESTS ?= % IMAGES ?= % +SRC_COPY := $(shell mktemp -u /tmp/qemu-src.XXXXX) + +.PHONY: $(SRC_COPY) + +$(SRC_COPY): + @mkdir -p $@ + $(call quiet-command, \ + mkdir -p $@ && (if git diff-index --quiet HEAD -- &>/dev/null; then \ + git archive -1 HEAD --format=tar.gz; \ + else \ + git archive -1 $$(git stash create) --format=tar.gz; \ + fi) | tar -xz -C $@, \ + " COPY SRC $@") + +docker-qemu-src: $(SRC_COPY) $(foreach i,$(DOCKER_IMAGES), \ $(eval docker-image: docker-image-$i) \ @@ -23,8 +38,7 @@ $(foreach i,$(DOCKER_IMAGES), \ $(eval .PHONY: docker-image-$i docker-@$i) \ $(foreach t,$(DOCKER_TESTS) $(DOCKER_TOOLS), \ $(eval .PHONY: docker-$t@$i) \ - $(eval docker-$t@$i: docker-image-$i) \ - $(eval docker-$t@$i: docker-run-$t@$i) \ + $(eval docker-$t@$i: docker-image-$i docker-run-$t@$i) \ $(eval docker-@$i: docker-$t@$i) \ $(eval docker-test: docker-run-$t@$i) \ ) \ @@ -73,7 +87,7 @@ docker-image-%: docker-run-%: CMD = $(shell echo '$@' | sed -e 's/docker-run-\([^@]*\)@\(.*\)/\1/') docker-run-%: IMAGE = $(shell echo '$@' | sed -e 's/docker-run-\([^@]*\)@\(.*\)/\2/') -docker-run-%: +docker-run-%: docker-qemu-src @if test -z "$(IMAGE)" || test -z "$(CMD)"; \ then echo "Invalid target"; exit 1; \ fi