diff mbox series

[4/8] binman: Add a function to check for special section nodes

Message ID 20230111231019.3828687-5-sjg@chromium.org
State Accepted
Commit 97fb8081ec0c8009ff5e70c054e8ece08e4465ed
Delegated to: Simon Glass
Headers show
Series binman: Enhancements for symbol handling | expand

Commit Message

Simon Glass Jan. 11, 2023, 11:10 p.m. UTC
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     |  3 +--
 tools/binman/etype/section.py | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

Comments

Simon Glass Jan. 19, 2023, 2:11 a.m. UTC | #1
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     |  3 +--
 tools/binman/etype/section.py | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index f0e3fd1a092..0e9d81b9e84 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -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.
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 28f04cb84a5..a22be7ec774 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -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,