mirror of
https://xff.cz/git/u-boot/
synced 2025-11-01 19:05:51 +01:00
@@ -2,18 +2,68 @@
|
||||
# Copyright (c) 2016 Google, Inc
|
||||
# Written by Simon Glass <sjg@chromium.org>
|
||||
#
|
||||
# Command-line parser for binman
|
||||
#
|
||||
|
||||
"""Command-line parser for binman"""
|
||||
|
||||
import argparse
|
||||
from argparse import ArgumentParser
|
||||
import state
|
||||
|
||||
def make_extract_parser(subparsers):
|
||||
"""make_extract_parser: Make a subparser for the 'extract' command
|
||||
|
||||
Args:
|
||||
subparsers (ArgumentParser): parser to add this one to
|
||||
"""
|
||||
extract_parser = subparsers.add_parser('extract',
|
||||
help='Extract files from an image')
|
||||
extract_parser.add_argument('-F', '--format', type=str,
|
||||
help='Select an alternative format for extracted data')
|
||||
extract_parser.add_argument('-i', '--image', type=str, required=True,
|
||||
help='Image filename to extract')
|
||||
extract_parser.add_argument('-f', '--filename', type=str,
|
||||
help='Output filename to write to')
|
||||
extract_parser.add_argument('-O', '--outdir', type=str, default='',
|
||||
help='Path to directory to use for output files')
|
||||
extract_parser.add_argument('paths', type=str, nargs='*',
|
||||
help='Paths within file to extract (wildcard)')
|
||||
extract_parser.add_argument('-U', '--uncompressed', action='store_true',
|
||||
help='Output raw uncompressed data for compressed entries')
|
||||
|
||||
|
||||
#pylint: disable=R0903
|
||||
class BinmanVersion(argparse.Action):
|
||||
"""Handles the -V option to binman
|
||||
|
||||
This reads the version information from a file called 'version' in the same
|
||||
directory as this file.
|
||||
|
||||
If not present it assumes this is running from the U-Boot tree and collects
|
||||
the version from the Makefile.
|
||||
|
||||
The format of the version information is three VAR = VALUE lines, for
|
||||
example:
|
||||
|
||||
VERSION = 2022
|
||||
PATCHLEVEL = 01
|
||||
EXTRAVERSION = -rc2
|
||||
"""
|
||||
def __init__(self, nargs=0, **kwargs):
|
||||
super().__init__(nargs=nargs, **kwargs)
|
||||
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
parser._print_message(f'Binman {state.GetVersion()}\n')
|
||||
parser.exit()
|
||||
|
||||
|
||||
def ParseArgs(argv):
|
||||
"""Parse the binman command-line arguments
|
||||
|
||||
Args:
|
||||
argv: List of string arguments
|
||||
argv (list of str): List of string arguments
|
||||
|
||||
Returns:
|
||||
Tuple (options, args) with the command-line options and arugments.
|
||||
tuple: (options, args) with the command-line options and arugments.
|
||||
options provides access to the options (e.g. option.debug)
|
||||
args is a list of string arguments
|
||||
"""
|
||||
@@ -39,6 +89,7 @@ controlled by a description in the board device tree.'''
|
||||
parser.add_argument('-v', '--verbosity', default=1,
|
||||
type=int, help='Control verbosity: 0=silent, 1=warnings, 2=notices, '
|
||||
'3=info, 4=detail, 5=debug')
|
||||
parser.add_argument('-V', '--version', nargs=0, action=BinmanVersion)
|
||||
|
||||
subparsers = parser.add_subparsers(dest='cmd')
|
||||
subparsers.required = True
|
||||
@@ -76,8 +127,8 @@ controlled by a description in the board device tree.'''
|
||||
build_parser.add_argument('--update-fdt-in-elf', type=str,
|
||||
help='Update an ELF file with the output dtb: infile,outfile,begin_sym,end_sym')
|
||||
|
||||
entry_parser = subparsers.add_parser('entry-docs',
|
||||
help='Write out entry documentation (see entries.rst)')
|
||||
subparsers.add_parser(
|
||||
'entry-docs', help='Write out entry documentation (see entries.rst)')
|
||||
|
||||
list_parser = subparsers.add_parser('ls', help='List files in an image')
|
||||
list_parser.add_argument('-i', '--image', type=str, required=True,
|
||||
@@ -85,18 +136,7 @@ controlled by a description in the board device tree.'''
|
||||
list_parser.add_argument('paths', type=str, nargs='*',
|
||||
help='Paths within file to list (wildcard)')
|
||||
|
||||
extract_parser = subparsers.add_parser('extract',
|
||||
help='Extract files from an image')
|
||||
extract_parser.add_argument('-i', '--image', type=str, required=True,
|
||||
help='Image filename to extract')
|
||||
extract_parser.add_argument('-f', '--filename', type=str,
|
||||
help='Output filename to write to')
|
||||
extract_parser.add_argument('-O', '--outdir', type=str, default='',
|
||||
help='Path to directory to use for output files')
|
||||
extract_parser.add_argument('paths', type=str, nargs='*',
|
||||
help='Paths within file to extract (wildcard)')
|
||||
extract_parser.add_argument('-U', '--uncompressed', action='store_true',
|
||||
help='Output raw uncompressed data for compressed entries')
|
||||
make_extract_parser(subparsers)
|
||||
|
||||
replace_parser = subparsers.add_parser('replace',
|
||||
help='Replace entries in an image')
|
||||
|
||||
Reference in New Issue
Block a user