summaryrefslogtreecommitdiff
path: root/scripts/lib/wic/imager
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-02-08 23:52:00 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-14 08:40:34 +0000
commit233b631ece5ee14d057932c146327065064b5196 (patch)
tree2fcfeaa389fc1171413846c161fbd4475f9024f0 /scripts/lib/wic/imager
parenteea9ada645ea5f17cf2e0f2a89a790c26ad27e9d (diff)
downloadopenembedded-core-233b631ece5ee14d057932c146327065064b5196.tar.gz
openembedded-core-233b631ece5ee14d057932c146327065064b5196.tar.bz2
openembedded-core-233b631ece5ee14d057932c146327065064b5196.zip
wic: allow creation of partitions not in table
For some architectures it is necessary to reserve space on disk without it being present in the partition table. For example, u-boot on i.mx is placed at an offset of 1kB on the sdcard. While it would be possible to create a partition at that offset and place u-boot there, it would then be necessary to update the default u-boot environment to use partition 2 on the mmc instead of partition 1. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/lib/wic/imager')
-rw-r--r--scripts/lib/wic/imager/direct.py31
1 files changed, 21 insertions, 10 deletions
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index b1dc3e96f4..38d4e78e62 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -74,6 +74,22 @@ class DirectImageCreator(BaseImageCreator):
self.kernel_dir = kernel_dir
self.native_sysroot = native_sysroot
+ def __get_part_num(self, num, parts):
+ """calculate the real partition number, accounting for partitions not
+ in the partition table and logical partitions
+ """
+ realnum = 0
+ for n, p in enumerate(parts, 1):
+ if not p.no_table:
+ realnum += 1
+ if n == num:
+ if p.no_table:
+ return 0
+ if self._ptable_format == 'msdos' and realnum > 3:
+ # account for logical partition numbering, ex. sda5..
+ return realnum + 1
+ return realnum
+
def __write_fstab(self, image_rootfs):
"""overriden to generate fstab (temporarily) in rootfs. This is called
from _create, make sure it doesn't get called from
@@ -98,7 +114,8 @@ class DirectImageCreator(BaseImageCreator):
def _update_fstab(self, fstab_lines, parts):
"""Assume partition order same as in wks"""
for num, p in enumerate(parts, 1):
- if not p.mountpoint or p.mountpoint == "/" or p.mountpoint == "/boot":
+ pnum = self.__get_part_num(num, parts)
+ if not p.mountpoint or p.mountpoint == "/" or p.mountpoint == "/boot" or pnum == 0:
continue
part = ''
@@ -106,11 +123,6 @@ class DirectImageCreator(BaseImageCreator):
if p.disk.startswith('mmcblk'):
part = 'p'
- pnum = num
- if self._ptable_format == 'msdos' and pnum > 3:
- # account for logical partition numbering, ex. sda5..
- pnum += 1
-
device_name = "/dev/" + p.disk + part + str(pnum)
opts = "defaults"
@@ -262,6 +274,7 @@ class DirectImageCreator(BaseImageCreator):
fsopts = p.fsopts,
boot = p.active,
align = p.align,
+ no_table = p.no_table,
part_type = p.part_type)
self.__image.layout_partitions(self._ptable_format)
@@ -350,10 +363,8 @@ class DirectImageCreator(BaseImageCreator):
if p.disk.startswith('mmcblk'):
part = 'p'
- if self._ptable_format == 'msdos' and num > 3:
- rootdev = "/dev/%s%s%-d" % (p.disk, part, num + 1)
- else:
- rootdev = "/dev/%s%s%-d" % (p.disk, part, num)
+ pnum = self.__get_part_num(num, parts)
+ rootdev = "/dev/%s%s%-d" % (p.disk, part, pnum)
root_part_uuid = p.part_type
return (rootdev, root_part_uuid)