diff options
author | Simon Glass <sjg@chromium.org> | 2019-07-08 14:25:50 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2019-07-24 12:54:08 -0700 |
commit | f667e45b1c0a7f21d433ee8f3ec18858d87dd2e5 (patch) | |
tree | ae849665f80553e7689976d578e90250545f5423 /tools/binman/control.py | |
parent | eea264ead3ca198ed66f62a78dc4940075621ae7 (diff) |
binman: Allow reading an entry from an image
It is useful to be able to extract entry contents from an image to see
what is inside. Add a simple function to read the contents of an entry,
decompressing it by default.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/control.py')
-rw-r--r-- | tools/binman/control.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/binman/control.py b/tools/binman/control.py index 813c8b1bf9..b244e7a0cd 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -98,6 +98,26 @@ def ListEntries(image_fname, entry_paths): out += txt print(out.rstrip()) + +def ReadEntry(image_fname, entry_path, decomp=True): + """Extract an entry from an image + + This extracts the data from a particular entry in an image + + Args: + image_fname: Image filename to process + entry_path: Path to entry to extract + decomp: True to return uncompressed data, if the data is compress + False to return the raw data + + Returns: + data extracted from the entry + """ + image = Image.FromFile(image_fname) + entry = image.FindEntryPath(entry_path) + return entry.ReadData(decomp) + + def Binman(args): """The main control code for binman |