summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-02-08 20:51:28 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-15 20:06:44 -0800
commit4edcd63ba1a5baf24c75c1a236fe25824e75592a (patch)
tree263a538527ae6283c308f0abe68402e659893881 /scripts
parent6355150674b62f086b7c2bd82aad31973f748ada (diff)
downloadpoky-4edcd63ba1a5baf24c75c1a236fe25824e75592a.tar.gz
wic: direct: get rid of _get_parts getter
Replaced _get_parts getter with direct attribute access to self.parts Removed code that implicitly created partition if there are no partitions mentioned in .wks file (From OE-Core rev: 7ece57a80f4002d0d83dc322092e9178380ab509) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py36
1 files changed, 8 insertions, 28 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index ae420a687e..71ffc3680c 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -94,6 +94,7 @@ class DirectPlugin(ImagerPlugin):
94 self._disk_format = "direct" 94 self._disk_format = "direct"
95 self._disk_names = [] 95 self._disk_names = []
96 self.ptable_format = self.ks.bootloader.ptable 96 self.ptable_format = self.ks.bootloader.ptable
97 self.parts = self.ks.partitions
97 98
98 def do_create(self): 99 def do_create(self):
99 """ 100 """
@@ -140,7 +141,7 @@ class DirectPlugin(ImagerPlugin):
140 with open(fstab_path) as fstab: 141 with open(fstab_path) as fstab:
141 fstab_lines = fstab.readlines() 142 fstab_lines = fstab.readlines()
142 143
143 if self._update_fstab(fstab_lines, self._get_parts()): 144 if self._update_fstab(fstab_lines, self.parts):
144 shutil.copyfile(fstab_path, fstab_path + ".orig") 145 shutil.copyfile(fstab_path, fstab_path + ".orig")
145 146
146 with open(fstab_path, "w") as fstab: 147 with open(fstab_path, "w") as fstab:
@@ -179,22 +180,6 @@ class DirectPlugin(ImagerPlugin):
179 """ 180 """
180 self.bootimg_dir = bootimg_dir 181 self.bootimg_dir = bootimg_dir
181 182
182 def _get_parts(self):
183 if not self.ks:
184 raise CreatorError("Failed to get partition info, "
185 "please check your kickstart setting.")
186
187 # Set a default partition if no partition is given out
188 if not self.ks.partitions:
189 partstr = "part / --size 1900 --ondisk sda --fstype=ext3"
190 args = partstr.split()
191 part = self.ks.parse(args[1:])
192 if part not in self.ks.partitions:
193 self.ks.partitions.append(part)
194
195 # partitions list from kickstart file
196 return self.ks.partitions
197
198 def _full_path(self, path, name, extention): 183 def _full_path(self, path, name, extention):
199 """ Construct full file path to a file we generate. """ 184 """ Construct full file path to a file we generate. """
200 return os.path.join(path, "%s-%s.%s" % (self.name, name, extention)) 185 return os.path.join(path, "%s-%s.%s" % (self.name, name, extention))
@@ -208,12 +193,10 @@ class DirectPlugin(ImagerPlugin):
208 filesystems from the artifacts directly and combine them into 193 filesystems from the artifacts directly and combine them into
209 a partitioned image. 194 a partitioned image.
210 """ 195 """
211 parts = self._get_parts()
212
213 self._image = Image(self.native_sysroot) 196 self._image = Image(self.native_sysroot)
214 197
215 disk_ids = {} 198 disk_ids = {}
216 for num, part in enumerate(parts, 1): 199 for num, part in enumerate(self.parts, 1):
217 # as a convenience, set source to the boot partition source 200 # as a convenience, set source to the boot partition source
218 # instead of forcing it to be set via bootloader --source 201 # instead of forcing it to be set via bootloader --source
219 if not self.ks.bootloader.source and part.mountpoint == "/boot": 202 if not self.ks.bootloader.source and part.mountpoint == "/boot":
@@ -227,11 +210,11 @@ class DirectPlugin(ImagerPlugin):
227 if part.disk not in disk_ids: 210 if part.disk not in disk_ids:
228 disk_ids[part.disk] = int.from_bytes(os.urandom(4), 'little') 211 disk_ids[part.disk] = int.from_bytes(os.urandom(4), 'little')
229 disk_id = disk_ids[part.disk] 212 disk_id = disk_ids[part.disk]
230 part.uuid = '%0x-%02d' % (disk_id, self._get_part_num(num, parts)) 213 part.uuid = '%0x-%02d' % (disk_id, self._get_part_num(num, self.parts))
231 214
232 fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) 215 fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR"))
233 216
234 for part in parts: 217 for part in self.parts:
235 # get rootfs size from bitbake variable if it's not set in .ks file 218 # get rootfs size from bitbake variable if it's not set in .ks file
236 if not part.size: 219 if not part.size:
237 # and if rootfs name is specified for the partition 220 # and if rootfs name is specified for the partition
@@ -323,8 +306,6 @@ class DirectPlugin(ImagerPlugin):
323 """ 306 """
324 msg = "The new image(s) can be found here:\n" 307 msg = "The new image(s) can be found here:\n"
325 308
326 parts = self._get_parts()
327
328 for disk_name in self._image.disks: 309 for disk_name in self._image.disks:
329 extension = "direct" + {"gzip": ".gz", 310 extension = "direct" + {"gzip": ".gz",
330 "bzip2": ".bz2", 311 "bzip2": ".bz2",
@@ -334,7 +315,7 @@ class DirectPlugin(ImagerPlugin):
334 msg += ' %s\n\n' % full_path 315 msg += ' %s\n\n' % full_path
335 316
336 msg += 'The following build artifacts were used to create the image(s):\n' 317 msg += 'The following build artifacts were used to create the image(s):\n'
337 for part in parts: 318 for part in self.parts:
338 if part.rootfs_dir is None: 319 if part.rootfs_dir is None:
339 continue 320 continue
340 if part.mountpoint == '/': 321 if part.mountpoint == '/':
@@ -357,14 +338,13 @@ class DirectPlugin(ImagerPlugin):
357 338
358 Assume partition order same as in wks 339 Assume partition order same as in wks
359 """ 340 """
360 parts = self._get_parts() 341 for num, part in enumerate(self.parts, 1):
361 for num, part in enumerate(parts, 1):
362 if part.mountpoint == "/": 342 if part.mountpoint == "/":
363 if part.uuid: 343 if part.uuid:
364 return "PARTUUID=%s" % part.uuid 344 return "PARTUUID=%s" % part.uuid
365 else: 345 else:
366 suffix = 'p' if part.disk.startswith('mmcblk') else '' 346 suffix = 'p' if part.disk.startswith('mmcblk') else ''
367 pnum = self._get_part_num(num, parts) 347 pnum = self._get_part_num(num, self.parts)
368 return "/dev/%s%s%-d" % (part.disk, suffix, pnum) 348 return "/dev/%s%s%-d" % (part.disk, suffix, pnum)
369 349
370 def cleanup(self): 350 def cleanup(self):