Merge lp:~mwaddel/linaro-image-tools/null-string-vexpress into lp:linaro-image-tools/11.11

Proposed by Matt Waddel
Status: Merged
Merged at revision: 309
Proposed branch: lp:~mwaddel/linaro-image-tools/null-string-vexpress
Merge into: lp:linaro-image-tools/11.11
Diff against target: 130 lines (+17/-16)
1 file modified
linaro_image_tools/media_create/boards.py (+17/-16)
To merge this branch: bzr merge lp:~mwaddel/linaro-image-tools/null-string-vexpress
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) Approve
Review via email: mp+56028@code.launchpad.net

Description of the change

The call to make_boot_files() fails when boot_script_path isn't initialized. This happens in the Versatile Express because the boot script isn't used on this platform.

To post a comment you must log in.
Revision history for this message
Loïc Minier (lool) wrote :

On Sat, Apr 02, 2011, Matt Waddel wrote:
> + if cls.boot_script:
> + boot_script_path = os.path.join(boot_disk, cls.boot_script)
> + else:
> + boot_script_path = ''

 Can we make it None instead? '' + 'boot.scr' might actually work and
 result in either '/boot.scr' on the host or 'boot.scr' in the current
 working directory on the host, so I prefer we use None just in case

 Perhaps something like:
    boot_script_path = None
    if cls.boot_script:
        boot_script_path = os.path.join(boot_disk, cls.boot_script)

--
Loïc Minier

Revision history for this message
Guilherme Salgado (salgado) wrote :

Hi Matt,

Thanks for this fix; I have just one suggestion below.

On Sat, 2011-04-02 at 05:21 +0000, Matt Waddel wrote:
[...]
> === modified file 'linaro_image_tools/media_create/boards.py'
> --- linaro_image_tools/media_create/boards.py 2011-04-01 14:18:41 +0000
> +++ linaro_image_tools/media_create/boards.py 2011-04-02 05:21:29 +0000
> @@ -287,7 +287,10 @@
> cmd_runner.run(
> ['cp', '-v', uboot_bin, boot_disk], as_root=True).wait()
>
> - boot_script_path = os.path.join(boot_disk, cls.boot_script)
> + if cls.boot_script:
> + boot_script_path = os.path.join(boot_disk, cls.boot_script)
> + else:
> + boot_script_path = ''

I think it'd make more sense to just move the line you removed to the
_make_boot_files() methods that use it. For instance, in OmapConfig
we'd have:

   boot_script_path = os.path.join(boot_dir, cls.boot_script)
   [...]
   make_boot_script(boot_env, boot_script_path)
   [...]

That means we'd duplicate the boot_script_path initialization in a few
different methods, but it's just one line and I think that's cleaner
than having it initialized in populate_boot() and passed all the way
down to _make_boot_files()

310. By Matt Waddel

Removes potentially uninitialized variable, boot_script_path, from calls to make_boot_files()

Revision history for this message
Matt Waddel (mwaddel) wrote :

Hi Salgado,

I have made the changes you suggested. The changes are a bit more extensive than the original fix, but I tested in both a beagle and a vexpress deploy and everything seems to work.

Beagle deploy command used:
./linaro-image-tools/linaro-media-create --mmc /dev/sdb --dev beagle --console ttyAMA0,38400n8 --binary ./images/linaro-natty-nano-tar-20110329-0.tar.gz --hwpack ./images/hwpack_linaro-omap3_20110330-0_armel_supported.tar.gz

Vexpress deploy command used:
./linaro-image-tools/linaro-media-create --mmc /dev/sdb --dev vexpress --console ttyAMA0,38400n8 --binary ./images/linaro-natty-nano-tar-20110329-0.tar.gz --hwpack ./images/hwpack_linaro-vexpress_20110329-0_armel_supported.tar.gz

I think it's ready for a merge review again.

Revision history for this message
Guilherme Salgado (salgado) wrote :

Thanks for doing the changes, Matt. I'm happy to merge this but I think some tests will fail because of the signature change in make_boot_files(). Did you run the test suite ('testr run') to check?

If I'm not mistaken, you'll just have to remove the 'boot_disk/boot_script' string from TestPopulateBoot.expected_args[live] in tests/test_media_create.py.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py 2011-04-01 14:18:41 +0000
+++ linaro_image_tools/media_create/boards.py 2011-04-04 16:38:27 +0000
@@ -250,16 +250,15 @@
250250
251 @classmethod251 @classmethod
252 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,252 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
253 chroot_dir, rootfs_uuid, boot_dir, boot_script_path,253 chroot_dir, rootfs_uuid, boot_dir, boot_device_or_file):
254 boot_device_or_file):
255 boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_uuid)254 boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_uuid)
256 cls._make_boot_files(255 cls._make_boot_files(
257 uboot_parts_dir, boot_env, chroot_dir, boot_dir, boot_script_path,256 uboot_parts_dir, boot_env, chroot_dir, boot_dir,
258 boot_device_or_file)257 boot_device_or_file)
259258
260 @classmethod259 @classmethod
261 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,260 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
262 boot_script_path, boot_device_or_file):261 boot_device_or_file):
263 """Make the necessary boot files for this board.262 """Make the necessary boot files for this board.
264263
265 This is usually board-specific so ought to be defined in every264 This is usually board-specific so ought to be defined in every
@@ -287,11 +286,9 @@
287 cmd_runner.run(286 cmd_runner.run(
288 ['cp', '-v', uboot_bin, boot_disk], as_root=True).wait()287 ['cp', '-v', uboot_bin, boot_disk], as_root=True).wait()
289288
290 boot_script_path = os.path.join(boot_disk, cls.boot_script)
291
292 cls.make_boot_files(289 cls.make_boot_files(
293 uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir,290 uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
294 rootfs_uuid, boot_disk, boot_script_path, boot_device_or_file)291 rootfs_uuid, boot_disk, boot_device_or_file)
295292
296 cmd_runner.run(['sync']).wait()293 cmd_runner.run(['sync']).wait()
297 try:294 try:
@@ -346,23 +343,23 @@
346343
347 @classmethod344 @classmethod
348 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,345 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
349 chroot_dir, rootfs_uuid, boot_dir, boot_script_path,346 chroot_dir, rootfs_uuid, boot_dir, boot_device_or_file):
350 boot_device_or_file):
351 # XXX: This is also part of our temporary hack to fix bug 697824; we347 # XXX: This is also part of our temporary hack to fix bug 697824; we
352 # need to call set_appropriate_serial_tty() before doing anything that348 # need to call set_appropriate_serial_tty() before doing anything that
353 # may use cls.serial_tty.349 # may use cls.serial_tty.
354 cls.set_appropriate_serial_tty(chroot_dir)350 cls.set_appropriate_serial_tty(chroot_dir)
355 super(OmapConfig, cls).make_boot_files(351 super(OmapConfig, cls).make_boot_files(
356 uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir,352 uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
357 rootfs_uuid, boot_dir, boot_script_path, boot_device_or_file)353 rootfs_uuid, boot_dir, boot_device_or_file)
358354
359 @classmethod355 @classmethod
360 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,356 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
361 boot_script_path, boot_device_or_file):357 boot_device_or_file):
362 install_omap_boot_loader(chroot_dir, boot_dir)358 install_omap_boot_loader(chroot_dir, boot_dir)
363 make_uImage(359 make_uImage(
364 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)360 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
365 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)361 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
362 boot_script_path = os.path.join(boot_dir, cls.boot_script)
366 make_boot_script(boot_env, boot_script_path)363 make_boot_script(boot_env, boot_script_path)
367 make_boot_ini(boot_script_path, boot_dir)364 make_boot_ini(boot_script_path, boot_dir)
368365
@@ -414,10 +411,11 @@
414411
415 @classmethod412 @classmethod
416 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,413 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
417 boot_script_path, boot_device_or_file):414 boot_device_or_file):
418 make_uImage(415 make_uImage(
419 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)416 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
420 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)417 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
418 boot_script_path = os.path.join(boot_dir, cls.boot_script)
421 make_boot_script(boot_env, boot_script_path)419 make_boot_script(boot_env, boot_script_path)
422 make_boot_ini(boot_script_path, boot_dir)420 make_boot_ini(boot_script_path, boot_dir)
423421
@@ -440,10 +438,11 @@
440438
441 @classmethod439 @classmethod
442 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,440 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
443 boot_script_path, boot_device_or_file):441 boot_device_or_file):
444 make_uImage(442 make_uImage(
445 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)443 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
446 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)444 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
445 boot_script_path = os.path.join(boot_dir, cls.boot_script)
447 make_boot_script(boot_env, boot_script_path)446 make_boot_script(boot_env, boot_script_path)
448447
449448
@@ -485,13 +484,14 @@
485484
486 @classmethod485 @classmethod
487 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,486 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
488 boot_script_path, boot_device_or_file):487 boot_device_or_file):
489 uboot_file = os.path.join(488 uboot_file = os.path.join(
490 chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor, 'u-boot.imx')489 chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor, 'u-boot.imx')
491 install_mx5_boot_loader(uboot_file, boot_device_or_file)490 install_mx5_boot_loader(uboot_file, boot_device_or_file)
492 make_uImage(491 make_uImage(
493 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)492 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
494 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)493 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
494 boot_script_path = os.path.join(boot_dir, cls.boot_script)
495 make_boot_script(boot_env, boot_script_path)495 make_boot_script(boot_env, boot_script_path)
496496
497497
@@ -542,7 +542,7 @@
542542
543 @classmethod543 @classmethod
544 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,544 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
545 boot_script_path, boot_device_or_file):545 boot_device_or_file):
546 make_uImage(546 make_uImage(
547 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)547 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
548 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)548 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
@@ -604,7 +604,7 @@
604604
605 @classmethod605 @classmethod
606 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,606 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
607 boot_script_path, boot_device_or_file):607 boot_device_or_file):
608 uboot_file = os.path.join(608 uboot_file = os.path.join(
609 chroot_dir, 'usr', 'lib', 'u-boot', 'smdkv310', 'u-boot.v310')609 chroot_dir, 'usr', 'lib', 'u-boot', 'smdkv310', 'u-boot.v310')
610 install_smdkv310_boot_loader(uboot_file, boot_device_or_file)610 install_smdkv310_boot_loader(uboot_file, boot_device_or_file)
@@ -623,6 +623,7 @@
623623
624 # unused at the moment once FAT support enabled for the624 # unused at the moment once FAT support enabled for the
625 # Samsung u-boot this can be used bug 727978625 # Samsung u-boot this can be used bug 727978
626 #boot_script_path = os.path.join(boot_dir, cls.boot_script)
626 #make_boot_script(boot_env, boot_script_path)627 #make_boot_script(boot_env, boot_script_path)
627628
628629

Subscribers

People subscribed via source and target branches