summaryrefslogtreecommitdiffstats
path: root/documentation/dev-manual
diff options
context:
space:
mode:
authorScott Rifenbark <srifenbark@gmail.com>2018-01-10 11:36:56 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-02-14 15:25:27 +0000
commit8097a978cef998d82cc1e35e94b090b0c8bb264f (patch)
tree0e725c2d08c6961c1ace67139dbb5ce91429fb06 /documentation/dev-manual
parente2060287db8093b53d2d18a217c0c463eb6b0c86 (diff)
downloadpoky-8097a978cef998d82cc1e35e94b090b0c8bb264f.tar.gz
dev-manual, ref-manual: Moved Wic Plug-In section to dev-manual
Fixes [YOCTO #12370] I had a section on Wick Plug-Ins in the ref-manual in the "technical details" chapter. This section has been combined with the section on using Wic that lives in the dev-manual. This move creates a single section on using Wic to create Wic-partitioned images. The section was moved out of the ref-manual and merged into the dev-manual Wic section. (From yocto-docs rev: 8724049141c9a793312dcf5ff5c3425948d1cbd0) Signed-off-by: Scott Rifenbark <srifenbark@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/dev-manual')
-rw-r--r--documentation/dev-manual/dev-manual-common-tasks.xml213
1 files changed, 209 insertions, 4 deletions
diff --git a/documentation/dev-manual/dev-manual-common-tasks.xml b/documentation/dev-manual/dev-manual-common-tasks.xml
index 58bb6012ce..78825c7f1e 100644
--- a/documentation/dev-manual/dev-manual-common-tasks.xml
+++ b/documentation/dev-manual/dev-manual-common-tasks.xml
@@ -4878,16 +4878,17 @@
4878 customized images, and as such, was designed to be 4878 customized images, and as such, was designed to be
4879 completely extensible through a plug-in interface. 4879 completely extensible through a plug-in interface.
4880 See the 4880 See the
4881 "<ulink url='&YOCTO_DOCS_REF_URL;#wic-plug-ins-interface'>Wic Plug-Ins Interface</ulink>" 4881 "<link linkend='wic-using-the-wic-plug-ins-interface'>Using the Wic Plug-Ins Interface</link>"
4882 section in the Yocto Project Reference Manual for information 4882 section for information on these plug-ins.
4883 on these plug-ins.
4884 </para> 4883 </para>
4885 4884
4886 <para> 4885 <para>
4887 This section provides some background information on Wic, 4886 This section provides some background information on Wic,
4888 describes what you need to have in 4887 describes what you need to have in
4889 place to run the tool, provides instruction on how to use 4888 place to run the tool, provides instruction on how to use
4890 the Wic utility, and provides several examples. 4889 the Wic utility, provides information on using the Wic plug-ins
4890 interface, and provides several examples that show how to use
4891 Wic.
4891 </para> 4892 </para>
4892 4893
4893 <section id='wic-background'> 4894 <section id='wic-background'>
@@ -5265,6 +5266,210 @@
5265 </para> 5266 </para>
5266 </section> 5267 </section>
5267 5268
5269 <section id='wic-using-the-wic-plug-ins-interface'>
5270 <title>Using the Wic Plug-Ins Interface</title>
5271
5272 <para>
5273 You can extend and specialize Wic functionality by using
5274 Wic plug-ins.
5275 This section explains the Wic plug-in interface.
5276 <note>
5277 Wic plug-ins consist of "source" and "imager" plug-ins.
5278 Imager plug-ins are beyond the scope of this section.
5279 </note>
5280 </para>
5281
5282 <para>
5283 Source plug-ins provide a mechanism to customize partition
5284 content during the Wic image generation process.
5285 You can use source plug-ins to map values that you specify
5286 using <filename>--source</filename> commands in kickstart
5287 files (i.e. <filename>*.wks</filename>) to a plug-in
5288 implementation used to populate a given partition.
5289 <note>
5290 If you use plug-ins that have build-time dependencies
5291 (e.g. native tools, bootloaders, and so forth)
5292 when building a Wic image, you need to specify those
5293 dependencies using the
5294 <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE_DEPENDS'><filename>WKS_FILE_DEPENDS</filename></ulink>
5295 variable.
5296 </note>
5297 </para>
5298
5299 <para>
5300 Source plug-ins are subclasses defined in plug-in files.
5301 As shipped, the Yocto Project provides several plug-in
5302 files.
5303 You can see the source plug-in files that ship with the
5304 Yocto Project
5305 <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/source'>here</ulink>.
5306 Each of these plug-in files contains source plug-ins that
5307 are designed to populate a specific Wic image partition.
5308 </para>
5309
5310 <para>
5311 Source plug-ins are subclasses of the
5312 <filename>SourcePlugin</filename> class, which is
5313 defined in the
5314 <filename>poky/scripts/lib/wic/pluginbase.py</filename>
5315 file.
5316 For example, the <filename>BootimgEFIPlugin</filename>
5317 source plug-in found in the
5318 <filename>bootimg-efi.py</filename> file is a subclass of
5319 the <filename>SourcePlugin</filename> class, which is found
5320 in the <filename>pluginbase.py</filename> file.
5321 </para>
5322
5323 <para>
5324 You can also implement source plug-ins in a layer outside
5325 of the Source Repositories (external layer).
5326 To do so, be sure that your plug-in files are located in
5327 a directory whose path is
5328 <filename>scripts/lib/wic/plugins/source/</filename>
5329 within your external layer.
5330 When the plug-in files are located there, the source
5331 plug-ins they contain are made available to Wic.
5332 </para>
5333
5334 <para>
5335 When the Wic implementation needs to invoke a
5336 partition-specific implementation, it looks for the plug-in
5337 with the same name as the <filename>--source</filename>
5338 parameter used in the kickstart file given to that
5339 partition.
5340 For example, if the partition is set up using the following
5341 command in a kickstart file:
5342 <literallayout class='monospaced'>
5343 part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024
5344 </literallayout>
5345 The methods defined as class members of the matching
5346 source plug-in (i.e. <filename>bootimg-pcbios</filename>)
5347 in the <filename>bootimg-pcbios.py</filename> plug-in file
5348 are used.
5349 </para>
5350
5351 <para>
5352 To be more concrete, here is the corresponding plug-in
5353 definition from the <filename>bootimg-pcbios.py</filename>
5354 file for the previous command along with an example
5355 method called by the Wic implementation when it needs to
5356 prepare a partition using an implementation-specific
5357 function:
5358 <literallayout class='monospaced'>
5359 bootimg-pcbios.py
5360 .
5361 .
5362 .
5363 class BootimgPcbiosPlugin(SourcePlugin):
5364 """
5365 Create MBR boot partition and install syslinux on it.
5366 """
5367
5368 name = 'bootimg-pcbios'
5369 .
5370 .
5371 .
5372 @classmethod
5373 def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
5374 oe_builddir, bootimg_dir, kernel_dir,
5375 rootfs_dir, native_sysroot):
5376 """
5377 Called to do the actual content population for a partition i.e. it
5378 'prepares' the partition to be incorporated into the image.
5379 In this case, prepare content for legacy bios boot partition.
5380 """
5381 .
5382 .
5383 .
5384 </literallayout>
5385 If a subclass (plug-in) itself does not implement a
5386 particular function, Wic locates and uses the default
5387 version in the superclass.
5388 It is for this reason that all source plug-ins are derived
5389 from the <filename>SourcePlugin</filename> class.
5390 </para>
5391
5392 <para>
5393 The <filename>SourcePlugin</filename> class defined in
5394 the <filename>pluginbase.py</filename> file defines
5395 a set of methods that source plug-ins can implement or
5396 override.
5397 Any plug-ins (subclass of
5398 <filename>SourcePlugin</filename>) that do not implement
5399 a particular method inherit the implementation of the
5400 method from the <filename>SourcePlugin</filename> class.
5401 For more information, see the
5402 <filename>SourcePlugin</filename> class in the
5403 <filename>pluginbase.py</filename> file for details:
5404 </para>
5405
5406 <para>
5407 The following list describes the methods implemented in the
5408 <filename>SourcePlugin</filename> class:
5409 <itemizedlist>
5410 <listitem><para>
5411 <emphasis><filename>do_prepare_partition()</filename>:</emphasis>
5412 Called to populate a partition with actual content.
5413 In other words, the method prepares the final
5414 partition image that is incorporated into the
5415 disk image.
5416 </para></listitem>
5417 <listitem><para>
5418 <emphasis><filename>do_configure_partition()</filename>:</emphasis>
5419 Called before
5420 <filename>do_prepare_partition()</filename> to
5421 create custom configuration files for a partition
5422 (e.g. syslinux or grub configuration files).
5423 </para></listitem>
5424 <listitem><para>
5425 <emphasis><filename>do_install_disk()</filename>:</emphasis>
5426 Called after all partitions have been prepared and
5427 assembled into a disk image.
5428 This method provides a hook to allow finalization
5429 of a disk image (e.g. writing an MBR).
5430 </para></listitem>
5431 <listitem><para>
5432 <emphasis><filename>do_stage_partition()</filename>:</emphasis>
5433 Special content-staging hook called before
5434 <filename>do_prepare_partition()</filename>.
5435 This method is normally empty.</para>
5436
5437 <para>Typically, a partition just uses the passed-in
5438 parameters (e.g. the unmodified value of
5439 <filename>bootimg_dir</filename>).
5440 However, in some cases, things might need to be
5441 more tailored.
5442 As an example, certain files might additionally
5443 need to be taken from
5444 <filename>bootimg_dir + /boot</filename>.
5445 This hook allows those files to be staged in a
5446 customized fashion.
5447 <note>
5448 <filename>get_bitbake_var()</filename>
5449 allows you to access non-standard variables
5450 that you might want to use for this
5451 behavior.
5452 </note>
5453 </para></listitem>
5454 </itemizedlist>
5455 </para>
5456
5457 <para>
5458 You can extend the source plug-in mechanism.
5459 To add more hooks, create more source plug-in methods
5460 within <filename>SourcePlugin</filename> and the
5461 corresponding derived subclasses.
5462 The code that calls the plug-in methods uses the
5463 <filename>plugin.get_source_plugin_methods()</filename>
5464 function to find the method or methods needed by the call.
5465 Retrieval of those methods is accomplished by filling up
5466 a dict with keys that contain the method names of interest.
5467 On success, these will be filled in with the actual
5468 methods.
5469 See the Wic implementation for examples and details.
5470 </para>
5471 </section>
5472
5268 <section id='wic-usage-examples'> 5473 <section id='wic-usage-examples'>
5269 <title>Examples</title> 5474 <title>Examples</title>
5270 5475