diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-06-05 10:17:11 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-11 23:59:12 +0100 |
commit | c3148c6199756439d1802555b45249066eb7e6cf (patch) | |
tree | 67b8736c180038e91752ad4110234280eac69ffb /scripts/lib/wic | |
parent | 5b4ab4e4be2622a8d546dfd38de58bfd72cd4831 (diff) | |
download | poky-c3148c6199756439d1802555b45249066eb7e6cf.tar.gz |
wic: Refactored getting root device name
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'.
(From OE-Core rev: 4a303007149ea1205bbd454e70810e7dfa343d4c)
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/lib/wic')
-rw-r--r-- | scripts/lib/wic/imager/direct.py | 28 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 6 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-pcbios.py | 3 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py | 3 |
4 files changed, 16 insertions, 24 deletions
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py index 83f9688878..36150c9ad3 100644 --- a/scripts/lib/wic/imager/direct.py +++ b/scripts/lib/wic/imager/direct.py | |||
@@ -346,27 +346,23 @@ class DirectImageCreator(BaseImageCreator): | |||
346 | 346 | ||
347 | msger.info(msg) | 347 | msger.info(msg) |
348 | 348 | ||
349 | def _get_boot_config(self): | 349 | @property |
350 | def rootdev(self): | ||
350 | """ | 351 | """ |
351 | Return the rootdev/root_part_uuid (if specified by | 352 | Get root device name to use as a 'root' parameter |
352 | --part-type) | 353 | in kernel command line. |
353 | 354 | ||
354 | Assume partition order same as in wks | 355 | Assume partition order same as in wks |
355 | """ | 356 | """ |
356 | rootdev = None | ||
357 | root_part_uuid = None | ||
358 | parts = self._get_parts() | 357 | parts = self._get_parts() |
359 | for num, p in enumerate(parts, 1): | 358 | for num, part in enumerate(parts, 1): |
360 | if p.mountpoint == "/": | 359 | if part.mountpoint == "/": |
361 | part = '' | 360 | if part.uuid: |
362 | if p.disk.startswith('mmcblk'): | 361 | return "PARTUUID=%s" % part.uuid |
363 | part = 'p' | 362 | else: |
364 | 363 | suffix = 'p' if part.disk.startswith('mmcblk') else '' | |
365 | pnum = self.__get_part_num(num, parts) | 364 | pnum = self.__get_part_num(num, parts) |
366 | rootdev = "/dev/%s%s%-d" % (p.disk, part, pnum) | 365 | return "/dev/%s%s%-d" % (part.disk, suffix, pnum) |
367 | root_part_uuid = p.part_type | ||
368 | |||
369 | return (rootdev, root_part_uuid) | ||
370 | 366 | ||
371 | def _cleanup(self): | 367 | def _cleanup(self): |
372 | if not self.__image is None: | 368 | 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 400e3a2df8..39ce9f375e 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): | |||
47 | else: | 47 | else: |
48 | splashline = "" | 48 | splashline = "" |
49 | 49 | ||
50 | (rootdev, root_part_uuid) = cr._get_boot_config() | ||
51 | options = cr.ks.handler.bootloader.appendLine | 50 | options = cr.ks.handler.bootloader.appendLine |
52 | 51 | ||
53 | grubefi_conf = "" | 52 | grubefi_conf = "" |
@@ -62,7 +61,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
62 | kernel = "/bzImage" | 61 | kernel = "/bzImage" |
63 | 62 | ||
64 | if cr.ptable_format in ('msdos', 'gpt'): | 63 | if cr.ptable_format in ('msdos', 'gpt'): |
65 | rootstr = rootdev | 64 | rootstr = cr.rootdev |
66 | else: | 65 | else: |
67 | raise ImageError("Unsupported partition table format found") | 66 | raise ImageError("Unsupported partition table format found") |
68 | 67 | ||
@@ -87,7 +86,6 @@ class BootimgEFIPlugin(SourcePlugin): | |||
87 | install_cmd = "install -d %s/loader/entries" % hdddir | 86 | install_cmd = "install -d %s/loader/entries" % hdddir |
88 | exec_cmd(install_cmd) | 87 | exec_cmd(install_cmd) |
89 | 88 | ||
90 | (rootdev, root_part_uuid) = cr._get_boot_config() | ||
91 | options = cr.ks.handler.bootloader.appendLine | 89 | options = cr.ks.handler.bootloader.appendLine |
92 | 90 | ||
93 | timeout = kickstart.get_timeout(cr.ks) | 91 | timeout = kickstart.get_timeout(cr.ks) |
@@ -107,7 +105,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
107 | kernel = "/bzImage" | 105 | kernel = "/bzImage" |
108 | 106 | ||
109 | if cr.ptable_format in ('msdos', 'gpt'): | 107 | if cr.ptable_format in ('msdos', 'gpt'): |
110 | rootstr = rootdev | 108 | rootstr = cr.rootdev |
111 | else: | 109 | else: |
112 | raise ImageError("Unsupported partition table format found") | 110 | raise ImageError("Unsupported partition table format found") |
113 | 111 | ||
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py index 1c3c6e605c..dd49480141 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): | |||
83 | else: | 83 | else: |
84 | splashline = "" | 84 | splashline = "" |
85 | 85 | ||
86 | (rootdev, root_part_uuid) = cr._get_boot_config() | ||
87 | options = cr.ks.handler.bootloader.appendLine | 86 | options = cr.ks.handler.bootloader.appendLine |
88 | 87 | ||
89 | syslinux_conf = "" | 88 | syslinux_conf = "" |
@@ -105,7 +104,7 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
105 | syslinux_conf += "KERNEL " + kernel + "\n" | 104 | syslinux_conf += "KERNEL " + kernel + "\n" |
106 | 105 | ||
107 | if cr.ptable_format in ('msdos', 'gpt'): | 106 | if cr.ptable_format in ('msdos', 'gpt'): |
108 | rootstr = rootdev | 107 | rootstr = cr.rootdev |
109 | else: | 108 | else: |
110 | raise ImageError("Unsupported partition table format found") | 109 | raise ImageError("Unsupported partition table format found") |
111 | 110 | ||
diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py index 50b221382c..90dac05dca 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): | |||
82 | 82 | ||
83 | Called before do_prepare_partition() | 83 | Called before do_prepare_partition() |
84 | """ | 84 | """ |
85 | rootdev = image_creator._get_boot_config()[0] | ||
86 | options = image_creator.ks.handler.bootloader.appendLine | 85 | options = image_creator.ks.handler.bootloader.appendLine |
87 | 86 | ||
88 | syslinux_conf = "" | 87 | syslinux_conf = "" |
@@ -102,7 +101,7 @@ class RootfsPlugin(SourcePlugin): | |||
102 | syslinux_conf += " KERNEL /boot/bzImage\n" | 101 | syslinux_conf += " KERNEL /boot/bzImage\n" |
103 | 102 | ||
104 | if image_creator.ptable_format in ('msdos', 'gpt'): | 103 | if image_creator.ptable_format in ('msdos', 'gpt'): |
105 | rootstr = rootdev | 104 | rootstr = image_creator.rootdev |
106 | else: | 105 | else: |
107 | raise ImageError("Unsupported partition table format found") | 106 | raise ImageError("Unsupported partition table format found") |
108 | 107 | ||