Merge lp:~mabac/linaro-image-tools/bug-829220 into lp:linaro-image-tools/11.11

Proposed by Mattias Backman
Status: Merged
Merged at revision: 422
Proposed branch: lp:~mabac/linaro-image-tools/bug-829220
Merge into: lp:linaro-image-tools/11.11
Diff against target: 98 lines (+50/-4)
2 files modified
linaro_image_tools/media_create/boards.py (+10/-3)
linaro_image_tools/media_create/tests/test_media_create.py (+40/-1)
To merge this branch: bzr merge lp:~mabac/linaro-image-tools/bug-829220
Reviewer Review Type Date Requested Status
Loïc Minier (community) Approve
Review via email: mp+72405@code.launchpad.net

Description of the change

Hi,

This branch changes the format of the Snowball startfiles.cfg format a little bit.

L-m-c will now assume that the filename in the config file is an absolute path to the file on local file system. If that file does not exist, we fall back to assuming that the filename is relative to chroot/bin as is the case before this change.

This should make it backwards compatible for existing hwpacks but let anyone creating a Snowball hwpack specifiy absolute paths in case the files won't be installed to /boot on the target.

Also, if no interpretation of the path is found, we fall back to assuming that the filename is relative to /usr/lib/u-boot/u8500_snowball to support a hwpack where the uboot package does not link the binary in /boot. This should be removed asap or not merged if a fixed hwpack can be created.

Thanks,

Mattias

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

On Mon, Aug 22, 2011, Mattias Backman wrote:
> This branch changes the format of the Snowball startfiles.cfg format a
> little bit.
>
> L-m-c will now assume that the filname in the config file is an
> absolute path to the file on local file system. If that file does not
> exist, we fall back to assuming that the filename is relative to
> chroot/bin as is the case before this change.

 So the hwpack doesn't transport the files anymore? It seems to be the
 wrong thing to encourage

 Perhaps we could support looking up files in the hwpack tarball, or in
 a .deb in the hwpack tarball even if that isn't installed; e.g.
 startfiles.cfg would point at hwpack://xyz.bin or at
 hwpack+deb://xyz-files.deb/boot/xyz.bin?

--
Loïc Minier

419. By Mattias Backman

Remove hacky extra check. Fix absolute path to be relative to the chroot and not system root.

Revision history for this message
Mattias Backman (mabac) wrote :

> So the hwpack doesn't transport the files anymore? It seems to be the
> wrong thing to encourage

Sorry, that was unclear. Yes, the hwpack still transports the files and they will still be installed on target. The change is only about allowing the startfiles.cfg to specifiy the files relative to the chroot and not be contrained to /boot on the target system.

Fow hwpacks v2, I'm thinking that we could pick the files from the deb and not install it, but I have yet to make sure that it would work.

420. By Mattias Backman

Correct comment text.

Revision history for this message
Loïc Minier (lool) wrote :

On Mon, Aug 22, 2011, Mattias Backman wrote:
> Sorry, that was unclear. Yes, the hwpack still transports the files
> and they will still be installed on target. The change is only about
> allowing the startfiles.cfg to specifiy the files relative to the
> chroot and not be contrained to /boot on the target system.
>
> Fow hwpacks v2, I'm thinking that we could pick the files from the deb
> and not install it, but I have yet to make sure that it would work.

 Ok, we're in agreement them

 In terms of implementation, could we just check whether the filename is
 an absolute pathname in startfiles.cfg, and if it is use it relative to
 the chroot_dir, if not fallback to 'boot' + filename? That way,
 hwpack filenames would be required to have '/usr/lib/foo' or
 '/boot/foo' and we would fall back to '/boot/foo' if filename is 'foo'.

 I think it would be a matter of changing:
    filename = os.path.join(bin_dir, file_data[1])

 to:
    if file_data[1][0] == '/':
        filename = file_data[1]
    else:
        filename = os.path.join(bin_dir, file_data[1])

 and would force the hwpack to carry the filename that it ships rather
 than the linaro-image-tools code.

--
Loïc Minier

421. By Mattias Backman

Detect absolute path in startfiles.cfg instead of checking that the file exists.

Revision history for this message
Mattias Backman (mabac) wrote :

> In terms of implementation, could we just check whether the filename is
> an absolute pathname in startfiles.cfg, and if it is use it relative to
> the chroot_dir, if not fallback to 'boot' + filename? That way,
> hwpack filenames would be required to have '/usr/lib/foo' or
> '/boot/foo' and we would fall back to '/boot/foo' if filename is 'foo'.

Sure, I have made that change now, please have a look.

Revision history for this message
Loïc Minier (lool) wrote :

 review approve

On Tue, Aug 23, 2011, Mattias Backman wrote:
> Sure, I have made that change now, please have a look.

 Looks good; thanks!

--
Loïc Minier

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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:36:26 +0000
@@ -759,7 +759,7 @@
759 # Populate created raw partition with TOC and startup files.759 # Populate created raw partition with TOC and startup files.
760 config_files_path = os.path.join(chroot_dir, 'boot')760 config_files_path = os.path.join(chroot_dir, 'boot')
761 _, toc_filename = tempfile.mkstemp()761 _, toc_filename = tempfile.mkstemp()
762 new_files = cls.get_file_info(config_files_path)762 new_files = cls.get_file_info(chroot_dir)
763 with open(toc_filename, 'wb') as toc:763 with open(toc_filename, 'wb') as toc:
764 cls.create_toc(toc, new_files)764 cls.create_toc(toc, new_files)
765 cls.install_snowball_boot_loader(toc_filename, new_files,765 cls.install_snowball_boot_loader(toc_filename, new_files,
@@ -820,19 +820,26 @@
820 f.write(data)820 f.write(data)
821821
822 @classmethod822 @classmethod
823 def get_file_info(cls, bin_dir):823 def get_file_info(cls, chroot_dir):
824 ''' Fills in the offsets of files that are located in824 ''' Fills in the offsets of files that are located in
825 non-absolute memory locations depending on their sizes.'825 non-absolute memory locations depending on their sizes.'
826 Also fills in file sizes'''826 Also fills in file sizes'''
827 ofs = cls.TOC_SIZE827 ofs = cls.TOC_SIZE
828 files = []828 files = []
829 bin_dir = os.path.join(chroot_dir, 'boot')
829 with open(os.path.join(bin_dir, cls.SNOWBALL_STARTUP_FILES_CONFIG),830 with open(os.path.join(bin_dir, cls.SNOWBALL_STARTUP_FILES_CONFIG),
830 'r') as info_file:831 'r') as info_file:
831 for line in info_file:832 for line in info_file:
832 file_data = line.split()833 file_data = line.split()
833 if file_data[0][0] == '#':834 if file_data[0][0] == '#':
834 continue835 continue
835 filename = os.path.join(bin_dir, file_data[1])836 if file_data[1].startswith('/'):
837 filename = os.path.join(chroot_dir,
838 file_data[1].lstrip('/'))
839 else:
840 filename = os.path.join(bin_dir, file_data[1])
841 assert os.path.exists(filename), "File %s does not exist, " \
842 "please check the startfiles config file." % file_data[1]
836 address = long(file_data[3], 16)843 address = long(file_data[3], 16)
837 if address != 0:844 if address != 0:
838 ofs = address845 ofs = address
839846
=== 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:36:26 +0000
@@ -716,6 +716,45 @@
716 i += 1716 i += 1
717 return expected717 return expected
718718
719 def test_get_file_info_relative_path(self):
720 # Create a config file
721 cfg_file = os.path.join(self.temp_bootdir_path,
722 boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG)
723 uboot_file = 'u-boot.bin'
724 with open(cfg_file, 'w') as f:
725 f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0,
726 0xBA0000, '9'))
727 with open(os.path.join(self.temp_bootdir_path, uboot_file), 'w') as f:
728 file_info = boards.SnowballEmmcConfig.get_file_info(
729 self.tempdir)
730 self.assertEquals(file_info[0]['filename'],
731 os.path.join(self.temp_bootdir_path, uboot_file))
732
733 def test_get_file_info_abs_path(self):
734 # Create a config file
735 cfg_file = os.path.join(self.temp_bootdir_path,
736 boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG)
737 uboot_dir = tempfile.mkdtemp(dir=self.tempdir)
738 uboot_file = os.path.join(uboot_dir, 'u-boot.bin')
739 uboot_relative_file = uboot_file.replace(self.tempdir, '')
740 with open(cfg_file, 'w') as f:
741 f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_relative_file, 0,
742 0xBA0000, '9'))
743 with open(uboot_file, 'w') as f:
744 file_info = boards.SnowballEmmcConfig.get_file_info(
745 self.tempdir)
746 self.assertEquals(file_info[0]['filename'], uboot_file)
747
748 def test_get_file_info_raises(self):
749 # Create a config file
750 cfg_file = os.path.join(self.temp_bootdir_path,
751 boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG)
752 with open(cfg_file, 'w') as f:
753 f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0,
754 0xBA0000, '9'))
755 self.assertRaises(AssertionError, boards.SnowballEmmcConfig.get_file_info,
756 self.tempdir)
757
719 def test_file_name_size(self):758 def test_file_name_size(self):
720 ''' Test using a to large toc file '''759 ''' Test using a to large toc file '''
721 _, toc_filename = tempfile.mkstemp()760 _, toc_filename = tempfile.mkstemp()
@@ -829,7 +868,7 @@
829 def test_normal_case(self):868 def test_normal_case(self):
830 expected = self.setupFiles()869 expected = self.setupFiles()
831 actual = boards.SnowballEmmcConfig.get_file_info(870 actual = boards.SnowballEmmcConfig.get_file_info(
832 self.temp_bootdir_path)871 self.tempdir)
833 self.assertEquals(expected, actual)872 self.assertEquals(expected, actual)
834873
835874

Subscribers

People subscribed via source and target branches