]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Add support for symlinking images
authorNeha Malcom Francis <n-francis@ti.com>
Mon, 17 Oct 2022 11:06:25 +0000 (16:36 +0530)
committerSimon Glass <sjg@chromium.org>
Sat, 29 Oct 2022 13:36:33 +0000 (07:36 -0600)
Adding support to symlink an image packaged using binman.

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
tools/binman/binman.rst
tools/binman/ftest.py
tools/binman/image.py
tools/binman/test/259_symlink.dts [new file with mode: 0644]

index 4ee6f41f35e76910521f18d7ae1d86e60fa861a9..d8a3d776f46202d2dab93f1e87ffa9aeda9ae432 100644 (file)
@@ -780,6 +780,9 @@ align-default:
     This means that each section must specify its own default alignment, if
     required.
 
+symlink:
+    Adds a symlink to the image with string given in the symlink property.
+
 Examples of the above options can be found in the tests. See the
 tools/binman/test directory.
 
index 261107b33542b3a33a4c3e26da434b84a08d7733..232ac2cf18542b0592334a79fd037b3d80e7d81b 100644 (file)
@@ -5995,6 +5995,15 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         self.assertIn('Expected __bss_size symbol in vpl/u-boot-vpl',
                       str(e.exception))
 
+    def testSymlink(self):
+        """Test that image files can be named"""
+        retcode = self._DoTestFile('259_symlink.dts', debug=True, map=True)
+        self.assertEqual(0, retcode)
+        image = control.images['test_image']
+        fname = tools.get_output_filename('test_image.bin')
+        sname = tools.get_output_filename('symlink_to_test.bin')
+        self.assertTrue(os.path.islink(sname))
+        self.assertEqual(os.readlink(sname), fname)
 
 if __name__ == "__main__":
     unittest.main()
index afc4b4d64304c6aab99d7cc1a92a4a731d6249bc..6d4bff584363d9b5d7c25af6f3c01aed3cf81079 100644 (file)
@@ -38,6 +38,7 @@ class Image(section.Entry_section):
             repacked later
         test_section_timeout: Use a zero timeout for section multi-threading
             (for testing)
+        symlink: Name of symlink to image
 
     Args:
         copy_to_orig: Copy offset/size to orig_offset/orig_size after reading
@@ -97,6 +98,7 @@ class Image(section.Entry_section):
         if filename:
             self._filename = filename
         self.allow_repack = fdt_util.GetBool(self._node, 'allow-repack')
+        self._symlink = fdt_util.GetString(self._node, 'symlink')
 
     @classmethod
     def FromFile(cls, fname):
@@ -180,6 +182,10 @@ class Image(section.Entry_section):
             data = self.GetPaddedData()
             fd.write(data)
         tout.info("Wrote %#x bytes" % len(data))
+        # Create symlink to file if symlink given
+        if self._symlink is not None:
+            sname = tools.get_output_filename(self._symlink)
+            os.symlink(fname, sname)
 
     def WriteMap(self):
         """Write a map of the image to a .map file
diff --git a/tools/binman/test/259_symlink.dts b/tools/binman/test/259_symlink.dts
new file mode 100644 (file)
index 0000000..2ee1f7f
--- /dev/null
@@ -0,0 +1,16 @@
+/dts-v1/;
+
+/ {
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       binman {
+               multiple-images;
+               test_image {
+                       filename = "test_image.bin";
+                       symlink = "symlink_to_test.bin";
+                       u-boot {
+                       };
+               };
+       };
+};