Merge lp:~salgado/linaro-image-tools/bug-701678 into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: 264
Proposed branch: lp:~salgado/linaro-image-tools/bug-701678
Merge into: lp:linaro-image-tools/11.11
Diff against target: 72 lines (+16/-9)
2 files modified
linaro_media_create/partitions.py (+6/-6)
linaro_media_create/tests/test_media_create.py (+10/-3)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/bug-701678
Reviewer Review Type Date Requested Status
Loïc Minier (community) Approve
James Westby (community) Approve
Review via email: mp+47688@code.launchpad.net

Description of the change

Only ensure a partition is not mounted before running mkfs when we're burning an SD card.

That check is not necessary when we're writing an image file because there's nothing that would automount a loopback device that has just been setup.

Oh, and this will also get rid of the last remaining place using UDisks when creating an image file, hence fixing bug 705571.

To post a comment you must log in.
265. By Guilherme Salgado

Add a test to make sure ensure_partition_is_not_mounted is not called when generating image files

Revision history for this message
James Westby (james-w) wrote :

I like this one too. The error message will be very useful if someone
ever trips this, thanks.

James

review: Approve
Revision history for this message
Loïc Minier (lool) wrote :

(Sorry for reviewing this earlier; I got confused by the diff; now that I see it in context I understand the change)

This seems all fine; great to kill two bugs with this

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro_media_create/partitions.py'
2--- linaro_media_create/partitions.py 2011-01-26 18:03:50 +0000
3+++ linaro_media_create/partitions.py 2011-01-27 17:22:24 +0000
4@@ -54,15 +54,16 @@
5 if media.is_block_device:
6 bootfs, rootfs = get_boot_and_root_partitions_for_media(
7 media, board_config)
8- else:
9- bootfs, rootfs = get_boot_and_root_loopback_devices(media.path)
10-
11- if should_format_bootfs:
12- print "\nFormating boot partition\n"
13 # It looks like KDE somehow automounts the partitions after you
14 # repartition a disk so we need to unmount them here to create the
15 # filesystem.
16 ensure_partition_is_not_mounted(bootfs)
17+ ensure_partition_is_not_mounted(rootfs)
18+ else:
19+ bootfs, rootfs = get_boot_and_root_loopback_devices(media.path)
20+
21+ if should_format_bootfs:
22+ print "\nFormating boot partition\n"
23 proc = cmd_runner.run(
24 ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n',
25 bootfs_label],
26@@ -72,7 +73,6 @@
27 if should_format_rootfs:
28 print "\nFormating root partition\n"
29 mkfs = 'mkfs.%s' % rootfs_type
30- ensure_partition_is_not_mounted(rootfs)
31 proc = cmd_runner.run(
32 [mkfs, rootfs, '-L', rootfs_label],
33 as_root=True)
34
35=== modified file 'linaro_media_create/tests/test_media_create.py'
36--- linaro_media_create/tests/test_media_create.py 2011-01-26 18:03:50 +0000
37+++ linaro_media_create/tests/test_media_create.py 2011-01-27 17:22:24 +0000
38@@ -161,7 +161,7 @@
39 self.mock_all_boards_funcs()
40
41 def mock_all_boards_funcs(self):
42- """Mock all functions of linaro_media_create.boards with a call tracer."""
43+ """Mock functions of linaro_media_create.boards with a call tracer."""
44
45 def mock_func_creator(name):
46 return lambda *args, **kwargs: self.funcs_calls.append(name)
47@@ -680,8 +680,15 @@
48 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
49 self.useFixture(MockSomethingFixture(
50 sys, 'stdout', open('/dev/null', 'w')))
51+ def ensure_partition_not_mounted(part):
52+ raise AssertionError(
53+ "ensure_partition_is_not_mounted must not be called when "
54+ "generating image files. It makes no sense to do that and "
55+ "it depends on UDisks, thus making it hard to run on a "
56+ "chroot")
57 self.useFixture(MockSomethingFixture(
58- partitions, 'is_partition_mounted', lambda part: False))
59+ partitions,
60+ 'ensure_partition_is_not_mounted', ensure_partition_not_mounted))
61 self.useFixture(MockSomethingFixture(
62 partitions, 'get_boot_and_root_loopback_devices',
63 lambda image: ('/dev/loop99', '/dev/loop98')))
64@@ -724,8 +731,8 @@
65 # Since the partitions are mounted, setup_partitions will umount
66 # them before running mkfs.
67 ['sudo', 'umount', bootfs_dev],
68- ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],
69 ['sudo', 'umount', rootfs_dev],
70+ ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],
71 ['sudo', 'mkfs.ext3', rootfs_dev, '-L', 'root']],
72 popen_fixture.mock.calls)
73

Subscribers

People subscribed via source and target branches