From patchwork Fri Jun 15 19:47:01 2018 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: 138822 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1299378lji; Fri, 15 Jun 2018 13:46:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKmNqyr7HbGskKnA658/greWJnLGy3XagKfpOE1tSAJtsKMpGqrCksoIEzq/gcAiBACpFEZ X-Received: by 2002:ac8:7208:: with SMTP id a8-v6mr3060806qtp.222.1529095587339; Fri, 15 Jun 2018 13:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529095587; cv=none; d=google.com; s=arc-20160816; b=BR0h1ptgq6jeAKkhbDa31o1lcVuH2dPEKPEGA1KxJ98ny9TmoUnqD1w3JUvH6I7Sld aEYaoWWidU3AiZpJB1JwzkvPFt3XPHNbujPsf8VCQL1J/92e9xQMakFHgUsGhu2/nLKN JfrD1vmF9k3tzPs46Ng2jDL7TKv/p2aZWIQn9HDWPH/dtz4tybRU87aeWcCAL45qBb6p Eae8f+rlWe0tjsNANUcLGjK1oTL+HqyCc+I0QK+6fotQ+4PIz/XFWF3Baf0G//pr7rm7 8qMx1ZVmOMC1QPaDkmDxBYcugC5z+BXwh1i+aMdT5A3rJMhKgGoIekSeQJMWMO7ddfXe 1HsA== 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=SswNevRDqaQtg8Xuy/6vM3Ltl/4QCI68l1uxu1pc9cM=; b=Z6ukpIGrp5uIEldTGgJGn+dJI9BJIzho3+1aYNOkutZ3KWzaXQIeMVU81ukGr8Es6F onZMwVX7zxAwBCI6V6j61RLWQl4sEkNPneUBVTztHfxw0EX/upmaK+P/8TQ8zW+AC1pV Cbf1/yoLI1GNmGdBFy2O/H34/AmXw0zsn2q4BLCfdoo63rvm8R7ylnYwM+SiNH0l5y9P 9obq4DFIsuUOxSzNvpV5Ynu+i6wG+4nzfjQzTR9UlCKQ/rzcnX9XqTStQiSlsO3Zhf6A HF/IabzHofp6+L6Kz3MazK2hExRK1zp1KWB6Fyn1XezyJrTTE8unsFN0qsdkh7+sG8VD IBAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cWTseViE; 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 p47-v6si8580124qtp.296.2018.06.15.13.46.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 15 Jun 2018 13:46:27 -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.s=google header.b=cWTseViE; 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]:49326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTvc2-0006LL-Sy for patch@linaro.org; Fri, 15 Jun 2018 16:46:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTuyP-0000iY-HC for qemu-devel@nongnu.org; Fri, 15 Jun 2018 16:05:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTuyO-0007uf-IW for qemu-devel@nongnu.org; Fri, 15 Jun 2018 16:05:29 -0400 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]:44063) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTuyO-0007uJ-BI for qemu-devel@nongnu.org; Fri, 15 Jun 2018 16:05:28 -0400 Received: by mail-wr0-x236.google.com with SMTP id x4-v6so10997473wro.11 for ; Fri, 15 Jun 2018 13:05:28 -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=SswNevRDqaQtg8Xuy/6vM3Ltl/4QCI68l1uxu1pc9cM=; b=cWTseViEc5/VKPTWfAwRhC+0uAm247ssBzOtWbXJzbIx1N7/iBPoCc+jqV3rjCu5hB kaJHnLoDtss0g53e4WbmZQ4QLlpbxuRjhdhjrAHjWDXJZf7rvYUqygq9elpyI/PEKqBa nVCm/TLCzsItAwFCsJ+mHF9F1CDCMm4y7OyRs= 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=SswNevRDqaQtg8Xuy/6vM3Ltl/4QCI68l1uxu1pc9cM=; b=kfZsEW2zc3/JA7HtAJM2Lg6gO2UKbjEnBX9uGnF0uhHdh4ae5JCQucY/5/2+O1tyFX rlcxrpRFaukR87tbJqcgCkFgrG8iTvCElyhH8HgSf4SyQW8WGFbxB01BinjhXOlJ9MP0 0F3YlzNkPOGiptEZcNL9C5A7l93861RGyiaYkyvsgE/JOBElQb1xz2Yr7+DqbanhZ4kN WLbeJIFWsb+A8G5Fe+KZsqvhom2vZZd4lS8OCAP9Lsp8BTSzr1T768hTuyXE0lbJzRO1 o5Vqc8yKxRwzGrTv4bUalgVQuqtua1gTO/h7+Tpkuc9qG9roHjiy1SRvIBZSEWCgRzkw bOsg== X-Gm-Message-State: APt69E1gxZ0JGr5lkt4+2+zqu1mKl24IdOx5UxQfAbR/+HmMl4gf1q9o 5EVKm0j8kGdWwHRane2UrYU0Nw== X-Received: by 2002:a5d:49d1:: with SMTP id t17-v6mr2605773wrs.242.1529093127223; Fri, 15 Jun 2018 13:05:27 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c11-v6sm8866037wri.49.2018.06.15.13.05.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jun 2018 13:05:22 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id C65C33E1048; Fri, 15 Jun 2018 20:47:09 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: cota@braap.org, famz@redhat.com, berrange@redhat.com, f4bug@amsat.org, richard.henderson@linaro.org, balrogg@gmail.com, aurelien@aurel32.net, agraf@suse.de, peter.maydell@linaro.org Date: Fri, 15 Jun 2018 20:47:01 +0100 Message-Id: <20180615194705.28019-51-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615194705.28019-1-alex.bennee@linaro.org> References: <20180615194705.28019-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] [PATCH v7 50/54] docker: docker.py add check sub-command 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_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This command allows you to check if we need to re-build a docker image. If the image isn't in the repository or the checksums don't match then we return false and some text (for processing in makefiles). Signed-off-by: Alex Bennée --- - fix prints to be "modern" - PEP8 fixes --- tests/docker/docker.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 2593a12d04..3666197a16 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -442,6 +442,31 @@ class CcCommand(SubCommand): return Docker().command("run", cmd, args.quiet) +class CheckCommand(SubCommand): + """Check if we need to re-build a docker image out of a dockerfile. + Arguments: """ + name = "check" + + def args(self, parser): + parser.add_argument("tag", + help="Image Tag") + parser.add_argument("dockerfile", + help="Dockerfile name") + + def run(self, args, argv): + dockerfile = open(args.dockerfile, "rb").read() + tag = args.tag + + dkr = Docker() + if dkr.image_matches_dockerfile(tag, dockerfile): + if not args.quiet: + print("Image is up to date.") + return 0 + else: + print("Image needs updating") + return 1 + + def main(): parser = argparse.ArgumentParser(description="A Docker helper", usage="%s ..." % os.path.basename(sys.argv[0]))