aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/btool/cst.py
blob: 30e78bdbbd9d5f94bd58e29864a99729d389bd72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# SPDX-License-Identifier: GPL-2.0+
# Copyright 2024 Marek Vasut <marex@denx.de>
#
"""Bintool implementation for cst"""

import re

from binman import bintool

class Bintoolcst(bintool.Bintool):
    """Image generation for U-Boot

    This bintool supports running `cst` with some basic parameters as
    needed by binman.
    """
    def __init__(self, name):
        super().__init__(name, 'Sign NXP i.MX image')

    # pylint: disable=R0913
    def run(self, output_fname=None):
        """Run cst

        Args:
            output_fname: Output filename to write to
        """
        args = []
        if output_fname:
            args += ['-o', output_fname]
        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:
            return None
        return self.apt_install('imx-code-signing-tool')