=== modified file 'linaro_media_create/partitions.py'
@@ -54,15 +54,16 @@
if media.is_block_device:
bootfs, rootfs = get_boot_and_root_partitions_for_media(
media, board_config)
- else:
- bootfs, rootfs = get_boot_and_root_loopback_devices(media.path)
-
- if should_format_bootfs:
- print "\nFormating boot partition\n"
# It looks like KDE somehow automounts the partitions after you
# repartition a disk so we need to unmount them here to create the
# filesystem.
ensure_partition_is_not_mounted(bootfs)
+ ensure_partition_is_not_mounted(rootfs)
+ else:
+ bootfs, rootfs = get_boot_and_root_loopback_devices(media.path)
+
+ if should_format_bootfs:
+ print "\nFormating boot partition\n"
proc = cmd_runner.run(
['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n',
bootfs_label],
@@ -72,7 +73,6 @@
if should_format_rootfs:
print "\nFormating root partition\n"
mkfs = 'mkfs.%s' % rootfs_type
- ensure_partition_is_not_mounted(rootfs)
proc = cmd_runner.run(
[mkfs, rootfs, '-L', rootfs_label],
as_root=True)
=== modified file 'linaro_media_create/tests/test_media_create.py'
@@ -161,7 +161,7 @@
self.mock_all_boards_funcs()
def mock_all_boards_funcs(self):
- """Mock all functions of linaro_media_create.boards with a call tracer."""
+ """Mock functions of linaro_media_create.boards with a call tracer."""
def mock_func_creator(name):
return lambda *args, **kwargs: self.funcs_calls.append(name)
@@ -680,8 +680,15 @@
popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
self.useFixture(MockSomethingFixture(
sys, 'stdout', open('/dev/null', 'w')))
+ def ensure_partition_not_mounted(part):
+ raise AssertionError(
+ "ensure_partition_is_not_mounted must not be called when "
+ "generating image files. It makes no sense to do that and "
+ "it depends on UDisks, thus making it hard to run on a "
+ "chroot")
self.useFixture(MockSomethingFixture(
- partitions, 'is_partition_mounted', lambda part: False))
+ partitions,
+ 'ensure_partition_is_not_mounted', ensure_partition_not_mounted))
self.useFixture(MockSomethingFixture(
partitions, 'get_boot_and_root_loopback_devices',
lambda image: ('/dev/loop99', '/dev/loop98')))
@@ -724,8 +731,8 @@
# Since the partitions are mounted, setup_partitions will umount
# them before running mkfs.
['sudo', 'umount', bootfs_dev],
- ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],
['sudo', 'umount', rootfs_dev],
+ ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],
['sudo', 'mkfs.ext3', rootfs_dev, '-L', 'root']],
popen_fixture.mock.calls)