diff options
author | Simon Glass <sjg@chromium.org> | 2023-02-22 22:14:47 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2023-03-08 22:40:49 +0300 |
commit | 00f674db2dacfb6c62e274b5f87e13b5c97aee97 (patch) | |
tree | 5b44dd89699315a05311efc0be7e4557b0acd792 | |
parent | fbb0e480329e964598e79a7d67dbcdff19e7985d (diff) | |
download | u-boot-00f674db2dacfb6c62e274b5f87e13b5c97aee97.tar.xz |
binman: Move the tools directory into the Bintool class
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 <sjg@chromium.org>
-rw-r--r-- | tools/binman/bintool.py | 7 | ||||
-rw-r--r-- | 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 bb22968855..302161fcb4 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.expanduser('~/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 7efb8391db..57e866eff9 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, _): |