Merge lp:~milo/linaro-image-tools/dtb-files-support into lp:linaro-image-tools/11.11

Proposed by Milo Casagrande
Status: Merged
Approved by: James Tunnicliffe
Approved revision: 571
Merged at revision: 569
Proposed branch: lp:~milo/linaro-image-tools/dtb-files-support
Merge into: lp:linaro-image-tools/11.11
Diff against target: 228 lines (+104/-4)
5 files modified
linaro_image_tools/hwpack/config.py (+20/-1)
linaro_image_tools/hwpack/hardwarepack.py (+9/-3)
linaro_image_tools/hwpack/hwpack_fields.py (+1/-0)
linaro_image_tools/hwpack/tests/test_config_v3.py (+19/-0)
linaro_image_tools/media_create/boards.py (+55/-0)
To merge this branch: bzr merge lp:~milo/linaro-image-tools/dtb-files-support
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Approve
Paul Sokolovsky Pending
Review via email: mp+127224@code.launchpad.net

Description of the change

Branch adds dtb_files support for hwpack config and metadata.
dtb_files syntax is:

dtb_files:
- destination.dtb : source.dtb

source.dtb can contain basic globbing.

To post a comment you must log in.
Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks good.

It would be nice if we could combine all the static files copying code into one place. This is similar to the boot files copying that we do, but not the same as copy_files (since those files stay in their packages).

There is definitely room for tidying up that whole code area, but a bug fix isn't the place for it. If you have nothing else to do I am sure it will be... entertaining :-)

review: Approve
Revision history for this message
Milo Casagrande (milo) wrote :

Hey James,

thanks for taking a look.

On Mon, Oct 1, 2012 at 5:14 PM, James Tunnicliffe
<email address hidden> wrote:
> Review: Approve
>
> Looks good.
>
> It would be nice if we could combine all the static files copying code into one place. This is similar to the boot files copying that we do, but not the same as copy_files (since those files stay in their packages).
>
> There is definitely room for tidying up that whole code area, but a bug fix isn't the place for it. If you have nothing else to do I am sure it will be... entertaining :-)

Indeed, I wanted to combine them, but it would have been a little bit
too much for the bug report.
I will indeed try to do it during this maintenance cycle, maybe in a
separate bug.

Ciao.

--
Milo Casagrande
Infrastructure Engineer
Linaro.org <www.linaro.org> │ Open source software for ARM SoCs

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro_image_tools/hwpack/config.py'
--- linaro_image_tools/hwpack/config.py 2012-09-11 14:28:20 +0000
+++ linaro_image_tools/hwpack/config.py 2012-10-01 10:21:03 +0000
@@ -44,6 +44,7 @@
44 DD_FIELD,44 DD_FIELD,
45 DTB_ADDR_FIELD,45 DTB_ADDR_FIELD,
46 DTB_FILE_FIELD,46 DTB_FILE_FIELD,
47 DTB_FILES_FIELD,
47 ENV_DD_FIELD,48 ENV_DD_FIELD,
48 EXTRA_BOOT_OPTIONS_FIELD,49 EXTRA_BOOT_OPTIONS_FIELD,
49 EXTRA_SERIAL_OPTIONS_FIELD,50 EXTRA_SERIAL_OPTIONS_FIELD,
@@ -269,6 +270,7 @@
269 self._validate_vmlinuz()270 self._validate_vmlinuz()
270 self._validate_initrd()271 self._validate_initrd()
271 self._validate_dtb_file()272 self._validate_dtb_file()
273 self._validate_dtb_files()
272 self._validate_mmc_id()274 self._validate_mmc_id()
273 self._validate_extra_boot_options()275 self._validate_extra_boot_options()
274 self._validate_boot_script()276 self._validate_boot_script()
@@ -821,6 +823,14 @@
821 return self._get_option(DTB_FILE_FIELD)823 return self._get_option(DTB_FILE_FIELD)
822824
823 @property825 @property
826 def dtb_files(self):
827 """
828 The list of dtb files.
829 :return: A list of dtb files
830 """
831 return self._get_option(DTB_FILES_FIELD)
832
833 @property
824 def samsung_bl1_start(self):834 def samsung_bl1_start(self):
825 """BL1 start offset for Samsung boards.835 """BL1 start offset for Samsung boards.
826836
@@ -953,7 +963,16 @@
953 return "No " + thing + " in the [" + v2_section + "] section"963 return "No " + thing + " in the [" + v2_section + "] section"
954964
955 def _validate_dtb_file(self):965 def _validate_dtb_file(self):
956 dtb_file = self.dtb_file966 self._check_single_dtb_file(self.dtb_file)
967
968 def _validate_dtb_files(self):
969 dtb_files = self.dtb_files
970 if dtb_files:
971 for dtb_file in dtb_files:
972 for _, src in dtb_file.iteritems():
973 self._check_single_dtb_file(src)
974
975 def _check_single_dtb_file(self, dtb_file):
957 if dtb_file is not None:976 if dtb_file is not None:
958 self._assert_matches_pattern(977 self._assert_matches_pattern(
959 self.GLOB_REGEX, dtb_file, "Invalid path: %s" % dtb_file)978 self.GLOB_REGEX, dtb_file, "Invalid path: %s" % dtb_file)
960979
=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
--- linaro_image_tools/hwpack/hardwarepack.py 2012-08-29 10:31:19 +0000
+++ linaro_image_tools/hwpack/hardwarepack.py 2012-10-01 10:21:03 +0000
@@ -43,6 +43,7 @@
43 BOOT_SCRIPT_FIELD,43 BOOT_SCRIPT_FIELD,
44 DTB_ADDR_FIELD,44 DTB_ADDR_FIELD,
45 DTB_FILE_FIELD,45 DTB_FILE_FIELD,
46 DTB_FILES_FIELD,
46 EXTRA_SERIAL_OPTIONS_FIELD,47 EXTRA_SERIAL_OPTIONS_FIELD,
47 FORMAT_FIELD,48 FORMAT_FIELD,
48 INITRD_ADDR_FIELD,49 INITRD_ADDR_FIELD,
@@ -166,14 +167,16 @@
166 self.samsung_bl2_len = samsung_bl2_len167 self.samsung_bl2_len = samsung_bl2_len
167168
168 @classmethod169 @classmethod
169 def add_v3_config(self, boards=None, bootloaders=None):170 def add_v3_config(self, boards=None, bootloaders=None, dtb_files=None):
170 """Add fields that are specific to the v3 config format.171 """Add fields that are specific to the v3 config format.
171 These fields are not present in the earlier config files.172 These fields are not present in the earlier config files.
172173
173 :param boards: The boards section of the hwpack.174 :param boards: The boards section of the hwpack.
174 :param bootloaders: The bootloaders section of the hwpack."""175 :param bootloaders: The bootloaders section of the hwpack.
176 :param dtb_files: The dtb_files section of the hwpack."""
175 self.boards = boards177 self.boards = boards
176 self.bootloaders = bootloaders178 self.bootloaders = bootloaders
179 self.dtb_files = dtb_files
177180
178 @classmethod181 @classmethod
179 def from_config(cls, config, version, architecture):182 def from_config(cls, config, version, architecture):
@@ -235,7 +238,8 @@
235 )238 )
236 if config.format.format_as_string == '3.0':239 if config.format.format_as_string == '3.0':
237 metadata.add_v3_config(boards=config.boards,240 metadata.add_v3_config(boards=config.boards,
238 bootloaders=config.bootloaders)241 bootloaders=config.bootloaders,
242 dtb_files=config.dtb_files)
239 return metadata243 return metadata
240244
241 def __str__(self):245 def __str__(self):
@@ -305,6 +309,8 @@
305 if self.dtb_file is not None:309 if self.dtb_file is not None:
306 # XXX In V3 this one should be a list, called dtb_files.310 # XXX In V3 this one should be a list, called dtb_files.
307 metadata += dump({DTB_FILE_FIELD: self.dtb_file})311 metadata += dump({DTB_FILE_FIELD: self.dtb_file})
312 if self.dtb_files is not None:
313 metadata += dump({DTB_FILES_FIELD: self.dtb_files})
308 if self.boot_script is not None:314 if self.boot_script is not None:
309 metadata += dump({BOOT_SCRIPT_FIELD: self.boot_script})315 metadata += dump({BOOT_SCRIPT_FIELD: self.boot_script})
310 if self.extra_serial_opts is not None:316 if self.extra_serial_opts is not None:
311317
=== modified file 'linaro_image_tools/hwpack/hwpack_fields.py'
--- linaro_image_tools/hwpack/hwpack_fields.py 2012-09-24 09:07:37 +0000
+++ linaro_image_tools/hwpack/hwpack_fields.py 2012-10-01 10:21:03 +0000
@@ -110,6 +110,7 @@
110 ASSUME_INSTALLED_FIELD: None,110 ASSUME_INSTALLED_FIELD: None,
111 INCLUDE_DEBS_FIELD: None,111 INCLUDE_DEBS_FIELD: None,
112 DTB_FILE_FIELD: None,112 DTB_FILE_FIELD: None,
113 DTB_FILES_FIELD: None,
113 DTB_ADDR_FIELD: None,114 DTB_ADDR_FIELD: None,
114 SERIAL_TTY_FIELD: None,115 SERIAL_TTY_FIELD: None,
115 EXTRA_SERIAL_OPTIONS_FIELD: None,116 EXTRA_SERIAL_OPTIONS_FIELD: None,
116117
=== modified file 'linaro_image_tools/hwpack/tests/test_config_v3.py'
--- linaro_image_tools/hwpack/tests/test_config_v3.py 2012-09-24 11:29:40 +0000
+++ linaro_image_tools/hwpack/tests/test_config_v3.py 2012-10-01 10:21:03 +0000
@@ -825,3 +825,22 @@
825 config = self.get_config(self.valid_start_v3 +825 config = self.get_config(self.valid_start_v3 +
826 'samsung_wrong_field: 1\n')826 'samsung_wrong_field: 1\n')
827 self.assertRaises(HwpackConfigError, config._validate_keys)827 self.assertRaises(HwpackConfigError, config._validate_keys)
828
829 # Tests for dtb_files support
830 def test_dtb_files(self):
831 dtb_files = ('dtb_files:\n' +
832 ' - adest.dtb : boot/dt-*-linaro-omap/omap4-panda.dtb\n' +
833 ' - bdest.dtb : ' +
834 'boot/dt-*-linaro-omap2/omap4-panda2.dtb\n')
835 expected = [{'adest.dtb':'boot/dt-*-linaro-omap/omap4-panda.dtb'},
836 {'bdest.dtb': 'boot/dt-*-linaro-omap2/omap4-panda2.dtb'}]
837 config = self.get_config(self.valid_complete_v3 + dtb_files)
838 config.validate()
839 self.assertEqual(expected, config.dtb_files)
840
841 def test_dtb_files_one_wrong(self):
842 dtb_files = ('dtb_files:\n' +
843 ' - adest.dtb : boot/dt-*-linaro-omap/omap4-panda.dtb\n' +
844 ' - bdest.dtb : ~~~\n')
845 config = self.get_config(self.valid_start_v3 + dtb_files)
846 self.assertRaises(HwpackConfigError, config._validate_dtb_files)
828847
=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py 2012-09-12 10:51:00 +0000
+++ linaro_image_tools/media_create/boards.py 2012-10-01 10:21:03 +0000
@@ -404,6 +404,9 @@
404 partition_layout = None404 partition_layout = None
405 LOADER_START_S = 1405 LOADER_START_S = 1
406406
407 # Support for dtb_files as per hwpack v3 format.
408 dtb_files = None
409
407 # Samsung v310 implementation notes and terminology410 # Samsung v310 implementation notes and terminology
408 #411 #
409 # * BL0, BL1 etc. are the various bootloaders in order of execution412 # * BL0, BL1 etc. are the various bootloaders in order of execution
@@ -495,6 +498,7 @@
495 cls.vmlinuz = cls.get_metadata_field('vmlinuz')498 cls.vmlinuz = cls.get_metadata_field('vmlinuz')
496 cls.initrd = cls.get_metadata_field('initrd')499 cls.initrd = cls.get_metadata_field('initrd')
497 cls.dtb_file = cls.get_metadata_field('dtb_file')500 cls.dtb_file = cls.get_metadata_field('dtb_file')
501 cls.dtb_files = cls.get_metadata_field('dtb_files')
498 cls.extra_boot_args_options = cls.get_metadata_field(502 cls.extra_boot_args_options = cls.get_metadata_field(
499 'extra_boot_options')503 'extra_boot_options')
500 cls.boot_script = cls.get_metadata_field('boot_script')504 cls.boot_script = cls.get_metadata_field('boot_script')
@@ -840,6 +844,53 @@
840 boot_device_or_file, k_img_data, i_img_data, d_img_data)844 boot_device_or_file, k_img_data, i_img_data, d_img_data)
841845
842 @classmethod846 @classmethod
847 def _copy_dtb_files(cls, dtb_files, dest_dir, search_dir):
848 """Copy the files defined in dtb_files into the boot directory.
849
850 :param dtb_files: The list of dtb files
851 :param dest_dir: The directory where to copy each dtb file.
852 :param search_dir: The directory where to search for the real file.
853 """
854 logger = logging.getLogger("linaro_image_tools")
855 logger.info("Copying dtb files")
856 for dtb_file in dtb_files:
857 if dtb_file:
858 if isinstance(dtb_file, dict):
859 for key, value in dtb_file.iteritems():
860 # The name of the dtb file in the new position.
861 to_file = os.path.basename(key)
862 # The directory where to copy the dtb file.
863 to_dir = os.path.join(dest_dir, os.path.dirname(key))
864 from_file = value
865
866 # User specified only the directory, without renaming
867 # the file.
868 if not to_file:
869 to_file = os.path.basename(from_file)
870
871 if not os.path.exists(to_dir):
872 cmd_runner.run(["mkdir", "-p", to_dir],
873 as_root=True).wait()
874 dtb = _get_file_matching(os.path.join(search_dir,
875 from_file))
876 if not dtb:
877 logger.warn('Could not find a valid dtb file, '
878 'skipping it.')
879 continue
880 else:
881 dest = os.path.join(to_dir, to_file)
882 logger.debug('Copying %s into %s' % (dtb, dest))
883 cmd_runner.run(['cp', dtb, dest],
884 as_root=True).wait()
885 else:
886 # Hopefully we should never get here.
887 # This should only happen if the hwpack config YAML file is
888 # wrong
889 logger.warn('WARNING: Wrong syntax in metadata file. '
890 'Check the hwpack configuration file used to '
891 'generate the hwpack archive.')
892
893 @classmethod
843 def _dd_file(cls, from_file, to_file, seek, max_size=None):894 def _dd_file(cls, from_file, to_file, seek, max_size=None):
844 assert from_file is not None, "No source file name given."895 assert from_file is not None, "No source file name given."
845 if max_size is not None:896 if max_size is not None:
@@ -959,6 +1010,10 @@
959 # Handle copy_files field.1010 # Handle copy_files field.
960 cls.copy_files(boot_disk)1011 cls.copy_files(boot_disk)
9611012
1013 # Handle dtb_files field.
1014 if cls.dtb_files:
1015 cls._copy_dtb_files(cls.dtb_files, boot_disk, chroot_dir)
1016
962 cls.make_boot_files(1017 cls.make_boot_files(
963 bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir,1018 bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
964 rootfs_id, boot_disk, boot_device_or_file)1019 rootfs_id, boot_disk, boot_device_or_file)

Subscribers

People subscribed via source and target branches