Merge lp:~milo/linaro-image-tools/regression-fix into lp:linaro-image-tools/11.11

Proposed by Milo Casagrande
Status: Merged
Approved by: Fathi Boudra
Approved revision: 599
Merged at revision: 599
Proposed branch: lp:~milo/linaro-image-tools/regression-fix
Merge into: lp:linaro-image-tools/11.11
Diff against target: 103 lines (+27/-20)
2 files modified
linaro_image_tools/media_create/boards.py (+26/-19)
linaro_image_tools/media_create/tests/test_media_create.py (+1/-1)
To merge this branch: bzr merge lp:~milo/linaro-image-tools/regression-fix
Reviewer Review Type Date Requested Status
Fathi Boudra Approve
Review via email: mp+142460@code.launchpad.net

Description of the change

As reported on IRC this morning, we have a small regression after merging the code for Android hwpack.

This MP fixes the regression: a missing check on None strings.
It also addresses another change: the boot_args string, under some circumstance was coming out with a "None" inside, like this: "None root=/dev/mmcblk0p2 rootwait ro".

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

As reported on IRC this morning, we have a small regression after merging the code for Android hwpack.

This MP fixes the regression: a missing check on None strings.
It also addresses another change: the boot_args string, under some circumstance was coming out with a "None" inside, like this: "None root=/dev/mmcblk0p2 rootwait ro".

Revision history for this message
Fathi Boudra (fboudra) wrote :

ship it!

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 2013-01-07 12:40:41 +0000
3+++ linaro_image_tools/media_create/boards.py 2013-01-09 09:29:24 +0000
4@@ -212,10 +212,13 @@
5
6 # XXX: can be removed when killing v1 hwpack.
7 def _get_live_serial_options(self):
8- return_value = self._live_serial_options
9- if self._check_placeholder_presence(return_value, r'%s'):
10- return_value = self._live_serial_options % self.serial_tty
11- return return_value
12+ live_serial = self._live_serial_options
13+ if live_serial:
14+ if isinstance(live_serial, list):
15+ live_serial = ' '.join(live_serial)
16+ if self._check_placeholder_presence(live_serial, r'%s'):
17+ live_serial = live_serial % self.serial_tty
18+ return live_serial
19
20 def _set_live_serial_options(self, value):
21 self._live_serial_options = value
22@@ -225,16 +228,19 @@
23
24 # XXX: can be removed when killing v1 hwpack.
25 def _get_extra_serial_options(self):
26- return_value = self._extra_serial_options
27- if self._check_placeholder_presence(return_value, r'%s'):
28- return_value = return_value % self.serial_tty
29- return return_value
30+ extra_serial = self._extra_serial_options
31+ if extra_serial:
32+ if isinstance(extra_serial, list):
33+ extra_serial = ' '.join(extra_serial)
34+ if self._check_placeholder_presence(extra_serial, r'%s'):
35+ extra_serial = extra_serial % self.serial_tty
36+ return extra_serial
37
38 def _set_extra_serial_options(self, value):
39 self._extra_serial_options = value
40
41 extra_serial_options = property(_get_extra_serial_options,
42- _set_extra_serial_options)
43+ _set_extra_serial_options)
44
45 def get_metadata_field(self, field_name):
46 """ Return the metadata value for field_name if it can be found.
47@@ -539,9 +545,11 @@
48 In general subclasses should not have to override this.
49 """
50 boot_args_options = 'rootwait ro'
51+ serial_options = ''
52 if self.extra_boot_args_options:
53 boot_args_options += ' %s' % self.extra_boot_args_options
54- serial_options = self.extra_serial_options
55+ if self.extra_serial_options:
56+ serial_options = self.extra_serial_options
57 for console in consoles:
58 serial_options += ' console=%s' % console
59
60@@ -553,14 +561,13 @@
61 if is_lowmem:
62 lowmem_opt = 'only-ubiquity'
63
64- replacements = dict(
65- serial_options=serial_options,
66- lowmem_opt=lowmem_opt, boot_snippet=boot_snippet,
67- boot_args_options=boot_args_options)
68- return (
69- "%(serial_options)s %(lowmem_opt)s "
70- "%(boot_snippet)s %(boot_args_options)s"
71- % replacements)
72+ replacements = dict(serial_options=serial_options.strip(),
73+ lowmem_opt=lowmem_opt,
74+ boot_snippet=boot_snippet,
75+ boot_args_options=boot_args_options)
76+ boot_args = ("%(serial_options)s %(lowmem_opt)s %(boot_snippet)s"
77+ " %(boot_args_options)s" % replacements).strip()
78+ return boot_args
79
80 def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id,
81 i_img_data, d_img_data):
82@@ -859,7 +866,7 @@
83 """Checks if the passed string contains the particular placeholder."""
84 # Very simple way of achieving that.
85 presence = False
86- if placeholder in string:
87+ if string and placeholder in string:
88 presence = True
89 return presence
90
91
92=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
93--- linaro_image_tools/media_create/tests/test_media_create.py 2012-12-27 14:58:24 +0000
94+++ linaro_image_tools/media_create/tests/test_media_create.py 2013-01-09 09:29:24 +0000
95@@ -2123,7 +2123,7 @@
96 is_live=False, is_lowmem=False, consoles=['ttyXXX'],
97 rootfs_id="UUID=deadbeef", i_img_data=None, d_img_data=None)
98 expected = (
99- ' console=ttyXXX root=UUID=deadbeef rootwait ro %s' % boot_args)
100+ 'console=ttyXXX root=UUID=deadbeef rootwait ro %s' % boot_args)
101 self.assertEqual(expected, boot_commands['bootargs'])
102
103 def test_passing_None_to_add_boot_args(self):

Subscribers

People subscribed via source and target branches