Merge lp:~salgado/linaro-image-tools/fix-saving-plain-boot-script into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: 292
Proposed branch: lp:~salgado/linaro-image-tools/fix-saving-plain-boot-script
Merge into: lp:linaro-image-tools/11.11
Diff against target: 59 lines (+13/-5)
2 files modified
linaro_media_create/boards.py (+6/-1)
linaro_media_create/tests/test_media_create.py (+7/-4)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/fix-saving-plain-boot-script
Reviewer Review Type Date Requested Status
Loïc Minier (community) Approve
Review via email: mp+52067@code.launchpad.net

Description of the change

Saving of the plain boot script (boot.txt) on the boot partition was failing
with a permission error; this fixes it.

To post a comment you must log in.
Revision history for this message
Loïc Minier (lool) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro_media_create/boards.py'
2--- linaro_media_create/boards.py 2011-03-01 16:23:52 +0000
3+++ linaro_media_create/boards.py 2011-03-03 13:49:39 +0000
4@@ -24,9 +24,11 @@
5 board_configs at the bottom of this file.
6 """
7
8+import atexit
9 import glob
10 import os
11 import re
12+import tempfile
13
14 from linaro_media_create import cmd_runner
15 from linaro_media_create.partitions import SECTOR_SIZE
16@@ -496,10 +498,13 @@
17 def make_boot_script(boot_script_data, boot_script):
18 # Need to save the boot script data into a file that will be passed to
19 # mkimage.
20+ _, tmpfile = tempfile.mkstemp()
21+ atexit.register(os.unlink, tmpfile)
22 plain_boot_script = os.path.join(
23 os.path.dirname(boot_script), 'boot.txt')
24- with open(plain_boot_script, 'w') as fd:
25+ with open(tmpfile, 'w') as fd:
26 fd.write(boot_script_data)
27+ cmd_runner.run(['cp', tmpfile, plain_boot_script], as_root=True).wait()
28 return _run_mkimage(
29 'script', '0', '0', 'boot script', plain_boot_script, boot_script)
30
31
32=== modified file 'linaro_media_create/tests/test_media_create.py'
33--- linaro_media_create/tests/test_media_create.py 2011-03-01 16:23:52 +0000
34+++ linaro_media_create/tests/test_media_create.py 2011-03-03 13:49:39 +0000
35@@ -606,6 +606,8 @@
36 self.assertEqual(expected, fixture.mock.calls)
37
38 def test_make_boot_script(self):
39+ self.useFixture(MockSomethingFixture(
40+ tempfile, 'mkstemp', lambda: (-1, '/tmp/random-abxzr')))
41 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
42 self._mock_get_file_matching()
43 fixture = self._mock_Popen()
44@@ -613,10 +615,11 @@
45 plain_boot_script_path = os.path.join(tempdir, 'boot.txt')
46 make_boot_script('boot script data', boot_script_path)
47 expected = [
48- 'sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script',
49- '-C', 'none', '-a', '0', '-e', '0', '-n', 'boot script',
50- '-d', plain_boot_script_path, boot_script_path]
51- self.assertEqual([expected], fixture.mock.calls)
52+ ['sudo', 'cp', '/tmp/random-abxzr', plain_boot_script_path],
53+ ['sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script',
54+ '-C', 'none', '-a', '0', '-e', '0', '-n', 'boot script',
55+ '-d', plain_boot_script_path, boot_script_path]]
56+ self.assertEqual(expected, fixture.mock.calls)
57
58 def test_get_file_matching(self):
59 prefix = ''.join(

Subscribers

People subscribed via source and target branches