]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
binman: Move 'external' support into base class
authorSimon Glass <sjg@chromium.org>
Tue, 1 Sep 2020 11:13:57 +0000 (05:13 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 22 Sep 2020 18:50:43 +0000 (12:50 -0600)
At present we have an Entry_blob_ext which implement a blob which holds an
external binary. We need to support other entry types that hold external
binaries, e.g. Entry_blob_named_by_arg. Move the support into the base
Entry class to allow this.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/README.entries
tools/binman/entry.py
tools/binman/etype/blob.py
tools/binman/etype/blob_ext.py
tools/binman/etype/section.py

index 97bfae1611642b85113bf79777322b5edeb02ee1..1086a6a979030a85be24561633adb5ea0a5526fe 100644 (file)
@@ -692,7 +692,7 @@ Properties / Entry arguments: (see binman README for more information)
         when writing out the map
 
 Properties:
-    _allow_missing: True if this section permits external blobs to be
+    allow_missing: True if this section permits external blobs to be
         missing their contents. The second will produce an image but of
         course it will not work.
 
index c17a98958bd57ba1daa41f6de5bd8d8f4aefb6a9..0f128c4cf5e4d0bd0c4ce8f8dd8ea2bdfedb995d 100644 (file)
@@ -57,6 +57,10 @@ class Entry(object):
         compress: Compression algoithm used (e.g. 'lz4'), 'none' if none
         orig_offset: Original offset value read from node
         orig_size: Original size value read from node
+        missing: True if this entry is missing its contents
+        allow_missing: Allow children of this entry to be missing (used by
+            subclasses such as Entry_section)
+        external: True if this entry contains an external binary blob
     """
     def __init__(self, section, etype, node, name_prefix=''):
         # Put this here to allow entry-docs and help to work without libfdt
@@ -83,6 +87,8 @@ class Entry(object):
         self._expand_size = False
         self.compress = 'none'
         self.missing = False
+        self.external = False
+        self.allow_missing = False
 
     @staticmethod
     def Lookup(node_path, etype):
@@ -813,3 +819,11 @@ features to produce new behaviours.
         """
         if self.missing:
             missing_list.append(self)
+
+    def GetAllowMissing(self):
+        """Get whether a section allows missing external blobs
+
+        Returns:
+            True if allowed, False if not allowed
+        """
+        return self.allow_missing
index e507203709fc8191a9b6a596bf99da2b4a09ec5e..c5f97c85a38c3847f4f0ad0b62663c908a20804e 100644 (file)
@@ -37,7 +37,13 @@ class Entry_blob(Entry):
 
     def ObtainContents(self):
         self._filename = self.GetDefaultFilename()
-        self._pathname = tools.GetInputFilename(self._filename)
+        self._pathname = tools.GetInputFilename(self._filename,
+                                                self.section.GetAllowMissing())
+        # Allow the file to be missing
+        if self.external and not self._pathname:
+            self.SetContents(b'')
+            self.missing = True
+            return True
         self.ReadBlobContents()
         return True
 
index 8d641001a9e4080a51765a247b561f2f6a1de275..e372445f300f5fd34be14f4b2e3dd5da52e95030 100644 (file)
@@ -26,14 +26,3 @@ class Entry_blob_ext(Entry_blob):
     def __init__(self, section, etype, node):
         Entry_blob.__init__(self, section, etype, node)
         self.external = True
-
-    def ObtainContents(self):
-        self._filename = self.GetDefaultFilename()
-        self._pathname = tools.GetInputFilename(self._filename,
-                                                self.section.GetAllowMissing())
-        # Allow the file to be missing
-        if not self._pathname:
-            self.SetContents(b'')
-            self.missing = True
-            return True
-        return super().ObtainContents()
index 72600b1ef3a4b7660c23986e83de7ccf0c164714..515c97f92902e1d6f23e676d60c7815f664d7dad 100644 (file)
@@ -35,7 +35,7 @@ class Entry_section(Entry):
             when writing out the map
 
     Properties:
-        _allow_missing: True if this section permits external blobs to be
+        allow_missing: True if this section permits external blobs to be
             missing their contents. The second will produce an image but of
             course it will not work.
 
@@ -54,8 +54,6 @@ class Entry_section(Entry):
         self._sort = False
         self._skip_at_start = None
         self._end_4gb = False
-        self._allow_missing = False
-        self.missing = False
 
     def ReadNode(self):
         """Read properties from the image node"""
@@ -549,18 +547,10 @@ class Entry_section(Entry):
         Args:
             allow_missing: True if allowed, False if not allowed
         """
-        self._allow_missing = allow_missing
+        self.allow_missing = allow_missing
         for entry in self._entries.values():
             entry.SetAllowMissing(allow_missing)
 
-    def GetAllowMissing(self):
-        """Get whether a section allows missing external blobs
-
-        Returns:
-            True if allowed, False if not allowed
-        """
-        return self._allow_missing
-
     def CheckMissing(self, missing_list):
         """Check if any entries in this section have missing external blobs