=== modified file 'linaro-media-create'
@@ -47,6 +47,7 @@
ensure_command,
is_arm_host,
check_file_integrity_and_log_errors,
+ path_in_tarfile_exists,
)
# Just define the global variables
@@ -106,8 +107,12 @@
# If --help was specified this won't execute.
# Create temp dir and initialize rest of path vars.
+ filesystem_dir = 'binary'
+ if not path_in_tarfile_exists('binary/etc', args.binary):
+ # The binary image is in the new live format.
+ filesystem_dir = 'binary/boot/filesystem.dir'
TMP_DIR = tempfile.mkdtemp()
- ROOTFS_DIR = os.path.join(TMP_DIR, 'binary')
+ ROOTFS_DIR = os.path.join(TMP_DIR, filesystem_dir)
BOOT_DISK = os.path.join(TMP_DIR, 'boot-disc')
ROOT_DISK = os.path.join(TMP_DIR, 'root-disc')
=== modified file 'linaro_image_tools/tests/test_pyflakes.py'
@@ -29,8 +29,8 @@
(stdout, stderr) = proc.communicate()
stdout = stdout.splitlines()
stdout.sort()
- expected = ["./linaro_image_tools/utils.py:30: redefinition of "
- "unused 'CommandNotFound' from line 28" ]
+ expected = ["./linaro_image_tools/utils.py:31: redefinition of "
+ "unused 'CommandNotFound' from line 29" ]
self.assertEquals(expected, stdout)
self.assertEquals('', stderr)
=== modified file 'linaro_image_tools/tests/test_utils.py'
@@ -23,6 +23,7 @@
import sys
import logging
import tempfile
+import tarfile
from linaro_image_tools import cmd_runner, utils
from linaro_image_tools.testing import TestCaseWithFixtures
@@ -39,12 +40,32 @@
UnableToFindPackageProvidingCommand,
verify_file_integrity,
check_file_integrity_and_log_errors,
+ path_in_tarfile_exists,
)
sudo_args = " ".join(cmd_runner.SUDO_ARGS)
+class TestPathInTarfile(TestCaseWithFixtures):
+ def setUp(self):
+ super(TestPathInTarfile, self).setUp()
+ tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
+ self.tarfile_name = os.path.join(tempdir, 'test_tarfile.tar.gz')
+ self.tempfile_added = self.createTempFileAsFixture()
+ self.tempfile_unused = self.createTempFileAsFixture()
+ with tarfile.open(self.tarfile_name, 'w:gz') as tar:
+ tar.add(self.tempfile_added)
+
+ def test_file_exists(self):
+ self.assertTrue(path_in_tarfile_exists(self.tempfile_added[1:],
+ self.tarfile_name))
+
+ def test_file_does_not_exist(self):
+ self.assertFalse(path_in_tarfile_exists(self.tempfile_unused[1:],
+ self.tarfile_name))
+
+
class TestVerifyFileIntegrity(TestCaseWithFixtures):
filenames_in_shafile = ['verified-file1', 'verified-file2']
=== modified file 'linaro_image_tools/utils.py'
@@ -23,6 +23,7 @@
import re
import logging
import tempfile
+import tarfile
try:
from CommandNotFound import CommandNotFound
@@ -32,6 +33,15 @@
from linaro_image_tools import cmd_runner
+def path_in_tarfile_exists(path, tar_file):
+ tarinfo = tarfile.open(tar_file, 'r:gz')
+ try:
+ tarinfo.getmember(path)
+ return True
+ except KeyError:
+ return False
+ tarinfo.close()
+
def verify_file_integrity(sig_file_list):
"""Verify a list of signature files.