Merge lp:~jeremychang/linaro-image-tools/android-boottarball into lp:linaro-image-tools/11.11
- android-boottarball
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | James Westby |
Approved revision: | 330 |
Merged at revision: | 328 |
Proposed branch: | lp:~jeremychang/linaro-image-tools/android-boottarball |
Merge into: | lp:linaro-image-tools/11.11 |
Diff against target: |
503 lines (+201/-129) (has conflicts) 5 files modified
linaro-android-media-create (+14/-19) linaro_image_tools/media_create/__init__.py (+6/-14) linaro_image_tools/media_create/android_boards.py (+158/-0) linaro_image_tools/media_create/boards.py (+0/-53) linaro_image_tools/media_create/partitions.py (+23/-43) Text conflict in linaro-android-media-create |
To merge this branch: | bzr merge lp:~jeremychang/linaro-image-tools/android-boottarball |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby (community) | Approve | ||
Review via email: mp+58545@code.launchpad.net |
Commit message
Description of the change
The change is dedicated on android tarballs deployment.
Some functions/fixes are list below:
* Android boot tarball deployment added.
* fix bug, https:/
James Westby (james-w) wrote : | # |
Alexander Sack (asac) wrote : | # |
this is needed for next week android beta release. please merge and file bugs for us to follow up on comments.
Alexander Sack (asac) wrote : | # |
let me test ....
Alexander Sack (asac) wrote : | # |
--dev panda spits out a warning after formatting, but seems to work.
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
mkfs.vfat 3.0.9 (31 Jan 2010)
Image Name: boot script
Created: Fri Apr 22 12:23:05 2011
Image Type: ARM Linux Script (uncompressed)
Data Size: 330 Bytes = 0.32 kB = 0.00 MB
Load Address: 00000000
Entry Point: 00000000
Contents:
Image 0: 322 Bytes = 0.31 kB = 0.00 MB
umount: /tmp/tmpESyiEo/
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
- 328. By Jeremy Chang
-
Use import to replace the duplicatd code
- 329. By Jeremy Chang
-
Fix umount error
Fix the error of umount: device is busy by close the file
- 330. By Jeremy Chang
-
Share more between the two bootscript
Jeremy Chang (jeremychang) wrote : | # |
Hi, Alexander:
I fixed the umount error. Thanks for the feedback.
Hi, James:
Thanks for your review and suggestion. I improved the code to
share more in between and pushed.
If there's more could be better or comments, please let me know.
Thanks,
--
-Jeremy
On Fri, Apr 22, 2011 at 7:03 PM, Alexander Sack <email address hidden> wrote:
> --dev panda spits out a warning after formatting, but seems to work.
>
> This filesystem will be automatically checked every 23 mounts or
> 180 days, whichever comes first. Use tune2fs -c or -i to override.
> mkfs.vfat 3.0.9 (31 Jan 2010)
> Image Name: boot script
> Created: Fri Apr 22 12:23:05 2011
> Image Type: ARM Linux Script (uncompressed)
> Data Size: 330 Bytes = 0.32 kB = 0.00 MB
> Load Address: 00000000
> Entry Point: 00000000
> Contents:
> Image 0: 322 Bytes = 0.31 kB = 0.00 MB
> umount: /tmp/tmpESyiEo/
> (In some cases useful info about processes that use
> the device is found by lsof(8) or fuser(1))
> --
> https:/
> You are the owner of lp:~jeremychang/linaro-image-tools/android-boottarball.
>
James Westby (james-w) : | # |
Preview Diff
1 | === modified file 'linaro-android-media-create' |
2 | --- linaro-android-media-create 2011-04-22 07:42:34 +0000 |
3 | +++ linaro-android-media-create 2011-04-22 15:11:32 +0000 |
4 | @@ -25,10 +25,13 @@ |
5 | |
6 | from linaro_image_tools import cmd_runner |
7 | |
8 | -from linaro_image_tools.media_create.boards import android_board_configs |
9 | +from linaro_image_tools.media_create.android_boards import android_board_configs |
10 | from linaro_image_tools.media_create.check_device import ( |
11 | confirm_device_selection_and_ensure_it_is_ready) |
12 | +<<<<<<< TREE |
13 | from linaro_image_tools.media_create.chroot_utils import install_hwpacks |
14 | +======= |
15 | +>>>>>>> MERGE-SOURCE |
16 | from linaro_image_tools.media_create.partitions import ( |
17 | Media, |
18 | setup_partitions, |
19 | @@ -46,9 +49,7 @@ |
20 | |
21 | # Just define the global variables |
22 | TMP_DIR = None |
23 | -ROOTFS_DIR = None |
24 | BOOT_DISK = None |
25 | -ROOT_DISK = None |
26 | SYSTEM_DISK = None |
27 | CACHE_DISK = None |
28 | DATA_DISK = None |
29 | @@ -61,11 +62,11 @@ |
30 | def cleanup_tempdir(): |
31 | """Remove TEMP_DIR with all its contents. |
32 | |
33 | - Before doing so, make sure BOOT_DISK and ROOT_DISK are not mounted. |
34 | + Before doing so, make sure DISKs are not mounted. |
35 | """ |
36 | devnull = open('/dev/null', 'w') |
37 | # ignore non-zero return codes |
38 | - for disk in BOOT_DISK, ROOT_DISK, SYSTEM_DISK, CACHE_DISK, DATA_DISK, \ |
39 | + for disk in BOOT_DISK, SYSTEM_DISK, CACHE_DISK, DATA_DISK, \ |
40 | SDCARD_DISK: |
41 | if disk is not None: |
42 | try: |
43 | @@ -86,10 +87,6 @@ |
44 | if not is_arm_host(): |
45 | required_commands.append('qemu-arm-static') |
46 | required_commands.append('qemu-img') |
47 | - if args.rootfs in ['ext2', 'ext3', 'ext4']: |
48 | - required_commands.append('mkfs.%s' % args.rootfs) |
49 | - else: |
50 | - required_commands.append('mkfs.btrfs') |
51 | for command in required_commands: |
52 | ensure_command(command) |
53 | |
54 | @@ -108,12 +105,11 @@ |
55 | # If --help was specified this won't execute. |
56 | # Create temp dir and initialize rest of path vars. |
57 | TMP_DIR = tempfile.mkdtemp() |
58 | - ROOT_DIR = os.path.join(TMP_DIR, 'root') |
59 | + BOOT_DIR = os.path.join(TMP_DIR, 'boot') |
60 | SYSTEM_DIR = os.path.join(TMP_DIR, 'system') |
61 | DATA_DIR = os.path.join(TMP_DIR, 'data') |
62 | |
63 | BOOT_DISK = os.path.join(TMP_DIR, 'boot-disc') |
64 | - ROOT_DISK = os.path.join(TMP_DIR, 'root-disc') |
65 | SYSTEM_DISK = os.path.join(TMP_DIR, 'system-disc') |
66 | CACHE_DISK = os.path.join(TMP_DIR, 'cache-disc') |
67 | DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc') |
68 | @@ -135,23 +131,22 @@ |
69 | # All good, move on. |
70 | pass |
71 | |
72 | - |
73 | - cmd_runner.run(['mkdir', '-p', ROOT_DIR]).wait() |
74 | + cmd_runner.run(['mkdir', '-p', BOOT_DIR]).wait() |
75 | cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait() |
76 | cmd_runner.run(['mkdir', '-p', DATA_DIR]).wait() |
77 | |
78 | - unpack_android_binary_tarball(args.root, ROOT_DIR) |
79 | + unpack_android_binary_tarball(args.boot, BOOT_DIR) |
80 | unpack_android_binary_tarball(args.system, SYSTEM_DIR) |
81 | unpack_android_binary_tarball(args.userdata, DATA_DIR) |
82 | |
83 | # Create partitions |
84 | - boot_partition, root_partition, system_partition, cache_partition, \ |
85 | + boot_partition, system_partition, cache_partition, \ |
86 | data_partition, sdcard_partition = setup_android_partitions( \ |
87 | - board_config, media, args.boot_label, args.rfs_label, |
88 | - args.rootfs, args.should_create_partitions, args.should_format_bootfs, |
89 | - args.should_format_rootfs, args.should_align_boot_part) |
90 | + board_config, media, args.boot_label, args.should_create_partitions, |
91 | + args.should_align_boot_part) |
92 | |
93 | - populate_partition(ROOT_DIR, ROOT_DISK, root_partition) |
94 | + populate_partition(BOOT_DIR + "/boot", BOOT_DISK, boot_partition) |
95 | + board_config.populate_boot_script(boot_partition, BOOT_DISK, args.consoles) |
96 | populate_partition(SYSTEM_DIR + "/system", SYSTEM_DISK, system_partition) |
97 | populate_partition(DATA_DIR + "/data", DATA_DISK, data_partition) |
98 | print "Done creating Linaro Android image on %s" % args.device |
99 | |
100 | === modified file 'linaro_image_tools/media_create/__init__.py' |
101 | --- linaro_image_tools/media_create/__init__.py 2011-03-31 19:03:31 +0000 |
102 | +++ linaro_image_tools/media_create/__init__.py 2011-04-22 15:11:32 +0000 |
103 | @@ -20,7 +20,7 @@ |
104 | import argparse |
105 | |
106 | from linaro_image_tools.media_create.boards import board_configs |
107 | -from linaro_image_tools.media_create.boards import android_board_configs |
108 | +from linaro_image_tools.media_create.android_boards import android_board_configs |
109 | |
110 | |
111 | KNOWN_BOARDS = board_configs.keys() |
112 | @@ -122,14 +122,12 @@ |
113 | '--dev', required=True, dest='board', choices=ANDROID_KNOWN_BOARDS, |
114 | help='Generate an SD card or image for the given board.') |
115 | parser.add_argument( |
116 | - '--rootfs', default='ext4', choices=['ext3', 'ext4'], |
117 | - help='Type of filesystem to use for the rootfs') |
118 | - parser.add_argument( |
119 | - '--rfs_label', default='rootfs', |
120 | - help='Label to use for the root filesystem.') |
121 | - parser.add_argument( |
122 | '--boot_label', default='boot', |
123 | help='Label to use for the boot filesystem.') |
124 | + parser.add_argument( |
125 | + '--console', action='append', dest='consoles', default=[], |
126 | + help=('Add a console to kernel boot parameter; this parameter can be ' |
127 | + 'defined multiple times.')) |
128 | |
129 | parser.add_argument( |
130 | '--system', default='system.tar.bz2', required=True, |
131 | @@ -138,16 +136,10 @@ |
132 | '--userdata', default='userdata.tar.bz2', required=True, |
133 | help=('The tarball containing the Android data paritition')) |
134 | parser.add_argument( |
135 | - '--root', default='root.tar.bz2', required=True, |
136 | + '--boot', default='boot.tar.bz2', required=True, |
137 | help=('The tarball containing the Android root partition')) |
138 | |
139 | parser.add_argument( |
140 | - '--no-rootfs', dest='should_format_rootfs', action='store_false', |
141 | - help='Do not deploy the root filesystem.') |
142 | - parser.add_argument( |
143 | - '--no-bootfs', dest='should_format_bootfs', action='store_false', |
144 | - help='Do not deploy the boot filesystem.') |
145 | - parser.add_argument( |
146 | '--no-part', dest='should_create_partitions', action='store_false', |
147 | help='Reuse existing partitions on the given media.') |
148 | parser.add_argument( |
149 | |
150 | === added file 'linaro_image_tools/media_create/android_boards.py' |
151 | --- linaro_image_tools/media_create/android_boards.py 1970-01-01 00:00:00 +0000 |
152 | +++ linaro_image_tools/media_create/android_boards.py 2011-04-22 15:11:32 +0000 |
153 | @@ -0,0 +1,158 @@ |
154 | +# Copyright (C) 2011 Linaro |
155 | +# |
156 | +# Author: Jeremy Chang <jeremy.chang@linaro.org> |
157 | +# |
158 | +# This file is part of Linaro Image Tools. |
159 | +# |
160 | +# Linaro Image Tools is free software: you can redistribute it and/or modify |
161 | +# it under the terms of the GNU General Public License as published by |
162 | +# the Free Software Foundation, either version 3 of the License, or |
163 | +# (at your option) any later version. |
164 | +# |
165 | +# Linaro Image Tools is distributed in the hope that it will be useful, |
166 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
167 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
168 | +# GNU General Public License for more details. |
169 | +# |
170 | +# You should have received a copy of the GNU General Public License |
171 | +# along with Linaro Image Tools. If not, see <http://www.gnu.org/licenses/>. |
172 | + |
173 | +"""Configuration for boards supported by linaro-android-media-create. |
174 | + |
175 | +To add support for a new board, you need to create a subclass of |
176 | +AndroidBoardConfig, set appropriate values for its variables and add it to |
177 | +android_board_configs at the bottom of this file. |
178 | +""" |
179 | + |
180 | +from linaro_image_tools.media_create.partitions import SECTOR_SIZE |
181 | +from linaro_image_tools.media_create.boards import PART_ALIGN_S |
182 | +from linaro_image_tools.media_create.boards import BeagleConfig |
183 | +from linaro_image_tools.media_create.boards import PandaConfig |
184 | +from linaro_image_tools.media_create.boards import ( |
185 | + align_up, |
186 | + align_partition, |
187 | + make_boot_script |
188 | + ) |
189 | + |
190 | +from linaro_image_tools import cmd_runner |
191 | +import os |
192 | + |
193 | +class AndroidBoardConfig(object): |
194 | + @classmethod |
195 | + def _get_bootargs(cls, consoles): |
196 | + """Get the bootargs for this board. |
197 | + |
198 | + In general subclasses should not have to override this. |
199 | + """ |
200 | + boot_args_options = 'rootwait ro' |
201 | + if cls.extra_boot_args_options is not None: |
202 | + boot_args_options += ' %s' % cls.extra_boot_args_options |
203 | + boot_args_options += ' %s' % cls.android_specific_args |
204 | + serial_opts = cls._extra_serial_opts |
205 | + for console in consoles: |
206 | + serial_opts += ' console=%s' % console |
207 | + |
208 | + replacements = dict( |
209 | + serial_opts=serial_opts, |
210 | + boot_args_options=boot_args_options) |
211 | + return ( |
212 | + "%(serial_opts)s " |
213 | + "%(boot_args_options)s" |
214 | + % replacements) |
215 | + |
216 | + @classmethod |
217 | + def _get_boot_env(cls, consoles): |
218 | + """Get the boot environment for this board. |
219 | + |
220 | + In general subclasses should not have to override this. |
221 | + """ |
222 | + boot_env = {} |
223 | + boot_env["bootargs"] = cls._get_bootargs(consoles) |
224 | + boot_env["bootcmd"] = cls._get_bootcmd(None) |
225 | + return boot_env |
226 | + |
227 | + @classmethod |
228 | + def populate_boot_script(cls, boot_partition, boot_disk, consoles): |
229 | + cmd_runner.run(['mkdir', '-p', boot_disk]).wait() |
230 | + cmd_runner.run(['mount', boot_partition, boot_disk], |
231 | + as_root=True).wait() |
232 | + |
233 | + boot_env = cls._get_boot_env(consoles) |
234 | + cmdline_filepath = os.path.join(boot_disk, "cmdline") |
235 | + cmdline_file = open(cmdline_filepath, 'r') |
236 | + android_kernel_cmdline = cmdline_file.read() |
237 | + boot_env['bootargs'] = boot_env['bootargs'] + ' ' + \ |
238 | + android_kernel_cmdline |
239 | + cmdline_file.close() |
240 | + |
241 | + boot_dir = boot_disk |
242 | + boot_script_path = os.path.join(boot_dir, cls.boot_script) |
243 | + make_boot_script(boot_env, boot_script_path) |
244 | + |
245 | + cmd_runner.run(['sync']).wait() |
246 | + try: |
247 | + cmd_runner.run(['umount', boot_disk], as_root=True).wait() |
248 | + except cmd_runner.SubcommandNonZeroReturnValue: |
249 | + pass |
250 | + |
251 | + @classmethod |
252 | + def get_sfdisk_cmd(cls, should_align_boot_part=False): |
253 | + if cls.fat_size == 32: |
254 | + partition_type = '0x0C' |
255 | + else: |
256 | + partition_type = '0x0E' |
257 | + |
258 | + BOOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
259 | + SYSTEM_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
260 | + CACHE_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
261 | + USERDATA_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
262 | + SDCARD_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
263 | + |
264 | + # align on sector 63 for compatibility with broken versions of x-loader |
265 | + # unless align_boot_part is set |
266 | + boot_align = 63 |
267 | + if should_align_boot_part: |
268 | + boot_align = PART_ALIGN_S |
269 | + |
270 | + # can only start on sector 1 (sector 0 is MBR / partition table) |
271 | + boot_start, boot_end, boot_len = align_partition( |
272 | + 1, BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S) |
273 | + # apparently OMAP3 ROMs require the vfat length to be an even number |
274 | + # of sectors (multiple of 1 KiB); decrease the length if it's odd, |
275 | + # there should still be enough room |
276 | + boot_len = boot_len - boot_len % 2 |
277 | + boot_end = boot_start + boot_len - 1 |
278 | + |
279 | + system_start, _system_end, _system_len = align_partition( |
280 | + boot_end + 1, SYSTEM_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
281 | + cache_start, _cache_end, _cache_len = align_partition( |
282 | + _system_end + 1, CACHE_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
283 | + userdata_start, _userdata_end, _userdata_len = align_partition( |
284 | + _cache_end + 1, USERDATA_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
285 | + sdcard_start, _sdcard_end, _sdcard_len = align_partition( |
286 | + _userdata_end + 1, SDCARD_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
287 | + |
288 | + return '%s,%s,%s,*\n%s,%s,L\n%s,%s,L\n%s,-,E\n%s,%s,L\n%s,,,-' % ( |
289 | + boot_start, boot_len, partition_type, system_start, _system_len, |
290 | + cache_start, _cache_len, userdata_start, userdata_start, |
291 | + _userdata_len, sdcard_start) |
292 | + |
293 | + |
294 | +class AndroidOmapConfig(AndroidBoardConfig): |
295 | + pass |
296 | + |
297 | + |
298 | +class AndroidBeagleConfig(AndroidOmapConfig, BeagleConfig): |
299 | + _extra_serial_opts = 'console=tty0 console=ttyO2,115200n8' |
300 | + android_specific_args = 'init=/init androidboot.console=ttyO2' |
301 | + |
302 | + |
303 | +class AndroidPandaConfig(AndroidOmapConfig, PandaConfig): |
304 | + _extra_serial_opts = 'console=tty0 console=ttyO2,115200n8' |
305 | + android_specific_args = 'init=/init androidboot.console=ttyO2' |
306 | + |
307 | + |
308 | +android_board_configs = { |
309 | + 'beagle': AndroidBeagleConfig, |
310 | + 'panda': AndroidPandaConfig, |
311 | + } |
312 | |
313 | === modified file 'linaro_image_tools/media_create/boards.py' |
314 | --- linaro_image_tools/media_create/boards.py 2011-04-21 13:12:57 +0000 |
315 | +++ linaro_image_tools/media_create/boards.py 2011-04-22 15:11:32 +0000 |
316 | @@ -193,54 +193,6 @@ |
317 | return '%s,%s,%s,*\n%s,,,-' % ( |
318 | boot_start, boot_len, partition_type, root_start) |
319 | |
320 | - # TODO: Create separate config classes for android and move this method |
321 | - # into them, also renaming it to get_sfdisk_cmd() so that we don't need |
322 | - # the image_type check in partitions.py. |
323 | - @classmethod |
324 | - def get_android_sfdisk_cmd(cls, should_align_boot_part=False): |
325 | - if cls.fat_size == 32: |
326 | - partition_type = '0x0C' |
327 | - else: |
328 | - partition_type = '0x0E' |
329 | - |
330 | - BOOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
331 | - ROOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
332 | - SYSTEM_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
333 | - CACHE_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
334 | - USERDATA_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
335 | - SDCARD_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
336 | - |
337 | - # align on sector 63 for compatibility with broken versions of x-loader |
338 | - # unless align_boot_part is set |
339 | - boot_align = 63 |
340 | - if should_align_boot_part: |
341 | - boot_align = PART_ALIGN_S |
342 | - |
343 | - # can only start on sector 1 (sector 0 is MBR / partition table) |
344 | - boot_start, boot_end, boot_len = align_partition( |
345 | - 1, BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S) |
346 | - # apparently OMAP3 ROMs require the vfat length to be an even number |
347 | - # of sectors (multiple of 1 KiB); decrease the length if it's odd, |
348 | - # there should still be enough room |
349 | - boot_len = boot_len - boot_len % 2 |
350 | - boot_end = boot_start + boot_len - 1 |
351 | - |
352 | - root_start, _root_end, _root_len = align_partition( |
353 | - boot_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
354 | - system_start, _system_end, _system_len = align_partition( |
355 | - _root_end + 1, SYSTEM_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
356 | - cache_start, _cache_end, _cache_len = align_partition( |
357 | - _system_end + 1, CACHE_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
358 | - userdata_start, _userdata_end, _userdata_len = align_partition( |
359 | - _cache_end + 1, USERDATA_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
360 | - sdcard_start, _sdcard_end, _sdcard_len = align_partition( |
361 | - _userdata_end + 1, SDCARD_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
362 | - |
363 | - return '%s,%s,%s,*\n%s,%s,L\n%s,%s,L\n%s,-,E\n%s,%s,L\n%s,%s,L\n%s,,,-' % ( |
364 | - boot_start, boot_len, partition_type, root_start, _root_len, |
365 | - system_start, _system_len, cache_start, cache_start, _cache_len, |
366 | - userdata_start, _userdata_len, sdcard_start) |
367 | - |
368 | @classmethod |
369 | def _get_bootcmd(cls, d_img_data): |
370 | """Get the bootcmd for this board. |
371 | @@ -743,11 +695,6 @@ |
372 | 'smdkv310': SMDKV310Config, |
373 | } |
374 | |
375 | -android_board_configs = { |
376 | - 'beagle': BeagleConfig, |
377 | - 'panda': PandaConfig, |
378 | - } |
379 | - |
380 | |
381 | def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None, |
382 | skip=None): |
383 | |
384 | === modified file 'linaro_image_tools/media_create/partitions.py' |
385 | --- linaro_image_tools/media_create/partitions.py 2011-04-05 11:06:49 +0000 |
386 | +++ linaro_image_tools/media_create/partitions.py 2011-04-22 15:11:32 +0000 |
387 | @@ -42,40 +42,28 @@ |
388 | |
389 | |
390 | def setup_android_partitions(board_config, media, bootfs_label, |
391 | - rootfs_label, rootfs_type, should_create_partitions, |
392 | - should_format_bootfs, should_format_rootfs, |
393 | - should_align_boot_part=False): |
394 | + should_create_partitions, should_align_boot_part=False): |
395 | cylinders = None |
396 | |
397 | if should_create_partitions: |
398 | create_partitions( |
399 | board_config, media, HEADS, SECTORS, cylinders, |
400 | - should_align_boot_part=should_align_boot_part, image_type="ANDROID") |
401 | + should_align_boot_part=should_align_boot_part) |
402 | |
403 | - bootfs, rootfs, system, cache, data, sdcard = \ |
404 | + bootfs, system, cache, data, sdcard = \ |
405 | get_android_partitions_for_media (media, board_config) |
406 | ensure_partition_is_not_mounted(bootfs) |
407 | - ensure_partition_is_not_mounted(rootfs) |
408 | ensure_partition_is_not_mounted(system) |
409 | ensure_partition_is_not_mounted(cache) |
410 | ensure_partition_is_not_mounted(data) |
411 | ensure_partition_is_not_mounted(sdcard) |
412 | |
413 | - if should_format_bootfs: |
414 | - print "\nFormating boot partition\n" |
415 | - proc = cmd_runner.run( |
416 | - ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n', |
417 | - bootfs_label], |
418 | - as_root=True) |
419 | - proc.wait() |
420 | - |
421 | - if should_format_rootfs: |
422 | - print "\nFormating root partition\n" |
423 | - mkfs = 'mkfs.%s' % rootfs_type |
424 | - proc = cmd_runner.run( |
425 | - [mkfs, rootfs, '-L', rootfs_label], |
426 | - as_root=True) |
427 | - proc.wait() |
428 | + print "\nFormating boot partition\n" |
429 | + proc = cmd_runner.run( |
430 | + ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n', |
431 | + bootfs_label], |
432 | + as_root=True) |
433 | + proc.wait() |
434 | |
435 | ext4_partitions = {"system": system, "cache": cache, "userdata": data} |
436 | for label, dev in ext4_partitions.iteritems(): |
437 | @@ -91,7 +79,7 @@ |
438 | as_root=True) |
439 | proc.wait() |
440 | |
441 | - return bootfs, rootfs, system, cache, data, sdcard |
442 | + return bootfs, system, cache, data, sdcard |
443 | |
444 | # I wonder if it'd make sense to convert this into a small shim which calls |
445 | # the appropriate function for the given type of device? I think it's still |
446 | @@ -277,22 +265,20 @@ |
447 | |
448 | boot_partition = _get_device_file_for_partition_number( |
449 | media.path, 1 + board_config.mmc_part_offset) |
450 | - root_partition = _get_device_file_for_partition_number( |
451 | - media.path, 2 + board_config.mmc_part_offset) |
452 | system_partition = _get_device_file_for_partition_number( |
453 | + media.path, 2 + board_config.mmc_part_offset) |
454 | + cache_partition = _get_device_file_for_partition_number( |
455 | media.path, 3 + board_config.mmc_part_offset) |
456 | - cache_partition = _get_device_file_for_partition_number( |
457 | + data_partition = _get_device_file_for_partition_number( |
458 | media.path, 5 + board_config.mmc_part_offset) |
459 | - data_partition = _get_device_file_for_partition_number( |
460 | + sdcard_partition = _get_device_file_for_partition_number( |
461 | media.path, 6 + board_config.mmc_part_offset) |
462 | - sdcard_partition = _get_device_file_for_partition_number( |
463 | - media.path, 7 + board_config.mmc_part_offset) |
464 | - |
465 | - assert boot_partition is not None and root_partition is not None, ( |
466 | - "Could not find boot/root partition for %s" % media.path) |
467 | - |
468 | - return boot_partition, root_partition, system_partition, \ |
469 | - cache_partition, data_partition, sdcard_partition |
470 | + |
471 | + assert boot_partition is not None, ( |
472 | + "Could not find boot partition for %s" % media.path) |
473 | + |
474 | + return boot_partition, system_partition, cache_partition, \ |
475 | + data_partition, sdcard_partition |
476 | |
477 | def get_boot_and_root_partitions_for_media(media, board_config): |
478 | """Return the device files for the boot and root partitions of media. |
479 | @@ -388,7 +374,7 @@ |
480 | |
481 | |
482 | def create_partitions(board_config, media, heads, sectors, cylinders=None, |
483 | - should_align_boot_part=False, image_type=None): |
484 | + should_align_boot_part=False): |
485 | """Partition the given media according to the board requirements. |
486 | |
487 | :param board_config: A BoardConfig class. |
488 | @@ -407,14 +393,8 @@ |
489 | ['parted', '-s', media.path, 'mklabel', 'msdos'], as_root=True) |
490 | proc.wait() |
491 | |
492 | - # XXX: We should get rid of this by using separate config classes for |
493 | - # android -- see comment in get_android_sfdisk_cmd() for more details. |
494 | - if image_type == "ANDROID": |
495 | - sfdisk_cmd = board_config.get_android_sfdisk_cmd( |
496 | - should_align_boot_part=should_align_boot_part) |
497 | - else: |
498 | - sfdisk_cmd = board_config.get_sfdisk_cmd( |
499 | - should_align_boot_part=should_align_boot_part) |
500 | + sfdisk_cmd = board_config.get_sfdisk_cmd( |
501 | + should_align_boot_part=should_align_boot_part) |
502 | |
503 | run_sfdisk_commands(sfdisk_cmd, heads, sectors, cylinders, media.path) |
504 |
Hi,
Thanks for the changes.
I'd like to try and reduce some duplication between
boards.py and android_boards.py. In particular the
align_up etc. functions could be shared.
Also, it seems like more could be shared between the
two bootscript etc. implementations.
Thanks,
James