Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02EE8C05027 for ; Fri, 17 Feb 2023 23:20:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7D6AE85A03; Sat, 18 Feb 2023 00:19:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="fhAt4Yzr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B4AC98575C; Sat, 18 Feb 2023 00:19:46 +0100 (CET) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 113838598E for ; Sat, 18 Feb 2023 00:19:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x133.google.com with SMTP id d4so961689ilm.1 for ; Fri, 17 Feb 2023 15:19:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I0ccIB6qCYHj67Ztdxe7Jedv+OC8AGIFFmotFj6ktLY=; b=fhAt4YzrAf4eoobokn6TOO38C535PN8YvOSgfNtCwH7HIWxvrOz+p79gR9epcYYhvb GaGPkUkv8RRz7n8TbNf6rFggeuPHkYtg3+SFrcFlWOwiueJaSHvBYaV3sUT1dfL2Jaeh jVJX4AnMj5aiF6UK167sjnIRW3jgfjw/nnJPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I0ccIB6qCYHj67Ztdxe7Jedv+OC8AGIFFmotFj6ktLY=; b=XWZv9qjuyp0foEMK0S/U6icEsLOLiktqot2IXNWytzP76oAnRjTroRQqypBA3qqyt+ R9WQkxkB6CK2ihCBn60qqrmeVFmdgCPBTO+b6Gf3jwk/SbDLG6jIuVj9iYmd8657V1Ik paqQz7WrnYQMl4ZLMxfywnyC7PR+nvqWTgsYd6DZkrk42ofzWnHgGIQLsX70tI5X3ojs V7Swd5hCl5X0GnaX0sFCXFEMn9nGtp9ZC6Mxthg3xJhx3CY5SRm7s7a/7UdfT0Vn1rzT f+63l/w6h9kvuqw3zUb6fsa7MjjJki3tDBF8rWB+tXLyd6Uq0FJdmJioR4mhJWbfmYoP 1Yvw== X-Gm-Message-State: AO0yUKUCLBUOYOHup+NB90UTmESCCOWhkeZbyN5tTL3H8uvKFdaqP6cK MrkAfGo4vDfHGjU7goVyayiWzGYEaH5+qYi/ X-Google-Smtp-Source: AK7set9ddnW1wrJayLwasB4BxwSVNNHA6gQ0dBMOwCplaxkNSy8qzfVr5uGkyX6TLIbnvXjFb5g9TQ== X-Received: by 2002:a05:6e02:1a88:b0:315:4a48:aaf with SMTP id k8-20020a056e021a8800b003154a480aafmr6342266ilv.14.1676675980517; Fri, 17 Feb 2023 15:19:40 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id e3-20020a02caa3000000b003c46345b48bsm1099685jap.89.2023.02.17.15.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 15:19:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Alper Nebi Yasak , Neha Malcom Francis , Stefan Herbrechtsmeier , Philippe Reynes , Peng Fan , Mike Frysinger , Mark Kettenis , Simon Glass Subject: [PATCH 3/5] binman: Move the tools directory into the Bintool class Date: Fri, 17 Feb 2023 16:19:21 -0700 Message-Id: <20230217231924.1654243-4-sjg@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230217231924.1654243-1-sjg@chromium.org> References: <20230217231924.1654243-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean We want to be able to change this directory. Use a class member to hold the value, since changing a constant is not good. Signed-off-by: Simon Glass --- tools/binman/bintool.py | 7 ++++--- tools/binman/bintool_test.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py index e1dff9aa1b5..302161fcb47 100644 --- a/tools/binman/bintool.py +++ b/tools/binman/bintool.py @@ -43,8 +43,6 @@ FETCH_NAMES = { # Status of tool fetching FETCHED, FAIL, PRESENT, STATUS_COUNT = range(4) -DOWNLOAD_DESTDIR = os.path.join(os.getenv('HOME'), 'bin') - class Bintool: """Tool which operates on binaries to help produce entry contents @@ -53,6 +51,9 @@ class Bintool: # List of bintools to regard as missing missing_list = [] + # Directory to store tools + tooldir = os.path.join(os.getenv('HOME'), 'bin') + def __init__(self, name, desc, version_regex=None, version_args='-V'): self.name = name self.desc = desc @@ -208,7 +209,7 @@ class Bintool: return FAIL if result is not True: fname, tmpdir = result - dest = os.path.join(DOWNLOAD_DESTDIR, self.name) + dest = os.path.join(self.tooldir, self.name) print(f"- writing to '{dest}'") shutil.move(fname, dest) if tmpdir: diff --git a/tools/binman/bintool_test.py b/tools/binman/bintool_test.py index 7efb8391db2..57e866eff93 100644 --- a/tools/binman/bintool_test.py +++ b/tools/binman/bintool_test.py @@ -139,7 +139,7 @@ class TestBintool(unittest.TestCase): dest_fname = os.path.join(destdir, '_testing') self.seq = 0 - with unittest.mock.patch.object(bintool, 'DOWNLOAD_DESTDIR', destdir): + with unittest.mock.patch.object(bintool.Bintool, 'tooldir', destdir): with unittest.mock.patch.object(tools, 'download', side_effect=handle_download): with test_util.capture_sys_output() as (stdout, _): @@ -250,7 +250,7 @@ class TestBintool(unittest.TestCase): btest = Bintool.create('_testing') col = terminal.Color() self.fname = None - with unittest.mock.patch.object(bintool, 'DOWNLOAD_DESTDIR', + with unittest.mock.patch.object(bintool.Bintool, 'tooldir', self._indir): with unittest.mock.patch.object(tools, 'run', side_effect=fake_run): with test_util.capture_sys_output() as (stdout, _): -- 2.39.2.637.g21b0678d19-goog