blob: d79173ff55066ff163d09ad955eeee44bdb64287 [file] [log] [blame]
Andrew Geisslerf0343792020-11-18 10:42:21 -06001.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002
3*****************************************
4The Yocto Project Development Environment
5*****************************************
6
7This chapter takes a look at the Yocto Project development environment.
8The chapter provides Yocto Project Development environment concepts that
9help you understand how work is accomplished in an open source
10environment, which is very different as compared to work accomplished in
11a closed, proprietary environment.
12
13Specifically, this chapter addresses open source philosophy, source
14repositories, workflows, Git, and licensing.
15
16Open Source Philosophy
17======================
18
19Open source philosophy is characterized by software development directed
20by peer production and collaboration through an active community of
21developers. Contrast this to the more standard centralized development
22models used by commercial software companies where a finite set of
23developers produces a product for sale using a defined set of procedures
24that ultimately result in an end product whose architecture and source
25material are closed to the public.
26
27Open source projects conceptually have differing concurrent agendas,
28approaches, and production. These facets of the development process can
29come from anyone in the public (community) who has a stake in the
30software project. The open source environment contains new copyright,
31licensing, domain, and consumer issues that differ from the more
32traditional development environment. In an open source environment, the
33end product, source material, and documentation are all available to the
34public at no cost.
35
36A benchmark example of an open source project is the Linux kernel, which
37was initially conceived and created by Finnish computer science student
38Linus Torvalds in 1991. Conversely, a good example of a non-open source
39project is the Windows family of operating systems developed by
40Microsoft Corporation.
41
Patrick Williams7784c422022-11-17 07:29:11 -060042Wikipedia has a good :wikipedia:`historical description of the Open Source
43Philosophy <Open_source>`. You can also find helpful information on how
44to participate in the Linux Community
Andrew Geisslerc3d88e42020-10-02 09:45:00 -050045`here <https://www.kernel.org/doc/html/latest/process/index.html>`__.
Andrew Geisslerc9f78652020-09-18 14:11:35 -050046
Andrew Geisslerc9f78652020-09-18 14:11:35 -050047The Development Host
48====================
49
50A development host or :term:`Build Host` is key to
51using the Yocto Project. Because the goal of the Yocto Project is to
52develop images or applications that run on embedded hardware,
53development of those images and applications generally takes place on a
Andrew Geissler615f2f12022-07-15 14:00:58 -050054system not intended to run the software --- the development host.
Andrew Geisslerc9f78652020-09-18 14:11:35 -050055
56You need to set up a development host in order to use it with the Yocto
57Project. Most find that it is best to have a native Linux machine
58function as the development host. However, it is possible to use a
59system that does not run Linux as its operating system as your
60development host. When you have a Mac or Windows-based system, you can
61set 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
64to set up a CROPS machine, you effectively have access to a shell
65environment that is similar to what you see when using a Linux-based
66development host. For the steps needed to set up a system using CROPS,
67see the
Andrew Geissler09209ee2020-12-13 08:44:15 -060068":ref:`dev-manual/start:setting up to use cross platforms (crops)`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -050069section in
70the Yocto Project Development Tasks Manual.
71
72If your development host is going to be a system that runs a Linux
William A. Kennington IIIac69b482021-06-02 12:28:27 -070073distribution, you must still take steps to prepare the system
Andrew Geisslerc9f78652020-09-18 14:11:35 -050074for use with the Yocto Project. You need to be sure that the Linux
75distribution on the system is one that supports the Yocto Project. You
76also need to be sure that the correct set of host packages are installed
77that allow development using the Yocto Project. For the steps needed to
78set up a development host that runs Linux, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -060079":ref:`dev-manual/start:setting up a native linux host`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -050080section in the Yocto Project Development Tasks Manual.
81
William A. Kennington IIIac69b482021-06-02 12:28:27 -070082Once your development host is set up to use the Yocto Project, there
83are several ways of working in the Yocto Project environment:
Andrew Geisslerc9f78652020-09-18 14:11:35 -050084
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 Geissler517393d2023-01-13 08:55:19 -060096 ":ref:`dev-manual/building:building a simple image`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -050097 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 Geissler09209ee2020-12-13 08:44:15 -0600105 The :doc:`/bsp-guide/index` provides BSP-related development
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500106 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 Geissler09209ee2020-12-13 08:44:15 -0600116 The :doc:`/kernel-dev/index` provides kernel-related
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500117 development information. For specifics on development host
118 preparation, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600119 ":ref:`kernel-dev/common:preparing the build host to work on the kernel`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500120 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 Geissler09209ee2020-12-13 08:44:15 -0600132 :doc:`/toaster-manual/index`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500133
Patrick Williams705982a2024-01-12 09:51:57 -0600134- *Using the VSCode Extension:* You can use the `Yocto Project BitBake
135 <https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake>`__
136 extension for Visual Studio Code to start your BitBake builds through a
137 graphical user interface.
138
139 Learn more about the VSCode Extension on the `extension's marketplace page
140 <https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake>`__.
141
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500142Yocto Project Source Repositories
143=================================
144
145The Yocto Project team maintains complete source repositories for all
146Yocto Project files at :yocto_git:`/`. This web-based source
147code browser is organized into categories by function such as IDE
148Plugins, Matchbox, Poky, Yocto Linux Kernel, and so forth. From the
149interface, you can click on any particular item in the "Name" column and
150see the URL at the bottom of the page that you need to clone a Git
151repository for that particular item. Having a local Git repository of
152the :term:`Source Directory`, which
153is usually named "poky", allows you to make changes, contribute to the
154history, and ultimately enhance the Yocto Project's tools, Board Support
155Packages, and so forth.
156
157For any supported release of Yocto Project, you can also go to the
158:yocto_home:`Yocto Project Website <>` and select the "DOWNLOADS"
159item from the "SOFTWARE" menu and get a released tarball of the ``poky``
160repository, any supported BSP tarball, or Yocto Project tools. Unpacking
161these tarballs gives you a snapshot of the released files.
162
163.. note::
164
165 - The recommended method for setting up the Yocto Project
166 :term:`Source Directory` and the files
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500167 for supported BSPs (e.g., ``meta-intel``) is to use
168 :ref:`overview-manual/development-environment:git`
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500169 to create a local copy of the upstream repositories.
170
171 - Be sure to always work in matching branches for both the selected
172 BSP repository and the Source Directory (i.e. ``poky``)
Andrew Geissler595f6302022-01-24 19:11:47 +0000173 repository. For example, if you have checked out the "&DISTRO_NAME_NO_CAP;"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500174 branch of ``poky`` and you are going to use ``meta-intel``, be
Andrew Geissler595f6302022-01-24 19:11:47 +0000175 sure to checkout the "&DISTRO_NAME_NO_CAP;" branch of ``meta-intel``.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500176
177In summary, here is where you can get the project files needed for
178development:
179
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500180- :yocto_git:`Source Repositories: <>` This area contains Poky, Yocto
181 documentation, metadata layers, and Linux kernel. You can create local
182 copies of Git repositories for each of these areas.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500183
184 .. image:: figures/source-repos.png
Andrew Geisslerd5838332022-05-27 11:33:10 -0500185 :width: 100%
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500186
187 For steps on how to view and access these upstream Git repositories,
Andrew Geissler09209ee2020-12-13 08:44:15 -0600188 see the ":ref:`dev-manual/start:accessing source repositories`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500189 Section in the Yocto Project Development Tasks Manual.
190
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500191- :yocto_dl:`Yocto release archives: </releases/yocto>` This is where you can
192 download tarballs corresponding to each Yocto Project release. Downloading
193 and extracting these files does not produce a local copy of a Git repository
194 but rather a snapshot corresponding to a particular release.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500195
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500196- :yocto_home:`DOWNLOADS page </software-overview/downloads/>`:
197 The :yocto_home:`Yocto Project website <>` includes a "DOWNLOADS" page accessible
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500198 through the "SOFTWARE" menu that allows you to download any Yocto
199 Project release, tool, and Board Support Package (BSP) in tarball
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500200 form. The hyperlinks point to the tarballs under
201 :yocto_dl:`/releases/yocto/`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500202
203 .. image:: figures/yp-download.png
Andrew Geisslerd5838332022-05-27 11:33:10 -0500204 :width: 100%
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500205
206 For steps on how to use the "DOWNLOADS" page, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600207 ":ref:`dev-manual/start:using the downloads page`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500208 section in the Yocto Project Development Tasks Manual.
209
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500210Git Workflows and the Yocto Project
211===================================
212
213Developing using the Yocto Project likely requires the use of
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500214:ref:`overview-manual/development-environment:git`.
215Git is a free, open source distributed version control
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500216system used as part of many collaborative design environments. This
217section provides workflow concepts using the Yocto Project and Git. In
218particular, the information covers basic practices that describe roles
219and actions in a collaborative development environment.
220
221.. note::
222
223 If you are familiar with this type of development environment, you
224 might not want to read this section.
225
226The Yocto Project files are maintained using Git in "branches" whose Git
227histories track every change and whose structures provide branches for
228all diverging functionality. Although there is no need to use Git, many
229open source projects do so.
230
231For the Yocto Project, a key individual called the "maintainer" is
Andrew Geissler595f6302022-01-24 19:11:47 +0000232responsible for the integrity of the development branch of a given Git
233repository. The development branch is the "upstream" repository from which
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500234final or most recent builds of a project occur. The maintainer is
235responsible for accepting changes from other developers and for
236organizing the underlying branch structure to reflect release strategies
237and so forth.
238
239.. note::
240
241 For information on finding out who is responsible for (maintains) a
242 particular area of code in the Yocto Project, see the
Andrew Geissler5082cc72023-09-11 08:41:39 -0400243 ":doc:`../contributor-guide/identify-component`"
244 section of the Yocto Project and OpenEmbedded Contributor Guide.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500245
246The Yocto Project ``poky`` Git repository also has an upstream
247contribution Git repository named ``poky-contrib``. You can see all the
248branches in this repository using the web interface of the
249:yocto_git:`Source Repositories <>` organized within the "Poky Support"
250area. These branches hold changes (commits) to the project that have
251been submitted or committed by the Yocto Project development team and by
252community members who contribute to the project. The maintainer
253determines if the changes are qualified to be moved from the "contrib"
254branches into the "master" branch of the Git repository.
255
256Developers (including contributing community members) create and
257maintain cloned repositories of upstream branches. The cloned
258repositories are local to their development platforms and are used to
259develop changes. When a developer is satisfied with a particular feature
260or change, they "push" the change to the appropriate "contrib"
261repository.
262
263Developers are responsible for keeping their local repository up-to-date
264with whatever upstream branch they are working against. They are also
265responsible for straightening out any conflicts that might arise within
266files that are being worked on simultaneously by more than one person.
267All this work is done locally on the development host before anything is
268pushed to a "contrib" area and examined at the maintainer's level.
269
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700270There is a somewhat formal method by which developers commit changes and
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500271push them into the "contrib" area and subsequently request that the
272maintainer include them into an upstream branch. This process is called
273"submitting a patch" or "submitting a change." For information on
274submitting patches and changes, see the
Andrew Geissler5082cc72023-09-11 08:41:39 -0400275":doc:`../contributor-guide/submit-changes`" section in the Yocto Project
276and OpenEmbedded Contributor Guide.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500277
Andrew Geissler595f6302022-01-24 19:11:47 +0000278In summary, there is a single point of entry for changes into the
279development branch of the Git repository, which is controlled by the
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700280project's maintainer. A set of developers independently
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500281develop, test, and submit changes to "contrib" areas for the maintainer
282to examine. The maintainer then chooses which changes are going to
283become a permanent part of the project.
284
Andrew Geisslereff27472021-10-29 15:35:00 -0500285.. image:: svg/git-workflow.*
286 :width: 100%
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500287
288While each development environment is unique, there are some best
289practices or methods that help development run smoothly. The following
290list describes some of these practices. For more information about Git
291workflows, see the workflow topics in the `Git Community
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600292Book <https://book.git-scm.com>`__.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500293
294- *Make Small Changes:* It is best to keep the changes you commit small
295 as compared to bundling many disparate changes into a single commit.
296 This practice not only keeps things manageable but also allows the
297 maintainer to more easily include or refuse changes.
298
299- *Make Complete Changes:* It is also good practice to leave the
300 repository in a state that allows you to still successfully build
301 your project. In other words, do not commit half of a feature, then
302 add the other half as a separate, later commit. Each commit should
303 take you from one buildable project state to another buildable state.
304
305- *Use Branches Liberally:* It is very easy to create, use, and delete
306 local branches in your working Git repository on the development
307 host. You can name these branches anything you like. It is helpful to
308 give them names associated with the particular feature or change on
309 which you are working. Once you are done with a feature or change and
Andrew Geissler595f6302022-01-24 19:11:47 +0000310 have merged it into your local development branch, simply discard the
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500311 temporary branch.
312
313- *Merge Changes:* The ``git merge`` command allows you to take the
314 changes from one branch and fold them into another branch. This
315 process is especially helpful when more than a single developer might
316 be working on different parts of the same feature. Merging changes
317 also automatically identifies any collisions or "conflicts" that
318 might happen as a result of the same lines of code being altered by
319 two different developers.
320
321- *Manage Branches:* Because branches are easy to use, you should use a
322 system where branches indicate varying levels of code readiness. For
323 example, you can have a "work" branch to develop in, a "test" branch
324 where the code or change is tested, a "stage" branch where changes
325 are ready to be committed, and so forth. As your project develops,
326 you can merge code across the branches to reflect ever-increasing
327 stable states of the development.
328
329- *Use Push and Pull:* The push-pull workflow is based on the concept
330 of developers "pushing" local commits to a remote repository, which
331 is usually a contribution repository. This workflow is also based on
332 developers "pulling" known states of the project down into their
333 local development repositories. The workflow easily allows you to
334 pull changes submitted by other developers from the upstream
335 repository into your work area ensuring that you have the most recent
336 software on which to develop. The Yocto Project has two scripts named
337 ``create-pull-request`` and ``send-pull-request`` that ship with the
338 release to facilitate this workflow. You can find these scripts in
Andrew Geissler5082cc72023-09-11 08:41:39 -0400339 the ``scripts`` folder of the :term:`Source Directory`. For information
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500340 on how to use these scripts, see the
Andrew Geissler5082cc72023-09-11 08:41:39 -0400341 ":ref:`contributor-guide/submit-changes:using scripts to push a change upstream and request a pull`"
342 section in the Yocto Project and OpenEmbedded Contributor Guide.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500343
344- *Patch Workflow:* This workflow allows you to notify the maintainer
345 through an email that you have a change (or patch) you would like
Andrew Geissler595f6302022-01-24 19:11:47 +0000346 considered for the development branch of the Git repository. To send
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500347 this type of change, you format the patch and then send the email
348 using the Git commands ``git format-patch`` and ``git send-email``.
349 For information on how to use these scripts, see the
Andrew Geissler5082cc72023-09-11 08:41:39 -0400350 ":doc:`../contributor-guide/submit-changes`" section in the Yocto Project
351 and OpenEmbedded Contributor Guide.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500352
353Git
354===
355
356The Yocto Project makes extensive use of Git, which is a free, open
357source distributed version control system. Git supports distributed
358development, non-linear development, and can handle large projects. It
359is best that you have some fundamental understanding of how Git tracks
360projects and how to work with Git if you are going to use the Yocto
361Project for development. This section provides a quick overview of how
362Git works and provides you with a summary of some essential Git
363commands.
364
365.. note::
366
367 - For more information on Git, see
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600368 https://git-scm.com/documentation.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500369
370 - If you need to download Git, it is recommended that you add Git to
371 your system through your distribution's "software store" (e.g. for
372 Ubuntu, use the Ubuntu Software feature). For the Git download
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600373 page, see https://git-scm.com/download.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500374
375 - For information beyond the introductory nature in this section,
Andrew Geissler09209ee2020-12-13 08:44:15 -0600376 see the ":ref:`dev-manual/start:locating yocto project source files`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500377 section in the Yocto Project Development Tasks Manual.
378
379Repositories, Tags, and Branches
380--------------------------------
381
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500382As mentioned briefly in the previous section and also in the
383":ref:`overview-manual/development-environment:git workflows and the yocto project`"
384section, the Yocto Project maintains source repositories at :yocto_git:`/`.
385If you look at this web-interface of the repositories, each item is a separate
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500386Git repository.
387
388Git repositories use branching techniques that track content change (not
389files) within a project (e.g. a new feature or updated documentation).
390Creating a tree-like structure based on project divergence allows for
391excellent historical information over the life of a project. This
392methodology also allows for an environment from which you can do lots of
393local experimentation on projects as you develop changes or new
394features.
395
396A Git repository represents all development efforts for a given project.
397For example, the Git repository ``poky`` contains all changes and
398developments for that repository over the course of its entire life.
399That means that all changes that make up all releases are captured. The
400repository maintains a complete history of changes.
401
402You can create a local copy of any repository by "cloning" it with the
403``git clone`` command. When you clone a Git repository, you end up with
404an identical copy of the repository on your development system. Once you
405have a local copy of a repository, you can take steps to develop
406locally. For examples on how to clone Git repositories, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600407":ref:`dev-manual/start:locating yocto project source files`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500408section in the Yocto Project Development Tasks Manual.
409
410It is important to understand that Git tracks content change and not
411files. Git uses "branches" to organize different development efforts.
412For example, the ``poky`` repository has several branches that include
413the current "&DISTRO_NAME_NO_CAP;" branch, the "master" branch, and many
414branches for past Yocto Project releases. You can see all the branches
Andrew Geissler09209ee2020-12-13 08:44:15 -0600415by going to :yocto_git:`/poky/` and clicking on the
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500416``[...]`` link beneath the "Branch" heading.
417
418Each of these branches represents a specific area of development. The
419"master" branch represents the current or most recent development. All
420other branches represent offshoots of the "master" branch.
421
422When you create a local copy of a Git repository, the copy has the same
423set of branches as the original. This means you can use Git to create a
424local working area (also called a branch) that tracks a specific
Patrick Williams45852732022-04-02 08:58:32 -0500425development branch from the upstream source Git repository. In other
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500426words, you can define your local Git environment to work on any
427development branch in the repository. To help illustrate, consider the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500428following example Git commands::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500429
430 $ cd ~
Andrew Geissler595f6302022-01-24 19:11:47 +0000431 $ git clone git://git.yoctoproject.org/poky -b &DISTRO_NAME_NO_CAP;
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500432
433In the previous example
434after moving to the home directory, the ``git clone`` command creates a
Andrew Geissler595f6302022-01-24 19:11:47 +0000435local copy of the upstream ``poky`` Git repository and checks out a
436local branch named "&DISTRO_NAME_NO_CAP;", which tracks the upstream
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500437"origin/&DISTRO_NAME_NO_CAP;" branch. Changes you make while in this
438branch would ultimately affect the upstream "&DISTRO_NAME_NO_CAP;" branch
439of the ``poky`` repository.
440
441It is important to understand that when you create and checkout a local
442working branch based on a branch name, your local environment matches
443the "tip" of that particular development branch at the time you created
444your local branch, which could be different from the files in the
445"master" branch of the upstream repository. In other words, creating and
446checking out a local branch based on the "&DISTRO_NAME_NO_CAP;" branch
447name is not the same as checking out the "master" branch in the
448repository. Keep reading to see how you create a local snapshot of a
449Yocto Project Release.
450
451Git uses "tags" to mark specific changes in a repository branch
452structure. Typically, a tag is used to mark a special point such as the
453final change (or commit) before a project is released. You can see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600454tags used with the ``poky`` Git repository by going to :yocto_git:`/poky/`
455and clicking on the ``[...]`` link beneath the "Tag" heading.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500456
457Some key tags for the ``poky`` repository are ``jethro-14.0.3``,
458``morty-16.0.1``, ``pyro-17.0.0``, and
Andrew Geissler9aee5002022-03-30 16:27:02 +0000459``&DISTRO_NAME_NO_CAP;-&DISTRO;``. These tags represent Yocto Project
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500460releases.
461
462When you create a local copy of the Git repository, you also have access
463to all the tags in the upstream repository. Similar to branches, you can
464create and checkout a local working Git branch based on a tag name. When
465you do this, you get a snapshot of the Git repository that reflects the
466state of the files when the change was made associated with that tag.
467The most common use is to checkout a working branch that matches a
Andrew Geisslerc926e172021-05-07 16:11:35 -0500468specific Yocto Project release. Here is an example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500469
470 $ cd ~
471 $ git clone git://git.yoctoproject.org/poky
472 $ cd poky
473 $ git fetch --tags
474 $ git checkout tags/rocko-18.0.0 -b my_rocko-18.0.0
475
476In this example, the name
477of the top-level directory of your local Yocto Project repository is
478``poky``. After moving to the ``poky`` directory, the ``git fetch``
479command makes all the upstream tags available locally in your
480repository. Finally, the ``git checkout`` command creates and checks out
481a branch named "my-rocko-18.0.0" that is based on the upstream branch
482whose "HEAD" matches the commit in the repository associated with the
483"rocko-18.0.0" tag. The files in your repository now exactly match that
484particular Yocto Project release as it is tagged in the upstream Git
485repository. It is important to understand that when you create and
486checkout a local working branch based on a tag, your environment matches
487a specific point in time and not the entire development branch (i.e.
488from the "tip" of the branch backwards).
489
490Basic Commands
491--------------
492
493Git has an extensive set of commands that lets you manage changes and
494perform collaboration over the life of a project. Conveniently though,
495you can manage with a small set of basic operations and workflows once
496you understand the basic philosophy behind Git. You do not have to be an
497expert in Git to be functional. A good place to look for instruction on
498a minimal set of Git commands is
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600499`here <https://git-scm.com/documentation>`__.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500500
501The following list of Git commands briefly describes some basic Git
502operations as a way to get started. As with any set of commands, this
503list (in most cases) simply shows the base command and omits the many
504arguments it supports. See the Git documentation for complete
505descriptions and strategies on how to use these commands:
506
507- *git init:* Initializes an empty Git repository. You cannot use
508 Git commands unless you have a ``.git`` repository.
509
510- *git clone:* Creates a local clone of a Git repository that is on
511 equal footing with a fellow developer's Git repository or an upstream
512 repository.
513
514- *git add:* Locally stages updated file contents to the index that
515 Git uses to track changes. You must stage all files that have changed
516 before you can commit them.
517
518- *git commit:* Creates a local "commit" that documents the changes
519 you made. Only changes that have been staged can be committed.
520 Commits are used for historical purposes, for determining if a
521 maintainer of a project will allow the change, and for ultimately
522 pushing the change from your local Git repository into the project's
523 upstream repository.
524
525- *git status:* Reports any modified files that possibly need to be
526 staged and gives you a status of where you stand regarding local
527 commits as compared to the upstream repository.
528
529- *git checkout branch-name:* Changes your local working branch and
530 in this form assumes the local branch already exists. This command is
531 analogous to "cd".
532
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500533- *git checkout -b working-branch upstream-branch:* Creates and
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500534 checks out a working branch on your local machine. The local branch
535 tracks the upstream branch. You can use your local branch to isolate
536 your work. It is a good idea to use local branches when adding
537 specific features or changes. Using isolated branches facilitates
538 easy removal of changes if they do not work out.
539
540- *git branch:* Displays the existing local branches associated
541 with your local repository. The branch that you have currently
542 checked out is noted with an asterisk character.
543
544- *git branch -D branch-name:* Deletes an existing local branch.
545 You need to be in a local branch other than the one you are deleting
546 in order to delete branch-name.
547
Patrick Williams45852732022-04-02 08:58:32 -0500548- *git pull \-\-rebase*: Retrieves information from an upstream Git
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500549 repository and places it in your local Git repository. You use this
550 command to make sure you are synchronized with the repository from
Andrew Geissler595f6302022-01-24 19:11:47 +0000551 which you are basing changes (e.g. the "&DISTRO_NAME_NO_CAP;"
Patrick Williams45852732022-04-02 08:58:32 -0500552 branch). The ``--rebase`` option ensures that any local commits you
Andrew Geissler595f6302022-01-24 19:11:47 +0000553 have in your branch are preserved at the top of your local branch.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500554
555- *git push repo-name local-branch:upstream-branch:* Sends
556 all your committed local changes to the upstream Git repository that
557 your local repository is tracking (e.g. a contribution repository).
558 The maintainer of the project draws from these repositories to merge
559 changes (commits) into the appropriate branch of project's upstream
560 repository.
561
562- *git merge:* Combines or adds changes from one local branch of
563 your repository with another branch. When you create a local Git
Andrew Geissler595f6302022-01-24 19:11:47 +0000564 repository, the default branch may be named "main". A typical
565 workflow is to create a temporary branch that is based off "main"
566 that you would use for isolated work. You would make your changes in
567 that isolated branch, stage and commit them locally, switch to the
568 "main" branch, and then use the ``git merge`` command to apply the
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500569 changes from your isolated branch into the currently checked out
Andrew Geissler595f6302022-01-24 19:11:47 +0000570 branch (e.g. "main"). After the merge is complete and if you are
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500571 done with working in that isolated branch, you can safely delete the
572 isolated branch.
573
574- *git cherry-pick commits:* Choose and apply specific commits from
575 one branch into another branch. There are times when you might not be
576 able to merge all the changes in one branch with another but need to
577 pick out certain ones.
578
579- *gitk:* Provides a GUI view of the branches and changes in your
580 local Git repository. This command is a good way to graphically see
581 where things have diverged in your local repository.
582
583 .. note::
584
585 You need to install the
586 gitk
587 package on your development system to use this command.
588
589- *git log:* Reports a history of your commits to the repository.
590 This report lists all commits regardless of whether you have pushed
591 them upstream or not.
592
593- *git diff:* Displays line-by-line differences between a local
594 working file and the same file as understood by Git. This command is
595 useful to see what you have changed in any given file.
596
597Licensing
598=========
599
600Because open source projects are open to the public, they have different
601licensing structures in place. License evolution for both Open Source
602and Free Software has an interesting history. If you are interested in
603this history, you can find basic information here:
604
Patrick Williams7784c422022-11-17 07:29:11 -0600605- :wikipedia:`Open source license history <Open-source_license>`
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500606
Patrick Williams7784c422022-11-17 07:29:11 -0600607- :wikipedia:`Free software license history <Free_software_license>`
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500608
609In general, the Yocto Project is broadly licensed under the
610Massachusetts Institute of Technology (MIT) License. MIT licensing
611permits the reuse of software within proprietary software as long as the
Patrick Williams03907ee2022-05-01 06:28:52 -0500612license is distributed with that software. Patches to the Yocto Project
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500613follow the upstream licensing scheme. You can find information on the
Patrick Williams7784c422022-11-17 07:29:11 -0600614MIT license :wikipedia:`here <MIT_License>`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500615
616When you build an image using the Yocto Project, the build process uses
617a known list of licenses to ensure compliance. You can find this list in
Patrick Williams2390b1b2022-11-03 13:47:49 -0500618the :term:`Source Directory` at ``meta/files/common-licenses``. Once the
619build completes, the list of all licenses found and used during that build
620are kept in the :term:`Build Directory` at ``tmp/deploy/licenses``.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500621
622If a module requires a license that is not in the base list, the build
623process generates a warning during the build. These tools make it easier
624for a developer to be certain of the licenses with which their shipped
625products must comply. However, even with these tools it is still up to
626the developer to resolve potential licensing issues.
627
628The base list of licenses used by the build process is a combination of
629the Software Package Data Exchange (SPDX) list and the Open Source
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600630Initiative (OSI) projects. `SPDX Group <https://spdx.org>`__ is a working
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500631group of the Linux Foundation that maintains a specification for a
632standard format for communicating the components, licenses, and
633copyrights associated with a software package.
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600634`OSI <https://opensource.org>`__ is a corporation dedicated to the Open
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500635Source Definition and the effort for reviewing and approving licenses
636that conform to the Open Source Definition (OSD).
637
638You can find a list of the combined SPDX and OSI licenses that the Yocto
639Project uses in the ``meta/files/common-licenses`` directory in your
640:term:`Source Directory`.
641
642For information that can help you maintain compliance with various open
643source licensing during the lifecycle of a product created using the
644Yocto Project, see the
Andrew Geissler517393d2023-01-13 08:55:19 -0600645":ref:`dev-manual/licenses:maintaining open source license compliance during your product's lifecycle`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500646section in the Yocto Project Development Tasks Manual.