Merge lp:~lool/linaro-image-tools/move-populate-boot into lp:linaro-image-tools/11.11
- move-populate-boot
- Merge into trunk
Proposed by
Loïc Minier
Status: | Merged |
---|---|
Merged at revision: | 302 |
Proposed branch: | lp:~lool/linaro-image-tools/move-populate-boot |
Merge into: | lp:linaro-image-tools/11.11 |
Diff against target: |
320 lines (+63/-90) 4 files modified
linaro-media-create (+3/-4) linaro_image_tools/media_create/boards.py (+57/-24) linaro_image_tools/media_create/populate_boot.py (+0/-58) linaro_image_tools/media_create/tests/test_media_create.py (+3/-4) |
To merge this branch: | bzr merge lp:~lool/linaro-image-tools/move-populate-boot |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guilherme Salgado (community) | Approve | ||
Review via email: mp+54628@code.launchpad.net |
Commit message
Description of the change
This moves populate_boot() from media_create.
Guilherme, is this what you had in mind?
It seems fine there, albeit I didn't find any concrete things to do after the move.
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-media-create' |
2 | --- linaro-media-create 2011-03-23 22:25:10 +0000 |
3 | +++ linaro-media-create 2011-03-23 23:25:52 +0000 |
4 | @@ -32,7 +32,6 @@ |
5 | setup_partitions, |
6 | get_uuid, |
7 | ) |
8 | -from linaro_image_tools.media_create.populate_boot import populate_boot |
9 | from linaro_image_tools.media_create.rootfs import populate_rootfs |
10 | from linaro_image_tools.media_create.unpack_binary_tarball import ( |
11 | unpack_binary_tarball, |
12 | @@ -135,9 +134,9 @@ |
13 | rootfs_uuid = get_uuid(root_partition) |
14 | |
15 | if args.should_format_bootfs: |
16 | - populate_boot( |
17 | - board_config, ROOTFS_DIR, rootfs_uuid, boot_partition, BOOT_DISK, |
18 | - args.device, args.is_live, args.is_lowmem, args.consoles) |
19 | + board_config.populate_boot( |
20 | + ROOTFS_DIR, rootfs_uuid, boot_partition, BOOT_DISK, args.device, |
21 | + args.is_live, args.is_lowmem, args.consoles) |
22 | |
23 | if args.should_format_rootfs: |
24 | create_swap = False |
25 | |
26 | === modified file 'linaro_image_tools/media_create/boards.py' |
27 | --- linaro_image_tools/media_create/boards.py 2011-03-23 22:25:10 +0000 |
28 | +++ linaro_image_tools/media_create/boards.py 2011-03-23 23:25:52 +0000 |
29 | @@ -249,16 +249,16 @@ |
30 | |
31 | @classmethod |
32 | def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles, |
33 | - chroot_dir, rootfs_uuid, boot_dir, boot_script, |
34 | + chroot_dir, rootfs_uuid, boot_dir, boot_script_path, |
35 | boot_device_or_file): |
36 | boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_uuid) |
37 | cls._make_boot_files( |
38 | - uboot_parts_dir, boot_env, chroot_dir, boot_dir, boot_script, |
39 | + uboot_parts_dir, boot_env, chroot_dir, boot_dir, boot_script_path, |
40 | boot_device_or_file) |
41 | |
42 | @classmethod |
43 | def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
44 | - boot_script, boot_device_or_file): |
45 | + boot_script_path, boot_device_or_file): |
46 | """Make the necessary boot files for this board. |
47 | |
48 | This is usually board-specific so ought to be defined in every |
49 | @@ -266,6 +266,38 @@ |
50 | """ |
51 | raise NotImplementedError() |
52 | |
53 | + @classmethod |
54 | + def populate_boot(cls, chroot_dir, rootfs_uuid, boot_partition, boot_disk, |
55 | + boot_device_or_file, is_live, is_lowmem, consoles): |
56 | + parts_dir = 'boot' |
57 | + if is_live: |
58 | + parts_dir = 'casper' |
59 | + uboot_parts_dir = os.path.join(chroot_dir, parts_dir) |
60 | + |
61 | + cmd_runner.run(['mkdir', '-p', boot_disk]).wait() |
62 | + cmd_runner.run(['mount', boot_partition, boot_disk], |
63 | + as_root=True).wait() |
64 | + |
65 | + if cls.uboot_in_boot_part: |
66 | + assert cls.uboot_flavor is not None, ( |
67 | + "uboot_in_boot_part is set but not uboot_flavor") |
68 | + uboot_bin = os.path.join(chroot_dir, 'usr', 'lib', 'u-boot', |
69 | + cls.uboot_flavor, 'u-boot.bin') |
70 | + cmd_runner.run( |
71 | + ['cp', '-v', uboot_bin, boot_disk], as_root=True).wait() |
72 | + |
73 | + boot_script_path = os.path.join(boot_disk, cls.boot_script) |
74 | + |
75 | + cls.make_boot_files( |
76 | + uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir, |
77 | + rootfs_uuid, boot_disk, boot_script_path, boot_device_or_file) |
78 | + |
79 | + cmd_runner.run(['sync']).wait() |
80 | + try: |
81 | + cmd_runner.run(['umount', boot_disk], as_root=True).wait() |
82 | + except cmd_runner.SubcommandNonZeroReturnValue: |
83 | + pass |
84 | + |
85 | |
86 | class OmapConfig(BoardConfig): |
87 | kernel_suffix = 'linaro-omap' |
88 | @@ -313,7 +345,7 @@ |
89 | |
90 | @classmethod |
91 | def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles, |
92 | - chroot_dir, rootfs_uuid, boot_dir, boot_script, |
93 | + chroot_dir, rootfs_uuid, boot_dir, boot_script_path, |
94 | boot_device_or_file): |
95 | # XXX: This is also part of our temporary hack to fix bug 697824; we |
96 | # need to call set_appropriate_serial_tty() before doing anything that |
97 | @@ -321,17 +353,17 @@ |
98 | cls.set_appropriate_serial_tty(chroot_dir) |
99 | super(OmapConfig, cls).make_boot_files( |
100 | uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir, |
101 | - rootfs_uuid, boot_dir, boot_script, boot_device_or_file) |
102 | + rootfs_uuid, boot_dir, boot_script_path, boot_device_or_file) |
103 | |
104 | @classmethod |
105 | def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
106 | - boot_script, boot_device_or_file): |
107 | + boot_script_path, boot_device_or_file): |
108 | install_omap_boot_loader(chroot_dir, boot_dir) |
109 | make_uImage( |
110 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
111 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
112 | - make_boot_script(boot_env, boot_script) |
113 | - make_boot_ini(boot_script, boot_dir) |
114 | + make_boot_script(boot_env, boot_script_path) |
115 | + make_boot_ini(boot_script_path, boot_dir) |
116 | |
117 | |
118 | class BeagleConfig(OmapConfig): |
119 | @@ -381,12 +413,12 @@ |
120 | |
121 | @classmethod |
122 | def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
123 | - boot_script, boot_device_or_file): |
124 | + boot_script_path, boot_device_or_file): |
125 | make_uImage( |
126 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
127 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
128 | - make_boot_script(boot_env, boot_script) |
129 | - make_boot_ini(boot_script, boot_dir) |
130 | + make_boot_script(boot_env, boot_script_path) |
131 | + make_boot_ini(boot_script_path, boot_dir) |
132 | |
133 | |
134 | class Ux500Config(BoardConfig): |
135 | @@ -407,11 +439,11 @@ |
136 | |
137 | @classmethod |
138 | def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
139 | - boot_script, boot_device_or_file): |
140 | + boot_script_path, boot_device_or_file): |
141 | make_uImage( |
142 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
143 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
144 | - make_boot_script(boot_env, boot_script) |
145 | + make_boot_script(boot_env, boot_script_path) |
146 | |
147 | |
148 | class Mx5Config(BoardConfig): |
149 | @@ -452,14 +484,14 @@ |
150 | |
151 | @classmethod |
152 | def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
153 | - boot_script, boot_device_or_file): |
154 | + boot_script_path, boot_device_or_file): |
155 | uboot_file = os.path.join( |
156 | chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor, 'u-boot.imx') |
157 | install_mx5_boot_loader(uboot_file, boot_device_or_file) |
158 | make_uImage( |
159 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
160 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
161 | - make_boot_script(boot_env, boot_script) |
162 | + make_boot_script(boot_env, boot_script_path) |
163 | |
164 | |
165 | class Mx51Config(Mx5Config): |
166 | @@ -509,7 +541,7 @@ |
167 | |
168 | @classmethod |
169 | def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
170 | - boot_script, boot_device_or_file): |
171 | + boot_script_path, boot_device_or_file): |
172 | make_uImage( |
173 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
174 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
175 | @@ -571,7 +603,7 @@ |
176 | |
177 | @classmethod |
178 | def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
179 | - boot_script, boot_device_or_file): |
180 | + boot_script_path, boot_device_or_file): |
181 | uboot_file = os.path.join( |
182 | chroot_dir, 'usr', 'lib', 'u-boot', 'smdkv310', 'u-boot.v310') |
183 | install_smdkv310_boot_loader(uboot_file, boot_device_or_file) |
184 | @@ -588,9 +620,9 @@ |
185 | uboot_parts_dir, cls.kernel_suffix, boot_dir) |
186 | install_smdkv310_initrd(uInitrd_file, boot_device_or_file) |
187 | |
188 | - # unused at the moment once FAT support enabled for the |
189 | + # unused at the moment once FAT support enabled for the |
190 | # Samsung u-boot this can be used bug 727978 |
191 | - #make_boot_script(boot_env, boot_script) |
192 | + #make_boot_script(boot_env, boot_script_path) |
193 | |
194 | |
195 | board_configs = { |
196 | @@ -675,7 +707,7 @@ |
197 | return img |
198 | |
199 | |
200 | -def make_boot_script(boot_env, boot_script): |
201 | +def make_boot_script(boot_env, boot_script_path): |
202 | boot_script_data = ( |
203 | "setenv bootcmd '%(bootcmd)s'\n" |
204 | "setenv bootargs '%(bootargs)s'\n" |
205 | @@ -687,12 +719,12 @@ |
206 | _, tmpfile = tempfile.mkstemp() |
207 | atexit.register(os.unlink, tmpfile) |
208 | plain_boot_script = os.path.join( |
209 | - os.path.dirname(boot_script), 'boot.txt') |
210 | + os.path.dirname(boot_script_path), 'boot.txt') |
211 | with open(tmpfile, 'w') as fd: |
212 | fd.write(boot_script_data) |
213 | cmd_runner.run(['cp', tmpfile, plain_boot_script], as_root=True).wait() |
214 | return _run_mkimage( |
215 | - 'script', '0', '0', 'boot script', plain_boot_script, boot_script) |
216 | + 'script', '0', '0', 'boot script', plain_boot_script, boot_script_path) |
217 | |
218 | |
219 | def make_flashable_env(boot_env, env_size): |
220 | @@ -761,9 +793,10 @@ |
221 | cmd_runner.run(["sync"]).wait() |
222 | |
223 | |
224 | -def make_boot_ini(boot_script, boot_disk): |
225 | +def make_boot_ini(boot_script_path, boot_disk): |
226 | proc = cmd_runner.run( |
227 | - ["cp", "-v", boot_script, "%s/boot.ini" % boot_disk], as_root=True) |
228 | + ["cp", "-v", boot_script_path, "%s/boot.ini" % boot_disk], |
229 | + as_root=True) |
230 | proc.wait() |
231 | |
232 | |
233 | |
234 | === removed file 'linaro_image_tools/media_create/populate_boot.py' |
235 | --- linaro_image_tools/media_create/populate_boot.py 2011-03-23 22:25:10 +0000 |
236 | +++ linaro_image_tools/media_create/populate_boot.py 1970-01-01 00:00:00 +0000 |
237 | @@ -1,58 +0,0 @@ |
238 | -# Copyright (C) 2010, 2011 Linaro |
239 | -# |
240 | -# Author: Guilherme Salgado <guilherme.salgado@linaro.org> |
241 | -# |
242 | -# This file is part of Linaro Image Tools. |
243 | -# |
244 | -# Linaro Image Tools is free software: you can redistribute it and/or modify |
245 | -# it under the terms of the GNU General Public License as published by |
246 | -# the Free Software Foundation, either version 3 of the License, or |
247 | -# (at your option) any later version. |
248 | -# |
249 | -# Linaro Image Tools is distributed in the hope that it will be useful, |
250 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
251 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
252 | -# GNU General Public License for more details. |
253 | -# |
254 | -# You should have received a copy of the GNU General Public License |
255 | -# along with Linaro Image Tools. If not, see <http://www.gnu.org/licenses/>. |
256 | - |
257 | -import os |
258 | - |
259 | -from linaro_image_tools.media_create import cmd_runner |
260 | - |
261 | - |
262 | -def populate_boot(board_config, chroot_dir, rootfs_uuid, boot_partition, |
263 | - boot_disk, boot_device_or_file, is_live, is_lowmem, |
264 | - consoles): |
265 | - |
266 | - parts_dir = 'boot' |
267 | - if is_live: |
268 | - parts_dir = 'casper' |
269 | - uboot_parts_dir = os.path.join(chroot_dir, parts_dir) |
270 | - |
271 | - cmd_runner.run(['mkdir', '-p', boot_disk]).wait() |
272 | - cmd_runner.run(['mount', boot_partition, boot_disk], as_root=True).wait() |
273 | - |
274 | - if board_config.uboot_in_boot_part: |
275 | - uboot_flavor = board_config.uboot_flavor |
276 | - assert uboot_flavor is not None, ( |
277 | - "uboot_in_boot_part is set but not uboot_flavor") |
278 | - uboot_bin = os.path.join( |
279 | - chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor, 'u-boot.bin') |
280 | - cmd_runner.run( |
281 | - ['cp', '-v', uboot_bin, boot_disk], as_root=True).wait() |
282 | - |
283 | - boot_script = "%(boot_disk)s/%(boot_script_name)s" % ( |
284 | - dict(boot_disk=boot_disk, |
285 | - boot_script_name=board_config.boot_script)) |
286 | - |
287 | - board_config.make_boot_files( |
288 | - uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir, rootfs_uuid, |
289 | - boot_disk, boot_script, boot_device_or_file) |
290 | - |
291 | - cmd_runner.run(['sync']).wait() |
292 | - try: |
293 | - cmd_runner.run(['umount', boot_disk], as_root=True).wait() |
294 | - except cmd_runner.SubcommandNonZeroReturnValue: |
295 | - pass |
296 | |
297 | === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' |
298 | --- linaro_image_tools/media_create/tests/test_media_create.py 2011-03-23 22:25:10 +0000 |
299 | +++ linaro_image_tools/media_create/tests/test_media_create.py 2011-03-23 23:25:52 +0000 |
300 | @@ -81,7 +81,6 @@ |
301 | get_uuid, |
302 | _parse_blkid_output, |
303 | ) |
304 | -from linaro_image_tools.media_create.populate_boot import populate_boot |
305 | from linaro_image_tools.media_create.rootfs import ( |
306 | create_flash_kernel_config, |
307 | has_space_left_for_swap, |
308 | @@ -1083,9 +1082,9 @@ |
309 | self.config, 'make_boot_files', self.save_args)) |
310 | |
311 | def call_populate_boot(self, config, is_live=False): |
312 | - populate_boot( |
313 | - config, 'chroot_dir', 'rootfs_uuid', 'boot_partition', |
314 | - 'boot_disk', 'boot_device_or_file', is_live, False, []) |
315 | + config.populate_boot( |
316 | + 'chroot_dir', 'rootfs_uuid', 'boot_partition', 'boot_disk', |
317 | + 'boot_device_or_file', is_live, False, []) |
318 | |
319 | def test_populate_boot_live(self): |
320 | self.prepare_config(boards.BoardConfig) |
On Wed, 2011-03-23 at 23:25 +0000, Loïc Minier wrote: populate_ boot to media_create. boards. BoardConfig; bug #716469.
[...]
>
> This moves populate_boot() from media_create.
>
> Guilherme, is this what you had in mind?
Yep, that's exactly what I had in mind.
> It seems fine there, albeit I didn't find any concrete things to do after the move.
The BoardConfig class indeed seems like a more natural place for it, but
my motivation to file the bug was because of a branch that was about to
land which added some board-specific code to populate_boot(). Because
of that change we'd have to move populate_boot to the BoardConfig class
so that we could get rid of the board-specific code outside of there.
That change didn't land, though, so now this is just a nice refactoring
which doesn't unblock anything else. I really appreciate you working on
it, though.
review approve