binman: build_from_git: Add argument specifying branch
PATCH v2 1/3 binman: build_from_git: Add argument specifying branch
Add optional argument git_branch to build_from_git. The new argument allows specifying which branch of the repo to use.
--- tools/binman/bintool.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
tools/binman/bintool.py +8 -2
@@ -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): """Build a bintool from a git repo This clones the repo in a temporary directory, builds it with 'make',
@@ -341,6 +342,7 @@ 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 Returns: tuple:
@@ -350,7 +352,11 @@ 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()}',
Signature · 1 line
2.34.1
PATCH v2 2/3 binman: build_from_git: Add optional make path inside git repo
Add optional argument make_path to build_from git. The new argument allows specifying the path to a Makefile in case it is not in the root of the git repo.
Also adjust the corresponding test.
---
v2: fix tests
--- tools/binman/bintool.py | 9 +++++++-- tools/binman/bintool_test.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-)
tools/binman/bintool.py +7 -2
@@ -329,7 +329,7 @@ class Bintool: @classmethod def build_from_git(cls, git_repo, make_targets, bintool_path, - flags=None, git_branch=None): + 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',
@@ -343,6 +343,8 @@ class Bintool: 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:
@@ -359,7 +361,10 @@ class Bintool: 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
tools/binman/bintool_test.py +1 -0
@@ -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'
Signature · 1 line
2.34.1
Re: [PATCH v2 2/3] binman: build_from_git: Add optional make path inside git repo
Quoted 6 lines · Leonard Anderweit
Add optional argument
make_pathtobuild_fromgit. The new argument allows specifying the path to aMakefilein case it is not in the root of the git repo.
Also adjust the corresponding test.
Quoted 7 lines
Signed-off-by Leonard Anderweit <[email protected]>---
v2: fix tests--- tools/binman/bintool.py | 9 +++++++-- tools/binman/bintool_test.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-)
PATCH v2 3/3 binman: cst: Build from source
In reply to Leonard AnderweitBuild the imx code singing tool from source instead of relying on the distro to provide the tool.
Use the debian/unstable branch because the default branch is outdated. The binary is supposed to be build with docker, work around that by selecting the correct Makefile directly.
Also append the description and add a link to documentation.
---
v2: add documentation
--- tools/binman/bintools.rst | 8 ++++++++ tools/binman/btool/cst.py | 37 +++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 16 deletions(-)
tools/binman/bintools.rst +8 -0
@@ -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)
tools/binman/btool/cst.py +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
Signature · 1 line
2.34.1
Re: [PATCH v2 3/3] binman: cst: Build from source
Quoted 8 lines · Leonard Anderweit
Build the imx code singing tool from source instead of relying on the distro to provide the tool.
Use the debian/unstable branch because the default branch is outdated. The binary is supposed to be build with docker, work around that by selecting the correctMakefiledirectly.
Also append the description and add a link to documentation.
Quoted 8 lines
Signed-off-by Leonard Anderweit <[email protected]>---
v2: add documentation--- tools/binman/bintools.rst | 8 ++++++++ tools/binman/btool/cst.py | 37 +++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 16 deletions(-)
Quoted 8 lines · Leonard Anderweit
Add optional argument
git_branchtobuild_from_git. The new argument allows specifying which branch of the repo to use.Signed-off-by Leonard Anderweit <[email protected]>--- tools/binman/bintool.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Quoted 4 lines · Leonard Anderweit
Add optional argument
git_branchtobuild_from_git. The new argument allows specifying which branch of the repo to use.
Applied to u-boot/next, thanks!
[1/3] binman: build_from_git: Add argument specifying branch
commit: 5f2096d2bc58ac265110777d08673a0e4b27cd84
[2/3] binman: build_from_git: Add optional make path inside git repo
commit: b48bc416206788da990c34ddcf92d5c3816247ea
[3/3] binman: cst: Build from source
commit: 326b7ea9823a74a83b3a7ef6ee3f4927eb36987eSignature · 1 line
Tom