Merge lp:~gesha/linaro-image-tools/1235941 into lp:linaro-image-tools/11.11

Proposed by Georgy Redkozubov
Status: Merged
Approved by: Milo Casagrande
Approved revision: 647
Merged at revision: 647
Proposed branch: lp:~gesha/linaro-image-tools/1235941
Merge into: lp:linaro-image-tools/11.11
Diff against target: 99 lines (+44/-2)
3 files modified
linaro-media-create (+2/-1)
linaro_image_tools/media_create/__init__.py (+5/-0)
linaro_image_tools/media_create/boards.py (+37/-1)
To merge this branch: bzr merge lp:~gesha/linaro-image-tools/1235941
Reviewer Review Type Date Requested Status
Milo Casagrande (community) Approve
Review via email: mp+198406@code.launchpad.net

Description of the change

This branch adds checks for dtb_files and if found set first entry as default dtb file.

To post a comment you must log in.
Revision history for this message
Milo Casagrande (milo) wrote :

Thanks Georgy,

I tested it with a modified hwpack and it works correctly.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro-media-create'
2--- linaro-media-create 2013-08-19 07:39:34 +0000
3+++ linaro-media-create 2013-12-10 14:27:54 +0000
4@@ -144,7 +144,8 @@
5 atexit.register(enable_automount)
6
7 board_config = get_board_config(args.dev)
8- board_config.set_metadata(args.hwpacks, args.bootloader, args.dev)
9+ board_config.set_metadata(args.hwpacks, args.bootloader, args.dev,
10+ args.dtb_file)
11 board_config.add_boot_args(args.extra_boot_args)
12 board_config.add_boot_args_from_file(args.extra_boot_args_file)
13
14
15=== modified file 'linaro_image_tools/media_create/__init__.py'
16--- linaro_image_tools/media_create/__init__.py 2013-02-17 13:53:41 +0000
17+++ linaro_image_tools/media_create/__init__.py 2013-12-10 14:27:54 +0000
18@@ -174,6 +174,11 @@
19 help="Select a bootloader from a hardware pack that contains more "
20 "than one. If not specified, it will default to '%s'." %
21 DEFAULT_BOOTLOADER)
22+ parser.add_argument(
23+ '--dtb-file',
24+ help="Select a DTB file from a hardware pack that contains more "
25+ "than one. If not specified, it will default to the first "
26+ "entry in 'dtb_files' list.")
27
28 add_common_options(parser)
29 return parser
30
31=== modified file 'linaro_image_tools/media_create/boards.py'
32--- linaro_image_tools/media_create/boards.py 2013-09-23 09:55:03 +0000
33+++ linaro_image_tools/media_create/boards.py 2013-12-10 14:27:54 +0000
34@@ -257,7 +257,8 @@
35 data, _ = self.hardwarepack_handler.get_field(field_name)
36 return data
37
38- def set_metadata(self, hwpacks, bootloader=None, board=None):
39+ def set_metadata(self, hwpacks, bootloader=None, board=None,
40+ dtb_file=None):
41 self.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader,
42 board)
43 with self.hardwarepack_handler:
44@@ -310,6 +311,12 @@
45 logger.warn("Deprecation warning: use the 'dtb_files' field "
46 "instead of 'dtb_file'.")
47 self.dtb_files = self.get_metadata_field(DTB_FILES_FIELD)
48+ if dtb_file:
49+ dtb_dict = self._find_dtb_dict(dtb_file)
50+ if dtb_dict:
51+ self.dtb_files = []
52+ self.dtb_files.append(dtb_dict)
53+
54 self.extra_boot_args_options = self.get_metadata_field(
55 EXTRA_BOOT_OPTIONS_FIELD)
56 self.boot_script = self.get_metadata_field(BOOT_SCRIPT_FIELD)
57@@ -873,6 +880,25 @@
58 if self.dtb_file:
59 dtb = _get_file_matching(os.path.join(path, self.dtb_file))
60 if not self.dtb_file or not dtb:
61+ logger.warn("Could not find a valid dtb file from dtb_file, "
62+ "trying dtb_files...")
63+
64+ if self.dtb_files:
65+ # Use first file from list as a default dtb file.
66+ dtb_file = self.dtb_files[0]
67+ if dtb_file:
68+ if isinstance(dtb_file, dict):
69+ for key, value in dtb_file.iteritems():
70+ # The name of the dtb file.
71+ to_file = os.path.basename(key)
72+ from_file = value
73+
74+ # User specified only the directory, without renaming
75+ # the file.
76+ if not to_file:
77+ to_file = os.path.basename(from_file)
78+ dtb = _get_file_matching(os.path.join(path, from_file))
79+ if not self.dtb_files or not dtb:
80 logger.warn("Could not find a valid dtb file, skipping it.")
81
82 logger.info("Will use kernel=%s, initrd=%s, dtb=%s." %
83@@ -900,6 +926,16 @@
84 presence = True
85 return presence
86
87+ def _find_dtb_dict(self, dtb):
88+ """Returns dictionary entry from dt_files containing dtb file."""
89+ for dtb_file in self.dtb_files:
90+ if isinstance(dtb_file, dict):
91+ for key, value in dtb_file.iteritems():
92+ # The name of the dtb file.
93+ if dtb in key:
94+ return dtb_file
95+ return None
96+
97
98 class OmapConfig(BoardConfig):
99 def __init__(self):

Subscribers

People subscribed via source and target branches