]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Change how faked blobs are created
authorSimon Glass <sjg@chromium.org>
Sun, 6 Mar 2022 03:19:03 +0000 (20:19 -0700)
committerSimon Glass <sjg@chromium.org>
Sat, 19 Mar 2022 01:24:25 +0000 (19:24 -0600)
At present fake blobs are created but internally an empty blob is used.
Change it to use the contents of the faked file. Also return whether the
blob was faked, in case the caller needs to know that.

Add a TODO to put fake blobs in their own directory.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
tools/binman/binman.rst
tools/binman/entry.py
tools/binman/etype/blob.py
tools/binman/etype/blob_ext_list.py

index 509fc8da6dea822bcd3dca1b10d193bb6663c5b9..935839c433e897b2a19ef596879fec4013542eb7 100644 (file)
@@ -1500,7 +1500,8 @@ Some ideas:
 - Figure out how to make Fdt support changing the node order, so that
   Node.AddSubnode() can support adding a node before another, existing node.
   Perhaps it should completely regenerate the flat tree?
-
+- Put faked files into a separate subdir and remove them on start-up, to avoid
+  seeing them as 'real' files on a subsequent run
 
 --
 Simon Glass <sjg@chromium.org>
index 786c959911fb5c46cd961283eaf3c59c0316b2df..9d499f07aab41baa76d5168d055c3fa9fb227c36 100644 (file)
@@ -999,15 +999,18 @@ features to produce new behaviours.
             fname (str): Filename to check
 
         Returns:
-            fname (str): Filename of faked file
+            tuple:
+                fname (str): Filename of faked file
+                bool: True if the blob was faked, False if not
         """
         if self.allow_fake and not pathlib.Path(fname).is_file():
             outfname = tools.get_output_filename(os.path.basename(fname))
             with open(outfname, "wb") as out:
                 out.truncate(1024)
             self.faked = True
-            return outfname
-        return fname
+            tout.info(f"Entry '{self._node.path}': Faked file '{outfname}'")
+            return outfname, True
+        return fname, False
 
     def CheckFakedBlobs(self, faked_blobs_list):
         """Check if any entries in this section have faked external blobs
index 25ec5d26c9bced328a7d5999d50cd7eb49260a1b..89f089e740ef5d2cbefa00f83e3f742197b7c886 100644 (file)
@@ -41,10 +41,11 @@ class Entry_blob(Entry):
             self.external and self.section.GetAllowMissing())
         # Allow the file to be missing
         if not self._pathname:
-            self._pathname = self.check_fake_fname(self._filename)
-            self.SetContents(b'')
+            self._pathname, faked = self.check_fake_fname(self._filename)
             self.missing = True
-            return True
+            if not faked:
+                self.SetContents(b'')
+                return True
 
         self.ReadBlobContents()
         return True
index 76ad32a1eea1bea5567c9936ea1ad7b2258476cb..f00202e9ebc20fa4c1918f6d12bcdcdde81d4c8f 100644 (file)
@@ -37,7 +37,7 @@ class Entry_blob_ext_list(Entry_blob):
         missing = False
         pathnames = []
         for fname in self._filenames:
-            fname = self.check_fake_fname(fname)
+            fname, _ = self.check_fake_fname(fname)
             pathname = tools.get_input_filename(
                 fname, self.external and self.section.GetAllowMissing())
             # Allow the file to be missing