1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2018 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
5 # Entry-type module for a set of files which are placed in individual
12 from binman.etype.section import Entry_section
13 from dtoc import fdt_util
14 from patman import tools
17 class Entry_files(Entry_section):
18 """Entry containing a set of files
20 Properties / Entry arguments:
21 - pattern: Filename pattern to match the files to include
22 - compress: Compression algorithm to use:
24 lz4: Use lz4 compression (via 'lz4' command-line utility)
26 This entry reads a number of files and places each in a separate sub-entry
27 within this entry. To access these you need to enable device-tree updates
28 at run-time so you can obtain the file positions.
30 def __init__(self, section, etype, node):
31 # Put this here to allow entry-docs and help to work without libfdt
33 from binman import state
35 Entry_section.__init__(self, section, etype, node)
36 self._pattern = fdt_util.GetString(self._node, 'pattern')
38 self.Raise("Missing 'pattern' property")
39 self._compress = fdt_util.GetString(self._node, 'compress', 'none')
40 self._require_matches = fdt_util.GetBool(self._node,
43 def ExpandEntries(self):
44 files = tools.GetInputFilenameGlob(self._pattern)
45 if self._require_matches and not files:
46 self.Raise("Pattern '%s' matched no files" % self._pattern)
48 if not os.path.isfile(fname):
50 name = os.path.basename(fname)
51 subnode = self._node.FindNode(name)
53 subnode = state.AddSubnode(self._node, name)
54 state.AddString(subnode, 'type', 'blob')
55 state.AddString(subnode, 'filename', fname)
56 state.AddString(subnode, 'compress', self._compress)
58 # Read entries again, now that we have some