patman: Move library functions into a library directory
The patman directory has a number of modules which are used by other tools
in U-Boot. This makes it hard to package the tools using pypi since the
common files must be copied along with the tool that uses them.
To address this, move these files into a new u_boot_pylib library. This
can be packaged separately and listed as a dependency of each tool.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/scripts/event_dump.py b/scripts/event_dump.py
index d87823f..0117457 100755
--- a/scripts/event_dump.py
+++ b/scripts/event_dump.py
@@ -15,7 +15,7 @@
sys.path.insert(1, os.path.join(our_path, '../tools'))
from binman import elf
-from patman import tools
+from u_boot_pylib import tools
# A typical symbol looks like this:
# _u_boot_list_2_evspy_info_2_EVT_MISC_INIT_F_3_sandbox_misc_init_f
diff --git a/test/run b/test/run
index c4ab046..93b556f 100755
--- a/test/run
+++ b/test/run
@@ -76,6 +76,7 @@
run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test
run_test "patman" ./tools/patman/patman test
+run_test "u_boot_pylib" ./tools/u_boot_pylib/u_boot_pylib
run_test "buildman" ./tools/buildman/buildman -t ${skip}
run_test "fdt" ./tools/dtoc/test_fdt -t
diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py
index 7674dfd..8162968 100644
--- a/tools/binman/bintool.py
+++ b/tools/binman/bintool.py
@@ -18,10 +18,10 @@
import tempfile
import urllib.error
-from patman import command
-from patman import terminal
-from patman import tools
-from patman import tout
+from u_boot_pylib import command
+from u_boot_pylib import terminal
+from u_boot_pylib import tools
+from u_boot_pylib import tout
BINMAN_DIR = os.path.dirname(os.path.realpath(__file__))
diff --git a/tools/binman/bintool_test.py b/tools/binman/bintool_test.py
index 39e4fb1..f9b16d4 100644
--- a/tools/binman/bintool_test.py
+++ b/tools/binman/bintool_test.py
@@ -16,10 +16,10 @@
from binman import bintool
from binman.bintool import Bintool
-from patman import command
-from patman import terminal
-from patman import test_util
-from patman import tools
+from u_boot_pylib import command
+from u_boot_pylib import terminal
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
# pylint: disable=R0904
class TestBintool(unittest.TestCase):
diff --git a/tools/binman/btool/lz4.py b/tools/binman/btool/lz4.py
index dc9e379..fd520d1 100644
--- a/tools/binman/btool/lz4.py
+++ b/tools/binman/btool/lz4.py
@@ -60,7 +60,7 @@
import tempfile
from binman import bintool
-from patman import tools
+from u_boot_pylib import tools
# pylint: disable=C0103
class Bintoollz4(bintool.Bintool):
diff --git a/tools/binman/btool/lzma_alone.py b/tools/binman/btool/lzma_alone.py
index 52a960f..1fda2f6 100644
--- a/tools/binman/btool/lzma_alone.py
+++ b/tools/binman/btool/lzma_alone.py
@@ -37,7 +37,7 @@
import tempfile
from binman import bintool
-from patman import tools
+from u_boot_pylib import tools
# pylint: disable=C0103
class Bintoollzma_alone(bintool.Bintool):
diff --git a/tools/binman/cbfs_util.py b/tools/binman/cbfs_util.py
index 7bd3d89..fc56b40 100644
--- a/tools/binman/cbfs_util.py
+++ b/tools/binman/cbfs_util.py
@@ -22,8 +22,8 @@
from binman import bintool
from binman import elf
-from patman import command
-from patman import tools
+from u_boot_pylib import command
+from u_boot_pylib import tools
# Set to True to enable printing output while working
DEBUG = False
diff --git a/tools/binman/cbfs_util_test.py b/tools/binman/cbfs_util_test.py
index e0f792f..ee951d1 100755
--- a/tools/binman/cbfs_util_test.py
+++ b/tools/binman/cbfs_util_test.py
@@ -20,8 +20,8 @@
from binman import cbfs_util
from binman.cbfs_util import CbfsWriter
from binman import elf
-from patman import test_util
-from patman import tools
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
U_BOOT_DATA = b'1234'
U_BOOT_DTB_DATA = b'udtb'
diff --git a/tools/binman/control.py b/tools/binman/control.py
index abe01b7..9b183ed 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -12,14 +12,14 @@
import re
import sys
-from patman import tools
from binman import bintool
from binman import cbfs_util
-from patman import command
from binman import elf
from binman import entry
-from patman import tout
+from u_boot_pylib import command
+from u_boot_pylib import tools
+from u_boot_pylib import tout
# These are imported if needed since they import libfdt
state = None
diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index 3cc8a38..5816284 100644
--- a/tools/binman/elf.py
+++ b/tools/binman/elf.py
@@ -13,9 +13,9 @@
import struct
import tempfile
-from patman import command
-from patman import tools
-from patman import tout
+from u_boot_pylib import command
+from u_boot_pylib import tools
+from u_boot_pylib import tout
ELF_TOOLS = True
try:
diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py
index 8cb55eb..c980839 100644
--- a/tools/binman/elf_test.py
+++ b/tools/binman/elf_test.py
@@ -12,10 +12,10 @@
import unittest
from binman import elf
-from patman import command
-from patman import test_util
-from patman import tools
-from patman import tout
+from u_boot_pylib import command
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
+from u_boot_pylib import tout
binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 11aa8e5..f732d40 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -14,9 +14,9 @@
from binman import bintool
from binman import elf
from dtoc import fdt_util
-from patman import tools
-from patman.tools import to_hex, to_hex_size
-from patman import tout
+from u_boot_pylib import tools
+from u_boot_pylib.tools import to_hex, to_hex_size
+from u_boot_pylib import tout
modules = {}
diff --git a/tools/binman/entry_test.py b/tools/binman/entry_test.py
index a6fbf62..ac6582c 100644
--- a/tools/binman/entry_test.py
+++ b/tools/binman/entry_test.py
@@ -14,7 +14,7 @@
from binman.etype.blob import Entry_blob
from dtoc import fdt
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class TestEntry(unittest.TestCase):
def setUp(self):
diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py
index 1c1efb2..e092d98 100644
--- a/tools/binman/etype/_testing.py
+++ b/tools/binman/etype/_testing.py
@@ -9,7 +9,7 @@
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry__testing(Entry):
diff --git a/tools/binman/etype/atf_fip.py b/tools/binman/etype/atf_fip.py
index 6ecd95b..d5b8620 100644
--- a/tools/binman/etype/atf_fip.py
+++ b/tools/binman/etype/atf_fip.py
@@ -11,7 +11,7 @@
from binman.etype.section import Entry_section
from binman.fip_util import FIP_TYPES, FipReader, FipWriter, UUID_LEN
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry_atf_fip(Entry_section):
"""ARM Trusted Firmware's Firmware Image Package (FIP)
diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index a80741e..064fae5 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -8,8 +8,8 @@
from binman.entry import Entry
from binman import state
from dtoc import fdt_util
-from patman import tools
-from patman import tout
+from u_boot_pylib import tools
+from u_boot_pylib import tout
class Entry_blob(Entry):
"""Arbitrary binary blob
diff --git a/tools/binman/etype/blob_ext.py b/tools/binman/etype/blob_ext.py
index d6b0ca1..ca26530 100644
--- a/tools/binman/etype/blob_ext.py
+++ b/tools/binman/etype/blob_ext.py
@@ -9,8 +9,8 @@
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
-from patman import tools
-from patman import tout
+from u_boot_pylib import tools
+from u_boot_pylib import tout
class Entry_blob_ext(Entry_blob):
"""Externally built binary blob
diff --git a/tools/binman/etype/blob_ext_list.py b/tools/binman/etype/blob_ext_list.py
index f00202e..1bfcf67 100644
--- a/tools/binman/etype/blob_ext_list.py
+++ b/tools/binman/etype/blob_ext_list.py
@@ -9,8 +9,8 @@
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
-from patman import tools
-from patman import tout
+from u_boot_pylib import tools
+from u_boot_pylib import tout
class Entry_blob_ext_list(Entry_blob):
"""List of externally built binary blobs
diff --git a/tools/binman/etype/fdtmap.py b/tools/binman/etype/fdtmap.py
index 33c9d03..f1f6217 100644
--- a/tools/binman/etype/fdtmap.py
+++ b/tools/binman/etype/fdtmap.py
@@ -9,8 +9,8 @@
"""
from binman.entry import Entry
-from patman import tools
-from patman import tout
+from u_boot_pylib import tools
+from u_boot_pylib import tout
FDTMAP_MAGIC = b'_FDTMAP_'
FDTMAP_HDR_LEN = 16
diff --git a/tools/binman/etype/files.py b/tools/binman/etype/files.py
index 2081bc7..c8757ea 100644
--- a/tools/binman/etype/files.py
+++ b/tools/binman/etype/files.py
@@ -11,7 +11,7 @@
from binman.etype.section import Entry_section
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
# This is imported if needed
state = None
diff --git a/tools/binman/etype/fill.py b/tools/binman/etype/fill.py
index c91d015..7c93d4e 100644
--- a/tools/binman/etype/fill.py
+++ b/tools/binman/etype/fill.py
@@ -5,7 +5,7 @@
from binman.entry import Entry
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry_fill(Entry):
"""An entry which is filled to a particular byte value
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index 822de79..9def443 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -12,7 +12,7 @@
from binman import elf
from dtoc import fdt_util
from dtoc.fdt import Fdt
-from patman import tools
+from u_boot_pylib import tools
# Supported operations, with the fit,operation property
OP_GEN_FDT_NODES, OP_SPLIT_ELF = range(2)
diff --git a/tools/binman/etype/fmap.py b/tools/binman/etype/fmap.py
index b35450f..3669d91 100644
--- a/tools/binman/etype/fmap.py
+++ b/tools/binman/etype/fmap.py
@@ -7,9 +7,9 @@
from binman.entry import Entry
from binman import fmap_util
-from patman import tools
-from patman.tools import to_hex_size
-from patman import tout
+from u_boot_pylib import tools
+from u_boot_pylib.tools import to_hex_size
+from u_boot_pylib import tout
class Entry_fmap(Entry):
diff --git a/tools/binman/etype/gbb.py b/tools/binman/etype/gbb.py
index ba2a362..cca18af 100644
--- a/tools/binman/etype/gbb.py
+++ b/tools/binman/etype/gbb.py
@@ -8,11 +8,11 @@
from collections import OrderedDict
-from patman import command
+from u_boot_pylib import command
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
# Build GBB flags.
# (src/platform/vboot_reference/firmware/include/gbb_header.h)
diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py
index 04fad40..6513b97 100644
--- a/tools/binman/etype/intel_ifwi.py
+++ b/tools/binman/etype/intel_ifwi.py
@@ -10,7 +10,7 @@
from binman.entry import Entry
from binman.etype.blob_ext import Entry_blob_ext
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry_intel_ifwi(Entry_blob_ext):
"""Intel Integrated Firmware Image (IFWI) file
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index cb264c3c..27a0c4b 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -9,7 +9,7 @@
from binman.entry import Entry
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry_mkimage(Entry):
"""Binary produced by mkimage
diff --git a/tools/binman/etype/null.py b/tools/binman/etype/null.py
index c10d482..263fb52 100644
--- a/tools/binman/etype/null.py
+++ b/tools/binman/etype/null.py
@@ -5,7 +5,7 @@
from binman.entry import Entry
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry_null(Entry):
"""An entry which has no contents of its own
diff --git a/tools/binman/etype/pre_load.py b/tools/binman/etype/pre_load.py
index b622281..bd3545b 100644
--- a/tools/binman/etype/pre_load.py
+++ b/tools/binman/etype/pre_load.py
@@ -8,7 +8,7 @@
import os
import struct
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
from binman.entry import Entry
from binman.etype.collection import Entry_collection
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index d3926f7..eb73367 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -16,9 +16,9 @@
from binman.entry import Entry
from binman import state
from dtoc import fdt_util
-from patman import tools
-from patman import tout
-from patman.tools import to_hex_size
+from u_boot_pylib import tools
+from u_boot_pylib import tout
+from u_boot_pylib.tools import to_hex_size
class Entry_section(Entry):
diff --git a/tools/binman/etype/text.py b/tools/binman/etype/text.py
index c55e023..e4deb4a 100644
--- a/tools/binman/etype/text.py
+++ b/tools/binman/etype/text.py
@@ -7,7 +7,7 @@
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry_text(Entry):
diff --git a/tools/binman/etype/u_boot_dtb_with_ucode.py b/tools/binman/etype/u_boot_dtb_with_ucode.py
index 047d310..f7225ce 100644
--- a/tools/binman/etype/u_boot_dtb_with_ucode.py
+++ b/tools/binman/etype/u_boot_dtb_with_ucode.py
@@ -7,7 +7,7 @@
from binman.entry import Entry
from binman.etype.blob_dtb import Entry_blob_dtb
-from patman import tools
+from u_boot_pylib import tools
# This is imported if needed
state = None
diff --git a/tools/binman/etype/u_boot_elf.py b/tools/binman/etype/u_boot_elf.py
index 3ec774f..f4d86aa 100644
--- a/tools/binman/etype/u_boot_elf.py
+++ b/tools/binman/etype/u_boot_elf.py
@@ -9,7 +9,7 @@
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry_u_boot_elf(Entry_blob):
"""U-Boot ELF image
diff --git a/tools/binman/etype/u_boot_env.py b/tools/binman/etype/u_boot_env.py
index c38340b..c027e93 100644
--- a/tools/binman/etype/u_boot_env.py
+++ b/tools/binman/etype/u_boot_env.py
@@ -8,7 +8,7 @@
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry_u_boot_env(Entry_blob):
"""An entry which contains a U-Boot environment
diff --git a/tools/binman/etype/u_boot_spl_bss_pad.py b/tools/binman/etype/u_boot_spl_bss_pad.py
index 680d198..1ffeb39 100644
--- a/tools/binman/etype/u_boot_spl_bss_pad.py
+++ b/tools/binman/etype/u_boot_spl_bss_pad.py
@@ -10,7 +10,7 @@
from binman import elf
from binman.entry import Entry
from binman.etype.blob import Entry_blob
-from patman import tools
+from u_boot_pylib import tools
class Entry_u_boot_spl_bss_pad(Entry_blob):
"""U-Boot SPL binary padded with a BSS region
diff --git a/tools/binman/etype/u_boot_spl_expanded.py b/tools/binman/etype/u_boot_spl_expanded.py
index 319f670..fcd0dd1 100644
--- a/tools/binman/etype/u_boot_spl_expanded.py
+++ b/tools/binman/etype/u_boot_spl_expanded.py
@@ -5,7 +5,7 @@
# Entry-type module for expanded U-Boot SPL binary
#
-from patman import tout
+from u_boot_pylib import tout
from binman import state
from binman.etype.blob_phase import Entry_blob_phase
diff --git a/tools/binman/etype/u_boot_tpl_bss_pad.py b/tools/binman/etype/u_boot_tpl_bss_pad.py
index 47f4b23..29c6a95 100644
--- a/tools/binman/etype/u_boot_tpl_bss_pad.py
+++ b/tools/binman/etype/u_boot_tpl_bss_pad.py
@@ -10,7 +10,7 @@
from binman import elf
from binman.entry import Entry
from binman.etype.blob import Entry_blob
-from patman import tools
+from u_boot_pylib import tools
class Entry_u_boot_tpl_bss_pad(Entry_blob):
"""U-Boot TPL binary padded with a BSS region
diff --git a/tools/binman/etype/u_boot_tpl_expanded.py b/tools/binman/etype/u_boot_tpl_expanded.py
index 55fde3c..58db4f3 100644
--- a/tools/binman/etype/u_boot_tpl_expanded.py
+++ b/tools/binman/etype/u_boot_tpl_expanded.py
@@ -5,7 +5,7 @@
# Entry-type module for expanded U-Boot TPL binary
#
-from patman import tout
+from u_boot_pylib import tout
from binman import state
from binman.etype.blob_phase import Entry_blob_phase
diff --git a/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py b/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py
index c7f3f9d..86f9578 100644
--- a/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py
+++ b/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py
@@ -7,11 +7,11 @@
import struct
-from patman import command
from binman.entry import Entry
from binman.etype.blob import Entry_blob
from binman.etype.u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr
-from patman import tools
+from u_boot_pylib import command
+from u_boot_pylib import tools
class Entry_u_boot_tpl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr):
"""U-Boot TPL with embedded microcode pointer
diff --git a/tools/binman/etype/u_boot_ucode.py b/tools/binman/etype/u_boot_ucode.py
index 6945411..97ed7d7 100644
--- a/tools/binman/etype/u_boot_ucode.py
+++ b/tools/binman/etype/u_boot_ucode.py
@@ -7,7 +7,7 @@
from binman.entry import Entry
from binman.etype.blob import Entry_blob
-from patman import tools
+from u_boot_pylib import tools
class Entry_u_boot_ucode(Entry_blob):
"""U-Boot microcode block
diff --git a/tools/binman/etype/u_boot_vpl_bss_pad.py b/tools/binman/etype/u_boot_vpl_bss_pad.py
index b2ce2a3..bba38cc 100644
--- a/tools/binman/etype/u_boot_vpl_bss_pad.py
+++ b/tools/binman/etype/u_boot_vpl_bss_pad.py
@@ -10,7 +10,7 @@
from binman import elf
from binman.entry import Entry
from binman.etype.blob import Entry_blob
-from patman import tools
+from u_boot_pylib import tools
class Entry_u_boot_vpl_bss_pad(Entry_blob):
"""U-Boot VPL binary padded with a BSS region
diff --git a/tools/binman/etype/u_boot_vpl_expanded.py b/tools/binman/etype/u_boot_vpl_expanded.py
index 92c64f0..deff5a3 100644
--- a/tools/binman/etype/u_boot_vpl_expanded.py
+++ b/tools/binman/etype/u_boot_vpl_expanded.py
@@ -5,7 +5,7 @@
# Entry-type module for expanded U-Boot VPL binary
#
-from patman import tout
+from u_boot_pylib import tout
from binman import state
from binman.etype.blob_phase import Entry_blob_phase
diff --git a/tools/binman/etype/u_boot_with_ucode_ptr.py b/tools/binman/etype/u_boot_with_ucode_ptr.py
index e275698..41731fd 100644
--- a/tools/binman/etype/u_boot_with_ucode_ptr.py
+++ b/tools/binman/etype/u_boot_with_ucode_ptr.py
@@ -11,8 +11,8 @@
from binman.entry import Entry
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
-from patman import tools
-from patman import command
+from u_boot_pylib import tools
+from u_boot_pylib import command
class Entry_u_boot_with_ucode_ptr(Entry_blob):
"""U-Boot with embedded microcode pointer
diff --git a/tools/binman/etype/vblock.py b/tools/binman/etype/vblock.py
index 04cb722..4adb9a4 100644
--- a/tools/binman/etype/vblock.py
+++ b/tools/binman/etype/vblock.py
@@ -13,7 +13,7 @@
from binman.etype.collection import Entry_collection
from dtoc import fdt_util
-from patman import tools
+from u_boot_pylib import tools
class Entry_vblock(Entry_collection):
"""An entry which contains a Chromium OS verified boot block
diff --git a/tools/binman/fdt_test.py b/tools/binman/fdt_test.py
index 94347b1..7ef8729 100644
--- a/tools/binman/fdt_test.py
+++ b/tools/binman/fdt_test.py
@@ -12,7 +12,7 @@
from dtoc import fdt
from dtoc import fdt_util
from dtoc.fdt import FdtScan
-from patman import tools
+from u_boot_pylib import tools
class TestFdt(unittest.TestCase):
@classmethod
diff --git a/tools/binman/fip_util.py b/tools/binman/fip_util.py
index 95eee32..b5caab2 100755
--- a/tools/binman/fip_util.py
+++ b/tools/binman/fip_util.py
@@ -37,8 +37,8 @@
sys.path.insert(2, os.path.join(OUR_PATH, '..'))
# pylint: disable=C0413
-from patman import command
-from patman import tools
+from u_boot_pylib import command
+from u_boot_pylib import tools
# The TOC header, at the start of the FIP
HEADER_FORMAT = '<IIQ'
diff --git a/tools/binman/fip_util_test.py b/tools/binman/fip_util_test.py
index cf6d000..56aa56f 100755
--- a/tools/binman/fip_util_test.py
+++ b/tools/binman/fip_util_test.py
@@ -20,10 +20,10 @@
sys.path.insert(2, os.path.join(OUR_PATH, '..'))
# pylint: disable=C0413
-from patman import test_util
-from patman import tools
from binman import bintool
from binman import fip_util
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
FIPTOOL = bintool.Bintool.create('fiptool')
HAVE_FIPTOOL = FIPTOOL.is_present()
diff --git a/tools/binman/fmap_util.py b/tools/binman/fmap_util.py
index 82e0f74..40f2dbf 100644
--- a/tools/binman/fmap_util.py
+++ b/tools/binman/fmap_util.py
@@ -10,7 +10,7 @@
import struct
import sys
-from patman import tools
+from u_boot_pylib import tools
# constants imported from lib/fmap.h
FMAP_SIGNATURE = b'__FMAP__'
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index d5cae38..5908580 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -34,10 +34,10 @@
from binman.etype import fdtmap
from binman.etype import image_header
from binman.image import Image
-from patman import command
-from patman import test_util
-from patman import tools
-from patman import tout
+from u_boot_pylib import command
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
+from u_boot_pylib import tout
# Contents of test files, corresponding to different entry types
U_BOOT_DATA = b'1234'
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 9415963..8ebf71d 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -18,8 +18,8 @@
from binman.etype import section
from dtoc import fdt
from dtoc import fdt_util
-from patman import tools
-from patman import tout
+from u_boot_pylib import tools
+from u_boot_pylib import tout
class Image(section.Entry_section):
"""A Image, representing an output from binman
diff --git a/tools/binman/image_test.py b/tools/binman/image_test.py
index e351fa8..bd51c1e 100644
--- a/tools/binman/image_test.py
+++ b/tools/binman/image_test.py
@@ -7,7 +7,7 @@
import unittest
from binman.image import Image
-from patman.test_util import capture_sys_output
+from u_boot_pylib.test_util import capture_sys_output
class TestImage(unittest.TestCase):
def testInvalidFormat(self):
diff --git a/tools/binman/main.py b/tools/binman/main.py
index 14432a8..eef17b7 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -34,7 +34,7 @@
sys.path.insert(2, our1_path)
from binman import bintool
-from patman import test_util
+from u_boot_pylib import test_util
# Bring in the libfdt module
sys.path.insert(2, 'scripts/dtc/pylibfdt')
@@ -44,7 +44,7 @@
from binman import cmdline
from binman import control
-from patman import test_util
+from u_boot_pylib import test_util
def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
"""Run the functional tests and any embedded doctests
@@ -95,7 +95,8 @@
for path in toolpath:
extra_args += ' --toolpath %s' % path
test_util.run_test_coverage('tools/binman/binman', None,
- ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*'],
+ ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*',
+ 'tools/u_boot_pylib/*'],
args.build_dir, all_set, extra_args or None)
def RunBinman(args):
diff --git a/tools/binman/state.py b/tools/binman/state.py
index 3356319..3e78cf3 100644
--- a/tools/binman/state.py
+++ b/tools/binman/state.py
@@ -13,8 +13,8 @@
from dtoc import fdt
import os
-from patman import tools
-from patman import tout
+from u_boot_pylib import tools
+from u_boot_pylib import tout
OUR_PATH = os.path.dirname(os.path.realpath(__file__))
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 7b9be88..d81752e 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -19,10 +19,10 @@
from buildman import builderthread
from buildman import toolchain
-from patman import command
from patman import gitutil
-from patman import terminal
-from patman.terminal import tprint
+from u_boot_pylib import command
+from u_boot_pylib import terminal
+from u_boot_pylib.terminal import tprint
# This indicates an new int or hex Kconfig property with no default
# It hangs the build since the 'conf' tool cannot proceed without valid input.
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 8b88c68..879ff138 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -10,8 +10,8 @@
import threading
from buildman import cfgutil
-from patman import command
from patman import gitutil
+from u_boot_pylib import command
RETURN_CODE_RETRY = -1
BASE_ELF_FILENAMES = ['u-boot', 'spl/u-boot-spl', 'tpl/u-boot-tpl']
diff --git a/tools/buildman/cfgutil.py b/tools/buildman/cfgutil.py
index ab74a8e..a340e01 100644
--- a/tools/buildman/cfgutil.py
+++ b/tools/buildman/cfgutil.py
@@ -7,7 +7,7 @@
import re
-from patman import tools
+from u_boot_pylib import tools
RE_LINE = re.compile(r'(# )?CONFIG_([A-Z0-9_]+)(=(.*)| is not set)')
RE_CFG = re.compile(r'(~?)(CONFIG_)?([A-Z0-9_]+)(=.*)?')
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index c3c5388..f765fe3 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -13,12 +13,12 @@
from buildman import cfgutil
from buildman import toolchain
from buildman.builder import Builder
-from patman import command
from patman import gitutil
from patman import patchstream
-from patman import terminal
-from patman import tools
-from patman.terminal import tprint
+from u_boot_pylib import command
+from u_boot_pylib import terminal
+from u_boot_pylib import tools
+from u_boot_pylib.terminal import tprint
def GetPlural(count):
"""Returns a plural 's' if count is not 1"""
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index cf91c33..ebd78f2 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -14,11 +14,11 @@
from buildman import cmdline
from buildman import control
from buildman import toolchain
-from patman import command
from patman import gitutil
-from patman import terminal
-from patman import test_util
-from patman import tools
+from u_boot_pylib import command
+from u_boot_pylib import terminal
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
settings_data = '''
# Buildman settings file
diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 67c560c..6076ba5 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -25,8 +25,8 @@
from buildman import toolchain
from patman import patchstream
from patman import gitutil
-from patman import terminal
-from patman import test_util
+from u_boot_pylib import terminal
+from u_boot_pylib import test_util
def RunTests(skip_net_tests, verboose, args):
from buildman import func_test
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index daf5467..9fa6445 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -17,10 +17,10 @@
from buildman import control
from buildman import toolchain
from patman import commit
-from patman import command
-from patman import terminal
-from patman import test_util
-from patman import tools
+from u_boot_pylib import command
+from u_boot_pylib import terminal
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
use_network = True
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index ea1ad1b..688f2e2 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -11,9 +11,9 @@
import urllib.request, urllib.error, urllib.parse
from buildman import bsettings
-from patman import command
-from patman import terminal
-from patman import tools
+from u_boot_pylib import command
+from u_boot_pylib import terminal
+from u_boot_pylib import tools
(PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH,
PRIORITY_CALC) = list(range(4))
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index d933972..a8e0534 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -12,7 +12,7 @@
from dtoc import fdt_util
import libfdt
from libfdt import QUIET_NOTFOUND
-from patman import tools
+from u_boot_pylib import tools
# This deals with a device tree, presenting it as an assortment of Node and
# Prop objects, representing nodes and properties, respectively. This file
diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index f343166..f1f7056 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -13,8 +13,8 @@
import sys
import tempfile
-from patman import command
-from patman import tools
+from u_boot_pylib import command
+from u_boot_pylib import tools
def fdt32_to_cpu(val):
"""Convert a device tree cell to an integer
diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py
index 5508759..fc9207d 100755
--- a/tools/dtoc/main.py
+++ b/tools/dtoc/main.py
@@ -35,7 +35,7 @@
'../../build-sandbox_spl/scripts/dtc/pylibfdt'))
from dtoc import dtb_platdata
-from patman import test_util
+from u_boot_pylib import test_util
def run_tests(processes, args):
"""Run all the test we have for dtoc
@@ -65,7 +65,8 @@
"""Run the tests and check that we get 100% coverage"""
sys.argv = [sys.argv[0]]
test_util.run_test_coverage('tools/dtoc/dtoc', '/main.py',
- ['tools/patman/*.py', '*/fdt*', '*test*'], args.build_dir)
+ ['tools/patman/*.py', 'tools/u_boot_pylib/*','*/fdt*', '*test*'],
+ args.build_dir)
if __name__ != '__main__':
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index c62fcba..0f544f9 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -25,8 +25,8 @@
from dtoc.dtb_platdata import tab_to
from dtoc.src_scan import conv_name_to_c
from dtoc.src_scan import get_compat_name
-from patman import test_util
-from patman import tools
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
OUR_PATH = os.path.dirname(os.path.realpath(__file__))
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index dffa86f..32fa69c 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -30,8 +30,8 @@
from dtoc.fdt_util import fdt32_to_cpu, fdt64_to_cpu
from dtoc.fdt import Type, BytesToValue
import libfdt
-from patman import test_util
-from patman import tools
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
#pylint: disable=protected-access
@@ -814,7 +814,8 @@
build_dir (str): Directory containing the build output
"""
test_util.run_test_coverage('tools/dtoc/test_fdt.py', None,
- ['tools/patman/*.py', '*test_fdt.py'], build_dir)
+ ['tools/patman/*.py', 'tools/u_boot_pylib/*', '*test_fdt.py'],
+ build_dir)
def run_tests(names, processes):
diff --git a/tools/dtoc/test_src_scan.py b/tools/dtoc/test_src_scan.py
index f93cd7f..64b7408 100644
--- a/tools/dtoc/test_src_scan.py
+++ b/tools/dtoc/test_src_scan.py
@@ -15,8 +15,8 @@
from unittest import mock
from dtoc import src_scan
-from patman import test_util
-from patman import tools
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
OUR_PATH = os.path.dirname(os.path.realpath(__file__))
diff --git a/tools/patman/__init__.py b/tools/patman/__init__.py
index 1b98ec7..08eeffd 100644
--- a/tools/patman/__init__.py
+++ b/tools/patman/__init__.py
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: GPL-2.0+
-__all__ = ['checkpatch', 'command', 'commit', 'control', 'cros_subprocess',
- 'func_test', 'get_maintainer', 'gitutil', '__main__', 'patchstream',
- 'project', 'series', 'setup', 'settings', 'terminal',
- 'test_checkpatch', 'test_util', 'tools', 'tout']
+__all__ = ['checkpatch', 'commit', 'control', 'func_test', 'get_maintainer',
+ 'gitutil', '__main__', 'patchstream', 'project', 'series',
+ 'settings','setup', 'status', 'test_checkpatch', 'test_settings']
diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 749e634..3063255 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -24,10 +24,10 @@
from patman import gitutil
from patman import project
from patman import settings
-from patman import terminal
-from patman import test_util
from patman import test_checkpatch
-from patman import tools
+from u_boot_pylib import terminal
+from u_boot_pylib import test_util
+from u_boot_pylib import tools
epilog = '''Create patches from commits in a branch, check them and email them
as specified by tags you place in the commits. Use -n to do a dry run first.'''
@@ -150,7 +150,7 @@
result = test_util.run_test_suites(
'patman', False, False, False, None, None, None,
[test_checkpatch.TestPatch, func_test.TestFunctional,
- 'gitutil', 'settings', 'terminal'])
+ 'gitutil', 'settings'])
sys.exit(0 if result.wasSuccessful() else 1)
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index d1b902d..c1dec32 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -7,9 +7,9 @@
import re
import sys
-from patman import command
from patman import gitutil
-from patman import terminal
+from u_boot_pylib import command
+from u_boot_pylib import terminal
EMACS_PREFIX = r'(?:[0-9]{4}.*\.patch:[0-9]+: )?'
TYPE_NAME = r'([A-Z_]+:)?'
diff --git a/tools/patman/control.py b/tools/patman/control.py
index 38e98da..d1bcea0 100644
--- a/tools/patman/control.py
+++ b/tools/patman/control.py
@@ -14,7 +14,7 @@
from patman import checkpatch
from patman import gitutil
from patman import patchstream
-from patman import terminal
+from u_boot_pylib import terminal
def setup():
"""Do required setup before doing anything"""
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index c25a47b..8c2dfbe 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -23,9 +23,9 @@
from patman.patchstream import PatchStream
from patman.series import Series
from patman import settings
-from patman import terminal
-from patman import tools
-from patman.test_util import capture_sys_output
+from u_boot_pylib import terminal
+from u_boot_pylib import tools
+from u_boot_pylib.test_util import capture_sys_output
import pygit2
from patman import status
diff --git a/tools/patman/get_maintainer.py b/tools/patman/get_maintainer.py
index f7011be..8df3d12 100644
--- a/tools/patman/get_maintainer.py
+++ b/tools/patman/get_maintainer.py
@@ -7,8 +7,8 @@
import shlex
import shutil
-from patman import command
from patman import gitutil
+from u_boot_pylib import command
def find_get_maintainer(script_file_name):
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index 5e74210..6700057 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -5,9 +5,9 @@
import os
import sys
-from patman import command
from patman import settings
-from patman import terminal
+from u_boot_pylib import command
+from u_boot_pylib import terminal
# True to use --no-decorate - we check this in setup()
use_no_decorate = True
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index fb6a603..f91669a 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -14,10 +14,10 @@
import shutil
import tempfile
-from patman import command
from patman import commit
from patman import gitutil
from patman.series import Series
+from u_boot_pylib import command
# Tags that we detect and remove
RE_REMOVE = re.compile(r'^BUG=|^TEST=|^BRANCH=|^Review URL:'
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 2eeeef7..88417ac 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -11,8 +11,8 @@
from patman import get_maintainer
from patman import gitutil
from patman import settings
-from patman import terminal
-from patman import tools
+from u_boot_pylib import terminal
+from u_boot_pylib import tools
# Series-xxx tags that we understand
valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',
diff --git a/tools/patman/status.py b/tools/patman/status.py
index 47ed6d6..5fb436e 100644
--- a/tools/patman/status.py
+++ b/tools/patman/status.py
@@ -18,8 +18,8 @@
from patman import patchstream
from patman.patchstream import PatchStream
-from patman import terminal
-from patman import tout
+from u_boot_pylib import terminal
+from u_boot_pylib import tout
# Patches which are part of a multi-patch series are shown with a prefix like
# [prefix, version, sequence], for example '[RFC, v2, 3/5]'. All but the last
diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
index c768a2f..06b7cbc 100644
--- a/tools/patman/test_settings.py
+++ b/tools/patman/test_settings.py
@@ -10,7 +10,7 @@
import tempfile
from patman import settings
-from patman import tools
+from u_boot_pylib import tools
@contextlib.contextmanager
diff --git a/tools/rmboard.py b/tools/rmboard.py
index ae25632..0c56b14 100755
--- a/tools/rmboard.py
+++ b/tools/rmboard.py
@@ -28,7 +28,7 @@
import re
import sys
-from patman import command
+from u_boot_pylib import command
def rm_kconfig_include(path):
"""Remove a path from Kconfig files
diff --git a/tools/u_boot_pylib/__init__.py b/tools/u_boot_pylib/__init__.py
new file mode 100644
index 0000000..63c88e8
--- /dev/null
+++ b/tools/u_boot_pylib/__init__.py
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+__all__ = ['command', 'cros_subprocess','terminal', 'test_util', 'tools',
+ 'tout']
diff --git a/tools/u_boot_pylib/__main__.py b/tools/u_boot_pylib/__main__.py
new file mode 100755
index 0000000..8f98d7b
--- /dev/null
+++ b/tools/u_boot_pylib/__main__.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright 2023 Google LLC
+#
+
+import os
+import sys
+
+if __name__ == "__main__":
+ # Allow 'from u_boot_pylib import xxx to work'
+ our_path = os.path.dirname(os.path.realpath(__file__))
+ sys.path.append(os.path.join(our_path, '..'))
+
+ # Run tests
+ from u_boot_pylib import terminal
+ from u_boot_pylib import test_util
+
+ result = test_util.run_test_suites(
+ 'u_boot_pylib', False, False, False, None, None, None,
+ ['terminal'])
+
+ sys.exit(0 if result.wasSuccessful() else 1)
diff --git a/tools/patman/command.py b/tools/u_boot_pylib/command.py
similarity index 98%
rename from tools/patman/command.py
rename to tools/u_boot_pylib/command.py
index 92c453b..9bbfc5b 100644
--- a/tools/patman/command.py
+++ b/tools/u_boot_pylib/command.py
@@ -4,7 +4,7 @@
import os
-from patman import cros_subprocess
+from u_boot_pylib import cros_subprocess
"""Shell command ease-ups for Python."""
diff --git a/tools/patman/cros_subprocess.py b/tools/u_boot_pylib/cros_subprocess.py
similarity index 100%
rename from tools/patman/cros_subprocess.py
rename to tools/u_boot_pylib/cros_subprocess.py
diff --git a/tools/patman/terminal.py b/tools/u_boot_pylib/terminal.py
similarity index 100%
rename from tools/patman/terminal.py
rename to tools/u_boot_pylib/terminal.py
diff --git a/tools/patman/test_util.py b/tools/u_boot_pylib/test_util.py
similarity index 99%
rename from tools/patman/test_util.py
rename to tools/u_boot_pylib/test_util.py
index 9e0811b..e7564e1 100644
--- a/tools/patman/test_util.py
+++ b/tools/u_boot_pylib/test_util.py
@@ -11,7 +11,7 @@
import sys
import unittest
-from patman import command
+from u_boot_pylib import command
from io import StringIO
diff --git a/tools/patman/tools.py b/tools/u_boot_pylib/tools.py
similarity index 99%
rename from tools/patman/tools.py
rename to tools/u_boot_pylib/tools.py
index 2ac814d..187725b 100644
--- a/tools/patman/tools.py
+++ b/tools/u_boot_pylib/tools.py
@@ -11,8 +11,8 @@
import tempfile
import urllib.request
-from patman import command
-from patman import tout
+from u_boot_pylib import command
+from u_boot_pylib import tout
# Output directly (generally this is temporary)
outdir = None
diff --git a/tools/patman/tout.py b/tools/u_boot_pylib/tout.py
similarity index 98%
rename from tools/patman/tout.py
rename to tools/u_boot_pylib/tout.py
index ff0fd92..6bd2806 100644
--- a/tools/patman/tout.py
+++ b/tools/u_boot_pylib/tout.py
@@ -6,7 +6,7 @@
import sys
-from patman import terminal
+from u_boot_pylib import terminal
# Output verbosity levels that we support
ERROR, WARNING, NOTICE, INFO, DETAIL, DEBUG = range(6)
diff --git a/tools/u_boot_pylib/u_boot_pylib b/tools/u_boot_pylib/u_boot_pylib
new file mode 120000
index 0000000..5a427d1
--- /dev/null
+++ b/tools/u_boot_pylib/u_boot_pylib
@@ -0,0 +1 @@
+__main__.py
\ No newline at end of file