diff options
author | Milo Casagrande <milo@ubuntu.com> | 2012-10-02 16:53:56 +0200 |
---|---|---|
committer | Milo Casagrande <milo@ubuntu.com> | 2012-10-02 16:53:56 +0200 |
commit | 433f8935721bbdde4d8a9d361703c3a05fa63e06 (patch) | |
tree | 2933b5b65b480f604ef6fb655c8736abdd1d5515 /linaro_image_tools/media_create/boards.py | |
parent | c659b31008033ba30a9cf98a42e5384b701a98ac (diff) | |
parent | c70a07203995f5541e5ba71c258c12e519e5b183 (diff) |
Added dtb_files support.
Diffstat (limited to 'linaro_image_tools/media_create/boards.py')
-rw-r--r-- | linaro_image_tools/media_create/boards.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/linaro_image_tools/media_create/boards.py b/linaro_image_tools/media_create/boards.py index 9cfd716..44c06b0 100644 --- a/linaro_image_tools/media_create/boards.py +++ b/linaro_image_tools/media_create/boards.py @@ -408,6 +408,9 @@ class BoardConfig(object): partition_layout = None LOADER_START_S = 1 + # Support for dtb_files as per hwpack v3 format. + dtb_files = None + # Samsung v310 implementation notes and terminology # # * BL0, BL1 etc. are the various bootloaders in order of execution @@ -515,6 +518,7 @@ class BoardConfig(object): cls.vmlinuz = cls.get_metadata_field('vmlinuz') cls.initrd = cls.get_metadata_field('initrd') cls.dtb_file = cls.get_metadata_field('dtb_file') + cls.dtb_files = cls.get_metadata_field('dtb_files') cls.extra_boot_args_options = cls.get_metadata_field( 'extra_boot_options') cls.boot_script = cls.get_metadata_field('boot_script') @@ -860,6 +864,53 @@ class BoardConfig(object): boot_device_or_file, k_img_data, i_img_data, d_img_data) @classmethod + def _copy_dtb_files(cls, dtb_files, dest_dir, search_dir): + """Copy the files defined in dtb_files into the boot directory. + + :param dtb_files: The list of dtb files + :param dest_dir: The directory where to copy each dtb file. + :param search_dir: The directory where to search for the real file. + """ + logger = logging.getLogger("linaro_image_tools") + logger.info("Copying dtb files") + for dtb_file in dtb_files: + if dtb_file: + if isinstance(dtb_file, dict): + for key, value in dtb_file.iteritems(): + # The name of the dtb file in the new position. + to_file = os.path.basename(key) + # The directory where to copy the dtb file. + to_dir = os.path.join(dest_dir, os.path.dirname(key)) + from_file = value + + # User specified only the directory, without renaming + # the file. + if not to_file: + to_file = os.path.basename(from_file) + + if not os.path.exists(to_dir): + cmd_runner.run(["mkdir", "-p", to_dir], + as_root=True).wait() + dtb = _get_file_matching(os.path.join(search_dir, + from_file)) + if not dtb: + logger.warn('Could not find a valid dtb file, ' + 'skipping it.') + continue + else: + dest = os.path.join(to_dir, to_file) + logger.debug('Copying %s into %s' % (dtb, dest)) + cmd_runner.run(['cp', dtb, dest], + as_root=True).wait() + else: + # Hopefully we should never get here. + # This should only happen if the hwpack config YAML file is + # wrong + logger.warn('WARNING: Wrong syntax in metadata file. ' + 'Check the hwpack configuration file used to ' + 'generate the hwpack archive.') + + @classmethod def _dd_file(cls, from_file, to_file, seek, max_size=None): assert from_file is not None, "No source file name given." if max_size is not None: @@ -979,6 +1030,10 @@ class BoardConfig(object): # Handle copy_files field. cls.copy_files(boot_disk) + # Handle dtb_files field. + if cls.dtb_files: + cls._copy_dtb_files(cls.dtb_files, boot_disk, chroot_dir) + cls.make_boot_files( bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir, rootfs_id, boot_disk, boot_device_or_file) |