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 section import Entry_section
19 class Entry_files(Entry_section):
20 """Entry containing a set of files
22 Properties / Entry arguments:
23 - pattern: Filename pattern to match the files to include
24 - compress: Compression algorithm to use:
26 lz4: Use lz4 compression (via 'lz4' command-line utility)
28 This entry reads a number of files and places each in a separate sub-entry
29 within this entry. To access these you need to enable device-tree updates
30 at run-time so you can obtain the file positions.
32 def __init__(self, section, etype, node):
33 Entry_section.__init__(self, section, etype, node)
34 self._pattern = fdt_util.GetString(self._node, 'pattern')
36 self.Raise("Missing 'pattern' property")
37 self._compress = fdt_util.GetString(self._node, 'compress', 'none')
38 self._require_matches = fdt_util.GetBool(self._node,
41 def ExpandEntries(self):
42 files = tools.GetInputFilenameGlob(self._pattern)
43 if self._require_matches and not files:
44 self.Raise("Pattern '%s' matched no files" % self._pattern)
46 if not os.path.isfile(fname):
48 name = os.path.basename(fname)
49 subnode = self._node.FindNode(name)
51 subnode = state.AddSubnode(self._node, name)
52 state.AddString(subnode, 'type', 'blob')
53 state.AddString(subnode, 'filename', fname)
54 state.AddString(subnode, 'compress', self._compress)
56 # Read entries again, now that we have some
57 self._section._ReadEntries()