From patchwork Wed Jun 21 14:47:57 2017 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: 106083 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp1860967obh; Wed, 21 Jun 2017 07:54:46 -0700 (PDT) X-Received: by 10.237.34.233 with SMTP id q38mr39777595qtc.39.1498056886901; Wed, 21 Jun 2017 07:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498056886; cv=none; d=google.com; s=arc-20160816; b=eQHRnM8CAEj0V6g4IZ9zI+RbY4a/3Ae3l509iEIwKSuD1hI9K0g4dnbAuFzpwdGvRV jAVYHcGUyqCGhbWwyO0en0SmZEndDA2qtSBQ+9gjXIOv/+Ihp7XeD8jFbxsW+ivzOtv+ boZIUSoBKjV7Ljwbzqr0b9Dw81QC63Cveq/PgYZTI+WPgGZp0WxL/S7v5Ss/ILMtJ4s+ Aly3WIxLRdtE+G1365GHZXsmaw6NlM4sS8YWcEA5KGntR2yiy3aNbvpIV2avZxvla7zC VH08uZ0mMbPPnxFJwfQGTNXgvAbfLWs6BSGaE5JkY3YtuZQtJKj432VSPI/XJAWtqM7q 3HdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=AO4UOghIHwSDS6+2JxfN/qfxalVpaai16dg/kt6rnJM=; b=Na5kXEWNH+kEQ4B6lEfpr0GFqKJktmpHG+9Y2C0jeKhWPjdzA9nz67Vj7Di1bGaSUJ g1EhBi1V7by4PmgysjHAA/+LUyawz/5riQGZekAq6eECJhkzFuOVjUbeC2MBHLZxDGy7 56Ac2eGWu2lfytLHnZ3+38G8WImrwe1E7qmfv1diUkH3f89hU7yz0ZNP0OwM3eMvnsmc U3Jz/U9l4aK6IZsiL4QGeWaodtW54DfapqrPqgSRKN4gJYQGse4Crj8aBURK3pyBDg0d cvtYuxBjNMEf09kQ9kDkWLZOqJ1UzpNjowrxiJ3Yt8mYxcEppcrjl5KTAGC7beZhrwEC yF5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=KzZMQ1OS; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x33si15078020qte.360.2017.06.21.07.54.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 07:54:46 -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 header.b=KzZMQ1OS; 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 sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNh1o-00052d-5o for patch@linaro.org; Wed, 21 Jun 2017 10:54:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNguz-0006mi-Ee for qemu-devel@nongnu.org; Wed, 21 Jun 2017 10:47:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNgut-000520-RE for qemu-devel@nongnu.org; Wed, 21 Jun 2017 10:47:41 -0400 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]:33966) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNgut-00051V-LM for qemu-devel@nongnu.org; Wed, 21 Jun 2017 10:47:35 -0400 Received: by mail-wr0-x236.google.com with SMTP id 77so138147021wrb.1 for ; Wed, 21 Jun 2017 07:47:35 -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=AO4UOghIHwSDS6+2JxfN/qfxalVpaai16dg/kt6rnJM=; b=KzZMQ1OSHj9TfZ1wBKW5kQ2bNLGvGwGnb21ivHUh2HUebvuZsj7uU8vEMQcNs6mloK sJRWDlcAsC5GKmiGf+ErwPbkauVtR66HBoKse8ec7HLyp5xwTfcSvqOOhSU3XpUWGFVZ CrdrdTEUbY0ogFSyosUIZqbFrxjfV1u/+CMTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AO4UOghIHwSDS6+2JxfN/qfxalVpaai16dg/kt6rnJM=; b=N31s0MIjxBVFWaViXqHtcNsa78uK++ElKnxQfdgu5pb8B/8FBxEcqHXMI8u4JGnfSB 5zeQGw/stf6X7R6gVvyE5H4dRp0UJNVksXJJK3zX2P2JFPHI1czZKCzueNqLvUUkI383 mDYtF8Esluf5mUyHt1bb+Zu7PDuTeVPs/mCZONnfZBl+fMTGQAsHA/zdMdYLqqCKaUuQ VjvhASCYauQ1nO/GNhR05gkxBmTq7tpE5o0MlWZPcx3zK3oW2iRU7RWX72JOkZJaJzL0 E1g64uCNrxDflIZPB1TVbO5CipatIwbgJ2SwtKO5pqXaBIx0VFsIJ5Zavivf9nO2a8y9 UySQ== X-Gm-Message-State: AKS2vOyNF1DXlcbRwgAo6zkAYwbxQ2Fp5GBmEKctryVDvV/yJMFSC4G/ 6eBACBCffmmoyV14 X-Received: by 10.28.173.10 with SMTP id w10mr6775407wme.98.1498056454517; Wed, 21 Jun 2017 07:47:34 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w197sm6038938wme.20.2017.06.21.07.47.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 07:47:31 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7C4C43E0F74; Wed, 21 Jun 2017 15:48:14 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 15:47:57 +0100 Message-Id: <20170621144814.15324-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621144814.15324-1-alex.bennee@linaro.org> References: <20170621144814.15324-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::236 Subject: [Qemu-devel] [PULL 04/21] docker: rebuild image if 'extra files' checksum does not match 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: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Alex Bennée -- 2.13.0 diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 10fa907905..e707e5bcca 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -38,6 +38,9 @@ def _text_checksum(text): """Calculate a digest string unique to the text content""" return hashlib.sha1(text).hexdigest() +def _file_checksum(filename): + return _text_checksum(open(filename, 'rb').read()) + def _guess_docker_command(): """ Guess a working docker command or raise exception if not found""" commands = [["docker"], ["sudo", "-n", "docker"]] @@ -154,7 +157,7 @@ class Docker(object): return labels.get("com.qemu.dockerfile-checksum", "") def build_image(self, tag, docker_dir, dockerfile, - quiet=True, user=False, argv=None): + quiet=True, user=False, argv=None, extra_files_cksum=[]): if argv == None: argv = [] @@ -170,7 +173,8 @@ class Docker(object): tmp_df.write("\n") tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s" % - _text_checksum(dockerfile)) + _text_checksum("\n".join([dockerfile] + + extra_files_cksum))) tmp_df.flush() self._do(["build", "-t", tag, "-f", tmp_df.name] + argv + \ @@ -276,16 +280,22 @@ class BuildCommand(SubCommand): # Copy any extra files into the Docker context. These can be # included by the use of the ADD directive in the Dockerfile. + cksum = [] if args.include_executable: + # FIXME: there is no checksum of this executable and the linked + # libraries, once the image built any change of this executable + # or any library won't trigger another build. _copy_binary_with_libs(args.include_executable, docker_dir) for filename in args.extra_files or []: _copy_with_mkdir(filename, docker_dir) + cksum += [_file_checksum(filename)] argv += ["--build-arg=" + k.lower() + "=" + v for k, v in os.environ.iteritems() if k.lower() in FILTERED_ENV_NAMES] dkr.build_image(tag, docker_dir, dockerfile, - quiet=args.quiet, user=args.user, argv=argv) + quiet=args.quiet, user=args.user, argv=argv, + extra_files_cksum=cksum) rmtree(docker_dir)