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