From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [wic][PATCH v2 4/9] wic: Refactored getting root device name
Date: Fri, 5 Jun 2015 10:17:11 +0300 [thread overview]
Message-ID: <1433488636-4540-5-git-send-email-ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <1433488636-4540-1-git-send-email-ed.bartosh@linux.intel.com>
Replaced DirectImageCreator._get_boot_config private method
with a 'rootdev' property.
Simplified the code and API.
Used 'uuid' property instead of incorrectly used 'part_type'.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index 83f9688..36150c9 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -346,27 +346,23 @@ class DirectImageCreator(BaseImageCreator):
msger.info(msg)
- def _get_boot_config(self):
+ @property
+ def rootdev(self):
"""
- Return the rootdev/root_part_uuid (if specified by
- --part-type)
+ Get root device name to use as a 'root' parameter
+ in kernel command line.
Assume partition order same as in wks
"""
- rootdev = None
- root_part_uuid = None
parts = self._get_parts()
- for num, p in enumerate(parts, 1):
- if p.mountpoint == "/":
- part = ''
- if p.disk.startswith('mmcblk'):
- part = 'p'
-
- 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)
+ for num, part in enumerate(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)
+ return "/dev/%s%s%-d" % (part.disk, suffix, pnum)
def _cleanup(self):
if not self.__image is None:
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 400e3a2..39ce9f3 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -47,7 +47,6 @@ class BootimgEFIPlugin(SourcePlugin):
else:
splashline = ""
- (rootdev, root_part_uuid) = cr._get_boot_config()
options = cr.ks.handler.bootloader.appendLine
grubefi_conf = ""
@@ -62,7 +61,7 @@ class BootimgEFIPlugin(SourcePlugin):
kernel = "/bzImage"
if cr.ptable_format in ('msdos', 'gpt'):
- rootstr = rootdev
+ rootstr = cr.rootdev
else:
raise ImageError("Unsupported partition table format found")
@@ -87,7 +86,6 @@ class BootimgEFIPlugin(SourcePlugin):
install_cmd = "install -d %s/loader/entries" % hdddir
exec_cmd(install_cmd)
- (rootdev, root_part_uuid) = cr._get_boot_config()
options = cr.ks.handler.bootloader.appendLine
timeout = kickstart.get_timeout(cr.ks)
@@ -107,7 +105,7 @@ class BootimgEFIPlugin(SourcePlugin):
kernel = "/bzImage"
if cr.ptable_format in ('msdos', 'gpt'):
- rootstr = rootdev
+ rootstr = cr.rootdev
else:
raise ImageError("Unsupported partition table format found")
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index 1c3c6e6..dd49480 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -83,7 +83,6 @@ class BootimgPcbiosPlugin(SourcePlugin):
else:
splashline = ""
- (rootdev, root_part_uuid) = cr._get_boot_config()
options = cr.ks.handler.bootloader.appendLine
syslinux_conf = ""
@@ -105,7 +104,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
syslinux_conf += "KERNEL " + kernel + "\n"
if cr.ptable_format in ('msdos', 'gpt'):
- rootstr = rootdev
+ rootstr = cr.rootdev
else:
raise ImageError("Unsupported partition table format found")
diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py
index 50b2213..90dac05 100644
--- a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py
+++ b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py
@@ -82,7 +82,6 @@ class RootfsPlugin(SourcePlugin):
Called before do_prepare_partition()
"""
- rootdev = image_creator._get_boot_config()[0]
options = image_creator.ks.handler.bootloader.appendLine
syslinux_conf = ""
@@ -102,7 +101,7 @@ class RootfsPlugin(SourcePlugin):
syslinux_conf += " KERNEL /boot/bzImage\n"
if image_creator.ptable_format in ('msdos', 'gpt'):
- rootstr = rootdev
+ rootstr = image_creator.rootdev
else:
raise ImageError("Unsupported partition table format found")
--
2.1.4
next prev parent reply other threads:[~2015-06-05 9:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 7:17 [wic][PATCH v2 0/9] UUID support Ed Bartosh
2015-06-05 7:17 ` [wic][PATCH v2 1/9] wic: Add --use-uuid partition option Ed Bartosh
2015-06-05 7:17 ` [wic][PATCH v2 2/9] wic: Generate random uuid for partition Ed Bartosh
2015-06-05 7:17 ` [wic][PATCH v2 3/9] wic: Fix format string Ed Bartosh
2015-06-05 7:17 ` Ed Bartosh [this message]
2015-06-05 7:17 ` [wic][PATCH v2 5/9] wic: Add parameter 'uuid' to Image.add_partition method Ed Bartosh
2015-06-05 7:17 ` [wic][PATCH v2 6/9] wic: Set type GUID and UUID for partition Ed Bartosh
2015-06-05 7:17 ` [wic][PATCH v2 7/9] wic: Use partition UUID in directdisk-gpt Ed Bartosh
2015-06-05 7:17 ` [wic][PATCH v2 8/9] wic: oe-selftest: Configure testing of gpt/UUID image Ed Bartosh
2015-06-05 7:17 ` [wic][PATCH v2 9/9] wic: Add help for --part-type and --use-uuid options Ed Bartosh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433488636-4540-5-git-send-email-ed.bartosh@linux.intel.com \
--to=ed.bartosh@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox