diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-02-08 20:51:28 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-15 20:06:32 -0800 |
commit | 7ece57a80f4002d0d83dc322092e9178380ab509 (patch) | |
tree | 5c1c0a1ec17ff8a038aa48844c3a07197bcc58b4 /scripts/lib/wic | |
parent | 26f3218070d34ccd4e81fa3b8e1a15c03583d070 (diff) | |
download | openembedded-core-7ece57a80f4002d0d83dc322092e9178380ab509.tar.gz openembedded-core-7ece57a80f4002d0d83dc322092e9178380ab509.tar.bz2 openembedded-core-7ece57a80f4002d0d83dc322092e9178380ab509.zip |
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
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 36 |
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): self._disk_format = "direct" self._disk_names = [] self.ptable_format = self.ks.bootloader.ptable + self.parts = self.ks.partitions def do_create(self): """ @@ -140,7 +141,7 @@ class DirectPlugin(ImagerPlugin): with open(fstab_path) as fstab: fstab_lines = fstab.readlines() - if self._update_fstab(fstab_lines, self._get_parts()): + if self._update_fstab(fstab_lines, self.parts): shutil.copyfile(fstab_path, fstab_path + ".orig") with open(fstab_path, "w") as fstab: @@ -179,22 +180,6 @@ class DirectPlugin(ImagerPlugin): """ self.bootimg_dir = bootimg_dir - def _get_parts(self): - if not self.ks: - raise CreatorError("Failed to get partition info, " - "please check your kickstart setting.") - - # Set a default partition if no partition is given out - if not self.ks.partitions: - partstr = "part / --size 1900 --ondisk sda --fstype=ext3" - args = partstr.split() - part = self.ks.parse(args[1:]) - if part not in self.ks.partitions: - self.ks.partitions.append(part) - - # partitions list from kickstart file - return self.ks.partitions - def _full_path(self, path, name, extention): """ Construct full file path to a file we generate. """ return os.path.join(path, "%s-%s.%s" % (self.name, name, extention)) @@ -208,12 +193,10 @@ class DirectPlugin(ImagerPlugin): filesystems from the artifacts directly and combine them into a partitioned image. """ - parts = self._get_parts() - self._image = Image(self.native_sysroot) disk_ids = {} - for num, part in enumerate(parts, 1): + for num, part in enumerate(self.parts, 1): # as a convenience, set source to the boot partition source # instead of forcing it to be set via bootloader --source if not self.ks.bootloader.source and part.mountpoint == "/boot": @@ -227,11 +210,11 @@ class DirectPlugin(ImagerPlugin): if part.disk not in disk_ids: disk_ids[part.disk] = int.from_bytes(os.urandom(4), 'little') disk_id = disk_ids[part.disk] - part.uuid = '%0x-%02d' % (disk_id, self._get_part_num(num, parts)) + part.uuid = '%0x-%02d' % (disk_id, self._get_part_num(num, self.parts)) fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) - for part in parts: + for part in self.parts: # get rootfs size from bitbake variable if it's not set in .ks file if not part.size: # and if rootfs name is specified for the partition @@ -323,8 +306,6 @@ class DirectPlugin(ImagerPlugin): """ msg = "The new image(s) can be found here:\n" - parts = self._get_parts() - for disk_name in self._image.disks: extension = "direct" + {"gzip": ".gz", "bzip2": ".bz2", @@ -334,7 +315,7 @@ class DirectPlugin(ImagerPlugin): msg += ' %s\n\n' % full_path msg += 'The following build artifacts were used to create the image(s):\n' - for part in parts: + for part in self.parts: if part.rootfs_dir is None: continue if part.mountpoint == '/': @@ -357,14 +338,13 @@ class DirectPlugin(ImagerPlugin): Assume partition order same as in wks """ - parts = self._get_parts() - for num, part in enumerate(parts, 1): + for num, part in enumerate(self.parts, 1): if part.mountpoint == "/": if part.uuid: return "PARTUUID=%s" % part.uuid else: suffix = 'p' if part.disk.startswith('mmcblk') else '' - pnum = self._get_part_num(num, parts) + pnum = self._get_part_num(num, self.parts) return "/dev/%s%s%-d" % (part.disk, suffix, pnum) def cleanup(self): |