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
=== 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:49:39 +0000
@@ -24,9 +24,11 @@
24board_configs at the bottom of this file.24board_configs at the bottom of this file.
25"""25"""
2626
27import atexit
27import glob28import glob
28import os29import os
29import re30import re
31import tempfile
3032
31from linaro_media_create import cmd_runner33from linaro_media_create import cmd_runner
32from linaro_media_create.partitions import SECTOR_SIZE34from linaro_media_create.partitions import SECTOR_SIZE
@@ -496,10 +498,13 @@
496def make_boot_script(boot_script_data, boot_script):498def make_boot_script(boot_script_data, boot_script):
497 # Need to save the boot script data into a file that will be passed to499 # Need to save the boot script data into a file that will be passed to
498 # mkimage.500 # mkimage.
501 _, tmpfile = tempfile.mkstemp()
502 atexit.register(os.unlink, tmpfile)
499 plain_boot_script = os.path.join(503 plain_boot_script = os.path.join(
500 os.path.dirname(boot_script), 'boot.txt')504 os.path.dirname(boot_script), 'boot.txt')
501 with open(plain_boot_script, 'w') as fd:505 with open(tmpfile, 'w') as fd:
502 fd.write(boot_script_data)506 fd.write(boot_script_data)
507 cmd_runner.run(['cp', tmpfile, plain_boot_script], as_root=True).wait()
503 return _run_mkimage(508 return _run_mkimage(
504 'script', '0', '0', 'boot script', plain_boot_script, boot_script)509 'script', '0', '0', 'boot script', plain_boot_script, boot_script)
505510
506511
=== 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:49:39 +0000
@@ -606,6 +606,8 @@
606 self.assertEqual(expected, fixture.mock.calls)606 self.assertEqual(expected, fixture.mock.calls)
607607
608 def test_make_boot_script(self):608 def test_make_boot_script(self):
609 self.useFixture(MockSomethingFixture(
610 tempfile, 'mkstemp', lambda: (-1, '/tmp/random-abxzr')))
609 tempdir = self.useFixture(CreateTempDirFixture()).tempdir611 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
610 self._mock_get_file_matching()612 self._mock_get_file_matching()
611 fixture = self._mock_Popen()613 fixture = self._mock_Popen()
@@ -613,10 +615,11 @@
613 plain_boot_script_path = os.path.join(tempdir, 'boot.txt')615 plain_boot_script_path = os.path.join(tempdir, 'boot.txt')
614 make_boot_script('boot script data', boot_script_path)616 make_boot_script('boot script data', boot_script_path)
615 expected = [617 expected = [
616 'sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script',618 ['sudo', 'cp', '/tmp/random-abxzr', plain_boot_script_path],
617 '-C', 'none', '-a', '0', '-e', '0', '-n', 'boot script',619 ['sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script',
618 '-d', plain_boot_script_path, boot_script_path]620 '-C', 'none', '-a', '0', '-e', '0', '-n', 'boot script',
619 self.assertEqual([expected], fixture.mock.calls)621 '-d', plain_boot_script_path, boot_script_path]]
622 self.assertEqual(expected, fixture.mock.calls)
620623
621 def test_get_file_matching(self):624 def test_get_file_matching(self):
622 prefix = ''.join(625 prefix = ''.join(

Subscribers

People subscribed via source and target branches