Merge lp:~milo/linaro-image-tools/bootloader-selection into lp:linaro-image-tools/11.11
- bootloader-selection
- Merge into trunk
Proposed by
Milo Casagrande
Status: | Merged |
---|---|
Approved by: | James Tunnicliffe |
Approved revision: | 546 |
Merged at revision: | 542 |
Proposed branch: | lp:~milo/linaro-image-tools/bootloader-selection |
Merge into: | lp:linaro-image-tools/11.11 |
Diff against target: |
412 lines (+113/-44) 9 files modified
linaro-android-media-create (+2/-2) linaro-media-create (+4/-4) linaro_image_tools/hwpack/config.py (+5/-5) linaro_image_tools/hwpack/hardwarepack.py (+8/-5) linaro_image_tools/hwpack/tests/test_config.py (+1/-1) linaro_image_tools/hwpack/tests/test_config_v3.py (+6/-6) linaro_image_tools/media_create/__init__.py (+6/-2) linaro_image_tools/media_create/boards.py (+21/-16) linaro_image_tools/media_create/tests/test_media_create.py (+60/-3) |
To merge this branch: | bzr merge lp:~milo/linaro-image-tools/bootloader-selection |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Tunnicliffe (community) | Approve | ||
Linaro Infrastructure | Pending | ||
Review via email: mp+116885@code.launchpad.net |
Commit message
Description of the change
With this final merge, all the remaining bits of the blueprint are now done.
Here we have the selection for boards and bootloader from the command line, and we added a couple more tests.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'linaro-android-media-create' |
2 | --- linaro-android-media-create 2012-05-30 07:32:31 +0000 |
3 | +++ linaro-android-media-create 2012-07-26 14:57:30 +0000 |
4 | @@ -102,11 +102,11 @@ |
5 | DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc') |
6 | SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc') |
7 | |
8 | - board_config = android_board_configs[args.board] |
9 | + board_config = android_board_configs[args.dev] |
10 | board_config.add_boot_args(args.extra_boot_args) |
11 | board_config.add_boot_args_from_file(args.extra_boot_args_file) |
12 | |
13 | - if args.board == 'iMX53': |
14 | + if args.dev == 'iMX53': |
15 | # XXX: remove this and the corresponding entry in android_board_configs |
16 | print "DEPRECATION WARNING: iMX53 is deprecated, please use mx53loco." |
17 | |
18 | |
19 | === modified file 'linaro-media-create' |
20 | --- linaro-media-create 2012-07-25 11:48:47 +0000 |
21 | +++ linaro-media-create 2012-07-26 14:57:30 +0000 |
22 | @@ -129,9 +129,9 @@ |
23 | print >> sys.stderr, "\nError:", e.value |
24 | sys.exit(1) |
25 | |
26 | - board_config = board_configs[args.board] |
27 | - board_config.set_metadata(args.hwpacks) |
28 | - board_config.set_board(args.board) |
29 | + board_config = board_configs[args.dev] |
30 | + board_config.set_metadata(args.hwpacks, args.bootloader, args.dev) |
31 | + board_config.set_board(args.dev) |
32 | board_config.add_boot_args(args.extra_boot_args) |
33 | board_config.add_boot_args_from_file(args.extra_boot_args_file) |
34 | |
35 | @@ -141,7 +141,7 @@ |
36 | if not board_config.supports_writing_to_mmc: |
37 | print ("The board '%s' does not support the --mmc option. " |
38 | "Please use --image_file to create an image file for this " |
39 | - "board." % args.board) |
40 | + "board." % args.dev) |
41 | sys.exit(1) |
42 | if not confirm_device_selection_and_ensure_it_is_ready( |
43 | args.device, args.nocheck_mmc): |
44 | |
45 | === modified file 'linaro_image_tools/hwpack/config.py' |
46 | --- linaro_image_tools/hwpack/config.py 2012-07-23 14:44:37 +0000 |
47 | +++ linaro_image_tools/hwpack/config.py 2012-07-26 14:57:30 +0000 |
48 | @@ -215,7 +215,7 @@ |
49 | self._validate_mmc_id() |
50 | self._validate_extra_boot_options() |
51 | self._validate_boot_script() |
52 | - self._validate_uboot_in_boot_part() |
53 | + self._validate_bootloader_file_in_boot_part() |
54 | self._validate_uboot_dd() |
55 | self._validate_spl_in_boot_part() |
56 | self._validate_spl_dd() |
57 | @@ -289,7 +289,7 @@ |
58 | return self._get_option(BOARDS_FIELD) |
59 | |
60 | @property |
61 | - def uboot_in_boot_part(self): |
62 | + def bootloader_file_in_boot_part(self): |
63 | """Whether uboot binary should be put in the boot partition. A str.""" |
64 | return self._get_bootloader_option(self.UBOOT_IN_BOOT_PART_KEY) |
65 | |
66 | @@ -993,11 +993,11 @@ |
67 | return False |
68 | return string.lower(value) in ['yes', 'no'] |
69 | |
70 | - def _validate_uboot_in_boot_part(self): |
71 | - if not self._validate_bool(self.uboot_in_boot_part): |
72 | + def _validate_bootloader_file_in_boot_part(self): |
73 | + if not self._validate_bool(self.bootloader_file_in_boot_part): |
74 | raise HwpackConfigError( |
75 | "Invalid value for u_boot_in_boot_part: %s" |
76 | - % self.uboot_in_boot_part) |
77 | + % self.bootloader_file_in_boot_part) |
78 | |
79 | def _validate_spl_in_boot_part(self): |
80 | spl_in_boot_part = self.spl_in_boot_part |
81 | |
82 | === modified file 'linaro_image_tools/hwpack/hardwarepack.py' |
83 | --- linaro_image_tools/hwpack/hardwarepack.py 2012-07-23 14:44:37 +0000 |
84 | +++ linaro_image_tools/hwpack/hardwarepack.py 2012-07-26 14:57:30 +0000 |
85 | @@ -122,7 +122,8 @@ |
86 | partition_layout=None, mmc_id=None, boot_min_size=None, |
87 | root_min_size=None, loader_min_size=None, vmlinuz=None, |
88 | initrd=None, dtb_addr=None, extra_boot_options=None, |
89 | - env_dd=None, boot_script=None, uboot_in_boot_part=None, |
90 | + env_dd=None, boot_script=None, |
91 | + bootloader_file_in_boot_part=None, |
92 | uboot_dd=None, spl_in_boot_part=None, spl_dd=None, |
93 | extra_serial_opts=None, loader_start=None, |
94 | snowball_startup_files_config=None, |
95 | @@ -152,7 +153,7 @@ |
96 | self.dtb_addr = dtb_addr |
97 | self.extra_boot_options = extra_boot_options |
98 | self.boot_script = boot_script |
99 | - self.uboot_in_boot_part = uboot_in_boot_part |
100 | + self.bootloader_file_in_boot_part = bootloader_file_in_boot_part |
101 | self.uboot_dd = uboot_dd |
102 | self.spl_in_boot_part = spl_in_boot_part |
103 | self.spl_dd = spl_dd |
104 | @@ -226,7 +227,8 @@ |
105 | spl_dd=config.spl_dd, |
106 | spl_in_boot_part=config.spl_in_boot_part, |
107 | uboot_dd=config.uboot_dd, |
108 | - uboot_in_boot_part=config.uboot_in_boot_part, |
109 | + bootloader_file_in_boot_part=config. |
110 | + bootloader_file_in_boot_part, |
111 | vmlinuz=config.vmlinuz, |
112 | wired_interfaces=config.wired_interfaces, |
113 | wireless_interfaces=config.wireless_interfaces, |
114 | @@ -387,8 +389,9 @@ |
115 | metadata += "EXTRA_BOOT_OPTIONS=%s\n" % self.extra_boot_options |
116 | if self.boot_script is not None: |
117 | metadata += "BOOT_SCRIPT=%s\n" % self.boot_script |
118 | - if self.uboot_in_boot_part is not None: |
119 | - metadata += "U_BOOT_IN_BOOT_PART=%s\n" % self.uboot_in_boot_part |
120 | + if self.bootloader_file_in_boot_part is not None: |
121 | + metadata += ("U_BOOT_IN_BOOT_PART=%s\n" % |
122 | + self.bootloader_file_in_boot_part) |
123 | if self.spl_in_boot_part is not None: |
124 | metadata += "SPL_IN_BOOT_PART=%s\n" % self.spl_in_boot_part |
125 | if self.uboot_dd is not None: |
126 | |
127 | === modified file 'linaro_image_tools/hwpack/tests/test_config.py' |
128 | --- linaro_image_tools/hwpack/tests/test_config.py 2012-07-20 08:19:11 +0000 |
129 | +++ linaro_image_tools/hwpack/tests/test_config.py 2012-07-26 14:57:30 +0000 |
130 | @@ -514,7 +514,7 @@ |
131 | config = self.get_config(self.valid_complete_v2 + self.valid_end) |
132 | config.validate() |
133 | self.assertEqual("Yes", |
134 | - config.uboot_in_boot_part) |
135 | + config.bootloader_file_in_boot_part) |
136 | |
137 | def test_spl_package(self): |
138 | config = self.get_config(self.valid_complete_v2 + self.valid_end) |
139 | |
140 | === modified file 'linaro_image_tools/hwpack/tests/test_config_v3.py' |
141 | --- linaro_image_tools/hwpack/tests/test_config_v3.py 2012-07-20 13:47:37 +0000 |
142 | +++ linaro_image_tools/hwpack/tests/test_config_v3.py 2012-07-26 14:57:30 +0000 |
143 | @@ -280,7 +280,7 @@ |
144 | " in_boot_part: Nope\n") |
145 | self.assertValidationError( |
146 | "Invalid value for u_boot_in_boot_part: Nope", |
147 | - config._validate_uboot_in_boot_part) |
148 | + config._validate_bootloader_file_in_boot_part) |
149 | |
150 | def test_find_board_specific_variable(self): |
151 | config = self.get_config( |
152 | @@ -294,8 +294,8 @@ |
153 | config.set_bootloader("u_boot") |
154 | config.set_board("panda") |
155 | |
156 | - config._validate_uboot_in_boot_part() |
157 | - self.assertEqual(config.uboot_in_boot_part, "yes") |
158 | + config._validate_bootloader_file_in_boot_part() |
159 | + self.assertEqual(config.bootloader_file_in_boot_part, "yes") |
160 | |
161 | def test_board_specific_overwrites_global(self): |
162 | config = self.get_config( |
163 | @@ -312,8 +312,8 @@ |
164 | config.set_bootloader("u_boot") |
165 | config.set_board("panda") |
166 | |
167 | - config._validate_uboot_in_boot_part() |
168 | - self.assertEqual(config.uboot_in_boot_part, "yes") |
169 | + config._validate_bootloader_file_in_boot_part() |
170 | + self.assertEqual(config.bootloader_file_in_boot_part, "yes") |
171 | |
172 | def test_validate_serial_tty(self): |
173 | config = self.get_config(self.valid_start_v3 + "serial_tty: tty\n") |
174 | @@ -504,7 +504,7 @@ |
175 | config = self.get_config(self.valid_complete_v3 + self.valid_end) |
176 | config.validate() |
177 | self.assertEqual("yes", |
178 | - config.uboot_in_boot_part) |
179 | + config.bootloader_file_in_boot_part) |
180 | |
181 | def test_spl_package(self): |
182 | config = self.get_config(self.valid_complete_v3 + self.valid_end) |
183 | |
184 | === modified file 'linaro_image_tools/media_create/__init__.py' |
185 | --- linaro_image_tools/media_create/__init__.py 2012-07-25 11:36:00 +0000 |
186 | +++ linaro_image_tools/media_create/__init__.py 2012-07-26 14:57:30 +0000 |
187 | @@ -96,7 +96,7 @@ |
188 | help=('Read the hardware pack and print information about the ' |
189 | 'supported boards and bootloaders.')) |
190 | parser.add_argument( |
191 | - '--dev', dest='board', choices=KNOWN_BOARDS, |
192 | + '--dev', dest='dev', choices=KNOWN_BOARDS, |
193 | help='Generate an SD card or image for the given board.') |
194 | parser.add_argument( |
195 | '--rootfs', default='ext4', choices=['ext2', 'ext3', 'ext4', 'btrfs'], |
196 | @@ -165,6 +165,10 @@ |
197 | action='store_true', |
198 | help=('Assume yes to the question "Are you 100%% sure, ' |
199 | 'on selecting [mmc]"')) |
200 | + parser.add_argument( |
201 | + '--bootloader', |
202 | + help="Select a bootloader from a hardware pack that contains more than" |
203 | + "one.") |
204 | |
205 | add_common_options(parser) |
206 | return parser |
207 | @@ -184,7 +188,7 @@ |
208 | help=('The image size, specified in mega/giga bytes (e.g. 3000M or ' |
209 | '3G); use with --image_file only')) |
210 | parser.add_argument( |
211 | - '--dev', required=True, dest='board', choices=ANDROID_KNOWN_BOARDS, |
212 | + '--dev', required=True, dest='dev', choices=ANDROID_KNOWN_BOARDS, |
213 | help='Generate an SD card or image for the given board.') |
214 | parser.add_argument( |
215 | '--boot-label', '--boot_label', default='boot', |
216 | |
217 | === modified file 'linaro_image_tools/media_create/boards.py' |
218 | --- linaro_image_tools/media_create/boards.py 2012-07-23 15:28:30 +0000 |
219 | +++ linaro_image_tools/media_create/boards.py 2012-07-26 14:57:30 +0000 |
220 | @@ -123,9 +123,11 @@ |
221 | hwpack_tarfiles = [] |
222 | tempdir = None |
223 | |
224 | - def __init__(self, hwpacks): |
225 | + def __init__(self, hwpacks, bootloader=None, board=None): |
226 | self.hwpacks = hwpacks |
227 | self.hwpack_tarfiles = [] |
228 | + self.bootloader = bootloader |
229 | + self.board = board |
230 | |
231 | class FakeSecHead(object): |
232 | """ Add a fake section header to the metadata file. |
233 | @@ -169,7 +171,8 @@ |
234 | if re.search("=", lines[0]) and not re.search(":", lines[0]): |
235 | # Probably V2 hardware pack without [hwpack] on the first line |
236 | lines = ["[hwpack]\n"] + lines |
237 | - parser = Config(StringIO("".join(lines))) |
238 | + parser = Config(StringIO("".join(lines)), self.bootloader, |
239 | + self.board) |
240 | try: |
241 | new_data = parser.get_option(field) |
242 | if new_data is not None: |
243 | @@ -213,7 +216,7 @@ |
244 | # These attributes may not need to be redefined on some subclasses. |
245 | uboot_flavor = None |
246 | # whether to copy u-boot to the boot partition |
247 | - uboot_in_boot_part = False |
248 | + bootloader_file_in_boot_part = False |
249 | uboot_dd = False |
250 | spl_in_boot_part = False |
251 | spl_dd = False |
252 | @@ -299,8 +302,9 @@ |
253 | cls.board = board |
254 | |
255 | @classmethod |
256 | - def set_metadata(cls, hwpacks): |
257 | - cls.hardwarepack_handler = HardwarepackHandler(hwpacks) |
258 | + def set_metadata(cls, hwpacks, bootloader=None, board=None): |
259 | + cls.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader, |
260 | + board) |
261 | with cls.hardwarepack_handler: |
262 | cls.hwpack_format = cls.hardwarepack_handler.get_format() |
263 | if (cls.hwpack_format == cls.hardwarepack_handler.FORMAT_1): |
264 | @@ -380,13 +384,14 @@ |
265 | align_up(int(loader_min_size) * 1024 ** 2, |
266 | SECTOR_SIZE) / SECTOR_SIZE) |
267 | |
268 | - uboot_in_boot_part = cls.get_metadata_field('uboot_in_boot_part') |
269 | - if uboot_in_boot_part is None: |
270 | - cls.uboot_in_boot_part = False |
271 | - elif string.lower(uboot_in_boot_part) == 'yes': |
272 | - cls.uboot_in_boot_part = True |
273 | - elif string.lower(uboot_in_boot_part) == 'no': |
274 | - cls.uboot_in_boot_part = False |
275 | + bootloader_file_in_boot_part = cls.get_metadata_field( |
276 | + 'bootloader_file_in_boot_part') |
277 | + if bootloader_file_in_boot_part is None: |
278 | + cls.bootloader_file_in_boot_part = False |
279 | + elif string.lower(bootloader_file_in_boot_part) == 'yes': |
280 | + cls.bootloader_file_in_boot_part = True |
281 | + elif string.lower(bootloader_file_in_boot_part) == 'no': |
282 | + cls.bootloader_file_in_boot_part = False |
283 | spl_in_boot_part = cls.get_metadata_field('spl_in_boot_part') |
284 | if spl_in_boot_part is None: |
285 | cls.spl_in_boot_part = False |
286 | @@ -767,7 +772,7 @@ |
287 | uboot_parts_dir = os.path.join(chroot_dir, parts_dir) |
288 | cmd_runner.run(['mkdir', '-p', boot_disk]).wait() |
289 | with partition_mounted(boot_partition, boot_disk): |
290 | - if cls.uboot_in_boot_part: |
291 | + if cls.bootloader_file_in_boot_part: |
292 | with cls.hardwarepack_handler: |
293 | # <legacy v1 support> |
294 | if cls.uboot_flavor is not None: |
295 | @@ -855,7 +860,7 @@ |
296 | |
297 | class OmapConfig(BoardConfig): |
298 | kernel_flavors = ['linaro-omap4', 'linaro-lt-omap', 'linaro-omap', 'omap4'] |
299 | - uboot_in_boot_part = True |
300 | + bootloader_file_in_boot_part = True |
301 | |
302 | # XXX: Here we define these things as dynamic properties because our |
303 | # temporary hack to fix bug 697824 relies on changing the board's |
304 | @@ -978,7 +983,7 @@ |
305 | |
306 | |
307 | class IgepConfig(BeagleConfig): |
308 | - uboot_in_boot_part = False |
309 | + bootloader_file_in_boot_part = False |
310 | uboot_flavor = None |
311 | dtb_name = 'isee-igep-v2.dtb' |
312 | |
313 | @@ -1327,7 +1332,7 @@ |
314 | |
315 | class VexpressConfig(BoardConfig): |
316 | uboot_flavor = 'ca9x4_ct_vxp' |
317 | - uboot_in_boot_part = True |
318 | + bootloader_file_in_boot_part = True |
319 | serial_tty = 'ttyAMA0' |
320 | _extra_serial_opts = 'console=tty0 console=%s,38400n8' |
321 | _live_serial_opts = 'serialtty=%s' |
322 | |
323 | === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' |
324 | --- linaro_image_tools/media_create/tests/test_media_create.py 2012-07-23 15:28:30 +0000 |
325 | +++ linaro_image_tools/media_create/tests/test_media_create.py 2012-07-26 14:57:30 +0000 |
326 | @@ -142,6 +142,53 @@ |
327 | self.metadata = ( |
328 | "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\nORIGIN=linaro\n") |
329 | |
330 | + def test_hardwarepack_bootloaders(self): |
331 | + metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: " |
332 | + "armel\norigin: linaro\n") |
333 | + metadata += ("bootloaders:\n u_boot:\n file: a_file\n uefi:\n file: " |
334 | + "b_file\n") |
335 | + data = '3.0' |
336 | + format = "%s\n" % data |
337 | + tarball = self.add_to_tarball( |
338 | + [('FORMAT', format), ('metadata', metadata)]) |
339 | + hp = HardwarepackHandler([tarball], bootloader='u_boot') |
340 | + with hp: |
341 | + self.assertEquals(hp.get_field('u_boot_file')[0], 'a_file') |
342 | + |
343 | + def test_hardwarepack_boards(self): |
344 | + metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: " |
345 | + "armel\norigin: linaro\n") |
346 | + metadata += ("bootloaders:\n u_boot:\n file: a_file\n uefi:\n file: " |
347 | + "b_file\n") |
348 | + metadata += ("boards:\n panda:\n bootloaders:\n u_boot:\n " |
349 | + "file: panda_file") |
350 | + data = '3.0' |
351 | + format = "%s\n" % data |
352 | + tarball = self.add_to_tarball( |
353 | + [('FORMAT', format), ('metadata', metadata)]) |
354 | + hp = HardwarepackHandler([tarball], board='panda') |
355 | + with hp: |
356 | + self.assertEquals(hp.get_field('u_boot_file')[0], 'panda_file') |
357 | + |
358 | + def test_hardwarepack_boards_and_bootloaders(self): |
359 | + metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: " |
360 | + "armel\norigin: linaro\n") |
361 | + metadata += ("bootloaders:\n u_boot:\n file: a_file\n uefi:\n file: " |
362 | + "b_file\n") |
363 | + metadata += ("boards:\n panda:\n bootloaders:\n u_boot:\n " |
364 | + "file: panda_file\n uefi:\n file: " |
365 | + "uefi_panda_file\n") |
366 | + metadata += (" panda-lt:\n bootloaders:\n u_boot:\n " |
367 | + "file: panda_lt_file") |
368 | + data = '3.0' |
369 | + format = "%s\n" % data |
370 | + tarball = self.add_to_tarball( |
371 | + [('FORMAT', format), ('metadata', metadata)]) |
372 | + hp = HardwarepackHandler([tarball], board='panda', bootloader='uefi') |
373 | + with hp: |
374 | + self.assertEquals(hp.get_field('u_boot_file')[0], |
375 | + 'uefi_panda_file') |
376 | + |
377 | def add_to_tarball(self, files, tarball=None): |
378 | if tarball is None: |
379 | tarball = self.tarball_fixture.get_tarball() |
380 | @@ -2880,10 +2927,10 @@ |
381 | self.expected_calls, self.popen_fixture.mock.commands_executed) |
382 | self.assertEquals(self.expected_args, self.saved_args) |
383 | |
384 | - def test_populate_boot_uboot_in_boot_part(self): |
385 | + def test_populate_boot_bootloader_file_in_boot_part(self): |
386 | self.prepare_config(boards.BoardConfig) |
387 | self.config.uboot_flavor = "uboot_flavor" |
388 | - self.config.uboot_in_boot_part = True |
389 | + self.config.bootloader_file_in_boot_part = True |
390 | self.call_populate_boot(self.config) |
391 | expected_calls = self.expected_calls[:] |
392 | expected_calls.insert(2, |
393 | @@ -2893,9 +2940,19 @@ |
394 | expected_calls, self.popen_fixture.mock.commands_executed) |
395 | self.assertEquals(self.expected_args, self.saved_args) |
396 | |
397 | + def test_populate_boot_bootloader_file_in_boot_part_false(self): |
398 | + self.prepare_config(boards.BoardConfig) |
399 | + self.config.uboot_flavor = "uboot_flavor" |
400 | + self.config.bootloader_file_in_boot_part = False |
401 | + self.call_populate_boot(self.config) |
402 | + expected_calls = self.expected_calls[:] |
403 | + self.assertEquals( |
404 | + expected_calls, self.popen_fixture.mock.commands_executed) |
405 | + self.assertEquals(self.expected_args, self.saved_args) |
406 | + |
407 | def test_populate_boot_no_uboot_flavor(self): |
408 | self.prepare_config(boards.BoardConfig) |
409 | - self.config.uboot_in_boot_part = True |
410 | + self.config.bootloader_file_in_boot_part = True |
411 | self.assertRaises( |
412 | AssertionError, self.call_populate_boot, self.config) |
413 |
Lovely.