diff mbox

[Branch,~linaro-maintainers/linaro-image-tools/trunk] Rev 255: Make sure we create an extra (non-Data) partition for mx51evk boards

Message ID 20110124194134.3686.11963.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

Guilherme Salgado Jan. 24, 2011, 7:41 p.m. UTC
Merge authors:
  Guilherme Salgado (salgado)
Related merge proposals:
  https://code.launchpad.net/~salgado/linaro-image-tools/bug-705410/+merge/47290
  proposed by: Guilherme Salgado (salgado)
  review: Approve - Loïc Minier (lool)
------------------------------------------------------------
revno: 255 [merge]
fixes bug(s): https://launchpad.net/bugs/705410
committer: Guilherme Salgado <salgado@canonical.com>
branch nick: trunk
timestamp: Mon 2011-01-24 17:39:45 -0200
message:
  Make sure we create an extra (non-Data) partition for mx51evk boards
modified:
  linaro_media_create/partitions.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
diff mbox

Patch

=== modified file 'linaro_media_create/partitions.py'
--- linaro_media_create/partitions.py	2011-01-22 00:50:19 +0000
+++ linaro_media_create/partitions.py	2011-01-24 19:39:45 +0000
@@ -252,6 +252,10 @@ 
                         as_root=True, stderr=None):
     """Run the given commands under sfdisk.
 
+    Every time sfdisk is invoked it will repartition the device so to create
+    multiple partitions you should craft a list of newline-separated commands
+    to be executed in a single sfdisk run.
+
     :param commands: A string of sfdisk commands; each on a separate line.
     :return: A 2-tuple containing the subprocess' stdout and stderr.
     """
@@ -292,16 +296,16 @@ 
     else:
         partition_type = '0x0E'
 
+    sfdisk_cmd = ',9,%s,*\n,,,-' % partition_type
     if board == 'mx51evk':
         # Create a one cylinder partition for fixed-offset bootloader data at
         # the beginning of the image (size is one cylinder, so 8224768 bytes
         # with the first sector for MBR).
-        run_sfdisk_commands(',1,0xDA', heads, sectors, cylinders, media.path)
+        sfdisk_cmd = ',1,0xDA\n%s' % sfdisk_cmd
 
     # Create a VFAT or FAT16 partition of 9 cylinders (74027520 bytes, ~70
     # MiB), followed by a Linux-type partition containing the rest of the free
     # space.
-    sfdisk_cmd = ',9,%s,*\n,,,-' % partition_type
     run_sfdisk_commands(sfdisk_cmd, heads, sectors, cylinders, media.path)
 
     # Sync and sleep to wait for the partition to settle.

=== modified file 'linaro_media_create/tests/test_media_create.py'
--- linaro_media_create/tests/test_media_create.py	2011-01-22 00:50:54 +0000
+++ linaro_media_create/tests/test_media_create.py	2011-01-24 19:39:45 +0000
@@ -387,9 +387,11 @@ 
             [['sudo', 'parted', '-s', self.media.path, 'mklabel', 'msdos'],
              ['sync']],
             popen_fixture.mock.calls)
+        # Notice that we create all partitions in a single sfdisk run because
+        # every time we run sfdisk it actually repartitions the device,
+        # erasing any partitions created previously.
         self.assertEqual(
-            [(',1,0xDA', 255, 63, '', self.media.path),
-             (',9,0x0C,*\n,,,-', 255, 63, '', self.media.path)],
+            [(',1,0xDA\n,9,0x0C,*\n,,,-', 255, 63, '', self.media.path)],
             sfdisk_fixture.mock.calls)
 
     def test_create_partitions_for_beagle(self):