From patchwork Thu Oct 13 19:46:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Westby X-Patchwork-Id: 4666 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3B77023DEC for ; Thu, 13 Oct 2011 19:46:17 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id E0B47A186AB for ; Thu, 13 Oct 2011 19:46:16 +0000 (UTC) Received: by ywm14 with SMTP id 14so136014ywm.11 for ; Thu, 13 Oct 2011 12:46:16 -0700 (PDT) Received: by 10.223.77.71 with SMTP id f7mr7994826fak.33.1318535176070; Thu, 13 Oct 2011 12:46:16 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.24.41 with SMTP id r9cs273203laf; Thu, 13 Oct 2011 12:46:15 -0700 (PDT) Received: by 10.216.164.74 with SMTP id b52mr358688wel.94.1318535174899; Thu, 13 Oct 2011 12:46:14 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id c19si978120wed.61.2011.10.13.12.46.14 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Oct 2011 12:46:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1REREM-0007Cz-3V for ; Thu, 13 Oct 2011 19:46:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 11065E019F for ; Thu, 13 Oct 2011 19:46:14 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 447 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 447: Support the new path for the rootfs dir within the tarball. Message-Id: <20111013194614.27068.99717.launchpad@ackee.canonical.com> Date: Thu, 13 Oct 2011 19:46:14 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14124"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: ca60cde7ead8e99b69c8c45c3e94905577fd59ba Merge authors: Mattias Backman (mabac) Related merge proposals: https://code.launchpad.net/~mabac/linaro-image-tools/bug-872007-rootfsdir/+merge/79092 proposed by: Mattias Backman (mabac) review: Approve - James Westby (james-w) ------------------------------------------------------------ revno: 447 [merge] committer: James Westby branch nick: trunk timestamp: Thu 2011-10-13 15:43:59 -0400 message: Support the new path for the rootfs dir within the tarball. live-build has changed the path that it puts the rootfs at within the tarball, so we have to support both the old and new locations. modified: linaro-media-create linaro_image_tools/tests/test_pyflakes.py linaro_image_tools/tests/test_utils.py linaro_image_tools/utils.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro-media-create' --- linaro-media-create 2011-09-22 20:11:46 +0000 +++ linaro-media-create 2011-10-12 09:54:29 +0000 @@ -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' --- linaro_image_tools/tests/test_pyflakes.py 2011-08-18 16:00:26 +0000 +++ linaro_image_tools/tests/test_pyflakes.py 2011-10-12 09:54:29 +0000 @@ -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' --- linaro_image_tools/tests/test_utils.py 2011-08-18 16:00:26 +0000 +++ linaro_image_tools/tests/test_utils.py 2011-10-12 09:54:29 +0000 @@ -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' --- linaro_image_tools/utils.py 2011-08-15 16:57:07 +0000 +++ linaro_image_tools/utils.py 2011-10-13 14:49:05 +0000 @@ -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.