diff options
| author | Scott Rifenbark <srifenbark@gmail.com> | 2017-10-11 13:29:14 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-10-16 23:46:52 +0100 |
| commit | 6077ebbe806bb232e3d96b0f138e1f4748e5ef5b (patch) | |
| tree | f875bca0e44753c576cf2e67879e83e573919ff4 /documentation/ref-manual | |
| parent | 6cee5c8b9b07b1c660e8fdea7a3cb85d4ac238f6 (diff) | |
| download | poky-6077ebbe806bb232e3d96b0f138e1f4748e5ef5b.tar.gz | |
ref-manual, dev-manual: Moved plug-in section for wic to ref-manual
Fixed links affected by the move.
(From yocto-docs rev: 250d312274788b0eebf3ae9143f2f89eafd4ab90)
Signed-off-by: Scott Rifenbark <srifenbark@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/ref-manual')
| -rw-r--r-- | documentation/ref-manual/technical-details.xml | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/documentation/ref-manual/technical-details.xml b/documentation/ref-manual/technical-details.xml index f566ec243a..0cfc6e675e 100644 --- a/documentation/ref-manual/technical-details.xml +++ b/documentation/ref-manual/technical-details.xml | |||
| @@ -1252,6 +1252,213 @@ | |||
| 1252 | </para> | 1252 | </para> |
| 1253 | </section> | 1253 | </section> |
| 1254 | 1254 | ||
| 1255 | <section id='wic-plug-ins-interface'> | ||
| 1256 | <title>Wic Plug-Ins Interface</title> | ||
| 1257 | |||
| 1258 | <para> | ||
| 1259 | You can extend and specialize Wic functionality by using | ||
| 1260 | Wic plug-ins. | ||
| 1261 | This section explains the Wic plug-in interface. | ||
| 1262 | For information on using Wic in general, see the | ||
| 1263 | "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-partitioned-images'>Creating Partitioned Images</ulink>" | ||
| 1264 | section in the Yocto Project Development Manual. | ||
| 1265 | <note> | ||
| 1266 | Wic plug-ins consist of "source" and "imager" plug-ins. | ||
| 1267 | Imager plug-ins are beyond the scope of this section. | ||
| 1268 | </note> | ||
| 1269 | </para> | ||
| 1270 | |||
| 1271 | <para> | ||
| 1272 | Source plug-ins provide a mechanism to customize partition | ||
| 1273 | content during the Wic image generation process. | ||
| 1274 | You can use source plug-ins to map values that you specify | ||
| 1275 | using <filename>--source</filename> commands in kickstart | ||
| 1276 | files (i.e. <filename>*.wks</filename>) to a plug-in | ||
| 1277 | implementation used to populate a given partition. | ||
| 1278 | <note> | ||
| 1279 | If you use plug-ins that have build-time dependencies | ||
| 1280 | (e.g. native tools, bootloaders, and so forth) | ||
| 1281 | when building a Wic image, you need to specify those | ||
| 1282 | dependencies using the | ||
| 1283 | <link linkend='var-WKS_FILE_DEPENDS'><filename>WKS_FILE_DEPENDS</filename></link> | ||
| 1284 | variable. | ||
| 1285 | </note> | ||
| 1286 | </para> | ||
| 1287 | |||
| 1288 | <para> | ||
| 1289 | Source plug-ins are subclasses defined in plug-in files. | ||
| 1290 | As shipped, the Yocto Project provides several plug-in | ||
| 1291 | files. | ||
| 1292 | You can see the source plug-in files that ship with the | ||
| 1293 | Yocto Project | ||
| 1294 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/source'>here</ulink>. | ||
| 1295 | Each of these plug-in files contain source plug-ins that | ||
| 1296 | are designed to populate a specific Wic image partition. | ||
| 1297 | </para> | ||
| 1298 | |||
| 1299 | <para> | ||
| 1300 | Source plug-ins are subclasses of the | ||
| 1301 | <filename>SourcePlugin</filename> class, which is | ||
| 1302 | defined in the | ||
| 1303 | <filename>poky/scripts/lib/wic/pluginbase.py</filename> | ||
| 1304 | file. | ||
| 1305 | For example, the <filename>BootimgEFIPlugin</filename> | ||
| 1306 | source plug-in found in the | ||
| 1307 | <filename>bootimg-efi.py</filename> file is a subclass of | ||
| 1308 | the <filename>SourcePlugin</filename> class, which is found | ||
| 1309 | in the <filename>pluginbase.py</filename> file. | ||
| 1310 | </para> | ||
| 1311 | |||
| 1312 | <para> | ||
| 1313 | You can also implement source plug-ins in a layer outside | ||
| 1314 | of the Source Repositories (external layer). | ||
| 1315 | To do so, be sure that your plug-in files are located in | ||
| 1316 | a directory whose path is | ||
| 1317 | <filename>scripts/lib/wic/plugins/source/</filename> | ||
| 1318 | within your external layer. | ||
| 1319 | When the plug-in files are located there, the source | ||
| 1320 | plug-ins they contain are made available to Wic. | ||
| 1321 | </para> | ||
| 1322 | |||
| 1323 | <para> | ||
| 1324 | When the Wic implementation needs to invoke a | ||
| 1325 | partition-specific implementation, it looks for the plug-in | ||
| 1326 | with the same name as the <filename>--source</filename> | ||
| 1327 | parameter used in the kickstart file given to that | ||
| 1328 | partition. | ||
| 1329 | For example, if the partition is set up using the following | ||
| 1330 | command in a kickstart file: | ||
| 1331 | <literallayout class='monospaced'> | ||
| 1332 | part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024 | ||
| 1333 | </literallayout> | ||
| 1334 | The methods defined as class members of the matching | ||
| 1335 | source plug-in (i.e. <filename>bootimg-pcbios</filename>) | ||
| 1336 | in the <filename>bootimg-pcbios.py</filename> plug-in file | ||
| 1337 | are used. | ||
| 1338 | </para> | ||
| 1339 | |||
| 1340 | <para> | ||
| 1341 | To be more concrete, here is the corresponding plug-in | ||
| 1342 | definition from the <filename>bootimg-pcbios.py</filename> | ||
| 1343 | file for the previous command along with an example | ||
| 1344 | method called by the Wic implementation when it needs to | ||
| 1345 | prepare a partition using an implementation-specific | ||
| 1346 | function: | ||
| 1347 | <literallayout class='monospaced'> | ||
| 1348 | bootimg-pcbios.py | ||
| 1349 | . | ||
| 1350 | . | ||
| 1351 | . | ||
| 1352 | class BootimgPcbiosPlugin(SourcePlugin): | ||
| 1353 | """ | ||
| 1354 | Create MBR boot partition and install syslinux on it. | ||
| 1355 | """ | ||
| 1356 | |||
| 1357 | name = 'bootimg-pcbios' | ||
| 1358 | . | ||
| 1359 | . | ||
| 1360 | . | ||
| 1361 | @classmethod | ||
| 1362 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, | ||
| 1363 | oe_builddir, bootimg_dir, kernel_dir, | ||
| 1364 | rootfs_dir, native_sysroot): | ||
| 1365 | """ | ||
| 1366 | Called to do the actual content population for a partition i.e. it | ||
| 1367 | 'prepares' the partition to be incorporated into the image. | ||
| 1368 | In this case, prepare content for legacy bios boot partition. | ||
| 1369 | """ | ||
| 1370 | . | ||
| 1371 | . | ||
| 1372 | . | ||
| 1373 | </literallayout> | ||
| 1374 | If a subclass (plug-in) itself does not implement a | ||
| 1375 | particular function, Wic locates and uses the default | ||
| 1376 | version in the superclass. | ||
| 1377 | It is for this reason that all source plug-ins are derived | ||
| 1378 | from the <filename>SourcePlugin</filename> class. | ||
| 1379 | </para> | ||
| 1380 | |||
| 1381 | <para> | ||
| 1382 | The <filename>SourcePlugin</filename> class defined in | ||
| 1383 | the <filename>pluginbase.py</filename> file defines | ||
| 1384 | a set of methods that source plug-ins can implement or | ||
| 1385 | override. | ||
| 1386 | Any plug-ins (subclass of | ||
| 1387 | <filename>SourcePlugin</filename>) that do not implement | ||
| 1388 | a particular method inherit the implementation of the | ||
| 1389 | method from the <filename>SourcePlugin</filename> class. | ||
| 1390 | For more information, see the | ||
| 1391 | <filename>SourcePlugin</filename> class in the | ||
| 1392 | <filename>pluginbase.py</filename> file for details: | ||
| 1393 | </para> | ||
| 1394 | |||
| 1395 | <para> | ||
| 1396 | The following list describes the methods implemented in the | ||
| 1397 | <filename>SourcePlugin</filename> class: | ||
| 1398 | <itemizedlist> | ||
| 1399 | <listitem><para> | ||
| 1400 | <emphasis><filename>do_prepare_partition()</filename>:</emphasis> | ||
| 1401 | Called to populate a partition with actual content. | ||
| 1402 | In other words, the method prepares the final | ||
| 1403 | partition image that is incorporated into the | ||
| 1404 | disk image. | ||
| 1405 | </para></listitem> | ||
| 1406 | <listitem><para> | ||
| 1407 | <emphasis><filename>do_configure_partition()</filename>:</emphasis> | ||
| 1408 | Called before | ||
| 1409 | <filename>do_prepare_partition()</filename> to | ||
| 1410 | create custom configuration files for a partition | ||
| 1411 | (e.g. syslinux or grub configuration files). | ||
| 1412 | </para></listitem> | ||
| 1413 | <listitem><para> | ||
| 1414 | <emphasis><filename>do_install_disk()</filename>:</emphasis> | ||
| 1415 | Called after all partitions have been prepared and | ||
| 1416 | assembled into a disk image. | ||
| 1417 | This method provides a hook to allow finalization | ||
| 1418 | of a disk image (e.g. writing an MBR). | ||
| 1419 | </para></listitem> | ||
| 1420 | <listitem><para> | ||
| 1421 | <emphasis><filename>do_stage_partition()</filename>:</emphasis> | ||
| 1422 | Special content-staging hook called before | ||
| 1423 | <filename>do_prepare_partition()</filename>. | ||
| 1424 | This method is normally empty.</para> | ||
| 1425 | |||
| 1426 | <para>Typically, a partition just uses the passed-in | ||
| 1427 | parameters (e.g. the unmodified value of | ||
| 1428 | <filename>bootimg_dir</filename>). | ||
| 1429 | However, in some cases, things might need to be | ||
| 1430 | more tailored. | ||
| 1431 | As an example, certain files might additionally | ||
| 1432 | need to be taken from | ||
| 1433 | <filename>bootimg_dir + /boot</filename>. | ||
| 1434 | This hook allows those files to be staged in a | ||
| 1435 | customized fashion. | ||
| 1436 | <note> | ||
| 1437 | <filename>get_bitbake_var()</filename> | ||
| 1438 | allows you to access non-standard variables | ||
| 1439 | that you might want to use for this | ||
| 1440 | behavior. | ||
| 1441 | </note> | ||
| 1442 | </para></listitem> | ||
| 1443 | </itemizedlist> | ||
| 1444 | </para> | ||
| 1445 | |||
| 1446 | <para> | ||
| 1447 | You can extend the source plug-in mechanism. | ||
| 1448 | To add more hooks, create more source plug-in methods | ||
| 1449 | within <filename>SourcePlugin</filename> and the | ||
| 1450 | corresponding derived subclasses. | ||
| 1451 | The code that calls the plug-in methods uses the | ||
| 1452 | <filename>plugin.get_source_plugin_methods()</filename> | ||
| 1453 | function to find the method or methods needed by the call. | ||
| 1454 | Retrieval of those methods is accomplished by filling up | ||
| 1455 | a dict with keys that contain the method names of interest. | ||
| 1456 | On success, these will be filled in with the actual | ||
| 1457 | methods. | ||
| 1458 | See the Wic implementation for examples and details. | ||
| 1459 | </para> | ||
| 1460 | </section> | ||
| 1461 | |||
| 1255 | <section id='x32'> | 1462 | <section id='x32'> |
| 1256 | <title>x32</title> | 1463 | <title>x32</title> |
| 1257 | 1464 | ||
