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
1=== modified file 'linaro_image_tools/media_create/boards.py'
2--- linaro_image_tools/media_create/boards.py 2011-04-01 14:18:41 +0000
3+++ linaro_image_tools/media_create/boards.py 2011-04-04 16:38:27 +0000
4@@ -250,16 +250,15 @@
5
6 @classmethod
7 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
8- chroot_dir, rootfs_uuid, boot_dir, boot_script_path,
9- boot_device_or_file):
10+ chroot_dir, rootfs_uuid, boot_dir, boot_device_or_file):
11 boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_uuid)
12 cls._make_boot_files(
13- uboot_parts_dir, boot_env, chroot_dir, boot_dir, boot_script_path,
14+ uboot_parts_dir, boot_env, chroot_dir, boot_dir,
15 boot_device_or_file)
16
17 @classmethod
18 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
19- boot_script_path, boot_device_or_file):
20+ boot_device_or_file):
21 """Make the necessary boot files for this board.
22
23 This is usually board-specific so ought to be defined in every
24@@ -287,11 +286,9 @@
25 cmd_runner.run(
26 ['cp', '-v', uboot_bin, boot_disk], as_root=True).wait()
27
28- boot_script_path = os.path.join(boot_disk, cls.boot_script)
29-
30 cls.make_boot_files(
31 uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
32- rootfs_uuid, boot_disk, boot_script_path, boot_device_or_file)
33+ rootfs_uuid, boot_disk, boot_device_or_file)
34
35 cmd_runner.run(['sync']).wait()
36 try:
37@@ -346,23 +343,23 @@
38
39 @classmethod
40 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
41- chroot_dir, rootfs_uuid, boot_dir, boot_script_path,
42- boot_device_or_file):
43+ chroot_dir, rootfs_uuid, boot_dir, boot_device_or_file):
44 # XXX: This is also part of our temporary hack to fix bug 697824; we
45 # need to call set_appropriate_serial_tty() before doing anything that
46 # may use cls.serial_tty.
47 cls.set_appropriate_serial_tty(chroot_dir)
48 super(OmapConfig, cls).make_boot_files(
49 uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
50- rootfs_uuid, boot_dir, boot_script_path, boot_device_or_file)
51+ rootfs_uuid, boot_dir, boot_device_or_file)
52
53 @classmethod
54 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
55- boot_script_path, boot_device_or_file):
56+ boot_device_or_file):
57 install_omap_boot_loader(chroot_dir, boot_dir)
58 make_uImage(
59 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
60 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
61+ boot_script_path = os.path.join(boot_dir, cls.boot_script)
62 make_boot_script(boot_env, boot_script_path)
63 make_boot_ini(boot_script_path, boot_dir)
64
65@@ -414,10 +411,11 @@
66
67 @classmethod
68 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
69- boot_script_path, boot_device_or_file):
70+ boot_device_or_file):
71 make_uImage(
72 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
73 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
74+ boot_script_path = os.path.join(boot_dir, cls.boot_script)
75 make_boot_script(boot_env, boot_script_path)
76 make_boot_ini(boot_script_path, boot_dir)
77
78@@ -440,10 +438,11 @@
79
80 @classmethod
81 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
82- boot_script_path, boot_device_or_file):
83+ boot_device_or_file):
84 make_uImage(
85 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
86 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
87+ boot_script_path = os.path.join(boot_dir, cls.boot_script)
88 make_boot_script(boot_env, boot_script_path)
89
90
91@@ -485,13 +484,14 @@
92
93 @classmethod
94 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
95- boot_script_path, boot_device_or_file):
96+ boot_device_or_file):
97 uboot_file = os.path.join(
98 chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor, 'u-boot.imx')
99 install_mx5_boot_loader(uboot_file, boot_device_or_file)
100 make_uImage(
101 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
102 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
103+ boot_script_path = os.path.join(boot_dir, cls.boot_script)
104 make_boot_script(boot_env, boot_script_path)
105
106
107@@ -542,7 +542,7 @@
108
109 @classmethod
110 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
111- boot_script_path, boot_device_or_file):
112+ boot_device_or_file):
113 make_uImage(
114 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
115 make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir)
116@@ -604,7 +604,7 @@
117
118 @classmethod
119 def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir,
120- boot_script_path, boot_device_or_file):
121+ boot_device_or_file):
122 uboot_file = os.path.join(
123 chroot_dir, 'usr', 'lib', 'u-boot', 'smdkv310', 'u-boot.v310')
124 install_smdkv310_boot_loader(uboot_file, boot_device_or_file)
125@@ -623,6 +623,7 @@
126
127 # unused at the moment once FAT support enabled for the
128 # Samsung u-boot this can be used bug 727978
129+ #boot_script_path = os.path.join(boot_dir, cls.boot_script)
130 #make_boot_script(boot_env, boot_script_path)
131
132

Subscribers

People subscribed via source and target branches