summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source/bootimg-pcbios.py
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-03-22 15:42:31 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-23 13:19:49 +0000
commitfa10b24950d3c55b7d7ebb15a7f5ebe413ca42f1 (patch)
tree4f9578afd6dcad27a6e15ac35f272e2aecc999e3 /scripts/lib/wic/plugins/source/bootimg-pcbios.py
parent5c04e371405bb51159726c5265c35e96316f71fd (diff)
downloadpoky-fa10b24950d3c55b7d7ebb15a7f5ebe413ca42f1.tar.gz
wic: improve getting syslinux path
Used wic-tools STAGING_DATADIR if syslinux can't be found in default bootimg_dir. (From OE-Core rev: 79a935cfc86ffce6f4b4f328b90337de36ba6dbb) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/plugins/source/bootimg-pcbios.py')
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-pcbios.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index 1779520044..11db304550 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -44,17 +44,32 @@ class BootimgPcbiosPlugin(SourcePlugin):
44 name = 'bootimg-pcbios' 44 name = 'bootimg-pcbios'
45 45
46 @classmethod 46 @classmethod
47 def _get_syslinux_dir(cls, bootimg_dir):
48 """
49 Get path to syslinux from either default bootimg_dir
50 or wic-tools STAGING_DIR.
51 """
52 for path in (bootimg_dir, get_bitbake_var("STAGING_DATADIR", "wic-tools")):
53 if not path:
54 continue
55 syslinux_dir = os.path.join(path, 'syslinux')
56 if os.path.exists(syslinux_dir):
57 return syslinux_dir
58
59 raise WicError("Couldn't find syslinux directory, exiting")
60
61 @classmethod
47 def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, 62 def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir,
48 bootimg_dir, kernel_dir, native_sysroot): 63 bootimg_dir, kernel_dir, native_sysroot):
49 """ 64 """
50 Called after all partitions have been prepared and assembled into a 65 Called after all partitions have been prepared and assembled into a
51 disk image. In this case, we install the MBR. 66 disk image. In this case, we install the MBR.
52 """ 67 """
53 mbrfile = "%s/syslinux/" % bootimg_dir 68 syslinux_dir = cls._get_syslinux_dir(bootimg_dir)
54 if creator.ptable_format == 'msdos': 69 if creator.ptable_format == 'msdos':
55 mbrfile += "mbr.bin" 70 mbrfile = os.path.join(syslinux_dir, "mbr.bin")
56 elif creator.ptable_format == 'gpt': 71 elif creator.ptable_format == 'gpt':
57 mbrfile += "gptmbr.bin" 72 mbrfile = os.path.join(syslinux_dir, "gptmbr.bin")
58 else: 73 else:
59 raise WicError("Unsupported partition table: %s" % 74 raise WicError("Unsupported partition table: %s" %
60 creator.ptable_format) 75 creator.ptable_format)
@@ -140,19 +155,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
140 'prepares' the partition to be incorporated into the image. 155 'prepares' the partition to be incorporated into the image.
141 In this case, prepare content for legacy bios boot partition. 156 In this case, prepare content for legacy bios boot partition.
142 """ 157 """
143 def _has_syslinux(dirname): 158 syslinux_dir = cls._get_syslinux_dir(bootimg_dir)
144 if dirname:
145 syslinux = "%s/syslinux" % dirname
146 if os.path.exists(syslinux):
147 return True
148 return False
149
150 if not _has_syslinux(bootimg_dir):
151 bootimg_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools")
152 if not bootimg_dir:
153 raise WicError("Couldn't find STAGING_DATADIR, exiting")
154 if not _has_syslinux(bootimg_dir):
155 raise WicError("Please build syslinux first")
156 159
157 staging_kernel_dir = kernel_dir 160 staging_kernel_dir = kernel_dir
158 161
@@ -160,14 +163,14 @@ class BootimgPcbiosPlugin(SourcePlugin):
160 163
161 cmds = ("install -m 0644 %s/bzImage %s/vmlinuz" % 164 cmds = ("install -m 0644 %s/bzImage %s/vmlinuz" %
162 (staging_kernel_dir, hdddir), 165 (staging_kernel_dir, hdddir),
163 "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" % 166 "install -m 444 %s/ldlinux.sys %s/ldlinux.sys" %
164 (bootimg_dir, hdddir), 167 (syslinux_dir, hdddir),
165 "install -m 0644 %s/syslinux/vesamenu.c32 %s/vesamenu.c32" % 168 "install -m 0644 %s/vesamenu.c32 %s/vesamenu.c32" %
166 (bootimg_dir, hdddir), 169 (syslinux_dir, hdddir),
167 "install -m 444 %s/syslinux/libcom32.c32 %s/libcom32.c32" % 170 "install -m 444 %s/libcom32.c32 %s/libcom32.c32" %
168 (bootimg_dir, hdddir), 171 (syslinux_dir, hdddir),
169 "install -m 444 %s/syslinux/libutil.c32 %s/libutil.c32" % 172 "install -m 444 %s/libutil.c32 %s/libutil.c32" %
170 (bootimg_dir, hdddir)) 173 (syslinux_dir, hdddir))
171 174
172 for install_cmd in cmds: 175 for install_cmd in cmds:
173 exec_cmd(install_cmd) 176 exec_cmd(install_cmd)