From patchwork Thu Mar 3 13:55:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guilherme Salgado X-Patchwork-Id: 302 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:41:33 -0000 Delivered-To: patches@linaro.org Received: by 10.224.19.208 with SMTP id c16cs243776qab; Thu, 3 Mar 2011 05:55:51 -0800 (PST) Received: by 10.227.2.83 with SMTP id 19mr942615wbi.115.1299160550712; Thu, 03 Mar 2011 05:55:50 -0800 (PST) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id u2si2094237wbd.75.2011.03.03.05.55.50; Thu, 03 Mar 2011 05:55:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Pv90Q-0001Tw-4Q for ; Thu, 03 Mar 2011 13:55:50 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 1E9B72E811D for ; Thu, 3 Mar 2011 13:55:50 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-maintainers/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 292 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-maintainers/linaro-image-tools/trunk] Rev 292: Saving of the plain boot script (boot.txt) on the boot partition was failing with a permission er... Message-Id: <20110303135550.3754.13391.launchpad@loganberry.canonical.com> Date: Thu, 03 Mar 2011 13:55:50 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="12515"; Instance="initZopeless config overlay" X-Launchpad-Hash: 47c707991a92dbb81d6f60d249505b3f2f865da4 Merge authors: Guilherme Salgado (salgado) Related merge proposals: https://code.launchpad.net/~salgado/linaro-image-tools/fix-saving-plain-boot-script/+merge/52067 proposed by: Guilherme Salgado (salgado) review: Approve - Loïc Minier (lool) ------------------------------------------------------------ revno: 292 [merge] committer: Guilherme Salgado branch nick: trunk timestamp: Thu 2011-03-03 10:50:23 -0300 message: Saving of the plain boot script (boot.txt) on the boot partition was failing with a permission error; this fixes it. modified: linaro_media_create/boards.py linaro_media_create/tests/test_media_create.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-maintainers/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-maintainers/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_media_create/boards.py' --- linaro_media_create/boards.py 2011-03-01 16:23:52 +0000 +++ linaro_media_create/boards.py 2011-03-03 13:44:11 +0000 @@ -24,9 +24,11 @@ board_configs at the bottom of this file. """ +import atexit import glob import os import re +import tempfile from linaro_media_create import cmd_runner from linaro_media_create.partitions import SECTOR_SIZE @@ -496,10 +498,13 @@ def make_boot_script(boot_script_data, boot_script): # Need to save the boot script data into a file that will be passed to # mkimage. + _, tmpfile = tempfile.mkstemp() + atexit.register(os.unlink, tmpfile) plain_boot_script = os.path.join( os.path.dirname(boot_script), 'boot.txt') - with open(plain_boot_script, 'w') as fd: + with open(tmpfile, 'w') as fd: fd.write(boot_script_data) + cmd_runner.run(['cp', tmpfile, plain_boot_script], as_root=True).wait() return _run_mkimage( 'script', '0', '0', 'boot script', plain_boot_script, boot_script) === modified file 'linaro_media_create/tests/test_media_create.py' --- linaro_media_create/tests/test_media_create.py 2011-03-01 16:23:52 +0000 +++ linaro_media_create/tests/test_media_create.py 2011-03-03 13:44:11 +0000 @@ -606,6 +606,8 @@ self.assertEqual(expected, fixture.mock.calls) def test_make_boot_script(self): + self.useFixture(MockSomethingFixture( + tempfile, 'mkstemp', lambda: (-1, '/tmp/random-abxzr'))) tempdir = self.useFixture(CreateTempDirFixture()).tempdir self._mock_get_file_matching() fixture = self._mock_Popen() @@ -613,10 +615,11 @@ plain_boot_script_path = os.path.join(tempdir, 'boot.txt') make_boot_script('boot script data', boot_script_path) expected = [ - 'sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script', - '-C', 'none', '-a', '0', '-e', '0', '-n', 'boot script', - '-d', plain_boot_script_path, boot_script_path] - self.assertEqual([expected], fixture.mock.calls) + ['sudo', 'cp', '/tmp/random-abxzr', plain_boot_script_path], + ['sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script', + '-C', 'none', '-a', '0', '-e', '0', '-n', 'boot script', + '-d', plain_boot_script_path, boot_script_path]] + self.assertEqual(expected, fixture.mock.calls) def test_get_file_matching(self): prefix = ''.join(