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: 8324851 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 08ABEC02AA for ; Tue, 16 Feb 2016 12:50:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5FAC8200DE for ; Tue, 16 Feb 2016 12:50:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C0F6200D0 for ; Tue, 16 Feb 2016 12:50:46 +0000 (UTC) Received: from localhost ([::1]:45373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVf5a-0000GI-33 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Feb 2016 07:50:46 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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