custom-distribution.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. Creating Your Own Distribution
  3. ******************************
  4. When you build an image using the Yocto Project and do not alter any
  5. distribution :term:`Metadata`, you are using the Poky distribution.
  6. Poky is explicitly a *reference* distribution for testing and
  7. development purposes. It enables most hardware and software features
  8. so that they can be tested, but this also means that from a security
  9. point of view the attack surface is very large. Additionally, at some
  10. point it is likely that you will want to gain more control over package
  11. alternative selections, compile-time options, and other low-level
  12. configurations. For both of these reasons, if you are using the Yocto
  13. Project for production use then you are strongly encouraged to create
  14. your own distribution.
  15. To create your own distribution, the basic steps consist of creating
  16. your own distribution layer, creating your own distribution
  17. configuration file, and then adding any needed code and Metadata to the
  18. layer. The following steps provide some more detail:
  19. - *Create a layer for your new distro:* Create your distribution layer
  20. so that you can keep your Metadata and code for the distribution
  21. separate. It is strongly recommended that you create and use your own
  22. layer for configuration and code. Using your own layer as compared to
  23. just placing configurations in a ``local.conf`` configuration file
  24. makes it easier to reproduce the same build configuration when using
  25. multiple build machines. See the
  26. ":ref:`dev-manual/layers:creating a general layer using the \`\`bitbake-layers\`\` script`"
  27. section for information on how to quickly set up a layer.
  28. - *Create the distribution configuration file:* The distribution
  29. configuration file needs to be created in the ``conf/distro``
  30. directory of your layer. You need to name it using your distribution
  31. name (e.g. ``mydistro.conf``).
  32. .. note::
  33. The :term:`DISTRO` variable in your ``local.conf`` file determines the
  34. name of your distribution.
  35. You can split out parts of your configuration file into include files
  36. and then "require" them from within your distribution configuration
  37. file. Be sure to place the include files in the
  38. ``conf/distro/include`` directory of your layer. A common example
  39. usage of include files would be to separate out the selection of
  40. desired version and revisions for individual recipes.
  41. Your configuration file needs to set the following required
  42. variables:
  43. - :term:`DISTRO_NAME`
  44. - :term:`DISTRO_VERSION`
  45. These following variables are optional and you typically set them
  46. from the distribution configuration file:
  47. - :term:`DISTRO_FEATURES`
  48. - :term:`DISTRO_EXTRA_RDEPENDS`
  49. - :term:`DISTRO_EXTRA_RRECOMMENDS`
  50. - :term:`TCLIBC`
  51. .. tip::
  52. If you want to base your distribution configuration file on the
  53. very basic configuration from OE-Core, you can use
  54. ``conf/distro/defaultsetup.conf`` as a reference and just include
  55. variables that differ as compared to ``defaultsetup.conf``.
  56. Alternatively, you can create a distribution configuration file
  57. from scratch using the ``defaultsetup.conf`` file or configuration files
  58. from another distribution such as Poky as a reference.
  59. - *Provide miscellaneous variables:* Be sure to define any other
  60. variables for which you want to create a default or enforce as part
  61. of the distribution configuration. You can include nearly any
  62. variable from the ``local.conf`` file. The variables you use are not
  63. limited to the list in the previous bulleted item.
  64. - *Point to Your distribution configuration file:* In your ``local.conf``
  65. file in the :term:`Build Directory`, set your :term:`DISTRO` variable to
  66. point to your distribution's configuration file. For example, if your
  67. distribution's configuration file is named ``mydistro.conf``, then
  68. you point to it as follows::
  69. DISTRO = "mydistro"
  70. - *Add more to the layer if necessary:* Use your layer to hold other
  71. information needed for the distribution:
  72. - Add recipes for installing distro-specific configuration files
  73. that are not already installed by another recipe. If you have
  74. distro-specific configuration files that are included by an
  75. existing recipe, you should add an append file (``.bbappend``) for
  76. those. For general information and recommendations on how to add
  77. recipes to your layer, see the
  78. ":ref:`dev-manual/layers:creating your own layer`" and
  79. ":ref:`dev-manual/layers:following best practices when creating layers`"
  80. sections.
  81. - Add any image recipes that are specific to your distribution.
  82. - Add a ``psplash`` append file for a branded splash screen, using
  83. the :term:`SPLASH_IMAGES` variable.
  84. - Add any other append files to make custom changes that are
  85. specific to individual recipes.
  86. For information on append files, see the
  87. ":ref:`dev-manual/layers:appending other layers metadata with your layer`"
  88. section.
  89. Copying and modifying the Poky distribution
  90. ===========================================
  91. Instead of creating a custom distribution from scratch as per above, you may
  92. wish to start your custom distribution configuration by copying the Poky
  93. distribution provided within the ``meta-poky`` layer and then modifying it.
  94. This is fine, however if you do this you should keep the following in mind:
  95. - Every reference to Poky needs to be updated in your copy so that it
  96. will still apply. This includes override usage within files (e.g. ``:poky``)
  97. and in directory names. This is a good opportunity to evaluate each one of
  98. these customizations to see if they are needed for your use case.
  99. - Unless you also intend to use them, the ``poky-tiny``, ``poky-altcfg`` and
  100. ``poky-bleeding`` variants and any references to them can be removed.
  101. - More generally, the Poky distribution configuration enables a lot more
  102. than you likely need for your production use case. You should evaluate *every*
  103. configuration choice made in your copy to determine if it is needed.