[PATCH v2 1/4] binman: Allow preserving the output dir when replacing

Simon Glass sjg at chromium.org
Fri Mar 3 01:02:42 CET 2023


Add these flags for the 'replace' subcommand too, to aid debugging.

Signed-off-by: Simon Glass <sjg at chromium.org>

44 2023 -0700

---

Changes in v2:
- Add new patch to allow preserving the output dir when replacing

 tools/binman/binman.rst |  6 ++++++
 tools/binman/cmdline.py | 16 ++++++++++------
 tools/binman/control.py |  5 ++++-
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index 2bcb7d3886f..55ef317a691 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -1663,6 +1663,12 @@ Options:
 -m, --map
     Output a map file for the updated image
 
+-O OUTDIR, --outdir OUTDIR
+    Path to directory to use for intermediate and output files
+
+-p, --preserve
+    Preserve temporary output directory even if option -O is not given
+
 This replaces one or more entries in an existing image. See
 `Replacing files in an image`_.
 
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index 986d6f1a315..d690b8b0775 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -67,6 +67,14 @@ def ParseArgs(argv):
             options provides access to the options (e.g. option.debug)
             args is a list of string arguments
     """
+    def _AddPreserve(pars):
+        pars.add_argument('-O', '--outdir', type=str,
+            action='store', help='Path to directory to use for intermediate '
+            'and output files')
+        pars.add_argument('-p', '--preserve', action='store_true',\
+            help='Preserve temporary output directory even if option -O is not '
+                 'given')
+
     if '-H' in argv:
         argv.append('build')
 
@@ -118,12 +126,7 @@ controlled by a description in the board device tree.'''
     build_parser.add_argument('-n', '--no-expanded', action='store_true',
             help="Don't use 'expanded' versions of entries where available; "
                  "normally 'u-boot' becomes 'u-boot-expanded', for example")
-    build_parser.add_argument('-O', '--outdir', type=str,
-        action='store', help='Path to directory to use for intermediate and '
-        'output files')
-    build_parser.add_argument('-p', '--preserve', action='store_true',\
-        help='Preserve temporary output directory even if option -O is not '
-             'given')
+    _AddPreserve(build_parser)
     build_parser.add_argument('-u', '--update-fdt', action='store_true',
         default=False, help='Update the binman node with offset/size info')
     build_parser.add_argument('--update-fdt-in-elf', type=str,
@@ -160,6 +163,7 @@ controlled by a description in the board device tree.'''
         help='Path to directory to use for input files')
     replace_parser.add_argument('-m', '--map', action='store_true',
         default=False, help='Output a map file for the updated image')
+    _AddPreserve(replace_parser)
     replace_parser.add_argument('paths', type=str, nargs='*',
                                 help='Paths within file to replace (wildcard)')
 
diff --git a/tools/binman/control.py b/tools/binman/control.py
index e64740094f6..f4e3898b34c 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -653,7 +653,10 @@ def Binman(args):
     if args.cmd in ['ls', 'extract', 'replace', 'tool']:
         try:
             tout.init(args.verbosity)
-            tools.prepare_output_dir(None)
+            if args.cmd == 'replace':
+                tools.prepare_output_dir(args.outdir, args.preserve)
+            else:
+                tools.prepare_output_dir(None)
             if args.cmd == 'ls':
                 ListEntries(args.image, args.paths)
 
-- 
2.40.0.rc0.216.gc4246ad0f0-goog



More information about the U-Boot mailing list