From patchwork Tue Aug 23 10:53:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mattias Backman X-Patchwork-Id: 3619 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 8834723F27 for ; Tue, 23 Aug 2011 10:58:17 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 68066A186EF for ; Tue, 23 Aug 2011 10:58:17 +0000 (UTC) Received: by bkbzs2 with SMTP id zs2so6820638bkb.11 for ; Tue, 23 Aug 2011 03:58:17 -0700 (PDT) Received: by 10.204.146.140 with SMTP id h12mr1402726bkv.226.1314097096944; Tue, 23 Aug 2011 03:58: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.204.41.75 with SMTP id n11cs206653bke; Tue, 23 Aug 2011 03:58:16 -0700 (PDT) Received: by 10.227.19.132 with SMTP id a4mr146944wbb.46.1314097096432; Tue, 23 Aug 2011 03:58:16 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id b20si123029wbh.92.2011.08.23.03.58.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Aug 2011 03:58:16 -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 1QvogR-0002Pd-G3 for ; Tue, 23 Aug 2011 10:58:15 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 971AAE1698 for ; Tue, 23 Aug 2011 10:53: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: 422 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 422: Allow Snowball startfiles.cfg to specify full path to each individual startfile. If an absolute p... Message-Id: <20110823105313.7654.75265.launchpad@ackee.canonical.com> Date: Tue, 23 Aug 2011 10:53: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="13714"; Instance="initZopeless config overlay" X-Launchpad-Hash: 58881d8a08c9c452ab4c572a8cb96f7f6710885f Merge authors: Mattias Backman (mabac) Related merge proposals: https://code.launchpad.net/~mabac/linaro-image-tools/bug-829220/+merge/72405 proposed by: Mattias Backman (mabac) review: Approve - Loïc Minier (lool) ------------------------------------------------------------ revno: 422 [merge] committer: Mattias Backman branch nick: linaro-image-tools timestamp: Tue 2011-08-23 12:48:46 +0200 message: Allow Snowball startfiles.cfg to specify full path to each individual startfile. If an absolute path is not specified, the files are assumed to be in /boot of the chroot. modified: linaro_image_tools/media_create/boards.py linaro_image_tools/media_create/tests/test_media_create.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_image_tools/media_create/boards.py' --- linaro_image_tools/media_create/boards.py 2011-08-19 13:59:34 +0000 +++ linaro_image_tools/media_create/boards.py 2011-08-23 08:34:24 +0000 @@ -759,7 +759,7 @@ # Populate created raw partition with TOC and startup files. config_files_path = os.path.join(chroot_dir, 'boot') _, toc_filename = tempfile.mkstemp() - new_files = cls.get_file_info(config_files_path) + new_files = cls.get_file_info(chroot_dir) with open(toc_filename, 'wb') as toc: cls.create_toc(toc, new_files) cls.install_snowball_boot_loader(toc_filename, new_files, @@ -820,19 +820,26 @@ f.write(data) @classmethod - def get_file_info(cls, bin_dir): + def get_file_info(cls, chroot_dir): ''' Fills in the offsets of files that are located in non-absolute memory locations depending on their sizes.' Also fills in file sizes''' ofs = cls.TOC_SIZE files = [] + bin_dir = os.path.join(chroot_dir, 'boot') with open(os.path.join(bin_dir, cls.SNOWBALL_STARTUP_FILES_CONFIG), 'r') as info_file: for line in info_file: file_data = line.split() if file_data[0][0] == '#': continue - filename = os.path.join(bin_dir, file_data[1]) + if file_data[1].startswith('/'): + filename = os.path.join(chroot_dir, + file_data[1].lstrip('/')) + else: + filename = os.path.join(bin_dir, file_data[1]) + assert os.path.exists(filename), "File %s does not exist, " \ + "please check the startfiles config file." % file_data[1] address = long(file_data[3], 16) if address != 0: ofs = address === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2011-08-10 22:42:02 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2011-08-23 08:34:24 +0000 @@ -716,6 +716,45 @@ i += 1 return expected + def test_get_file_info_relative_path(self): + # Create a config file + cfg_file = os.path.join(self.temp_bootdir_path, + boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG) + uboot_file = 'u-boot.bin' + with open(cfg_file, 'w') as f: + f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0, + 0xBA0000, '9')) + with open(os.path.join(self.temp_bootdir_path, uboot_file), 'w') as f: + file_info = boards.SnowballEmmcConfig.get_file_info( + self.tempdir) + self.assertEquals(file_info[0]['filename'], + os.path.join(self.temp_bootdir_path, uboot_file)) + + def test_get_file_info_abs_path(self): + # Create a config file + cfg_file = os.path.join(self.temp_bootdir_path, + boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG) + uboot_dir = tempfile.mkdtemp(dir=self.tempdir) + uboot_file = os.path.join(uboot_dir, 'u-boot.bin') + uboot_relative_file = uboot_file.replace(self.tempdir, '') + with open(cfg_file, 'w') as f: + f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_relative_file, 0, + 0xBA0000, '9')) + with open(uboot_file, 'w') as f: + file_info = boards.SnowballEmmcConfig.get_file_info( + self.tempdir) + self.assertEquals(file_info[0]['filename'], uboot_file) + + def test_get_file_info_raises(self): + # Create a config file + cfg_file = os.path.join(self.temp_bootdir_path, + boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG) + with open(cfg_file, 'w') as f: + f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0, + 0xBA0000, '9')) + self.assertRaises(AssertionError, boards.SnowballEmmcConfig.get_file_info, + self.tempdir) + def test_file_name_size(self): ''' Test using a to large toc file ''' _, toc_filename = tempfile.mkstemp() @@ -829,7 +868,7 @@ def test_normal_case(self): expected = self.setupFiles() actual = boards.SnowballEmmcConfig.get_file_info( - self.temp_bootdir_path) + self.tempdir) self.assertEquals(expected, actual)