summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-03-22 15:42:25 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-23 13:19:49 +0000
commitd38d526991fa8e9e928eb3320f3b10a95bd76489 (patch)
tree8221042299d8be799f17a5a6cb97213d584807fe /scripts/lib/wic/plugins/source
parent49c2df5652d25e6e9b2a4976658ab9bb17fe6694 (diff)
downloadpoky-d38d526991fa8e9e928eb3320f3b10a95bd76489.tar.gz
wic: remove rootfs_pcbios_ext plugin
Removed broken unused plugin. (From OE-Core rev: 6d162118a2567ccbcdbc2a9ca14a8c358fa1a055) 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')
-rw-r--r--scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py213
1 files changed, 0 insertions, 213 deletions
diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py
deleted file mode 100644
index 94f80d07ae..0000000000
--- a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py
+++ /dev/null
@@ -1,213 +0,0 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3#
4# This program is free software; you can distribute it and/or modify
5# it under the terms of the GNU General Public License version 2 as
6# published by the Free Software Foundation.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for mo details.
12#
13# You should have received a copy of the GNU General Public License along
14# with this program; if not, write to the Free Software Foundation, Inc.,
15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16#
17# AUTHOR
18# Adrian Freihofer <adrian.freihofer (at] neratec.com>
19#
20
21import logging
22import os
23import re
24
25from wic import WicError
26from wic.utils import runner
27from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd
28from wic.pluginbase import SourcePlugin
29
30logger = logging.getLogger('wic')
31
32def serial_console_form_kargs(kernel_args):
33 """
34 Create SERIAL... line from kernel parameters
35
36 syslinux needs a line SERIAL port [baudrate [flowcontrol]]
37 in the syslinux.cfg file. The config line is generated based
38 on kernel boot parameters. The the parameters of the first
39 ttyS console are considered for syslinux config.
40 @param kernel_args kernel command line
41 @return line for syslinux config file e.g. "SERIAL 0 115200"
42 """
43 syslinux_conf = ""
44 for param in kernel_args.split():
45 param_match = re.match("console=ttyS([0-9]+),?([0-9]*)([noe]?)([0-9]?)(r?)", param)
46 if param_match:
47 syslinux_conf += "SERIAL " + param_match.group(1)
48 # baudrate
49 if param_match.group(2):
50 syslinux_conf += " " + param_match.group(2)
51 # parity
52 if param_match.group(3) and param_match.group(3) != 'n':
53 logger.warning("syslinux does not support parity for console. "
54 "%s is ignored.", param_match.group(3))
55 # number of bits
56 if param_match.group(4) and param_match.group(4) != '8':
57 logger.warning("syslinux supports 8 bit console configuration "
58 "only. %s is ignored.", param_match.group(4))
59 # flow control
60 if param_match.group(5) and param_match.group(5) != '':
61 logger.warning("syslinux console flowcontrol configuration. "
62 "%s is ignored.", param_match.group(5))
63 break
64
65 return syslinux_conf
66
67
68# pylint: disable=no-init
69class RootfsPlugin(SourcePlugin):
70 """
71 Create root partition and install syslinux bootloader
72
73 This plugin creates a disk image containing a bootable root partition with
74 syslinux installed. The filesystem is ext2/3/4, no extra boot partition is
75 required.
76
77 Example kickstart file:
78 part / --source rootfs-pcbios-ext --ondisk sda --fstype=ext4 --label rootfs --align 1024
79 bootloader --source rootfs-pcbios-ext --timeout=0 --append="rootwait rootfstype=ext4"
80
81 The first line generates a root file system including a syslinux.cfg file
82 The "--source rootfs-pcbios-ext" in the second line triggers the installation
83 of ldlinux.sys into the image.
84 """
85
86 name = 'rootfs-pcbios-ext'
87
88 @staticmethod
89 def _get_rootfs_dir(rootfs_dir):
90 """
91 Find rootfs pseudo dir
92
93 If rootfs_dir is a directory consider it as rootfs directory.
94 Otherwise ask bitbake about the IMAGE_ROOTFS directory.
95 """
96 if os.path.isdir(rootfs_dir):
97 return rootfs_dir
98
99 image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir)
100 if not os.path.isdir(image_rootfs_dir):
101 raise WicError("No valid artifact IMAGE_ROOTFS from image named %s "
102 "has been found at %s, exiting." %
103 (rootfs_dir, image_rootfs_dir))
104
105 return image_rootfs_dir
106
107 # pylint: disable=unused-argument
108 @classmethod
109 def do_configure_partition(cls, part, source_params, image_creator,
110 image_creator_workdir, oe_builddir, bootimg_dir,
111 kernel_dir, native_sysroot):
112 """
113 Creates syslinux config in rootfs directory
114
115 Called before do_prepare_partition()
116 """
117 bootloader = image_creator.ks.bootloader
118
119 syslinux_conf = ""
120 syslinux_conf += "PROMPT 0\n"
121
122 syslinux_conf += "TIMEOUT " + str(bootloader.timeout) + "\n"
123 syslinux_conf += "ALLOWOPTIONS 1\n"
124
125 # Derive SERIAL... line from from kernel boot parameters
126 syslinux_conf += serial_console_form_kargs(options) + "\n"
127
128 syslinux_conf += "DEFAULT linux\n"
129 syslinux_conf += "LABEL linux\n"
130 syslinux_conf += " KERNEL /boot/bzImage\n"
131
132 syslinux_conf += " APPEND label=boot root=%s %s\n" % \
133 (image_creator.rootdev, bootloader.append)
134
135 syslinux_cfg = os.path.join(image_creator.rootfs_dir['ROOTFS_DIR'], "boot", "syslinux.cfg")
136 logger.debug("Writing syslinux config %s", syslinux_cfg)
137 with open(syslinux_cfg, "w") as cfg:
138 cfg.write(syslinux_conf)
139
140 @classmethod
141 def do_prepare_partition(cls, part, source_params, image_creator,
142 image_creator_workdir, oe_builddir, bootimg_dir,
143 kernel_dir, krootfs_dir, native_sysroot):
144 """
145 Creates partition out of rootfs directory
146
147 Prepare content for a rootfs partition i.e. create a partition
148 and fill it from a /rootfs dir.
149 Install syslinux bootloader into root partition image file
150 """
151 def is_exe(exepath):
152 """Verify exepath is an executable file"""
153 return os.path.isfile(exepath) and os.access(exepath, os.X_OK)
154
155 # Make sure syslinux-nomtools is available in native sysroot or fail
156 native_syslinux_nomtools = os.path.join(native_sysroot, "usr/bin/syslinux-nomtools")
157 if not is_exe(native_syslinux_nomtools):
158 logger.info("building syslinux-native...")
159 exec_cmd("bitbake syslinux-native")
160 if not is_exe(native_syslinux_nomtools):
161 raise WicError("Couldn't find syslinux-nomtools (%s), exiting" %
162 native_syslinux_nomtools)
163
164 if part.rootfs is None:
165 if 'ROOTFS_DIR' not in krootfs_dir:
166 raise WicError("Couldn't find --rootfs-dir, exiting")
167 rootfs_dir = krootfs_dir['ROOTFS_DIR']
168 else:
169 if part.rootfs in krootfs_dir:
170 rootfs_dir = krootfs_dir[part.rootfs]
171 elif part.rootfs:
172 rootfs_dir = part.rootfs
173 else:
174 raise WicError("Couldn't find --rootfs-dir=%s connection or "
175 "it is not a valid path, exiting" % part.rootfs)
176
177 real_rootfs_dir = cls._get_rootfs_dir(rootfs_dir)
178
179 part.rootfs_dir = real_rootfs_dir
180 part.prepare_rootfs(image_creator_workdir, oe_builddir, real_rootfs_dir, native_sysroot)
181
182 # install syslinux into rootfs partition
183 syslinux_cmd = "syslinux-nomtools -d /boot -i %s" % part.source_file
184 exec_native_cmd(syslinux_cmd, native_sysroot)
185
186 @classmethod
187 def do_install_disk(cls, disk, disk_name, image_creator, workdir, oe_builddir,
188 bootimg_dir, kernel_dir, native_sysroot):
189 """
190 Assemble partitions to disk image
191
192 Called after all partitions have been prepared and assembled into a
193 disk image. In this case, we install the MBR.
194 """
195 mbrfile = os.path.join(native_sysroot, "usr/share/syslinux/")
196 if image_creator.ptable_format == 'msdos':
197 mbrfile += "mbr.bin"
198 elif image_creator.ptable_format == 'gpt':
199 mbrfile += "gptmbr.bin"
200 else:
201 raise WicError("Unsupported partition table: %s" %
202 image_creator.ptable_format)
203
204 if not os.path.exists(mbrfile):
205 raise WicError("Couldn't find %s. Has syslinux-native been baked?",
206 mbrfile)
207 full_path = disk.path
208 logger.debug("Installing MBR on disk %s as %s with size %s bytes",
209 disk_name, full_path, disk.min_size)
210
211 ret_code = runner.show(['dd', 'if=%s' % mbrfile, 'of=%s' % full_path, 'conv=notrunc'])
212 if ret_code != 0:
213 raise WicError("Unable to set MBR to %s" % full_path)