summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/imager/direct.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/imager/direct.py')
-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)