Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # ex:ts=4:sw=4:sts=4:et |
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- |
| 3 | # |
| 4 | # Copyright (c) 2013, Intel Corporation. |
| 5 | # All rights reserved. |
| 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License version 2 as |
| 9 | # published by the Free Software Foundation. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License along |
| 17 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | # |
| 20 | # DESCRIPTION |
| 21 | # This module implements some basic help invocation functions along |
| 22 | # with the bulk of the help topic text for the OE Core Image Tools. |
| 23 | # |
| 24 | # AUTHORS |
| 25 | # Tom Zanussi <tom.zanussi (at] linux.intel.com> |
| 26 | # |
| 27 | |
| 28 | import subprocess |
| 29 | import logging |
| 30 | |
| 31 | from wic.plugin import pluginmgr, PLUGIN_TYPES |
| 32 | |
| 33 | def subcommand_error(args): |
| 34 | logging.info("invalid subcommand %s" % args[0]) |
| 35 | |
| 36 | |
| 37 | def display_help(subcommand, subcommands): |
| 38 | """ |
| 39 | Display help for subcommand. |
| 40 | """ |
| 41 | if subcommand not in subcommands: |
| 42 | return False |
| 43 | |
| 44 | hlp = subcommands.get(subcommand, subcommand_error)[2] |
| 45 | if callable(hlp): |
| 46 | hlp = hlp() |
| 47 | pager = subprocess.Popen('less', stdin=subprocess.PIPE) |
| 48 | pager.communicate(hlp) |
| 49 | |
| 50 | return True |
| 51 | |
| 52 | |
| 53 | def wic_help(args, usage_str, subcommands): |
| 54 | """ |
| 55 | Subcommand help dispatcher. |
| 56 | """ |
| 57 | if len(args) == 1 or not display_help(args[1], subcommands): |
| 58 | print usage_str |
| 59 | |
| 60 | |
| 61 | def get_wic_plugins_help(): |
| 62 | """ |
| 63 | Combine wic_plugins_help with the help for every known |
| 64 | source plugin. |
| 65 | """ |
| 66 | result = wic_plugins_help |
| 67 | for plugin_type in PLUGIN_TYPES: |
| 68 | result += '\n\n%s PLUGINS\n\n' % plugin_type.upper() |
| 69 | for name, plugin in pluginmgr.get_plugins(plugin_type).iteritems(): |
| 70 | result += "\n %s plugin:\n" % name |
| 71 | if plugin.__doc__: |
| 72 | result += plugin.__doc__ |
| 73 | else: |
| 74 | result += "\n %s is missing docstring\n" % plugin |
| 75 | return result |
| 76 | |
| 77 | |
| 78 | def invoke_subcommand(args, parser, main_command_usage, subcommands): |
| 79 | """ |
| 80 | Dispatch to subcommand handler borrowed from combo-layer. |
| 81 | Should use argparse, but has to work in 2.6. |
| 82 | """ |
| 83 | if not args: |
| 84 | logging.error("No subcommand specified, exiting") |
| 85 | parser.print_help() |
| 86 | return 1 |
| 87 | elif args[0] == "help": |
| 88 | wic_help(args, main_command_usage, subcommands) |
| 89 | elif args[0] not in subcommands: |
| 90 | logging.error("Unsupported subcommand %s, exiting\n" % (args[0])) |
| 91 | parser.print_help() |
| 92 | return 1 |
| 93 | else: |
| 94 | usage = subcommands.get(args[0], subcommand_error)[1] |
| 95 | subcommands.get(args[0], subcommand_error)[0](args[1:], usage) |
| 96 | |
| 97 | |
| 98 | ## |
| 99 | # wic help and usage strings |
| 100 | ## |
| 101 | |
| 102 | wic_usage = """ |
| 103 | |
| 104 | Create a customized OpenEmbedded image |
| 105 | |
| 106 | usage: wic [--version] | [--help] | [COMMAND [ARGS]] |
| 107 | |
| 108 | Current 'wic' commands are: |
| 109 | help Show help for command or one of the topics (see below) |
| 110 | create Create a new OpenEmbedded image |
| 111 | list List available canned images and source plugins |
| 112 | |
| 113 | Help topics: |
| 114 | overview wic overview - General overview of wic |
| 115 | plugins wic plugins - Overview and API |
| 116 | kickstart wic kickstart - wic kickstart reference |
| 117 | """ |
| 118 | |
| 119 | wic_help_usage = """ |
| 120 | |
| 121 | usage: wic help <subcommand> |
| 122 | |
| 123 | This command displays detailed help for the specified subcommand. |
| 124 | """ |
| 125 | |
| 126 | wic_create_usage = """ |
| 127 | |
| 128 | Create a new OpenEmbedded image |
| 129 | |
| 130 | usage: wic create <wks file or image name> [-o <DIRNAME> | --outdir <DIRNAME>] |
| 131 | [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>] |
| 132 | [-e | --image-name] [-s, --skip-build-check] [-D, --debug] |
| 133 | [-r, --rootfs-dir] [-b, --bootimg-dir] |
| 134 | [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] |
| 135 | |
| 136 | This command creates an OpenEmbedded image based on the 'OE kickstart |
| 137 | commands' found in the <wks file>. |
| 138 | |
| 139 | The -o option can be used to place the image in a directory with a |
| 140 | different name and location. |
| 141 | |
| 142 | See 'wic help create' for more detailed instructions. |
| 143 | """ |
| 144 | |
| 145 | wic_create_help = """ |
| 146 | |
| 147 | NAME |
| 148 | wic create - Create a new OpenEmbedded image |
| 149 | |
| 150 | SYNOPSIS |
| 151 | wic create <wks file or image name> [-o <DIRNAME> | --outdir <DIRNAME>] |
| 152 | [-e | --image-name] [-s, --skip-build-check] [-D, --debug] |
| 153 | [-r, --rootfs-dir] [-b, --bootimg-dir] |
| 154 | [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] |
| 155 | [-c, --compress-with] |
| 156 | |
| 157 | DESCRIPTION |
| 158 | This command creates an OpenEmbedded image based on the 'OE |
| 159 | kickstart commands' found in the <wks file>. |
| 160 | |
| 161 | In order to do this, wic needs to know the locations of the |
| 162 | various build artifacts required to build the image. |
| 163 | |
| 164 | Users can explicitly specify the build artifact locations using |
| 165 | the -r, -b, -k, and -n options. See below for details on where |
| 166 | the corresponding artifacts are typically found in a normal |
| 167 | OpenEmbedded build. |
| 168 | |
| 169 | Alternatively, users can use the -e option to have 'wic' determine |
| 170 | those locations for a given image. If the -e option is used, the |
| 171 | user needs to have set the appropriate MACHINE variable in |
| 172 | local.conf, and have sourced the build environment. |
| 173 | |
| 174 | The -e option is used to specify the name of the image to use the |
| 175 | artifacts from e.g. core-image-sato. |
| 176 | |
| 177 | The -r option is used to specify the path to the /rootfs dir to |
| 178 | use as the .wks rootfs source. |
| 179 | |
| 180 | The -b option is used to specify the path to the dir containing |
| 181 | the boot artifacts (e.g. /EFI or /syslinux dirs) to use as the |
| 182 | .wks bootimg source. |
| 183 | |
| 184 | The -k option is used to specify the path to the dir containing |
| 185 | the kernel to use in the .wks bootimg. |
| 186 | |
| 187 | The -n option is used to specify the path to the native sysroot |
| 188 | containing the tools to use to build the image. |
| 189 | |
| 190 | The -f option is used to build rootfs by running "bitbake <image>" |
| 191 | |
| 192 | The -s option is used to skip the build check. The build check is |
| 193 | a simple sanity check used to determine whether the user has |
| 194 | sourced the build environment so that the -e option can operate |
| 195 | correctly. If the user has specified the build artifact locations |
| 196 | explicitly, 'wic' assumes the user knows what he or she is doing |
| 197 | and skips the build check. |
| 198 | |
| 199 | The -D option is used to display debug information detailing |
| 200 | exactly what happens behind the scenes when a create request is |
| 201 | fulfilled (or not, as the case may be). It enumerates and |
| 202 | displays the command sequence used, and should be included in any |
| 203 | bug report describing unexpected results. |
| 204 | |
| 205 | When 'wic -e' is used, the locations for the build artifacts |
| 206 | values are determined by 'wic -e' from the output of the 'bitbake |
| 207 | -e' command given an image name e.g. 'core-image-minimal' and a |
| 208 | given machine set in local.conf. In that case, the image is |
| 209 | created as if the following 'bitbake -e' variables were used: |
| 210 | |
| 211 | -r: IMAGE_ROOTFS |
| 212 | -k: STAGING_KERNEL_DIR |
| 213 | -n: STAGING_DIR_NATIVE |
| 214 | -b: empty (plugin-specific handlers must determine this) |
| 215 | |
| 216 | If 'wic -e' is not used, the user needs to select the appropriate |
| 217 | value for -b (as well as -r, -k, and -n). |
| 218 | |
| 219 | The -o option can be used to place the image in a directory with a |
| 220 | different name and location. |
| 221 | |
| 222 | The -c option is used to specify compressor utility to compress |
| 223 | an image. gzip, bzip2 and xz compressors are supported. |
| 224 | """ |
| 225 | |
| 226 | wic_list_usage = """ |
| 227 | |
| 228 | List available OpenEmbedded images and source plugins |
| 229 | |
| 230 | usage: wic list images |
| 231 | wic list <image> help |
| 232 | wic list source-plugins |
| 233 | |
| 234 | This command enumerates the set of available canned images as well as |
| 235 | help for those images. It also can be used to list of available source |
| 236 | plugins. |
| 237 | |
| 238 | The first form enumerates all the available 'canned' images. |
| 239 | |
| 240 | The second form lists the detailed help information for a specific |
| 241 | 'canned' image. |
| 242 | |
| 243 | The third form enumerates all the available --sources (source |
| 244 | plugins). |
| 245 | |
| 246 | See 'wic help list' for more details. |
| 247 | """ |
| 248 | |
| 249 | wic_list_help = """ |
| 250 | |
| 251 | NAME |
| 252 | wic list - List available OpenEmbedded images and source plugins |
| 253 | |
| 254 | SYNOPSIS |
| 255 | wic list images |
| 256 | wic list <image> help |
| 257 | wic list source-plugins |
| 258 | |
| 259 | DESCRIPTION |
| 260 | This command enumerates the set of available canned images as well |
| 261 | as help for those images. It also can be used to list available |
| 262 | source plugins. |
| 263 | |
| 264 | The first form enumerates all the available 'canned' images. |
| 265 | These are actually just the set of .wks files that have been moved |
| 266 | into the /scripts/lib/wic/canned-wks directory). |
| 267 | |
| 268 | The second form lists the detailed help information for a specific |
| 269 | 'canned' image. |
| 270 | |
| 271 | The third form enumerates all the available --sources (source |
| 272 | plugins). The contents of a given partition are driven by code |
| 273 | defined in 'source plugins'. Users specify a specific plugin via |
| 274 | the --source parameter of the partition .wks command. Normally |
| 275 | this is the 'rootfs' plugin but can be any of the more specialized |
| 276 | sources listed by the 'list source-plugins' command. Users can |
| 277 | also add their own source plugins - see 'wic help plugins' for |
| 278 | details. |
| 279 | """ |
| 280 | |
| 281 | wic_plugins_help = """ |
| 282 | |
| 283 | NAME |
| 284 | wic plugins - Overview and API |
| 285 | |
| 286 | DESCRIPTION |
| 287 | plugins allow wic functionality to be extended and specialized by |
| 288 | users. This section documents the plugin interface, which is |
| 289 | currently restricted to 'source' plugins. |
| 290 | |
| 291 | 'Source' plugins provide a mechanism to customize various aspects |
| 292 | of the image generation process in wic, mainly the contents of |
| 293 | partitions. |
| 294 | |
| 295 | Source plugins provide a mechanism for mapping values specified in |
| 296 | .wks files using the --source keyword to a particular plugin |
| 297 | implementation that populates a corresponding partition. |
| 298 | |
| 299 | A source plugin is created as a subclass of SourcePlugin (see |
| 300 | scripts/lib/wic/pluginbase.py) and the plugin file containing it |
| 301 | is added to scripts/lib/wic/plugins/source/ to make the plugin |
| 302 | implementation available to the wic implementation. |
| 303 | |
| 304 | Source plugins can also be implemented and added by external |
| 305 | layers - any plugins found in a scripts/lib/wic/plugins/source/ |
| 306 | directory in an external layer will also be made available. |
| 307 | |
| 308 | When the wic implementation needs to invoke a partition-specific |
| 309 | implementation, it looks for the plugin that has the same name as |
| 310 | the --source param given to that partition. For example, if the |
| 311 | partition is set up like this: |
| 312 | |
| 313 | part /boot --source bootimg-pcbios ... |
| 314 | |
| 315 | then the methods defined as class members of the plugin having the |
| 316 | matching bootimg-pcbios .name class member would be used. |
| 317 | |
| 318 | To be more concrete, here's the plugin definition that would match |
| 319 | a '--source bootimg-pcbios' usage, along with an example method |
| 320 | that would be called by the wic implementation when it needed to |
| 321 | invoke an implementation-specific partition-preparation function: |
| 322 | |
| 323 | class BootimgPcbiosPlugin(SourcePlugin): |
| 324 | name = 'bootimg-pcbios' |
| 325 | |
| 326 | @classmethod |
| 327 | def do_prepare_partition(self, part, ...) |
| 328 | |
| 329 | If the subclass itself doesn't implement a function, a 'default' |
| 330 | version in a superclass will be located and used, which is why all |
| 331 | plugins must be derived from SourcePlugin. |
| 332 | |
| 333 | The SourcePlugin class defines the following methods, which is the |
| 334 | current set of methods that can be implemented/overridden by |
| 335 | --source plugins. Any methods not implemented by a SourcePlugin |
| 336 | subclass inherit the implementations present in the SourcePlugin |
| 337 | class (see the SourcePlugin source for details): |
| 338 | |
| 339 | do_prepare_partition() |
| 340 | Called to do the actual content population for a |
| 341 | partition. In other words, it 'prepares' the final partition |
| 342 | image which will be incorporated into the disk image. |
| 343 | |
| 344 | do_configure_partition() |
| 345 | Called before do_prepare_partition(), typically used to |
| 346 | create custom configuration files for a partition, for |
| 347 | example syslinux or grub config files. |
| 348 | |
| 349 | do_install_disk() |
| 350 | Called after all partitions have been prepared and assembled |
| 351 | into a disk image. This provides a hook to allow |
| 352 | finalization of a disk image, for example to write an MBR to |
| 353 | it. |
| 354 | |
| 355 | do_stage_partition() |
| 356 | Special content-staging hook called before |
| 357 | do_prepare_partition(), normally empty. |
| 358 | |
| 359 | Typically, a partition will just use the passed-in |
| 360 | parameters, for example the unmodified value of bootimg_dir. |
| 361 | In some cases however, things may need to be more tailored. |
| 362 | As an example, certain files may additionally need to be |
| 363 | take from bootimg_dir + /boot. This hook allows those files |
| 364 | to be staged in a customized fashion. Note that |
| 365 | get_bitbake_var() allows you to access non-standard |
| 366 | variables that you might want to use for these types of |
| 367 | situations. |
| 368 | |
| 369 | This scheme is extensible - adding more hooks is a simple matter |
| 370 | of adding more plugin methods to SourcePlugin and derived classes. |
| 371 | The code that then needs to call the plugin methods uses |
| 372 | plugin.get_source_plugin_methods() to find the method(s) needed by |
| 373 | the call; this is done by filling up a dict with keys containing |
| 374 | the method names of interest - on success, these will be filled in |
| 375 | with the actual methods. Please see the implementation for |
| 376 | examples and details. |
| 377 | """ |
| 378 | |
| 379 | wic_overview_help = """ |
| 380 | |
| 381 | NAME |
| 382 | wic overview - General overview of wic |
| 383 | |
| 384 | DESCRIPTION |
| 385 | The 'wic' command generates partitioned images from existing |
| 386 | OpenEmbedded build artifacts. Image generation is driven by |
| 387 | partitioning commands contained in an 'Openembedded kickstart' |
| 388 | (.wks) file (see 'wic help kickstart') specified either directly |
| 389 | on the command-line or as one of a selection of canned .wks files |
| 390 | (see 'wic list images'). When applied to a given set of build |
| 391 | artifacts, the result is an image or set of images that can be |
| 392 | directly written onto media and used on a particular system. |
| 393 | |
| 394 | The 'wic' command and the infrastructure it's based on is by |
| 395 | definition incomplete - its purpose is to allow the generation of |
| 396 | customized images, and as such was designed to be completely |
| 397 | extensible via a plugin interface (see 'wic help plugins'). |
| 398 | |
| 399 | Background and Motivation |
| 400 | |
| 401 | wic is meant to be a completely independent standalone utility |
| 402 | that initially provides easier-to-use and more flexible |
| 403 | replacements for a couple bits of existing functionality in |
| 404 | oe-core: directdisk.bbclass and mkefidisk.sh. The difference |
| 405 | between wic and those examples is that with wic the functionality |
| 406 | of those scripts is implemented by a general-purpose partitioning |
| 407 | 'language' based on Redhat kickstart syntax). |
| 408 | |
| 409 | The initial motivation and design considerations that lead to the |
| 410 | current tool are described exhaustively in Yocto Bug #3847 |
| 411 | (https://bugzilla.yoctoproject.org/show_bug.cgi?id=3847). |
| 412 | |
| 413 | Implementation and Examples |
| 414 | |
| 415 | wic can be used in two different modes, depending on how much |
| 416 | control the user needs in specifying the Openembedded build |
| 417 | artifacts that will be used in creating the image: 'raw' and |
| 418 | 'cooked'. |
| 419 | |
| 420 | If used in 'raw' mode, artifacts are explicitly specified via |
| 421 | command-line arguments (see example below). |
| 422 | |
| 423 | The more easily usable 'cooked' mode uses the current MACHINE |
| 424 | setting and a specified image name to automatically locate the |
| 425 | artifacts used to create the image. |
| 426 | |
| 427 | OE kickstart files (.wks) can of course be specified directly on |
| 428 | the command-line, but the user can also choose from a set of |
| 429 | 'canned' .wks files available via the 'wic list images' command |
| 430 | (example below). |
| 431 | |
| 432 | In any case, the prerequisite for generating any image is to have |
| 433 | the build artifacts already available. The below examples assume |
| 434 | the user has already build a 'core-image-minimal' for a specific |
| 435 | machine (future versions won't require this redundant step, but |
| 436 | for now that's typically how build artifacts get generated). |
| 437 | |
| 438 | The other prerequisite is to source the build environment: |
| 439 | |
| 440 | $ source oe-init-build-env |
| 441 | |
| 442 | To start out with, we'll generate an image from one of the canned |
| 443 | .wks files. The following generates a list of availailable |
| 444 | images: |
| 445 | |
| 446 | $ wic list images |
| 447 | mkefidisk Create an EFI disk image |
| 448 | directdisk Create a 'pcbios' direct disk image |
| 449 | |
| 450 | You can get more information about any of the available images by |
| 451 | typing 'wic list xxx help', where 'xxx' is one of the image names: |
| 452 | |
| 453 | $ wic list mkefidisk help |
| 454 | |
| 455 | Creates a partitioned EFI disk image that the user can directly dd |
| 456 | to boot media. |
| 457 | |
| 458 | At any time, you can get help on the 'wic' command or any |
| 459 | subcommand (currently 'list' and 'create'). For instance, to get |
| 460 | the description of 'wic create' command and its parameters: |
| 461 | |
| 462 | $ wic create |
| 463 | |
| 464 | Usage: |
| 465 | |
| 466 | Create a new OpenEmbedded image |
| 467 | |
| 468 | usage: wic create <wks file or image name> [-o <DIRNAME> | ...] |
| 469 | [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>] |
| 470 | [-e | --image-name] [-s, --skip-build-check] [-D, --debug] |
| 471 | [-r, --rootfs-dir] [-b, --bootimg-dir] [-k, --kernel-dir] |
| 472 | [-n, --native-sysroot] [-f, --build-rootfs] |
| 473 | |
| 474 | This command creates an OpenEmbedded image based on the 'OE |
| 475 | kickstart commands' found in the <wks file>. |
| 476 | |
| 477 | The -o option can be used to place the image in a directory |
| 478 | with a different name and location. |
| 479 | |
| 480 | See 'wic help create' for more detailed instructions. |
| 481 | ... |
| 482 | |
| 483 | As mentioned in the command, you can get even more detailed |
| 484 | information by adding 'help' to the above: |
| 485 | |
| 486 | $ wic help create |
| 487 | |
| 488 | So, the easiest way to create an image is to use the -e option |
| 489 | with a canned .wks file. To use the -e option, you need to |
| 490 | specify the image used to generate the artifacts and you actually |
| 491 | need to have the MACHINE used to build them specified in your |
| 492 | local.conf (these requirements aren't necessary if you aren't |
| 493 | using the -e options.) Below, we generate a directdisk image, |
| 494 | pointing the process at the core-image-minimal artifacts for the |
| 495 | current MACHINE: |
| 496 | |
| 497 | $ wic create directdisk -e core-image-minimal |
| 498 | |
| 499 | Checking basic build environment... |
| 500 | Done. |
| 501 | |
| 502 | Creating image(s)... |
| 503 | |
| 504 | Info: The new image(s) can be found here: |
| 505 | /var/tmp/wic/build/directdisk-201309252350-sda.direct |
| 506 | |
| 507 | The following build artifacts were used to create the image(s): |
| 508 | |
| 509 | ROOTFS_DIR: ... |
| 510 | BOOTIMG_DIR: ... |
| 511 | KERNEL_DIR: ... |
| 512 | NATIVE_SYSROOT: ... |
| 513 | |
| 514 | The image(s) were created using OE kickstart file: |
| 515 | .../scripts/lib/wic/canned-wks/directdisk.wks |
| 516 | |
| 517 | The output shows the name and location of the image created, and |
| 518 | so that you know exactly what was used to generate the image, each |
| 519 | of the artifacts and the kickstart file used. |
| 520 | |
| 521 | Similarly, you can create a 'mkefidisk' image in the same way |
| 522 | (notice that this example uses a different machine - because it's |
| 523 | using the -e option, you need to change the MACHINE in your |
| 524 | local.conf): |
| 525 | |
| 526 | $ wic create mkefidisk -e core-image-minimal |
| 527 | Checking basic build environment... |
| 528 | Done. |
| 529 | |
| 530 | Creating image(s)... |
| 531 | |
| 532 | Info: The new image(s) can be found here: |
| 533 | /var/tmp/wic/build/mkefidisk-201309260027-sda.direct |
| 534 | |
| 535 | ... |
| 536 | |
| 537 | Here's an example that doesn't take the easy way out and manually |
| 538 | specifies each build artifact, along with a non-canned .wks file, |
| 539 | and also uses the -o option to have wic create the output |
| 540 | somewhere other than the default /var/tmp/wic: |
| 541 | |
| 542 | $ wic create ./test.wks -o ./out --rootfs-dir |
| 543 | tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 544 | --bootimg-dir tmp/sysroots/qemux86-64/usr/share |
| 545 | --kernel-dir tmp/deploy/images/qemux86-64 |
| 546 | --native-sysroot tmp/sysroots/x86_64-linux |
| 547 | |
| 548 | Creating image(s)... |
| 549 | |
| 550 | Info: The new image(s) can be found here: |
| 551 | out/build/test-201507211313-sda.direct |
| 552 | |
| 553 | The following build artifacts were used to create the image(s): |
| 554 | ROOTFS_DIR: tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 555 | BOOTIMG_DIR: tmp/sysroots/qemux86-64/usr/share |
| 556 | KERNEL_DIR: tmp/deploy/images/qemux86-64 |
| 557 | NATIVE_SYSROOT: tmp/sysroots/x86_64-linux |
| 558 | |
| 559 | The image(s) were created using OE kickstart file: |
| 560 | ./test.wks |
| 561 | |
| 562 | Here is a content of test.wks: |
| 563 | |
| 564 | part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024 |
| 565 | part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 |
| 566 | |
| 567 | bootloader --timeout=0 --append="rootwait rootfstype=ext3 video=vesafb vga=0x318 console=tty0" |
| 568 | |
| 569 | |
| 570 | Finally, here's an example of the actual partition language |
| 571 | commands used to generate the mkefidisk image i.e. these are the |
| 572 | contents of the mkefidisk.wks OE kickstart file: |
| 573 | |
| 574 | # short-description: Create an EFI disk image |
| 575 | # long-description: Creates a partitioned EFI disk image that the user |
| 576 | # can directly dd to boot media. |
| 577 | |
| 578 | part /boot --source bootimg-efi --ondisk sda --fstype=efi --active |
| 579 | |
| 580 | part / --source rootfs --ondisk sda --fstype=ext3 --label platform |
| 581 | |
| 582 | part swap --ondisk sda --size 44 --label swap1 --fstype=swap |
| 583 | |
| 584 | bootloader --timeout=10 --append="rootwait console=ttyPCH0,115200" |
| 585 | |
| 586 | You can get a complete listing and description of all the |
| 587 | kickstart commands available for use in .wks files from 'wic help |
| 588 | kickstart'. |
| 589 | """ |
| 590 | |
| 591 | wic_kickstart_help = """ |
| 592 | |
| 593 | NAME |
| 594 | wic kickstart - wic kickstart reference |
| 595 | |
| 596 | DESCRIPTION |
| 597 | This section provides the definitive reference to the wic |
| 598 | kickstart language. It also provides documentation on the list of |
| 599 | --source plugins available for use from the 'part' command (see |
| 600 | the 'Platform-specific Plugins' section below). |
| 601 | |
| 602 | The current wic implementation supports only the basic kickstart |
| 603 | partitioning commands: partition (or part for short) and |
| 604 | bootloader. |
| 605 | |
| 606 | The following is a listing of the commands, their syntax, and |
| 607 | meanings. The commands are based on the Fedora kickstart |
| 608 | documentation but with modifications to reflect wic capabilities. |
| 609 | |
| 610 | http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition |
| 611 | http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader |
| 612 | |
| 613 | Commands |
| 614 | |
| 615 | * 'part' or 'partition' |
| 616 | |
| 617 | This command creates a partition on the system and uses the |
| 618 | following syntax: |
| 619 | |
| 620 | part <mountpoint> |
| 621 | |
| 622 | The <mountpoint> is where the partition will be mounted and |
| 623 | must take of one of the following forms: |
| 624 | |
| 625 | /<path>: For example: /, /usr, or /home |
| 626 | |
| 627 | swap: The partition will be used as swap space. |
| 628 | |
| 629 | The following are supported 'part' options: |
| 630 | |
| 631 | --size: The minimum partition size. Specify an integer value |
| 632 | such as 500. Multipliers k, M ang G can be used. If |
| 633 | not specified, the size is in MB. |
| 634 | You do not need this option if you use --source. |
| 635 | |
| 636 | --source: This option is a wic-specific option that names the |
| 637 | source of the data that will populate the |
| 638 | partition. The most common value for this option |
| 639 | is 'rootfs', but can be any value which maps to a |
| 640 | valid 'source plugin' (see 'wic help plugins'). |
| 641 | |
| 642 | If '--source rootfs' is used, it tells the wic |
| 643 | command to create a partition as large as needed |
| 644 | and to fill it with the contents of the root |
| 645 | filesystem pointed to by the '-r' wic command-line |
| 646 | option (or the equivalent rootfs derived from the |
| 647 | '-e' command-line option). The filesystem type |
| 648 | that will be used to create the partition is driven |
| 649 | by the value of the --fstype option specified for |
| 650 | the partition (see --fstype below). |
| 651 | |
| 652 | If --source <plugin-name>' is used, it tells the |
| 653 | wic command to create a partition as large as |
| 654 | needed and to fill with the contents of the |
| 655 | partition that will be generated by the specified |
| 656 | plugin name using the data pointed to by the '-r' |
| 657 | wic command-line option (or the equivalent rootfs |
| 658 | derived from the '-e' command-line option). |
| 659 | Exactly what those contents and filesystem type end |
| 660 | up being are dependent on the given plugin |
| 661 | implementation. |
| 662 | |
| 663 | If --source option is not used, the wic command |
| 664 | will create empty partition. --size parameter has |
| 665 | to be used to specify size of empty partition. |
| 666 | |
| 667 | --ondisk or --ondrive: Forces the partition to be created on |
| 668 | a particular disk. |
| 669 | |
| 670 | --fstype: Sets the file system type for the partition. These |
| 671 | apply to partitions created using '--source rootfs' (see |
| 672 | --source above). Valid values are: |
| 673 | |
| 674 | ext2 |
| 675 | ext3 |
| 676 | ext4 |
| 677 | btrfs |
| 678 | squashfs |
| 679 | swap |
| 680 | |
| 681 | --fsoptions: Specifies a free-form string of options to be |
| 682 | used when mounting the filesystem. This string |
| 683 | will be copied into the /etc/fstab file of the |
| 684 | installed system and should be enclosed in |
| 685 | quotes. If not specified, the default string is |
| 686 | "defaults". |
| 687 | |
| 688 | --label label: Specifies the label to give to the filesystem |
| 689 | to be made on the partition. If the given |
| 690 | label is already in use by another filesystem, |
| 691 | a new label is created for the partition. |
| 692 | |
| 693 | --active: Marks the partition as active. |
| 694 | |
| 695 | --align (in KBytes): This option is specific to wic and says |
| 696 | to start a partition on an x KBytes |
| 697 | boundary. |
| 698 | |
| 699 | --no-table: This option is specific to wic. Space will be |
| 700 | reserved for the partition and it will be |
| 701 | populated but it will not be added to the |
| 702 | partition table. It may be useful for |
| 703 | bootloaders. |
| 704 | |
| 705 | --extra-space: This option is specific to wic. It adds extra |
| 706 | space after the space filled by the content |
| 707 | of the partition. The final size can go |
| 708 | beyond the size specified by --size. |
| 709 | By default, 10MB. |
| 710 | |
| 711 | --overhead-factor: This option is specific to wic. The |
| 712 | size of the partition is multiplied by |
| 713 | this factor. It has to be greater than or |
| 714 | equal to 1. |
| 715 | The default value is 1.3. |
| 716 | |
| 717 | --part-type: This option is specific to wic. It specifies partition |
| 718 | type GUID for GPT partitions. |
| 719 | List of partition type GUIDS can be found here: |
| 720 | http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs |
| 721 | |
| 722 | --use-uuid: This option is specific to wic. It makes wic to generate |
| 723 | random globally unique identifier (GUID) for the partition |
| 724 | and use it in bootloader configuration to specify root partition. |
| 725 | |
| 726 | --uuid: This option is specific to wic. It specifies partition UUID. |
| 727 | It's useful if preconfigured partition UUID is added to kernel command line |
| 728 | in bootloader configuration before running wic. In this case .wks file can |
| 729 | be generated or modified to set preconfigured parition UUID using this option. |
| 730 | |
| 731 | * bootloader |
| 732 | |
| 733 | This command allows the user to specify various bootloader |
| 734 | options. The following are supported 'bootloader' options: |
| 735 | |
| 736 | --timeout: Specifies the number of seconds before the |
| 737 | bootloader times out and boots the default option. |
| 738 | |
| 739 | --append: Specifies kernel parameters. These will be added to |
| 740 | bootloader command-line - for example, the syslinux |
| 741 | APPEND or grub kernel command line. |
| 742 | |
| 743 | Note that bootloader functionality and boot partitions are |
| 744 | implemented by the various --source plugins that implement |
| 745 | bootloader functionality; the bootloader command essentially |
| 746 | provides a means of modifying bootloader configuration. |
| 747 | """ |