From patchwork Wed Jan 30 12:11:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milo Casagrande X-Patchwork-Id: 14360 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 B59AA23F96 for ; Wed, 30 Jan 2013 12:11:16 +0000 (UTC) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by fiordland.canonical.com (Postfix) with ESMTP id 695EAA1924C for ; Wed, 30 Jan 2013 12:11:16 +0000 (UTC) Received: by mail-la0-f49.google.com with SMTP id fs13so1047383lab.36 for ; Wed, 30 Jan 2013 04:11:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:content-type:mime-version:x-launchpad-project :x-launchpad-branch:x-launchpad-message-rationale :x-launchpad-branch-revision-number:x-launchpad-notification-type:to :from:subject:message-id:date:reply-to:sender:errors-to:precedence :x-generated-by:x-launchpad-hash:x-gm-message-state; bh=PfBU0XfrL4RBkLmkx0Ws2Q5ojrs46fdN230orZCCHkE=; b=LJtPPtEKehQmBlptRUOgP5CEu6adL3uLJIYJQNdMUw9IA//UMkVbysiruZq/SkFCeq GYqDKORkpCMsGnRTWs/HCw8SmbpAdncDBVQPs/4Vo1JwlZggB1uky4BV66ZO6dbrA+6b LI9BfUFWD5HjDTIZAtm3SrP96+z00tfPJi8yh9msb3HcGhUovYZnsZkXFXpAZJ9YwBwx F9Ogp/DrR8H+k8sZDkjbO1JMVxDB7hzs6zhMN0P8iX6n0FM514dvUeo66jSylxJ6fOx8 M79eGeCftKzbFJY4FweFAPzMAux2DiVb0mEgObk71Nu4JxMSdUZKk4likzP+4aBXeSwL Bw/w== X-Received: by 10.152.144.130 with SMTP id sm2mr4314134lab.49.1359547875899; Wed, 30 Jan 2013 04:11:15 -0800 (PST) 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.112.27.168 with SMTP id u8csp203772lbg; Wed, 30 Jan 2013 04:11:15 -0800 (PST) X-Received: by 10.194.179.34 with SMTP id dd2mr8565526wjc.1.1359547874904; Wed, 30 Jan 2013 04:11:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id g12si380328wjn.193.2013.01.30.04.11.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 30 Jan 2013 04:11:14 -0800 (PST) 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 1U0WVV-000498-6c for ; Wed, 30 Jan 2013 12:11:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 1728CE0597 for ; Wed, 30 Jan 2013 12:11:13 +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: 603 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 603: Added support for Android hwpack in boot tarball, added tests. Message-Id: <20130130121113.18980.63595.launchpad@ackee.canonical.com> Date: Wed, 30 Jan 2013 12:11:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16455"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 3c40ef8fb841ffdaed9abcaaeefb93e41aeb9365 X-Gm-Message-State: ALoCoQkvRORfPYMl2GIdkVi/Rmff/iBujV3G8BMcFtZpOq9P5KbNmIhSzPas5AyibxKyyx/KGpPX Merge authors: Milo Casagrande (milo) vishal (vishalbhoj) Related merge proposals: https://code.launchpad.net/~milo/linaro-image-tools/hwpack-from-tarball/+merge/145583 proposed by: Milo Casagrande (milo) review: Approve - Georgy Redkozubov (gesha) https://code.launchpad.net/~vishalbhoj/linaro-image-tools/hwpack-from-boottarball/+merge/144305 proposed by: vishal (vishalbhoj) review: Needs Fixing - Milo Casagrande (milo) ------------------------------------------------------------ revno: 603 [merge] committer: Milo Casagrande branch nick: trunk timestamp: Wed 2013-01-30 13:10:59 +0100 message: Added support for Android hwpack in boot tarball, added tests. modified: linaro-android-media-create 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-android-media-create' --- linaro-android-media-create 2012-12-28 13:09:56 +0000 +++ linaro-android-media-create 2013-01-30 11:28:51 +0000 @@ -42,6 +42,7 @@ from linaro_image_tools.media_create import get_android_args_parser from linaro_image_tools.utils import ( additional_android_option_checks, + andorid_hwpack_in_boot_tarball, ensure_command, get_logger ) @@ -109,15 +110,6 @@ DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc') SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc') - board_config = get_board_config(args.dev) - if args.hwpack: - board_config.from_file(args.hwpack) - else: - logger.warning("No Android hwpack provided: default board values " - "will be used.") - board_config.add_boot_args(args.extra_boot_args) - board_config.add_boot_args_from_file(args.extra_boot_args_file) - if args.dev == 'iMX53': # XXX: remove this and the corresponding entry in android_board_configs logger.warning("DEPRECATION WARNING: iMX53 is deprecated, please " @@ -141,6 +133,23 @@ unpack_android_binary_tarball(args.system, SYSTEM_DIR) unpack_android_binary_tarball(args.userdata, DATA_DIR) + board_config = get_board_config(args.dev) + + hwpack_exists, config_file = andorid_hwpack_in_boot_tarball(BOOT_DIR) + if not args.hwpack and not hwpack_exists: + # No hwpack in the boot tarball nor provided on the command line. + logger.warning("No hwpack found in the boot tarball nor passed on " + "the command line. Default values will be used.") + elif not args.hwpack and hwpack_exists: + board_config.from_file(config_file) + elif args.hwpack: + logger.warning("Values from the hwpack provided on the command line " + "will be used.") + board_config.from_file(args.hwpack) + + board_config.add_boot_args(args.extra_boot_args) + board_config.add_boot_args_from_file(args.extra_boot_args_file) + # Create partitions boot_partition, system_partition, cache_partition, \ data_partition, sdcard_partition = setup_android_partitions( \ === modified file 'linaro_image_tools/tests/test_utils.py' --- linaro_image_tools/tests/test_utils.py 2012-06-13 14:55:34 +0000 +++ linaro_image_tools/tests/test_utils.py 2013-01-30 11:28:51 +0000 @@ -37,7 +37,9 @@ IncompatibleOptions, InvalidHwpackFile, UnableToFindPackageProvidingCommand, + additional_android_option_checks, additional_option_checks, + andorid_hwpack_in_boot_tarball, check_file_integrity_and_log_errors, ensure_command, find_command, @@ -335,6 +337,49 @@ sys.argv.remove("--mmc") +class TestAndroidOptionChecks(TestCaseWithFixtures): + + def test_hwpack_is_file(self): + class HwPacksArgs: + def __init__(self, hwpack): + self.hwpack = hwpack + + try: + tmpdir = tempfile.mkdtemp() + self.assertRaises(InvalidHwpackFile, + additional_android_option_checks, + HwPacksArgs(tmpdir)) + finally: + os.rmdir(tmpdir) + + def test_android_hwpack_in_boot(self): + """Test presence of config file in boot directory.""" + try: + tmpdir = tempfile.mkdtemp() + boot_dir = os.path.join(tmpdir, "boot") + os.mkdir(boot_dir) + config_file = os.path.join(boot_dir, "config") + expected = (True, config_file) + with open(config_file, "w"): + self.assertEqual(expected, + andorid_hwpack_in_boot_tarball(tmpdir)) + finally: + os.unlink(config_file) + os.removedirs(boot_dir) + + def test_android_hwpack_not_in_boot(self): + """Test missing config file.""" + try: + tmpdir = tempfile.mkdtemp() + boot_dir = os.path.join(tmpdir, "boot") + os.mkdir(boot_dir) + config_file = os.path.join(boot_dir, "config") + expected = (False, config_file) + self.assertEqual(expected, andorid_hwpack_in_boot_tarball(tmpdir)) + finally: + os.removedirs(boot_dir) + + class TestHwpackIsFile(TestCaseWithFixtures): """Testing '--hwpack' option only allows regular files.""" === modified file 'linaro_image_tools/utils.py' --- linaro_image_tools/utils.py 2012-12-05 14:54:29 +0000 +++ linaro_image_tools/utils.py 2013-01-30 11:28:51 +0000 @@ -30,6 +30,11 @@ DEFAULT_LOGGER_NAME = 'linaro_image_tools' +# The boot path in the boot tarball. +BOOT_DIR_IN_TARBALL = "boot" +# The name of the hwpack file found in the boot tarball. +HWPACK_NAME = "config" + # try_import was copied from python-testtools 0.9.12 and was originally # licensed under a MIT-style license but relicensed under the GPL in Linaro @@ -354,6 +359,19 @@ "--hwpack argument (%s) is not a regular file" % args.hwpack) +def andorid_hwpack_in_boot_tarball(boot_dir): + """Simple check for existence of a path. + + Needed to make cli command testable in some way. + :param boot_dir: The path where the boot tarball has been extracted. + :type str + :return A tuple with a bool if the path exists, and the path to the config + file. + """ + conf_file = os.path.join(boot_dir, BOOT_DIR_IN_TARBALL, HWPACK_NAME) + return os.path.exists(conf_file), conf_file + + def check_required_args(args): """Check that the required args are passed.""" if args.dev is None: