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 DA2CAC636D6 for ; Wed, 22 Feb 2023 19:16:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1623E85AF1; Wed, 22 Feb 2023 20:15:15 +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="WmJJUitx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 29DD185A82; Wed, 22 Feb 2023 20:15:04 +0100 (CET) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 02D2485A82 for ; Wed, 22 Feb 2023 20:14:59 +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-x12d.google.com with SMTP id i24so3885603ila.7 for ; Wed, 22 Feb 2023 11:14:59 -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=oxzowBRGYQP70aVHnvARJrsCLZA6VVBAy0Lp2tci9a8=; b=WmJJUitxDp7s8WmTnGKOuoE7ET0yZX/XleLbB3Fbm5Bd2yooZvCdwgSC5lhro9EOcm EjpoatmgWAUcyqPvWQsIkmquDvLGX4lbiq+2te51xKtJ2CtwRVWRGpZBG4FxF4FFBUUV /N9dar/kUAb4cUxtF+g0YWC+F2Q6DfTHeSkB8= 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=oxzowBRGYQP70aVHnvARJrsCLZA6VVBAy0Lp2tci9a8=; b=G6bP+pll/iiFmmc4CzB32JTw1tSlOdS3pt1Yr5S1BIOG2v+Qp2IrS6/7z+y12uN6x8 HO3f4UgWj6MIjMuJ4XT/3NBtafLqtyIvvluezBsfDlSkbgeghPAMzru/VW5DvWHMIjAF cqHvsAus/iYSxcmqvdJzLeSqlDMU4N8ET148Bl/CS7b20FJb7RTuPXSdZU6Vodk3S8t2 22FbHI8jjaj1YeRC413Pr7PEqw37VqC/EtZB0Gd1uWEtCexniAaNNXIljz0TG3R4guPE Gx6EBIYou2JtTZNolpuBMw6GtBYiuOMKo7oj+wSdPjp3Wj3jxZkDV4XLUiRK7n8YHgFh JEMA== X-Gm-Message-State: AO0yUKX6tWA4kxEO6kpkFOOLeK1FKPh6b83ujqLJ4xh3kHfpHQHV2MmN QxcYc3Jq2rtgxnl3YOKad9Co2GqM2s4N4xMQ X-Google-Smtp-Source: AK7set+iskdrhDEdA01l2ADY/1jqD/RNPgA7IIxJ6t7VIdos44FJ5NjKz+ECKPxos5z6j9keoOiYXA== X-Received: by 2002:a05:6e02:1948:b0:313:fea2:be5c with SMTP id x8-20020a056e02194800b00313fea2be5cmr7149264ilu.11.1677093297048; Wed, 22 Feb 2023 11:14:57 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:ba91:a998:7b71:c020]) by smtp.gmail.com with ESMTPSA id x18-20020a056e020f1200b00316e3a38becsm1212178ilj.18.2023.02.22.11.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 11:14:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Mark Kettenis , Tom Rini , Alper Nebi Yasak , Neha Malcom Francis , Stefan Herbrechtsmeier , Philippe Reynes , Peng Fan , Mike Frysinger , Simon Glass Subject: [PATCH v2 3/5] binman: Move the tools directory into the Bintool class Date: Wed, 22 Feb 2023 12:14:47 -0700 Message-Id: <20230222191449.1309107-4-sjg@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230222191449.1309107-1-sjg@chromium.org> References: <20230222191449.1309107-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 --- (no changes since v1) 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