Merge lp:~mabac/linaro-image-tools/bug-913819-additional-bootargs into lp:linaro-image-tools/11.11

Proposed by Mattias Backman
Status: Merged
Approved by: James Tunnicliffe
Approved revision: 485
Merged at revision: 483
Proposed branch: lp:~mabac/linaro-image-tools/bug-913819-additional-bootargs
Merge into: lp:linaro-image-tools/11.11
Diff against target: 202 lines (+121/-1)
5 files modified
linaro-android-media-create (+2/-0)
linaro-media-create (+2/-0)
linaro_image_tools/media_create/__init__.py (+10/-0)
linaro_image_tools/media_create/boards.py (+12/-0)
linaro_image_tools/media_create/tests/test_media_create.py (+95/-1)
To merge this branch: bzr merge lp:~mabac/linaro-image-tools/bug-913819-additional-bootargs
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Approve
Linaro Android Team functional Pending
Zach Pfeffer Pending
Review via email: mp+88868@code.launchpad.net

Description of the change

Hi,

This branch add two command line options for adding to the boot args.

  --extra-boot-args EXTRA_BOOT_ARGS
                        Extra boot args.
  --extra-boot-args-file EXTRA_BOOT_ARGS_FILE
                        File containing extra boot arguments.

These options are available for l-m-c and l-a-m-c.

Thanks,

Mattias

To post a comment you must log in.
Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks fine. I think I would call add_boot_args from add_boot_args_from_file so any extra checks that you put in add_boot_args are automatically picked up from add_boot_args_from_file. Not required to check in though.

review: Approve
486. By Mattias Backman

Call add_boot_args() from add_boot_args_from_file().

Revision history for this message
Mattias Backman (mabac) wrote :

On Wed, Jan 18, 2012 at 4:05 PM, James Tunnicliffe
<email address hidden> wrote:
> Review: Approve
>
> Looks fine. I think I would call add_boot_args from add_boot_args_from_file so any extra checks that you put in add_boot_args are automatically picked up from add_boot_args_from_file. Not required to check in though.

Cool, thanks. I've made that change.

linaro-android: please verify that this is works as you requested, I'd
like to merge it tomorrow if possible so it gets in the release.

> --
> https://code.launchpad.net/~mabac/linaro-image-tools/bug-913819-additional-bootargs/+merge/88868
> You are the owner of lp:~mabac/linaro-image-tools/bug-913819-additional-bootargs.

Revision history for this message
Amit Pundir (pundiramit) wrote :

Hi Mattias,

I checked out "bzr branch lp:~mabac/linaro-image-tools/bug-913819-additional-bootargs" and prepared sdcard image like this:

bug-913819-additional-bootargs/linaro-android-media-create --mmc /dev/sdb --dev origen --system system.tar.bz2 --userdata userdata.tar.bz2 --boot boot.tar.bz2 --extra-boot-args xyz=1

But I don't see "xyz=1" bootarg entry in boot.scr. Am I missing something?

Revision history for this message
Mattias Backman (mabac) wrote :

On Wed, Jan 18, 2012 at 9:37 PM, Amit Pundir <email address hidden> wrote:
> Hi Mattias,
>
> I checked out "bzr branch lp:~mabac/linaro-image-tools/bug-913819-additional-bootargs" and prepared sdcard image like this:
>
> bug-913819-additional-bootargs/linaro-android-media-create --mmc /dev/sdb --dev origen --system system.tar.bz2 --userdata userdata.tar.bz2 --boot boot.tar.bz2 --extra-boot-args xyz=1
>
> But I don't see "xyz=1" bootarg entry in boot.scr. Am I missing something?

Big oops, I think I missed adding the entry point to l-a-m-c while
trying to be clever and making this generic. Hang on while I fix it.

> --
> https://code.launchpad.net/~mabac/linaro-image-tools/bug-913819-additional-bootargs/+merge/88868
> You are the owner of lp:~mabac/linaro-image-tools/bug-913819-additional-bootargs.

487. By Mattias Backman

Add the new code to l-a-m-c as well.

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 2011-10-05 09:19:03 +0000
3+++ linaro-android-media-create 2012-01-19 09:46:07 +0000
4@@ -105,6 +105,8 @@
5 SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc')
6
7 board_config = android_board_configs[args.board]
8+ board_config.add_boot_args(args.extra_boot_args)
9+ board_config.add_boot_args_from_file(args.extra_boot_args_file)
10
11 if args.board == 'iMX53':
12 # XXX: remove this and the corresponding entry in android_board_configs
13
14=== modified file 'linaro-media-create'
15--- linaro-media-create 2011-10-19 12:19:33 +0000
16+++ linaro-media-create 2012-01-19 09:46:07 +0000
17@@ -119,6 +119,8 @@
18 board_config = board_configs[args.board]
19 board_config.set_metadata(args.hwpacks)
20 board_config.set_board(args.board)
21+ board_config.add_boot_args(args.extra_boot_args)
22+ board_config.add_boot_args_from_file(args.extra_boot_args_file)
23
24 ensure_required_commands(args)
25
26
27=== modified file 'linaro_image_tools/media_create/__init__.py'
28--- linaro_image_tools/media_create/__init__.py 2011-10-19 14:18:52 +0000
29+++ linaro_image_tools/media_create/__init__.py 2012-01-19 09:46:07 +0000
30@@ -66,6 +66,14 @@
31 qemu_version = "Cannot find %s." % qemu_path
32 return "%s\n: %s" % (__version__, qemu_version)
33
34+def add_common_options(parser):
35+ parser.add_argument(
36+ '--extra-boot-args', dest='extra_boot_args', required=False,
37+ help='Extra boot args.')
38+ parser.add_argument(
39+ '--extra-boot-args-file', dest='extra_boot_args_file',
40+ required=False, help=('File containing extra boot arguments.'))
41+
42 def get_args_parser():
43 """Get the ArgumentParser for the arguments given on the command line."""
44 parser = argparse.ArgumentParser(version='%(prog)s ' + get_version())
45@@ -145,6 +153,7 @@
46 action='store_true',
47 help='Assume yes to the question "Are you 100%% sure, on selecting [mmc]"')
48
49+ add_common_options(parser)
50 return parser
51
52 def get_android_args_parser():
53@@ -188,4 +197,5 @@
54 '--align-boot-part', dest='should_align_boot_part',
55 action='store_true',
56 help='Align boot partition too (might break older x-loaders).')
57+ add_common_options(parser)
58 return parser
59
60=== modified file 'linaro_image_tools/media_create/boards.py'
61--- linaro_image_tools/media_create/boards.py 2011-12-14 13:01:43 +0000
62+++ linaro_image_tools/media_create/boards.py 2012-01-19 09:46:07 +0000
63@@ -207,6 +207,7 @@
64 mmc_part_offset = 0
65 uimage_path = ''
66 fat_size = 32
67+ extra_serial_opts = ''
68 _extra_serial_opts = ''
69 _live_serial_opts = ''
70 extra_boot_args_options = None
71@@ -574,6 +575,17 @@
72 return boot_script
73
74 @classmethod
75+ def add_boot_args(cls, extra_args):
76+ if extra_args is not None:
77+ cls.extra_boot_args_options += ' %s' % extra_args
78+
79+ @classmethod
80+ def add_boot_args_from_file(cls, path):
81+ if path is not None:
82+ with open(path, 'r') as boot_args_file:
83+ cls.add_boot_args(boot_args_file.read().strip())
84+
85+ @classmethod
86 def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_uuid):
87 """Get the bootargs for this board.
88
89
90=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
91--- linaro_image_tools/media_create/tests/test_media_create.py 2011-12-23 10:35:27 +0000
92+++ linaro_image_tools/media_create/tests/test_media_create.py 2012-01-19 09:46:07 +0000
93@@ -1412,6 +1412,100 @@
94 self.assertEqual(expected, boot_commands)
95
96
97+class TestExtraBootCmd(TestCaseWithFixtures):
98+
99+ def test_no_extra_args(self):
100+ boot_args = ''.join(
101+ random.choice(string.ascii_lowercase) for x in range(15))
102+ class config(BoardConfig):
103+ extra_boot_args_options = boot_args
104+ boot_commands = config._get_boot_env(
105+ is_live=False, is_lowmem=False, consoles=['ttyXXX'],
106+ rootfs_uuid="deadbeef", d_img_data=None)
107+ expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro',
108+ boot_args])
109+ self.assertEqual(expected, boot_commands['bootargs'])
110+
111+ def test_none_extra_args(self):
112+ boot_args = ''.join(
113+ random.choice(string.ascii_lowercase) for x in range(15))
114+ extra_args = None
115+ class config(BoardConfig):
116+ extra_boot_args_options = boot_args
117+ config.add_boot_args(extra_args)
118+ boot_commands = config._get_boot_env(
119+ is_live=False, is_lowmem=False, consoles=['ttyXXX'],
120+ rootfs_uuid="deadbeef", d_img_data=None)
121+ expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro',
122+ boot_args])
123+ self.assertEqual(expected, boot_commands['bootargs'])
124+
125+ def test_string_extra_args(self):
126+ boot_args = ''.join(
127+ random.choice(string.ascii_lowercase) for x in range(15))
128+ extra_args = ''.join(
129+ random.choice(string.ascii_lowercase) for x in range(15))
130+ class config(BoardConfig):
131+ extra_boot_args_options = boot_args
132+ config.add_boot_args(extra_args)
133+ boot_commands = config._get_boot_env(
134+ is_live=False, is_lowmem=False, consoles=['ttyXXX'],
135+ rootfs_uuid="deadbeef", d_img_data=None)
136+ expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro',
137+ boot_args, extra_args])
138+ self.assertEqual(expected, boot_commands['bootargs'])
139+
140+ def test_file_extra_args(self):
141+ boot_args = ''.join(
142+ random.choice(string.ascii_lowercase) for x in range(15))
143+ extra_args = ''.join(
144+ random.choice(string.ascii_lowercase) for x in range(15))
145+ boot_arg_path = self.createTempFileAsFixture()
146+ with open(boot_arg_path, 'w') as boot_arg_file:
147+ boot_arg_file.write(extra_args)
148+ class config(BoardConfig):
149+ extra_boot_args_options = boot_args
150+ config.add_boot_args_from_file(boot_arg_path)
151+ boot_commands = config._get_boot_env(
152+ is_live=False, is_lowmem=False, consoles=['ttyXXX'],
153+ rootfs_uuid="deadbeef", d_img_data=None)
154+ expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro',
155+ boot_args, extra_args])
156+ self.assertEqual(expected, boot_commands['bootargs'])
157+
158+ def test_none_file_extra_args(self):
159+ boot_args = ''.join(
160+ random.choice(string.ascii_lowercase) for x in range(15))
161+ boot_arg_path = None
162+ class config(BoardConfig):
163+ extra_boot_args_options = boot_args
164+ config.add_boot_args_from_file(boot_arg_path)
165+ boot_commands = config._get_boot_env(
166+ is_live=False, is_lowmem=False, consoles=['ttyXXX'],
167+ rootfs_uuid="deadbeef", d_img_data=None)
168+ expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro',
169+ boot_args])
170+ self.assertEqual(expected, boot_commands['bootargs'])
171+
172+ def test_whitespace_file_extra_args(self):
173+ boot_args = ''.join(
174+ random.choice(string.ascii_lowercase) for x in range(15))
175+ extra_args = ''.join(
176+ random.choice(string.ascii_lowercase) for x in range(15))
177+ boot_arg_path = self.createTempFileAsFixture()
178+ with open(boot_arg_path, 'w') as boot_arg_file:
179+ boot_arg_file.write('\n\n \t ' + extra_args + ' \n\n')
180+ class config(BoardConfig):
181+ extra_boot_args_options = boot_args
182+ config.add_boot_args_from_file(boot_arg_path)
183+ boot_commands = config._get_boot_env(
184+ is_live=False, is_lowmem=False, consoles=['ttyXXX'],
185+ rootfs_uuid="deadbeef", d_img_data=None)
186+ expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro',
187+ boot_args, extra_args])
188+ self.assertEqual(expected, boot_commands['bootargs'])
189+
190+
191 class TestGetBootCmdAndroid(TestCase):
192 def test_panda(self):
193 # XXX: To fix bug 697824 we have to change class attributes of our
194@@ -1962,7 +2056,7 @@
195 def wait(self):
196 return self.returncode
197
198- fixture = self.useFixture(MockCmdRunnerPopenFixture())
199+ self.useFixture(MockCmdRunnerPopenFixture())
200
201 tmpfile = self.createTempFileAsFixture()
202 media = Media(tmpfile)

Subscribers

People subscribed via source and target branches