]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Add a function to check for special section nodes
authorSimon Glass <sjg@chromium.org>
Wed, 11 Jan 2023 23:10:15 +0000 (16:10 -0700)
committerSimon Glass <sjg@chromium.org>
Wed, 18 Jan 2023 21:55:40 +0000 (14:55 -0700)
This appears in two places in the code. Use a shared function instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/etype/fit.py
tools/binman/etype/section.py

index f0e3fd1a09229bcd261030d3f025cad3c3a0d5e9..0e9d81b9e84a19df75cf57a62ec2f189916b3474 100644 (file)
@@ -655,8 +655,7 @@ class Entry_fit(Entry_section):
 
             for subnode in node.subnodes:
                 subnode_path = f'{rel_path}/{subnode.name}'
-                if has_images and not (subnode.name.startswith('hash') or
-                                       subnode.name.startswith('signature')):
+                if has_images and not self.IsSpecialSubnode(subnode):
                     # This subnode is a content node not meant to appear in
                     # the FIT (e.g. "/images/kernel/u-boot"), so don't call
                     # fsw.add_node() or _add_node() for it.
index 28f04cb84a531a7184def15126205b16f0b75b37..a22be7ec774109230e073e382b6d6311e6ae934d 100644 (file)
@@ -169,6 +169,17 @@ class Entry_section(Entry):
         self._ignore_missing = False
         self._filename = None
 
+    def IsSpecialSubnode(self, node):
+        """Check if a node is a special one used by the section itself
+
+        Some notes are used for hashing / signatures and do not add entries to
+        the actual section.
+
+        Returns:
+            bool: True if the node is a special one, else False
+        """
+        return node.name.startswith('hash') or node.name.startswith('signature')
+
     def ReadNode(self):
         """Read properties from the section node"""
         super().ReadNode()
@@ -195,7 +206,7 @@ class Entry_section(Entry):
 
     def ReadEntries(self):
         for node in self._node.subnodes:
-            if node.name.startswith('hash') or node.name.startswith('signature'):
+            if self.IsSpecialSubnode(node):
                 continue
             entry = Entry.Create(self, node,
                                  expanded=self.GetImage().use_expanded,