Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 2 | |
| 3 | ***************************************** |
| 4 | The Yocto Project Development Environment |
| 5 | ***************************************** |
| 6 | |
| 7 | This chapter takes a look at the Yocto Project development environment. |
| 8 | The chapter provides Yocto Project Development environment concepts that |
| 9 | help you understand how work is accomplished in an open source |
| 10 | environment, which is very different as compared to work accomplished in |
| 11 | a closed, proprietary environment. |
| 12 | |
| 13 | Specifically, this chapter addresses open source philosophy, source |
| 14 | repositories, workflows, Git, and licensing. |
| 15 | |
| 16 | Open Source Philosophy |
| 17 | ====================== |
| 18 | |
| 19 | Open source philosophy is characterized by software development directed |
| 20 | by peer production and collaboration through an active community of |
| 21 | developers. Contrast this to the more standard centralized development |
| 22 | models used by commercial software companies where a finite set of |
| 23 | developers produces a product for sale using a defined set of procedures |
| 24 | that ultimately result in an end product whose architecture and source |
| 25 | material are closed to the public. |
| 26 | |
| 27 | Open source projects conceptually have differing concurrent agendas, |
| 28 | approaches, and production. These facets of the development process can |
| 29 | come from anyone in the public (community) who has a stake in the |
| 30 | software project. The open source environment contains new copyright, |
| 31 | licensing, domain, and consumer issues that differ from the more |
| 32 | traditional development environment. In an open source environment, the |
| 33 | end product, source material, and documentation are all available to the |
| 34 | public at no cost. |
| 35 | |
| 36 | A benchmark example of an open source project is the Linux kernel, which |
| 37 | was initially conceived and created by Finnish computer science student |
| 38 | Linus Torvalds in 1991. Conversely, a good example of a non-open source |
| 39 | project is the Windows family of operating systems developed by |
| 40 | Microsoft Corporation. |
| 41 | |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame] | 42 | Wikipedia has a good :wikipedia:`historical description of the Open Source |
| 43 | Philosophy <Open_source>`. You can also find helpful information on how |
| 44 | to participate in the Linux Community |
Andrew Geissler | c3d88e4 | 2020-10-02 09:45:00 -0500 | [diff] [blame] | 45 | `here <https://www.kernel.org/doc/html/latest/process/index.html>`__. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 46 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 47 | The Development Host |
| 48 | ==================== |
| 49 | |
| 50 | A development host or :term:`Build Host` is key to |
| 51 | using the Yocto Project. Because the goal of the Yocto Project is to |
| 52 | develop images or applications that run on embedded hardware, |
| 53 | development of those images and applications generally takes place on a |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 54 | system not intended to run the software --- the development host. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 55 | |
| 56 | You need to set up a development host in order to use it with the Yocto |
| 57 | Project. Most find that it is best to have a native Linux machine |
| 58 | function as the development host. However, it is possible to use a |
| 59 | system that does not run Linux as its operating system as your |
| 60 | development host. When you have a Mac or Windows-based system, you can |
| 61 | set it up as the development host by using |
| 62 | `CROPS <https://github.com/crops/poky-container>`__, which leverages |
| 63 | `Docker Containers <https://www.docker.com/>`__. Once you take the steps |
| 64 | to set up a CROPS machine, you effectively have access to a shell |
| 65 | environment that is similar to what you see when using a Linux-based |
| 66 | development host. For the steps needed to set up a system using CROPS, |
| 67 | see the |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 68 | ":ref:`dev-manual/start:setting up to use cross platforms (crops)`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 69 | section in |
| 70 | the Yocto Project Development Tasks Manual. |
| 71 | |
| 72 | If your development host is going to be a system that runs a Linux |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 73 | distribution, you must still take steps to prepare the system |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 74 | for use with the Yocto Project. You need to be sure that the Linux |
| 75 | distribution on the system is one that supports the Yocto Project. You |
| 76 | also need to be sure that the correct set of host packages are installed |
| 77 | that allow development using the Yocto Project. For the steps needed to |
| 78 | set up a development host that runs Linux, see the |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 79 | ":ref:`dev-manual/start:setting up a native linux host`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 80 | section in the Yocto Project Development Tasks Manual. |
| 81 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 82 | Once your development host is set up to use the Yocto Project, there |
| 83 | are several ways of working in the Yocto Project environment: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 84 | |
| 85 | - *Command Lines, BitBake, and Shells:* Traditional development in the |
| 86 | Yocto Project involves using the :term:`OpenEmbedded Build System`, |
| 87 | which uses |
| 88 | BitBake, in a command-line environment from a shell on your |
| 89 | development host. You can accomplish this from a host that is a |
| 90 | native Linux machine or from a host that has been set up with CROPS. |
| 91 | Either way, you create, modify, and build images and applications all |
| 92 | within a shell-based environment using components and tools available |
| 93 | through your Linux distribution and the Yocto Project. |
| 94 | |
| 95 | For a general flow of the build procedures, see the |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 96 | ":ref:`dev-manual/building:building a simple image`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 97 | section in the Yocto Project Development Tasks Manual. |
| 98 | |
| 99 | - *Board Support Package (BSP) Development:* Development of BSPs |
| 100 | involves using the Yocto Project to create and test layers that allow |
| 101 | easy development of images and applications targeted for specific |
| 102 | hardware. To development BSPs, you need to take some additional steps |
| 103 | beyond what was described in setting up a development host. |
| 104 | |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 105 | The :doc:`/bsp-guide/index` provides BSP-related development |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 106 | information. For specifics on development host preparation, see the |
| 107 | ":ref:`bsp-guide/bsp:preparing your build host to work with bsp layers`" |
| 108 | section in the Yocto Project Board Support Package (BSP) Developer's |
| 109 | Guide. |
| 110 | |
| 111 | - *Kernel Development:* If you are going to be developing kernels using |
| 112 | the Yocto Project you likely will be using ``devtool``. A workflow |
| 113 | using ``devtool`` makes kernel development quicker by reducing |
| 114 | iteration cycle times. |
| 115 | |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 116 | The :doc:`/kernel-dev/index` provides kernel-related |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 117 | development information. For specifics on development host |
| 118 | preparation, see the |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 119 | ":ref:`kernel-dev/common:preparing the build host to work on the kernel`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 120 | section in the Yocto Project Linux Kernel Development Manual. |
| 121 | |
| 122 | - *Using Toaster:* The other Yocto Project development method that |
| 123 | involves an interface that effectively puts the Yocto Project into |
| 124 | the background is Toaster. Toaster provides an interface to the |
| 125 | OpenEmbedded build system. The interface enables you to configure and |
| 126 | run your builds. Information about builds is collected and stored in |
| 127 | a database. You can use Toaster to configure and start builds on |
| 128 | multiple remote build servers. |
| 129 | |
| 130 | For steps that show you how to set up your development host to use |
| 131 | Toaster and on how to use Toaster in general, see the |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 132 | :doc:`/toaster-manual/index`. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 133 | |
| 134 | Yocto Project Source Repositories |
| 135 | ================================= |
| 136 | |
| 137 | The Yocto Project team maintains complete source repositories for all |
| 138 | Yocto Project files at :yocto_git:`/`. This web-based source |
| 139 | code browser is organized into categories by function such as IDE |
| 140 | Plugins, Matchbox, Poky, Yocto Linux Kernel, and so forth. From the |
| 141 | interface, you can click on any particular item in the "Name" column and |
| 142 | see the URL at the bottom of the page that you need to clone a Git |
| 143 | repository for that particular item. Having a local Git repository of |
| 144 | the :term:`Source Directory`, which |
| 145 | is usually named "poky", allows you to make changes, contribute to the |
| 146 | history, and ultimately enhance the Yocto Project's tools, Board Support |
| 147 | Packages, and so forth. |
| 148 | |
| 149 | For any supported release of Yocto Project, you can also go to the |
| 150 | :yocto_home:`Yocto Project Website <>` and select the "DOWNLOADS" |
| 151 | item from the "SOFTWARE" menu and get a released tarball of the ``poky`` |
| 152 | repository, any supported BSP tarball, or Yocto Project tools. Unpacking |
| 153 | these tarballs gives you a snapshot of the released files. |
| 154 | |
| 155 | .. note:: |
| 156 | |
| 157 | - The recommended method for setting up the Yocto Project |
| 158 | :term:`Source Directory` and the files |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 159 | for supported BSPs (e.g., ``meta-intel``) is to use |
| 160 | :ref:`overview-manual/development-environment:git` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 161 | to create a local copy of the upstream repositories. |
| 162 | |
| 163 | - Be sure to always work in matching branches for both the selected |
| 164 | BSP repository and the Source Directory (i.e. ``poky``) |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 165 | repository. For example, if you have checked out the "&DISTRO_NAME_NO_CAP;" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 166 | branch of ``poky`` and you are going to use ``meta-intel``, be |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 167 | sure to checkout the "&DISTRO_NAME_NO_CAP;" branch of ``meta-intel``. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 168 | |
| 169 | In summary, here is where you can get the project files needed for |
| 170 | development: |
| 171 | |
| 172 | - :yocto_git:`Source Repositories: <>` This area contains IDE |
| 173 | Plugins, Matchbox, Poky, Poky Support, Tools, Yocto Linux Kernel, and |
| 174 | Yocto Metadata Layers. You can create local copies of Git |
| 175 | repositories for each of these areas. |
| 176 | |
| 177 | .. image:: figures/source-repos.png |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 178 | :width: 100% |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 179 | |
| 180 | For steps on how to view and access these upstream Git repositories, |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 181 | see the ":ref:`dev-manual/start:accessing source repositories`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 182 | Section in the Yocto Project Development Tasks Manual. |
| 183 | |
Andrew Geissler | c3d88e4 | 2020-10-02 09:45:00 -0500 | [diff] [blame] | 184 | - :yocto_dl:`Index of /releases: </releases>` This is an index |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 185 | of releases such as Poky, Pseudo, installers for cross-development |
| 186 | toolchains, miscellaneous support and all released versions of Yocto |
| 187 | Project in the form of images or tarballs. Downloading and extracting |
| 188 | these files does not produce a local copy of the Git repository but |
| 189 | rather a snapshot of a particular release or image. |
| 190 | |
| 191 | .. image:: figures/index-downloads.png |
| 192 | :align: center |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 193 | :width: 50% |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 194 | |
| 195 | For steps on how to view and access these files, see the |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 196 | ":ref:`dev-manual/start:accessing index of releases`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 197 | section in the Yocto Project Development Tasks Manual. |
| 198 | |
| 199 | - *"DOWNLOADS" page for the* :yocto_home:`Yocto Project Website <>` *:* |
| 200 | |
| 201 | The Yocto Project website includes a "DOWNLOADS" page accessible |
| 202 | through the "SOFTWARE" menu that allows you to download any Yocto |
| 203 | Project release, tool, and Board Support Package (BSP) in tarball |
| 204 | form. The tarballs are similar to those found in the |
Andrew Geissler | c3d88e4 | 2020-10-02 09:45:00 -0500 | [diff] [blame] | 205 | :yocto_dl:`Index of /releases: </releases>` area. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 206 | |
| 207 | .. image:: figures/yp-download.png |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 208 | :width: 100% |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 209 | |
| 210 | For steps on how to use the "DOWNLOADS" page, see the |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 211 | ":ref:`dev-manual/start:using the downloads page`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 212 | section in the Yocto Project Development Tasks Manual. |
| 213 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 214 | Git Workflows and the Yocto Project |
| 215 | =================================== |
| 216 | |
| 217 | Developing using the Yocto Project likely requires the use of |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 218 | :ref:`overview-manual/development-environment:git`. |
| 219 | Git is a free, open source distributed version control |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 220 | system used as part of many collaborative design environments. This |
| 221 | section provides workflow concepts using the Yocto Project and Git. In |
| 222 | particular, the information covers basic practices that describe roles |
| 223 | and actions in a collaborative development environment. |
| 224 | |
| 225 | .. note:: |
| 226 | |
| 227 | If you are familiar with this type of development environment, you |
| 228 | might not want to read this section. |
| 229 | |
| 230 | The Yocto Project files are maintained using Git in "branches" whose Git |
| 231 | histories track every change and whose structures provide branches for |
| 232 | all diverging functionality. Although there is no need to use Git, many |
| 233 | open source projects do so. |
| 234 | |
| 235 | For the Yocto Project, a key individual called the "maintainer" is |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 236 | responsible for the integrity of the development branch of a given Git |
| 237 | repository. The development branch is the "upstream" repository from which |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 238 | final or most recent builds of a project occur. The maintainer is |
| 239 | responsible for accepting changes from other developers and for |
| 240 | organizing the underlying branch structure to reflect release strategies |
| 241 | and so forth. |
| 242 | |
| 243 | .. note:: |
| 244 | |
| 245 | For information on finding out who is responsible for (maintains) a |
| 246 | particular area of code in the Yocto Project, see the |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 247 | ":ref:`dev-manual/changes:submitting a change to the yocto project`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 248 | section of the Yocto Project Development Tasks Manual. |
| 249 | |
| 250 | The Yocto Project ``poky`` Git repository also has an upstream |
| 251 | contribution Git repository named ``poky-contrib``. You can see all the |
| 252 | branches in this repository using the web interface of the |
| 253 | :yocto_git:`Source Repositories <>` organized within the "Poky Support" |
| 254 | area. These branches hold changes (commits) to the project that have |
| 255 | been submitted or committed by the Yocto Project development team and by |
| 256 | community members who contribute to the project. The maintainer |
| 257 | determines if the changes are qualified to be moved from the "contrib" |
| 258 | branches into the "master" branch of the Git repository. |
| 259 | |
| 260 | Developers (including contributing community members) create and |
| 261 | maintain cloned repositories of upstream branches. The cloned |
| 262 | repositories are local to their development platforms and are used to |
| 263 | develop changes. When a developer is satisfied with a particular feature |
| 264 | or change, they "push" the change to the appropriate "contrib" |
| 265 | repository. |
| 266 | |
| 267 | Developers are responsible for keeping their local repository up-to-date |
| 268 | with whatever upstream branch they are working against. They are also |
| 269 | responsible for straightening out any conflicts that might arise within |
| 270 | files that are being worked on simultaneously by more than one person. |
| 271 | All this work is done locally on the development host before anything is |
| 272 | pushed to a "contrib" area and examined at the maintainer's level. |
| 273 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 274 | There is a somewhat formal method by which developers commit changes and |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 275 | push them into the "contrib" area and subsequently request that the |
| 276 | maintainer include them into an upstream branch. This process is called |
| 277 | "submitting a patch" or "submitting a change." For information on |
| 278 | submitting patches and changes, see the |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 279 | ":ref:`dev-manual/changes:submitting a change to the yocto project`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 280 | section in the Yocto Project Development Tasks Manual. |
| 281 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 282 | In summary, there is a single point of entry for changes into the |
| 283 | development branch of the Git repository, which is controlled by the |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 284 | project's maintainer. A set of developers independently |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 285 | develop, test, and submit changes to "contrib" areas for the maintainer |
| 286 | to examine. The maintainer then chooses which changes are going to |
| 287 | become a permanent part of the project. |
| 288 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 289 | .. image:: svg/git-workflow.* |
| 290 | :width: 100% |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 291 | |
| 292 | While each development environment is unique, there are some best |
| 293 | practices or methods that help development run smoothly. The following |
| 294 | list describes some of these practices. For more information about Git |
| 295 | workflows, see the workflow topics in the `Git Community |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 296 | Book <https://book.git-scm.com>`__. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 297 | |
| 298 | - *Make Small Changes:* It is best to keep the changes you commit small |
| 299 | as compared to bundling many disparate changes into a single commit. |
| 300 | This practice not only keeps things manageable but also allows the |
| 301 | maintainer to more easily include or refuse changes. |
| 302 | |
| 303 | - *Make Complete Changes:* It is also good practice to leave the |
| 304 | repository in a state that allows you to still successfully build |
| 305 | your project. In other words, do not commit half of a feature, then |
| 306 | add the other half as a separate, later commit. Each commit should |
| 307 | take you from one buildable project state to another buildable state. |
| 308 | |
| 309 | - *Use Branches Liberally:* It is very easy to create, use, and delete |
| 310 | local branches in your working Git repository on the development |
| 311 | host. You can name these branches anything you like. It is helpful to |
| 312 | give them names associated with the particular feature or change on |
| 313 | which you are working. Once you are done with a feature or change and |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 314 | have merged it into your local development branch, simply discard the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 315 | temporary branch. |
| 316 | |
| 317 | - *Merge Changes:* The ``git merge`` command allows you to take the |
| 318 | changes from one branch and fold them into another branch. This |
| 319 | process is especially helpful when more than a single developer might |
| 320 | be working on different parts of the same feature. Merging changes |
| 321 | also automatically identifies any collisions or "conflicts" that |
| 322 | might happen as a result of the same lines of code being altered by |
| 323 | two different developers. |
| 324 | |
| 325 | - *Manage Branches:* Because branches are easy to use, you should use a |
| 326 | system where branches indicate varying levels of code readiness. For |
| 327 | example, you can have a "work" branch to develop in, a "test" branch |
| 328 | where the code or change is tested, a "stage" branch where changes |
| 329 | are ready to be committed, and so forth. As your project develops, |
| 330 | you can merge code across the branches to reflect ever-increasing |
| 331 | stable states of the development. |
| 332 | |
| 333 | - *Use Push and Pull:* The push-pull workflow is based on the concept |
| 334 | of developers "pushing" local commits to a remote repository, which |
| 335 | is usually a contribution repository. This workflow is also based on |
| 336 | developers "pulling" known states of the project down into their |
| 337 | local development repositories. The workflow easily allows you to |
| 338 | pull changes submitted by other developers from the upstream |
| 339 | repository into your work area ensuring that you have the most recent |
| 340 | software on which to develop. The Yocto Project has two scripts named |
| 341 | ``create-pull-request`` and ``send-pull-request`` that ship with the |
| 342 | release to facilitate this workflow. You can find these scripts in |
| 343 | the ``scripts`` folder of the |
| 344 | :term:`Source Directory`. For information |
| 345 | on how to use these scripts, see the |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 346 | ":ref:`dev-manual/changes:using scripts to push a change upstream and request a pull`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 347 | section in the Yocto Project Development Tasks Manual. |
| 348 | |
| 349 | - *Patch Workflow:* This workflow allows you to notify the maintainer |
| 350 | through an email that you have a change (or patch) you would like |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 351 | considered for the development branch of the Git repository. To send |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 352 | this type of change, you format the patch and then send the email |
| 353 | using the Git commands ``git format-patch`` and ``git send-email``. |
| 354 | For information on how to use these scripts, see the |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 355 | ":ref:`dev-manual/changes:submitting a change to the yocto project`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 356 | section in the Yocto Project Development Tasks Manual. |
| 357 | |
| 358 | Git |
| 359 | === |
| 360 | |
| 361 | The Yocto Project makes extensive use of Git, which is a free, open |
| 362 | source distributed version control system. Git supports distributed |
| 363 | development, non-linear development, and can handle large projects. It |
| 364 | is best that you have some fundamental understanding of how Git tracks |
| 365 | projects and how to work with Git if you are going to use the Yocto |
| 366 | Project for development. This section provides a quick overview of how |
| 367 | Git works and provides you with a summary of some essential Git |
| 368 | commands. |
| 369 | |
| 370 | .. note:: |
| 371 | |
| 372 | - For more information on Git, see |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 373 | https://git-scm.com/documentation. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 374 | |
| 375 | - If you need to download Git, it is recommended that you add Git to |
| 376 | your system through your distribution's "software store" (e.g. for |
| 377 | Ubuntu, use the Ubuntu Software feature). For the Git download |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 378 | page, see https://git-scm.com/download. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 379 | |
| 380 | - For information beyond the introductory nature in this section, |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 381 | see the ":ref:`dev-manual/start:locating yocto project source files`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 382 | section in the Yocto Project Development Tasks Manual. |
| 383 | |
| 384 | Repositories, Tags, and Branches |
| 385 | -------------------------------- |
| 386 | |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 387 | As mentioned briefly in the previous section and also in the |
| 388 | ":ref:`overview-manual/development-environment:git workflows and the yocto project`" |
| 389 | section, the Yocto Project maintains source repositories at :yocto_git:`/`. |
| 390 | If you look at this web-interface of the repositories, each item is a separate |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 391 | Git repository. |
| 392 | |
| 393 | Git repositories use branching techniques that track content change (not |
| 394 | files) within a project (e.g. a new feature or updated documentation). |
| 395 | Creating a tree-like structure based on project divergence allows for |
| 396 | excellent historical information over the life of a project. This |
| 397 | methodology also allows for an environment from which you can do lots of |
| 398 | local experimentation on projects as you develop changes or new |
| 399 | features. |
| 400 | |
| 401 | A Git repository represents all development efforts for a given project. |
| 402 | For example, the Git repository ``poky`` contains all changes and |
| 403 | developments for that repository over the course of its entire life. |
| 404 | That means that all changes that make up all releases are captured. The |
| 405 | repository maintains a complete history of changes. |
| 406 | |
| 407 | You can create a local copy of any repository by "cloning" it with the |
| 408 | ``git clone`` command. When you clone a Git repository, you end up with |
| 409 | an identical copy of the repository on your development system. Once you |
| 410 | have a local copy of a repository, you can take steps to develop |
| 411 | locally. For examples on how to clone Git repositories, see the |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 412 | ":ref:`dev-manual/start:locating yocto project source files`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 413 | section in the Yocto Project Development Tasks Manual. |
| 414 | |
| 415 | It is important to understand that Git tracks content change and not |
| 416 | files. Git uses "branches" to organize different development efforts. |
| 417 | For example, the ``poky`` repository has several branches that include |
| 418 | the current "&DISTRO_NAME_NO_CAP;" branch, the "master" branch, and many |
| 419 | branches for past Yocto Project releases. You can see all the branches |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 420 | by going to :yocto_git:`/poky/` and clicking on the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 421 | ``[...]`` link beneath the "Branch" heading. |
| 422 | |
| 423 | Each of these branches represents a specific area of development. The |
| 424 | "master" branch represents the current or most recent development. All |
| 425 | other branches represent offshoots of the "master" branch. |
| 426 | |
| 427 | When you create a local copy of a Git repository, the copy has the same |
| 428 | set of branches as the original. This means you can use Git to create a |
| 429 | local working area (also called a branch) that tracks a specific |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 430 | development branch from the upstream source Git repository. In other |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 431 | words, you can define your local Git environment to work on any |
| 432 | development branch in the repository. To help illustrate, consider the |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 433 | following example Git commands:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 434 | |
| 435 | $ cd ~ |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 436 | $ git clone git://git.yoctoproject.org/poky -b &DISTRO_NAME_NO_CAP; |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 437 | |
| 438 | In the previous example |
| 439 | after moving to the home directory, the ``git clone`` command creates a |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 440 | local copy of the upstream ``poky`` Git repository and checks out a |
| 441 | local branch named "&DISTRO_NAME_NO_CAP;", which tracks the upstream |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 442 | "origin/&DISTRO_NAME_NO_CAP;" branch. Changes you make while in this |
| 443 | branch would ultimately affect the upstream "&DISTRO_NAME_NO_CAP;" branch |
| 444 | of the ``poky`` repository. |
| 445 | |
| 446 | It is important to understand that when you create and checkout a local |
| 447 | working branch based on a branch name, your local environment matches |
| 448 | the "tip" of that particular development branch at the time you created |
| 449 | your local branch, which could be different from the files in the |
| 450 | "master" branch of the upstream repository. In other words, creating and |
| 451 | checking out a local branch based on the "&DISTRO_NAME_NO_CAP;" branch |
| 452 | name is not the same as checking out the "master" branch in the |
| 453 | repository. Keep reading to see how you create a local snapshot of a |
| 454 | Yocto Project Release. |
| 455 | |
| 456 | Git uses "tags" to mark specific changes in a repository branch |
| 457 | structure. Typically, a tag is used to mark a special point such as the |
| 458 | final change (or commit) before a project is released. You can see the |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 459 | tags used with the ``poky`` Git repository by going to :yocto_git:`/poky/` |
| 460 | and clicking on the ``[...]`` link beneath the "Tag" heading. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 461 | |
| 462 | Some key tags for the ``poky`` repository are ``jethro-14.0.3``, |
| 463 | ``morty-16.0.1``, ``pyro-17.0.0``, and |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 464 | ``&DISTRO_NAME_NO_CAP;-&DISTRO;``. These tags represent Yocto Project |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 465 | releases. |
| 466 | |
| 467 | When you create a local copy of the Git repository, you also have access |
| 468 | to all the tags in the upstream repository. Similar to branches, you can |
| 469 | create and checkout a local working Git branch based on a tag name. When |
| 470 | you do this, you get a snapshot of the Git repository that reflects the |
| 471 | state of the files when the change was made associated with that tag. |
| 472 | The most common use is to checkout a working branch that matches a |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 473 | specific Yocto Project release. Here is an example:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 474 | |
| 475 | $ cd ~ |
| 476 | $ git clone git://git.yoctoproject.org/poky |
| 477 | $ cd poky |
| 478 | $ git fetch --tags |
| 479 | $ git checkout tags/rocko-18.0.0 -b my_rocko-18.0.0 |
| 480 | |
| 481 | In this example, the name |
| 482 | of the top-level directory of your local Yocto Project repository is |
| 483 | ``poky``. After moving to the ``poky`` directory, the ``git fetch`` |
| 484 | command makes all the upstream tags available locally in your |
| 485 | repository. Finally, the ``git checkout`` command creates and checks out |
| 486 | a branch named "my-rocko-18.0.0" that is based on the upstream branch |
| 487 | whose "HEAD" matches the commit in the repository associated with the |
| 488 | "rocko-18.0.0" tag. The files in your repository now exactly match that |
| 489 | particular Yocto Project release as it is tagged in the upstream Git |
| 490 | repository. It is important to understand that when you create and |
| 491 | checkout a local working branch based on a tag, your environment matches |
| 492 | a specific point in time and not the entire development branch (i.e. |
| 493 | from the "tip" of the branch backwards). |
| 494 | |
| 495 | Basic Commands |
| 496 | -------------- |
| 497 | |
| 498 | Git has an extensive set of commands that lets you manage changes and |
| 499 | perform collaboration over the life of a project. Conveniently though, |
| 500 | you can manage with a small set of basic operations and workflows once |
| 501 | you understand the basic philosophy behind Git. You do not have to be an |
| 502 | expert in Git to be functional. A good place to look for instruction on |
| 503 | a minimal set of Git commands is |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 504 | `here <https://git-scm.com/documentation>`__. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 505 | |
| 506 | The following list of Git commands briefly describes some basic Git |
| 507 | operations as a way to get started. As with any set of commands, this |
| 508 | list (in most cases) simply shows the base command and omits the many |
| 509 | arguments it supports. See the Git documentation for complete |
| 510 | descriptions and strategies on how to use these commands: |
| 511 | |
| 512 | - *git init:* Initializes an empty Git repository. You cannot use |
| 513 | Git commands unless you have a ``.git`` repository. |
| 514 | |
| 515 | - *git clone:* Creates a local clone of a Git repository that is on |
| 516 | equal footing with a fellow developer's Git repository or an upstream |
| 517 | repository. |
| 518 | |
| 519 | - *git add:* Locally stages updated file contents to the index that |
| 520 | Git uses to track changes. You must stage all files that have changed |
| 521 | before you can commit them. |
| 522 | |
| 523 | - *git commit:* Creates a local "commit" that documents the changes |
| 524 | you made. Only changes that have been staged can be committed. |
| 525 | Commits are used for historical purposes, for determining if a |
| 526 | maintainer of a project will allow the change, and for ultimately |
| 527 | pushing the change from your local Git repository into the project's |
| 528 | upstream repository. |
| 529 | |
| 530 | - *git status:* Reports any modified files that possibly need to be |
| 531 | staged and gives you a status of where you stand regarding local |
| 532 | commits as compared to the upstream repository. |
| 533 | |
| 534 | - *git checkout branch-name:* Changes your local working branch and |
| 535 | in this form assumes the local branch already exists. This command is |
| 536 | analogous to "cd". |
| 537 | |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 538 | - *git checkout -b working-branch upstream-branch:* Creates and |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 539 | checks out a working branch on your local machine. The local branch |
| 540 | tracks the upstream branch. You can use your local branch to isolate |
| 541 | your work. It is a good idea to use local branches when adding |
| 542 | specific features or changes. Using isolated branches facilitates |
| 543 | easy removal of changes if they do not work out. |
| 544 | |
| 545 | - *git branch:* Displays the existing local branches associated |
| 546 | with your local repository. The branch that you have currently |
| 547 | checked out is noted with an asterisk character. |
| 548 | |
| 549 | - *git branch -D branch-name:* Deletes an existing local branch. |
| 550 | You need to be in a local branch other than the one you are deleting |
| 551 | in order to delete branch-name. |
| 552 | |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 553 | - *git pull \-\-rebase*: Retrieves information from an upstream Git |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 554 | repository and places it in your local Git repository. You use this |
| 555 | command to make sure you are synchronized with the repository from |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 556 | which you are basing changes (e.g. the "&DISTRO_NAME_NO_CAP;" |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 557 | branch). The ``--rebase`` option ensures that any local commits you |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 558 | have in your branch are preserved at the top of your local branch. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 559 | |
| 560 | - *git push repo-name local-branch:upstream-branch:* Sends |
| 561 | all your committed local changes to the upstream Git repository that |
| 562 | your local repository is tracking (e.g. a contribution repository). |
| 563 | The maintainer of the project draws from these repositories to merge |
| 564 | changes (commits) into the appropriate branch of project's upstream |
| 565 | repository. |
| 566 | |
| 567 | - *git merge:* Combines or adds changes from one local branch of |
| 568 | your repository with another branch. When you create a local Git |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 569 | repository, the default branch may be named "main". A typical |
| 570 | workflow is to create a temporary branch that is based off "main" |
| 571 | that you would use for isolated work. You would make your changes in |
| 572 | that isolated branch, stage and commit them locally, switch to the |
| 573 | "main" branch, and then use the ``git merge`` command to apply the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 574 | changes from your isolated branch into the currently checked out |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 575 | branch (e.g. "main"). After the merge is complete and if you are |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 576 | done with working in that isolated branch, you can safely delete the |
| 577 | isolated branch. |
| 578 | |
| 579 | - *git cherry-pick commits:* Choose and apply specific commits from |
| 580 | one branch into another branch. There are times when you might not be |
| 581 | able to merge all the changes in one branch with another but need to |
| 582 | pick out certain ones. |
| 583 | |
| 584 | - *gitk:* Provides a GUI view of the branches and changes in your |
| 585 | local Git repository. This command is a good way to graphically see |
| 586 | where things have diverged in your local repository. |
| 587 | |
| 588 | .. note:: |
| 589 | |
| 590 | You need to install the |
| 591 | gitk |
| 592 | package on your development system to use this command. |
| 593 | |
| 594 | - *git log:* Reports a history of your commits to the repository. |
| 595 | This report lists all commits regardless of whether you have pushed |
| 596 | them upstream or not. |
| 597 | |
| 598 | - *git diff:* Displays line-by-line differences between a local |
| 599 | working file and the same file as understood by Git. This command is |
| 600 | useful to see what you have changed in any given file. |
| 601 | |
| 602 | Licensing |
| 603 | ========= |
| 604 | |
| 605 | Because open source projects are open to the public, they have different |
| 606 | licensing structures in place. License evolution for both Open Source |
| 607 | and Free Software has an interesting history. If you are interested in |
| 608 | this history, you can find basic information here: |
| 609 | |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame] | 610 | - :wikipedia:`Open source license history <Open-source_license>` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 611 | |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame] | 612 | - :wikipedia:`Free software license history <Free_software_license>` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 613 | |
| 614 | In general, the Yocto Project is broadly licensed under the |
| 615 | Massachusetts Institute of Technology (MIT) License. MIT licensing |
| 616 | permits the reuse of software within proprietary software as long as the |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 617 | license is distributed with that software. Patches to the Yocto Project |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 618 | follow the upstream licensing scheme. You can find information on the |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame] | 619 | MIT license :wikipedia:`here <MIT_License>`. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 620 | |
| 621 | When you build an image using the Yocto Project, the build process uses |
| 622 | a known list of licenses to ensure compliance. You can find this list in |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 623 | the :term:`Source Directory` at ``meta/files/common-licenses``. Once the |
| 624 | build completes, the list of all licenses found and used during that build |
| 625 | are kept in the :term:`Build Directory` at ``tmp/deploy/licenses``. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 626 | |
| 627 | If a module requires a license that is not in the base list, the build |
| 628 | process generates a warning during the build. These tools make it easier |
| 629 | for a developer to be certain of the licenses with which their shipped |
| 630 | products must comply. However, even with these tools it is still up to |
| 631 | the developer to resolve potential licensing issues. |
| 632 | |
| 633 | The base list of licenses used by the build process is a combination of |
| 634 | the Software Package Data Exchange (SPDX) list and the Open Source |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 635 | Initiative (OSI) projects. `SPDX Group <https://spdx.org>`__ is a working |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 636 | group of the Linux Foundation that maintains a specification for a |
| 637 | standard format for communicating the components, licenses, and |
| 638 | copyrights associated with a software package. |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 639 | `OSI <https://opensource.org>`__ is a corporation dedicated to the Open |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 640 | Source Definition and the effort for reviewing and approving licenses |
| 641 | that conform to the Open Source Definition (OSD). |
| 642 | |
| 643 | You can find a list of the combined SPDX and OSI licenses that the Yocto |
| 644 | Project uses in the ``meta/files/common-licenses`` directory in your |
| 645 | :term:`Source Directory`. |
| 646 | |
| 647 | For information that can help you maintain compliance with various open |
| 648 | source licensing during the lifecycle of a product created using the |
| 649 | Yocto Project, see the |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 650 | ":ref:`dev-manual/licenses:maintaining open source license compliance during your product's lifecycle`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 651 | section in the Yocto Project Development Tasks Manual. |