summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/imager/direct.py
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:58 +0000
commit0b156dac83258a2789f21038216e43aacc91555a (patch)
tree3d814ee83abb20173b099e2f8dd9c83365d45d94 /scripts/lib/wic/imager/direct.py
parentf923f0fde8af63c6ba7c232d1f25dd970d9e22e1 (diff)
downloadpoky-0b156dac83258a2789f21038216e43aacc91555a.tar.gz
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. (From OE-Core rev: 233b631ece5ee14d057932c146327065064b5196) Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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):
74 self.kernel_dir = kernel_dir 74 self.kernel_dir = kernel_dir
75 self.native_sysroot = native_sysroot 75 self.native_sysroot = native_sysroot
76 76
77 def __get_part_num(self, num, parts):
78 """calculate the real partition number, accounting for partitions not
79 in the partition table and logical partitions
80 """
81 realnum = 0
82 for n, p in enumerate(parts, 1):
83 if not p.no_table:
84 realnum += 1
85 if n == num:
86 if p.no_table:
87 return 0
88 if self._ptable_format == 'msdos' and realnum > 3:
89 # account for logical partition numbering, ex. sda5..
90 return realnum + 1
91 return realnum
92
77 def __write_fstab(self, image_rootfs): 93 def __write_fstab(self, image_rootfs):
78 """overriden to generate fstab (temporarily) in rootfs. This is called 94 """overriden to generate fstab (temporarily) in rootfs. This is called
79 from _create, make sure it doesn't get called from 95 from _create, make sure it doesn't get called from
@@ -98,7 +114,8 @@ class DirectImageCreator(BaseImageCreator):
98 def _update_fstab(self, fstab_lines, parts): 114 def _update_fstab(self, fstab_lines, parts):
99 """Assume partition order same as in wks""" 115 """Assume partition order same as in wks"""
100 for num, p in enumerate(parts, 1): 116 for num, p in enumerate(parts, 1):
101 if not p.mountpoint or p.mountpoint == "/" or p.mountpoint == "/boot": 117 pnum = self.__get_part_num(num, parts)
118 if not p.mountpoint or p.mountpoint == "/" or p.mountpoint == "/boot" or pnum == 0:
102 continue 119 continue
103 120
104 part = '' 121 part = ''
@@ -106,11 +123,6 @@ class DirectImageCreator(BaseImageCreator):
106 if p.disk.startswith('mmcblk'): 123 if p.disk.startswith('mmcblk'):
107 part = 'p' 124 part = 'p'
108 125
109 pnum = num
110 if self._ptable_format == 'msdos' and pnum > 3:
111 # account for logical partition numbering, ex. sda5..
112 pnum += 1
113
114 device_name = "/dev/" + p.disk + part + str(pnum) 126 device_name = "/dev/" + p.disk + part + str(pnum)
115 127
116 opts = "defaults" 128 opts = "defaults"
@@ -262,6 +274,7 @@ class DirectImageCreator(BaseImageCreator):
262 fsopts = p.fsopts, 274 fsopts = p.fsopts,
263 boot = p.active, 275 boot = p.active,
264 align = p.align, 276 align = p.align,
277 no_table = p.no_table,
265 part_type = p.part_type) 278 part_type = p.part_type)
266 279
267 self.__image.layout_partitions(self._ptable_format) 280 self.__image.layout_partitions(self._ptable_format)
@@ -350,10 +363,8 @@ class DirectImageCreator(BaseImageCreator):
350 if p.disk.startswith('mmcblk'): 363 if p.disk.startswith('mmcblk'):
351 part = 'p' 364 part = 'p'
352 365
353 if self._ptable_format == 'msdos' and num > 3: 366 pnum = self.__get_part_num(num, parts)
354 rootdev = "/dev/%s%s%-d" % (p.disk, part, num + 1) 367 rootdev = "/dev/%s%s%-d" % (p.disk, part, pnum)
355 else:
356 rootdev = "/dev/%s%s%-d" % (p.disk, part, num)
357 root_part_uuid = p.part_type 368 root_part_uuid = p.part_type
358 369
359 return (rootdev, root_part_uuid) 370 return (rootdev, root_part_uuid)