Merge patch series "binman: build_from_git: Add argument specifying branch"
This series from Leonard Anderweit <l.anderweit@phytec.de> provides some improvements to the binman tool and i.MX specific tooling then makes use of it. Link: https://lore.kernel.org/r/20250226210501.72794-1-l.anderweit@phytec.de
This commit is contained in:
+14
-3
@@ -328,7 +328,8 @@ class Bintool:
|
||||
return result.stdout
|
||||
|
||||
@classmethod
|
||||
def build_from_git(cls, git_repo, make_targets, bintool_path, flags=None):
|
||||
def build_from_git(cls, git_repo, make_targets, bintool_path,
|
||||
flags=None, git_branch=None, make_path=None):
|
||||
"""Build a bintool from a git repo
|
||||
|
||||
This clones the repo in a temporary directory, builds it with 'make',
|
||||
@@ -341,6 +342,9 @@ class Bintool:
|
||||
bintool_path (str): Relative path of the tool in the repo, after
|
||||
build is complete
|
||||
flags (list of str): Flags or variables to pass to make, or None
|
||||
git_branch (str): Branch of git repo, or None to use the default
|
||||
make_path (str): Relative path inside git repo containing the
|
||||
Makefile, or None
|
||||
|
||||
Returns:
|
||||
tuple:
|
||||
@@ -350,10 +354,17 @@ class Bintool:
|
||||
"""
|
||||
tmpdir = tempfile.mkdtemp(prefix='binmanf.')
|
||||
print(f"- clone git repo '{git_repo}' to '{tmpdir}'")
|
||||
tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir)
|
||||
if git_branch:
|
||||
tools.run('git', 'clone', '--depth', '1', '--branch', git_branch,
|
||||
git_repo, tmpdir)
|
||||
else:
|
||||
tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir)
|
||||
for target in make_targets:
|
||||
print(f"- build target '{target}'")
|
||||
cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}',
|
||||
makedir = tmpdir
|
||||
if make_path:
|
||||
makedir = os.path.join(tmpdir, make_path)
|
||||
cmd = ['make', '-C', makedir, '-j', f'{multiprocessing.cpu_count()}',
|
||||
target]
|
||||
if flags:
|
||||
cmd += flags
|
||||
|
||||
@@ -303,6 +303,7 @@ class TestBintool(unittest.TestCase):
|
||||
# See Bintool.build_from_git()
|
||||
tmpdir = cmd[2]
|
||||
self.fname = os.path.join(tmpdir, 'pathname')
|
||||
os.makedirs(os.path.dirname(tmpdir), exist_ok=True)
|
||||
tools.write_file(self.fname, b'hello')
|
||||
|
||||
expected = b'this is a test'
|
||||
|
||||
@@ -52,6 +52,14 @@ Bintool: cst: Image generation for U-Boot
|
||||
This bintool supports running `cst` with some basic parameters as
|
||||
needed by binman.
|
||||
|
||||
cst (imx code signing tool) is used for sigining bootloader binaries for
|
||||
various i.MX SoCs.
|
||||
|
||||
See `Code Signing Tool Users Guide`_ for more information.
|
||||
|
||||
.. _`Code Signing Tool Users Guide`:
|
||||
https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/202591/1/CST_UG.pdf
|
||||
|
||||
|
||||
|
||||
Bintool: fdt_add_pubkey: Add public key to control dtb (spl or u-boot proper)
|
||||
|
||||
+21
-16
@@ -12,6 +12,14 @@ class Bintoolcst(bintool.Bintool):
|
||||
|
||||
This bintool supports running `cst` with some basic parameters as
|
||||
needed by binman.
|
||||
|
||||
cst (imx code signing tool) is used for sigining bootloader binaries for
|
||||
various i.MX SoCs.
|
||||
|
||||
See `Code Signing Tool Users Guide`_ for more information.
|
||||
|
||||
.. _`Code Signing Tool Users Guide`:
|
||||
https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/202591/1/CST_UG.pdf
|
||||
"""
|
||||
def __init__(self, name):
|
||||
super().__init__(name, 'Sign NXP i.MX image')
|
||||
@@ -29,20 +37,17 @@ class Bintoolcst(bintool.Bintool):
|
||||
return self.run_cmd(*args)
|
||||
|
||||
def fetch(self, method):
|
||||
"""Fetch handler for cst
|
||||
|
||||
This installs cst using the apt utility.
|
||||
|
||||
Args:
|
||||
method (FETCH_...): Method to use
|
||||
|
||||
Returns:
|
||||
True if the file was fetched and now installed, None if a method
|
||||
other than FETCH_BIN was requested
|
||||
|
||||
Raises:
|
||||
Valuerror: Fetching could not be completed
|
||||
"""
|
||||
if method != bintool.FETCH_BIN:
|
||||
"""Build cst from git"""
|
||||
if method != bintool.FETCH_BUILD:
|
||||
return None
|
||||
return self.apt_install('imx-code-signing-tool')
|
||||
|
||||
from platform import architecture
|
||||
arch = 'linux64' if architecture()[0] == '64bit' else 'linux32'
|
||||
result = self.build_from_git(
|
||||
'https://gitlab.apertis.org/pkg/imx-code-signing-tool',
|
||||
['all'],
|
||||
f'code/obj.{arch}/cst',
|
||||
flags=[f'OSTYPE={arch}', 'ENCRYPTION=yes'],
|
||||
git_branch='debian/unstable',
|
||||
make_path=f'code/obj.{arch}/')
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user