aboutsummaryrefslogtreecommitdiff
path: root/linaro_image_tools/media_create
diff options
context:
space:
mode:
authorFathi Boudra <fathi.boudra@linaro.org>2013-12-13 11:03:04 +0200
committerFathi Boudra <fathi.boudra@linaro.org>2013-12-13 11:03:04 +0200
commitafe452a29514ae32503630095341172403256bd6 (patch)
treeab4a2a60d52b4174f323213fc21a3fc0f5fa9344 /linaro_image_tools/media_create
parent0609c3eac862930ce1e45adf008ecee4677f47a2 (diff)
downloadlinaro-image-tools-afe452a29514ae32503630095341172403256bd6.tar.gz
Refactor the code to detect rootfs distribution
Change-Id: Ib158ae468f3010cb49eef3b1453d20c5115bbca4 Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
Diffstat (limited to 'linaro_image_tools/media_create')
-rw-r--r--linaro_image_tools/media_create/rootfs.py19
-rw-r--r--linaro_image_tools/media_create/tests/test_media_create.py3
-rw-r--r--linaro_image_tools/media_create/unpack_binary_tarball.py5
3 files changed, 17 insertions, 10 deletions
diff --git a/linaro_image_tools/media_create/rootfs.py b/linaro_image_tools/media_create/rootfs.py
index 73bc8eb..765cc99 100644
--- a/linaro_image_tools/media_create/rootfs.py
+++ b/linaro_image_tools/media_create/rootfs.py
@@ -43,7 +43,8 @@ def rootfs_mount_options(rootfs_type):
def populate_rootfs(content_dir, root_disk, partition, rootfs_type,
rootfs_id, should_create_swap, swap_size,
- mmc_device_id, partition_offset, board_config=None):
+ mmc_device_id, partition_offset, os_release_id,
+ board_config=None):
"""Populate the rootfs and make the necessary tweaks to make it usable.
This consists of:
@@ -86,13 +87,14 @@ def populate_rootfs(content_dir, root_disk, partition, rootfs_type,
append_to_fstab(root_disk, fstab_additions)
- print "\nCreating /etc/flash-kernel.conf\n"
- create_flash_kernel_config(
- root_disk, mmc_device_id, 1 + partition_offset)
+ if os_release_id == 'debian' or os_release_id == 'ubuntu':
+ print "\nCreating /etc/flash-kernel.conf\n"
+ create_flash_kernel_config(
+ root_disk, mmc_device_id, 1 + partition_offset)
- if board_config is not None:
- print "\nUpdating /etc/network/interfaces\n"
- update_network_interfaces(root_disk, board_config)
+ if board_config is not None:
+ print "\nUpdating /etc/network/interfaces\n"
+ update_network_interfaces(root_disk, board_config)
def update_network_interfaces(root_disk, board_config):
@@ -136,7 +138,8 @@ def _list_files(directory):
not be world-readable.
"""
p = cmd_runner.run(
- ['find', directory, '-maxdepth', '1', '-mindepth', '1'],
+ ['find', directory, '-maxdepth', '1', '-mindepth', '1',
+ '!', '-name', 'lost+found'],
stdout=subprocess.PIPE, as_root=True)
stdout, _ = p.communicate()
return stdout.split()
diff --git a/linaro_image_tools/media_create/tests/test_media_create.py b/linaro_image_tools/media_create/tests/test_media_create.py
index 83681e1..a83a993 100644
--- a/linaro_image_tools/media_create/tests/test_media_create.py
+++ b/linaro_image_tools/media_create/tests/test_media_create.py
@@ -3673,7 +3673,8 @@ class TestPopulateRootFS(TestCaseWithFixtures):
populate_rootfs(
contents_dir, root_disk, partition='/dev/rootfs',
rootfs_type='ext3', rootfs_id='UUID=uuid', should_create_swap=True,
- swap_size=100, mmc_device_id=0, partition_offset=0)
+ swap_size=100, mmc_device_id=0, partition_offset=0,
+ os_release_id='ubuntu', board_config=None)
self.assertEqual(
['UUID=uuid / ext3 errors=remount-ro 0 1',
diff --git a/linaro_image_tools/media_create/unpack_binary_tarball.py b/linaro_image_tools/media_create/unpack_binary_tarball.py
index ba00261..8dcdef8 100644
--- a/linaro_image_tools/media_create/unpack_binary_tarball.py
+++ b/linaro_image_tools/media_create/unpack_binary_tarball.py
@@ -29,8 +29,11 @@ def unpack_android_binary_tarball(tarball, unpack_dir, as_root=True):
def unpack_binary_tarball(tarball, unpack_dir, as_root=True):
+ extract_opt = '-xf'
+ if tarball.endswith('.xz'):
+ extract_opt = '-Jxf'
proc = cmd_runner.run(
- ['tar', '--numeric-owner', '-C', unpack_dir, '-xf', tarball],
+ ['tar', '--numeric-owner', '-C', unpack_dir, extract_opt, tarball],
as_root=as_root)
proc.wait()
return proc.returncode