blob: 36ebf8a3218e6c91b0feb69c727e20b88ee6060e [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
2"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
3[<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
4
5<chapter id='overview-development-environment'>
6<title>The Yocto Project Development Environment</title>
7
8<para>
9 This chapter takes a look at the Yocto Project development
10 environment.
11 The chapter provides Yocto Project Development environment concepts that
12 help you understand how work is accomplished in an open source environment,
13 which is very different as compared to work accomplished in a closed,
14 proprietary environment.
15</para>
16
17<para>
18 Specifically, this chapter addresses open source philosophy, source
19 repositories, workflows, Git, and licensing.
20</para>
21
22<section id='open-source-philosophy'>
23 <title>Open Source Philosophy</title>
24
25 <para>
26 Open source philosophy is characterized by software development
27 directed by peer production and collaboration through an active
28 community of developers.
29 Contrast this to the more standard centralized development models
30 used by commercial software companies where a finite set of developers
31 produces a product for sale using a defined set of procedures that
32 ultimately result in an end product whose architecture and source
33 material are closed to the public.
34 </para>
35
36 <para>
37 Open source projects conceptually have differing concurrent agendas,
38 approaches, and production.
39 These facets of the development process can come from anyone in the
40 public (community) who has a stake in the software project.
41 The open source environment contains new copyright, licensing, domain,
42 and consumer issues that differ from the more traditional development
43 environment.
44 In an open source environment, the end product, source material,
45 and documentation are all available to the public at no cost.
46 </para>
47
48 <para>
49 A benchmark example of an open source project is the Linux kernel,
50 which was initially conceived and created by Finnish computer science
51 student Linus Torvalds in 1991.
52 Conversely, a good example of a non-open source project is the
53 <trademark class='registered'>Windows</trademark> family of operating
54 systems developed by
55 <trademark class='registered'>Microsoft</trademark> Corporation.
56 </para>
57
58 <para>
59 Wikipedia has a good historical description of the Open Source
60 Philosophy
61 <ulink url='http://en.wikipedia.org/wiki/Open_source'>here</ulink>.
62 You can also find helpful information on how to participate in the
63 Linux Community
64 <ulink url='http://ldn.linuxfoundation.org/book/how-participate-linux-community'>here</ulink>.
65 </para>
66</section>
67
68<section id='gs-the-development-host'>
69 <title>The Development Host</title>
70
71 <para>
72 A development host or
73 <ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>
74 is key to using the Yocto Project.
75 Because the goal of the Yocto Project is to develop images or
76 applications that run on embedded hardware, development of those
77 images and applications generally takes place on a system not
78 intended to run the software - the development host.
79 </para>
80
81 <para>
82 You need to set up a development host in order to use it with the
83 Yocto Project.
84 Most find that it is best to have a native Linux machine function as
85 the development host.
86 However, it is possible to use a system that does not run Linux
87 as its operating system as your development host.
88 When you have a Mac or Windows-based system, you can set it up
89 as the development host by using
Andrew Geissler82c905d2020-04-13 13:39:40 -050090 <ulink url='https://github.com/crops/poky-container'>CROPS</ulink>,
Brad Bishop316dfdd2018-06-25 12:45:53 -040091 which leverages
92 <ulink url='https://www.docker.com/'>Docker Containers</ulink>.
93 Once you take the steps to set up a CROPS machine, you effectively
94 have access to a shell environment that is similar to what you see
95 when using a Linux-based development host.
96 For the steps needed to set up a system using CROPS, see the
97 "<ulink url='&YOCTO_DOCS_DEV_URL;#setting-up-to-use-crops'>Setting Up to Use CROss PlatformS (CROPS)</ulink>"
98 section in the Yocto Project Development Tasks Manual.
99 </para>
100
101 <para>
102 If your development host is going to be a system that runs a Linux
103 distribution, steps still exist that you must take to prepare the
104 system for use with the Yocto Project.
105 You need to be sure that the Linux distribution on the system is
106 one that supports the Yocto Project.
107 You also need to be sure that the correct set of host packages are
108 installed that allow development using the Yocto Project.
109 For the steps needed to set up a development host that runs Linux,
110 see the
111 "<ulink url='&YOCTO_DOCS_DEV_URL;#setting-up-a-native-linux-host'>Setting Up a Native Linux Host</ulink>"
112 section in the Yocto Project Development Tasks Manual.
113 </para>
114
115 <para>
116 Once your development host is set up to use the Yocto Project,
117 several methods exist for you to do work in the Yocto Project
118 environment:
119 <itemizedlist>
120 <listitem><para>
121 <emphasis>Command Lines, BitBake, and Shells:</emphasis>
122 Traditional development in the Yocto Project involves using the
123 <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>,
124 which uses BitBake, in a command-line environment from a shell
125 on your development host.
126 You can accomplish this from a host that is a native Linux
127 machine or from a host that has been set up with CROPS.
128 Either way, you create, modify, and build images and
129 applications all within a shell-based environment using
130 components and tools available through your Linux distribution
131 and the Yocto Project.</para>
132
133 <para>For a general flow of the build procedures, see the
134 "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-building-a-simple-image'>Building a Simple Image</ulink>"
135 section in the Yocto Project Development Tasks Manual.
136 </para></listitem>
137 <listitem><para>
138 <emphasis>Board Support Package (BSP) Development:</emphasis>
139 Development of BSPs involves using the Yocto Project to
140 create and test layers that allow easy development of
141 images and applications targeted for specific hardware.
142 To development BSPs, you need to take some additional steps
143 beyond what was described in setting up a development host.
144 </para>
145
146 <para>The
147 <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>
148 provides BSP-related development information.
149 For specifics on development host preparation, see the
150 "<ulink url='&YOCTO_DOCS_BSP_URL;#preparing-your-build-host-to-work-with-bsp-layers'>Preparing Your Build Host to Work With BSP Layers</ulink>"
151 section in the Yocto Project Board Support Package (BSP)
152 Developer's Guide.
153 </para></listitem>
154 <listitem><para>
155 <emphasis>Kernel Development:</emphasis>
156 If you are going to be developing kernels using the Yocto
157 Project you likely will be using <filename>devtool</filename>.
158 A workflow using <filename>devtool</filename> makes kernel
159 development quicker by reducing iteration cycle times.</para>
160
161 <para>The
162 <ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;'>Yocto Project Linux Kernel Development Manual</ulink>
163 provides kernel-related development information.
164 For specifics on development host preparation, see the
165 "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#preparing-the-build-host-to-work-on-the-kernel'>Preparing the Build Host to Work on the Kernel</ulink>"
166 section in the Yocto Project Linux Kernel Development Manual.
167 </para></listitem>
168 <listitem><para>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400169 <emphasis>Using Toaster:</emphasis>
170 The other Yocto Project development method that involves an
171 interface that effectively puts the Yocto Project into the
172 background is Toaster.
173 Toaster provides an interface to the OpenEmbedded build system.
174 The interface enables you to configure and run your builds.
175 Information about builds is collected and stored in a database.
176 You can use Toaster to configure and start builds on multiple
177 remote build servers.</para>
178
179 <para>For steps that show you how to set up your development
180 host to use Toaster and on how to use Toaster in general,
181 see the
182 <ulink url='&YOCTO_DOCS_TOAST_URL;'>Toaster User Manual</ulink>.
183 </para></listitem>
184 </itemizedlist>
185 </para>
186</section>
187
188<section id='yocto-project-repositories'>
189 <title>Yocto Project Source Repositories</title>
190
191 <para>
192 The Yocto Project team maintains complete source repositories for all
193 Yocto Project files at
194 <ulink url='&YOCTO_GIT_URL;'></ulink>.
195 This web-based source code browser is organized into categories by
196 function such as IDE Plugins, Matchbox, Poky, Yocto Linux Kernel, and
197 so forth.
198 From the interface, you can click on any particular item in the "Name"
199 column and see the URL at the bottom of the page that you need to clone
200 a Git repository for that particular item.
201 Having a local Git repository of the
202 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>,
203 which is usually named "poky", allows
204 you to make changes, contribute to the history, and ultimately enhance
205 the Yocto Project's tools, Board Support Packages, and so forth.
206 </para>
207
208 <para>
209 For any supported release of Yocto Project, you can also go to the
210 <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink> and
211 select the "DOWNLOADS" item from the "SOFTWARE" menu and get a
212 released tarball of the <filename>poky</filename> repository, any
213 supported BSP tarball, or Yocto Project tools.
214 Unpacking these tarballs gives you a snapshot of the released
215 files.
216 <note><title>Notes</title>
217 <itemizedlist>
218 <listitem><para>
219 The recommended method for setting up the Yocto Project
220 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
221 and the files for supported BSPs
222 (e.g., <filename>meta-intel</filename>) is to use
223 <link linkend='git'>Git</link> to create a local copy of
224 the upstream repositories.
225 </para></listitem>
226 <listitem><para>
227 Be sure to always work in matching branches for both
228 the selected BSP repository and the Source Directory
229 (i.e. <filename>poky</filename>) repository.
230 For example, if you have checked out the "master" branch
231 of <filename>poky</filename> and you are going to use
232 <filename>meta-intel</filename>, be sure to checkout the
233 "master" branch of <filename>meta-intel</filename>.
234 </para></listitem>
235 </itemizedlist>
236 </note>
237 </para>
238
239 <para>
240 In summary, here is where you can get the project files needed for
241 development:
242 <itemizedlist>
243 <listitem><para id='source-repositories'>
244 <emphasis>
245 <ulink url='&YOCTO_GIT_URL;'>Source Repositories:</ulink>
246 </emphasis>
247 This area contains IDE Plugins, Matchbox, Poky, Poky Support,
248 Tools, Yocto Linux Kernel, and Yocto Metadata Layers.
249 You can create local copies of Git repositories for each of
250 these areas.</para>
251
252 <para>
253 <imagedata fileref="figures/source-repos.png" align="center" width="6in" depth="4in" />
254 For steps on how to view and access these upstream Git
255 repositories, see the
256 "<ulink url='&YOCTO_DOCS_DEV_URL;#accessing-source-repositories'>Accessing Source Repositories</ulink>"
257 Section in the Yocto Project Development Tasks Manual.
258 </para></listitem>
259 <listitem><para><anchor id='index-downloads' />
260 <emphasis>
261 <ulink url='&YOCTO_DL_URL;/releases/'>Index of /releases:</ulink>
262 </emphasis>
Brad Bishopc342db32019-05-15 21:57:59 -0400263 This is an index of releases such as Poky, Pseudo, installers
264 for cross-development toolchains, miscellaneous support
265 and all released versions of Yocto Project in the form of
266 images or tarballs.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400267 Downloading and extracting these files does not produce a local
268 copy of the Git repository but rather a snapshot of a
269 particular release or image.</para>
270
271 <para>
272 <imagedata fileref="figures/index-downloads.png" align="center" width="6in" depth="3.5in" />
273 For steps on how to view and access these files, see the
274 "<ulink url='&YOCTO_DOCS_DEV_URL;#accessing-index-of-releases'>Accessing Index of Releases</ulink>"
275 section in the Yocto Project Development Tasks Manual.
276 </para></listitem>
277 <listitem><para id='downloads-page'>
278 <emphasis>"DOWNLOADS" page for the
279 <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>:
280 </emphasis></para>
281
282 <para>The Yocto Project website includes a "DOWNLOADS" page
283 accessible through the "SOFTWARE" menu that allows you to
284 download any Yocto Project release, tool, and Board Support
285 Package (BSP) in tarball form.
286 The tarballs are similar to those found in the
287 <ulink url='&YOCTO_DL_URL;/releases/'>Index of /releases:</ulink>
288 area.</para>
289
290 <para>
291 <imagedata fileref="figures/yp-download.png" align="center" width="6in" depth="4in" />
292 For steps on how to use the "DOWNLOADS" page, see the
293 "<ulink url='&YOCTO_DOCS_DEV_URL;#using-the-downloads-page'>Using the Downloads Page</ulink>"
294 section in the Yocto Project Development Tasks Manual.
295 </para></listitem>
296 </itemizedlist>
297 </para>
298</section>
299
300<section id='gs-git-workflows-and-the-yocto-project'>
301 <title>Git Workflows and the Yocto Project</title>
302
303 <para>
304 Developing using the Yocto Project likely requires the use of
305 <link linkend='git'>Git</link>.
306 Git is a free, open source distributed version control system
307 used as part of many collaborative design environments.
308 This section provides workflow concepts using the Yocto Project and
309 Git.
310 In particular, the information covers basic practices that describe
311 roles and actions in a collaborative development environment.
312 <note>
313 If you are familiar with this type of development environment, you
314 might not want to read this section.
315 </note>
316 </para>
317
318 <para>
319 The Yocto Project files are maintained using Git in "branches"
320 whose Git histories track every change and whose structures
321 provide branches for all diverging functionality.
322 Although there is no need to use Git, many open source projects do so.
323 <para>
324
325 </para>
326 For the Yocto Project, a key individual called the "maintainer" is
327 responsible for the integrity of the "master" branch of a given Git
328 repository.
329 The "master" branch is the “upstream” repository from which final or
330 most recent builds of a project occur.
331 The maintainer is responsible for accepting changes from other
332 developers and for organizing the underlying branch structure to
333 reflect release strategies and so forth.
334 <note>
335 For information on finding out who is responsible for (maintains)
336 a particular area of code in the Yocto Project, see the
337 "<ulink url='&YOCTO_DOCS_DEV_URL;#how-to-submit-a-change'>Submitting a Change to the Yocto Project</ulink>"
338 section of the Yocto Project Development Tasks Manual.
339 </note>
340 </para>
341
342 <para>
343 The Yocto Project <filename>poky</filename> Git repository also has an
344 upstream contribution Git repository named
345 <filename>poky-contrib</filename>.
346 You can see all the branches in this repository using the web interface
347 of the
348 <ulink url='&YOCTO_GIT_URL;'>Source Repositories</ulink> organized
349 within the "Poky Support" area.
350 These branches hold changes (commits) to the project that have been
351 submitted or committed by the Yocto Project development team and by
352 community members who contribute to the project.
353 The maintainer determines if the changes are qualified to be moved
354 from the "contrib" branches into the "master" branch of the Git
355 repository.
356 </para>
357
358 <para>
359 Developers (including contributing community members) create and
360 maintain cloned repositories of upstream branches.
361 The cloned repositories are local to their development platforms and
362 are used to develop changes.
363 When a developer is satisfied with a particular feature or change,
364 they "push" the change to the appropriate "contrib" repository.
365 </para>
366
367 <para>
368 Developers are responsible for keeping their local repository
369 up-to-date with whatever upstream branch they are working against.
370 They are also responsible for straightening out any conflicts that
371 might arise within files that are being worked on simultaneously by
372 more than one person.
373 All this work is done locally on the development host before
374 anything is pushed to a "contrib" area and examined at the maintainer’s
375 level.
376 </para>
377
378 <para>
379 A somewhat formal method exists by which developers commit changes
380 and push them into the "contrib" area and subsequently request that
381 the maintainer include them into an upstream branch.
382 This process is called “submitting a patch” or "submitting a change."
383 For information on submitting patches and changes, see the
384 "<ulink url='&YOCTO_DOCS_DEV_URL;#how-to-submit-a-change'>Submitting a Change to the Yocto Project</ulink>"
385 section in the Yocto Project Development Tasks Manual.
386 </para>
387
388 <para>
389 In summary, a single point of entry
390 exists for changes into a "master" or development branch of the
391 Git repository, which is controlled by the project’s maintainer.
392 And, a set of developers exist who independently develop, test, and
393 submit changes to "contrib" areas for the maintainer to examine.
394 The maintainer then chooses which changes are going to become a
395 permanent part of the project.
396 </para>
397
398 <para>
399 <imagedata fileref="figures/git-workflow.png" width="6in" depth="3in" align="left" scalefit="1" />
400 </para>
401
402 <para>
403 While each development environment is unique, there are some best
404 practices or methods that help development run smoothly.
405 The following list describes some of these practices.
406 For more information about Git workflows, see the workflow topics in
407 the
408 <ulink url='http://book.git-scm.com'>Git Community Book</ulink>.
409 <itemizedlist>
410 <listitem><para>
411 <emphasis>Make Small Changes:</emphasis>
412 It is best to keep the changes you commit small as compared to
413 bundling many disparate changes into a single commit.
414 This practice not only keeps things manageable but also allows
415 the maintainer to more easily include or refuse changes.
416 </para></listitem>
417 <listitem><para>
418 <emphasis>Make Complete Changes:</emphasis>
419 It is also good practice to leave the repository in a
420 state that allows you to still successfully build your project.
421 In other words, do not commit half of a feature,
422 then add the other half as a separate, later commit.
423 Each commit should take you from one buildable project state
424 to another buildable state.
425 </para></listitem>
426 <listitem><para>
427 <emphasis>Use Branches Liberally:</emphasis>
428 It is very easy to create, use, and delete local branches in
429 your working Git repository on the development host.
430 You can name these branches anything you like.
431 It is helpful to give them names associated with the particular
432 feature or change on which you are working.
433 Once you are done with a feature or change and have merged it
434 into your local master branch, simply discard the temporary
435 branch.
436 </para></listitem>
437 <listitem><para>
438 <emphasis>Merge Changes:</emphasis>
439 The <filename>git merge</filename> command allows you to take
440 the changes from one branch and fold them into another branch.
441 This process is especially helpful when more than a single
442 developer might be working on different parts of the same
443 feature.
444 Merging changes also automatically identifies any collisions
445 or "conflicts" that might happen as a result of the same lines
446 of code being altered by two different developers.
447 </para></listitem>
448 <listitem><para>
449 <emphasis>Manage Branches:</emphasis>
450 Because branches are easy to use, you should use a system
451 where branches indicate varying levels of code readiness.
452 For example, you can have a "work" branch to develop in, a
453 "test" branch where the code or change is tested, a "stage"
454 branch where changes are ready to be committed, and so forth.
455 As your project develops, you can merge code across the
456 branches to reflect ever-increasing stable states of the
457 development.
458 </para></listitem>
459 <listitem><para>
460 <emphasis>Use Push and Pull:</emphasis>
461 The push-pull workflow is based on the concept of developers
462 "pushing" local commits to a remote repository, which is
463 usually a contribution repository.
464 This workflow is also based on developers "pulling" known
465 states of the project down into their local development
466 repositories.
467 The workflow easily allows you to pull changes submitted by
468 other developers from the upstream repository into your
469 work area ensuring that you have the most recent software
470 on which to develop.
471 The Yocto Project has two scripts named
472 <filename>create-pull-request</filename> and
473 <filename>send-pull-request</filename> that ship with the
474 release to facilitate this workflow.
475 You can find these scripts in the <filename>scripts</filename>
476 folder of the
477 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
478 For information on how to use these scripts, see the
479 "<ulink url='&YOCTO_DOCS_DEV_URL;#pushing-a-change-upstream'>Using Scripts to Push a Change Upstream and Request a Pull</ulink>"
480 section in the Yocto Project Development Tasks Manual.
481 </para></listitem>
482 <listitem><para>
483 <emphasis>Patch Workflow:</emphasis>
484 This workflow allows you to notify the maintainer through an
485 email that you have a change (or patch) you would like
486 considered for the "master" branch of the Git repository.
487 To send this type of change, you format the patch and then
488 send the email using the Git commands
489 <filename>git format-patch</filename> and
490 <filename>git send-email</filename>.
491 For information on how to use these scripts, see the
492 "<ulink url='&YOCTO_DOCS_DEV_URL;#how-to-submit-a-change'>Submitting a Change to the Yocto Project</ulink>"
493 section in the Yocto Project Development Tasks Manual.
494 </para></listitem>
495 </itemizedlist>
496 </para>
497</section>
498
499<section id='git'>
500 <title>Git</title>
501
502 <para>
503 The Yocto Project makes extensive use of Git, which is a
504 free, open source distributed version control system.
505 Git supports distributed development, non-linear development,
506 and can handle large projects.
507 It is best that you have some fundamental understanding
508 of how Git tracks projects and how to work with Git if
509 you are going to use the Yocto Project for development.
510 This section provides a quick overview of how Git works and
511 provides you with a summary of some essential Git commands.
512 <note><title>Notes</title>
513 <itemizedlist>
514 <listitem><para>
515 For more information on Git, see
516 <ulink url='http://git-scm.com/documentation'></ulink>.
517 </para></listitem>
518 <listitem><para>
519 If you need to download Git, it is recommended that you add
520 Git to your system through your distribution's "software
521 store" (e.g. for Ubuntu, use the Ubuntu Software feature).
522 For the Git download page, see
523 <ulink url='http://git-scm.com/download'></ulink>.
524 </para></listitem>
525 <listitem><para>
526 For information beyond the introductory nature in this
527 section, see the
528 "<ulink url='&YOCTO_DOCS_DEV_URL;#locating-yocto-project-source-files'>Locating Yocto Project Source Files</ulink>"
529 section in the Yocto Project Development Tasks Manual.
530 </para></listitem>
531 </itemizedlist>
532 </note>
533 </para>
534
535 <section id='repositories-tags-and-branches'>
536 <title>Repositories, Tags, and Branches</title>
537
538 <para>
539 As mentioned briefly in the previous section and also in the
540 "<link linkend='gs-git-workflows-and-the-yocto-project'>Git Workflows and the Yocto Project</link>"
541 section, the Yocto Project maintains source repositories at
542 <ulink url='&YOCTO_GIT_URL;'></ulink>.
543 If you look at this web-interface of the repositories, each item
544 is a separate Git repository.
545 </para>
546
547 <para>
548 Git repositories use branching techniques that track content
549 change (not files) within a project (e.g. a new feature or updated
550 documentation).
551 Creating a tree-like structure based on project divergence allows
552 for excellent historical information over the life of a project.
553 This methodology also allows for an environment from which you can
554 do lots of local experimentation on projects as you develop
555 changes or new features.
556 </para>
557
558 <para>
559 A Git repository represents all development efforts for a given
560 project.
561 For example, the Git repository <filename>poky</filename> contains
562 all changes and developments for that repository over the course
563 of its entire life.
564 That means that all changes that make up all releases are captured.
565 The repository maintains a complete history of changes.
566 </para>
567
568 <para>
569 You can create a local copy of any repository by "cloning" it
570 with the <filename>git clone</filename> command.
571 When you clone a Git repository, you end up with an identical
572 copy of the repository on your development system.
573 Once you have a local copy of a repository, you can take steps to
574 develop locally.
575 For examples on how to clone Git repositories, see the
576 "<ulink url='&YOCTO_DOCS_DEV_URL;#locating-yocto-project-source-files'>Locating Yocto Project Source Files</ulink>"
577 section in the Yocto Project Development Tasks Manual.
578 </para>
579
580 <para>
581 It is important to understand that Git tracks content change and
582 not files.
583 Git uses "branches" to organize different development efforts.
584 For example, the <filename>poky</filename> repository has
585 several branches that include the current "&DISTRO_NAME_NO_CAP;"
586 branch, the "master" branch, and many branches for past
587 Yocto Project releases.
588 You can see all the branches by going to
589 <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and
590 clicking on the
591 <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/heads'>[...]</ulink></filename>
592 link beneath the "Branch" heading.
593 </para>
594
595 <para>
596 Each of these branches represents a specific area of development.
597 The "master" branch represents the current or most recent
598 development.
599 All other branches represent offshoots of the "master" branch.
600 </para>
601
602 <para>
603 When you create a local copy of a Git repository, the copy has
604 the same set of branches as the original.
605 This means you can use Git to create a local working area
606 (also called a branch) that tracks a specific development branch
607 from the upstream source Git repository.
608 in other words, you can define your local Git environment to
609 work on any development branch in the repository.
610 To help illustrate, consider the following example Git commands:
611 <literallayout class='monospaced'>
612 $ cd ~
613 $ git clone git://git.yoctoproject.org/poky
614 $ cd poky
615 $ git checkout -b &DISTRO_NAME_NO_CAP; origin/&DISTRO_NAME_NO_CAP;
616 </literallayout>
617 In the previous example after moving to the home directory, the
618 <filename>git clone</filename> command creates a
619 local copy of the upstream <filename>poky</filename> Git repository.
620 By default, Git checks out the "master" branch for your work.
621 After changing the working directory to the new local repository
622 (i.e. <filename>poky</filename>), the
623 <filename>git checkout</filename> command creates
624 and checks out a local branch named "&DISTRO_NAME_NO_CAP;", which
625 tracks the upstream "origin/&DISTRO_NAME_NO_CAP;" branch.
626 Changes you make while in this branch would ultimately affect
627 the upstream "&DISTRO_NAME_NO_CAP;" branch of the
628 <filename>poky</filename> repository.
629 </para>
630
631 <para>
632 It is important to understand that when you create and checkout a
633 local working branch based on a branch name,
634 your local environment matches the "tip" of that particular
635 development branch at the time you created your local branch,
636 which could be different from the files in the "master" branch
637 of the upstream repository.
638 In other words, creating and checking out a local branch based on
639 the "&DISTRO_NAME_NO_CAP;" branch name is not the same as
640 checking out the "master" branch in the repository.
641 Keep reading to see how you create a local snapshot of a Yocto
642 Project Release.
643 </para>
644
645 <para>
646 Git uses "tags" to mark specific changes in a repository branch
647 structure.
648 Typically, a tag is used to mark a special point such as the final
649 change (or commit) before a project is released.
650 You can see the tags used with the <filename>poky</filename> Git
651 repository by going to
652 <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and
653 clicking on the
654 <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/tags'>[...]</ulink></filename>
655 link beneath the "Tag" heading.
656 </para>
657
658 <para>
659 Some key tags for the <filename>poky</filename> repository are
660 <filename>jethro-14.0.3</filename>,
661 <filename>morty-16.0.1</filename>,
662 <filename>pyro-17.0.0</filename>, and
663 <filename>&DISTRO_NAME_NO_CAP;-&POKYVERSION;</filename>.
664 These tags represent Yocto Project releases.
665 </para>
666
667 <para>
668 When you create a local copy of the Git repository, you also
669 have access to all the tags in the upstream repository.
670 Similar to branches, you can create and checkout a local working
671 Git branch based on a tag name.
672 When you do this, you get a snapshot of the Git repository that
673 reflects the state of the files when the change was made associated
674 with that tag.
675 The most common use is to checkout a working branch that matches
676 a specific Yocto Project release.
677 Here is an example:
678 <literallayout class='monospaced'>
679 $ cd ~
680 $ git clone git://git.yoctoproject.org/poky
681 $ cd poky
682 $ git fetch --tags
683 $ git checkout tags/rocko-18.0.0 -b my_rocko-18.0.0
684 </literallayout>
685 In this example, the name of the top-level directory of your
686 local Yocto Project repository is <filename>poky</filename>.
687 After moving to the <filename>poky</filename> directory, the
688 <filename>git fetch</filename> command makes all the upstream
689 tags available locally in your repository.
690 Finally, the <filename>git checkout</filename> command
691 creates and checks out a branch named "my-rocko-18.0.0" that is
692 based on the upstream branch whose "HEAD" matches the
693 commit in the repository associated with the "rocko-18.0.0" tag.
694 The files in your repository now exactly match that particular
695 Yocto Project release as it is tagged in the upstream Git
696 repository.
697 It is important to understand that when you create and
698 checkout a local working branch based on a tag, your environment
699 matches a specific point in time and not the entire development
700 branch (i.e. from the "tip" of the branch backwards).
701 </para>
702 </section>
703
704 <section id='basic-commands'>
705 <title>Basic Commands</title>
706
707 <para>
708 Git has an extensive set of commands that lets you manage changes
709 and perform collaboration over the life of a project.
710 Conveniently though, you can manage with a small set of basic
711 operations and workflows once you understand the basic
712 philosophy behind Git.
713 You do not have to be an expert in Git to be functional.
714 A good place to look for instruction on a minimal set of Git
715 commands is
716 <ulink url='http://git-scm.com/documentation'>here</ulink>.
717 </para>
718
719 <para>
720 The following list of Git commands briefly describes some basic
721 Git operations as a way to get started.
722 As with any set of commands, this list (in most cases) simply shows
723 the base command and omits the many arguments it supports.
724 See the Git documentation for complete descriptions and strategies
725 on how to use these commands:
726 <itemizedlist>
727 <listitem><para>
728 <emphasis><filename>git init</filename>:</emphasis>
729 Initializes an empty Git repository.
730 You cannot use Git commands unless you have a
731 <filename>.git</filename> repository.
732 </para></listitem>
733 <listitem><para id='git-commands-clone'>
734 <emphasis><filename>git clone</filename>:</emphasis>
735 Creates a local clone of a Git repository that is on
736 equal footing with a fellow developer’s Git repository
737 or an upstream repository.
738 </para></listitem>
739 <listitem><para>
740 <emphasis><filename>git add</filename>:</emphasis>
741 Locally stages updated file contents to the index that
742 Git uses to track changes.
743 You must stage all files that have changed before you
744 can commit them.
745 </para></listitem>
746 <listitem><para>
747 <emphasis><filename>git commit</filename>:</emphasis>
748 Creates a local "commit" that documents the changes you
749 made.
750 Only changes that have been staged can be committed.
751 Commits are used for historical purposes, for determining
752 if a maintainer of a project will allow the change,
753 and for ultimately pushing the change from your local
754 Git repository into the project’s upstream repository.
755 </para></listitem>
756 <listitem><para>
757 <emphasis><filename>git status</filename>:</emphasis>
758 Reports any modified files that possibly need to be
759 staged and gives you a status of where you stand regarding
760 local commits as compared to the upstream repository.
761 </para></listitem>
762 <listitem><para>
763 <emphasis><filename>git checkout</filename> <replaceable>branch-name</replaceable>:</emphasis>
764 Changes your local working branch and in this form
765 assumes the local branch already exists.
766 This command is analogous to "cd".
767 </para></listitem>
768 <listitem><para>
769 <emphasis><filename>git checkout –b</filename> <replaceable>working-branch</replaceable> <replaceable>upstream-branch</replaceable>:</emphasis>
770 Creates and checks out a working branch on your local
771 machine.
772 The local branch tracks the upstream branch.
773 You can use your local branch to isolate your work.
774 It is a good idea to use local branches when adding
775 specific features or changes.
776 Using isolated branches facilitates easy removal of
777 changes if they do not work out.
778 </para></listitem>
779 <listitem><para><emphasis><filename>git branch</filename>:</emphasis>
780 Displays the existing local branches associated with your
781 local repository.
782 The branch that you have currently checked out is noted
783 with an asterisk character.
784 </para></listitem>
785 <listitem><para>
786 <emphasis><filename>git branch -D</filename> <replaceable>branch-name</replaceable>:</emphasis>
787 Deletes an existing local branch.
788 You need to be in a local branch other than the one you
789 are deleting in order to delete
790 <replaceable>branch-name</replaceable>.
791 </para></listitem>
792 <listitem><para>
793 <emphasis><filename>git pull --rebase</filename>:</emphasis>
794 Retrieves information from an upstream Git repository
795 and places it in your local Git repository.
796 You use this command to make sure you are synchronized with
797 the repository from which you are basing changes
798 (.e.g. the "master" branch).
799 The "--rebase" option ensures that any local commits you
800 have in your branch are preserved at the top of your
801 local branch.
802 </para></listitem>
803 <listitem><para>
804 <emphasis><filename>git push</filename> <replaceable>repo-name</replaceable> <replaceable>local-branch</replaceable><filename>:</filename><replaceable>upstream-branch</replaceable>:</emphasis>
805 Sends all your committed local changes to the upstream Git
806 repository that your local repository is tracking
807 (e.g. a contribution repository).
808 The maintainer of the project draws from these repositories
809 to merge changes (commits) into the appropriate branch
810 of project's upstream repository.
811 </para></listitem>
812 <listitem><para>
813 <emphasis><filename>git merge</filename>:</emphasis>
814 Combines or adds changes from one
815 local branch of your repository with another branch.
816 When you create a local Git repository, the default branch
817 is named "master".
818 A typical workflow is to create a temporary branch that is
819 based off "master" that you would use for isolated work.
820 You would make your changes in that isolated branch,
821 stage and commit them locally, switch to the "master"
822 branch, and then use the <filename>git merge</filename>
823 command to apply the changes from your isolated branch
824 into the currently checked out branch (e.g. "master").
825 After the merge is complete and if you are done with
826 working in that isolated branch, you can safely delete
827 the isolated branch.
828 </para></listitem>
829 <listitem><para>
830 <emphasis><filename>git cherry-pick</filename> <replaceable>commits</replaceable>:</emphasis>
831 Choose and apply specific commits from one branch
832 into another branch.
833 There are times when you might not be able to merge
834 all the changes in one branch with
835 another but need to pick out certain ones.
836 </para></listitem>
837 <listitem><para>
838 <emphasis><filename>gitk</filename>:</emphasis>
839 Provides a GUI view of the branches and changes in your
840 local Git repository.
841 This command is a good way to graphically see where things
842 have diverged in your local repository.
843 <note>
844 You need to install the <filename>gitk</filename>
845 package on your development system to use this
846 command.
847 </note>
848 </para></listitem>
849 <listitem><para>
850 <emphasis><filename>git log</filename>:</emphasis>
851 Reports a history of your commits to the repository.
852 This report lists all commits regardless of whether you
853 have pushed them upstream or not.
854 </para></listitem>
855 <listitem><para>
856 <emphasis><filename>git diff</filename>:</emphasis>
857 Displays line-by-line differences between a local
858 working file and the same file as understood by Git.
859 This command is useful to see what you have changed
860 in any given file.
861 </para></listitem>
862 </itemizedlist>
863 </para>
864 </section>
865</section>
866
867<section id='licensing'>
868 <title>Licensing</title>
869
870 <para>
871 Because open source projects are open to the public, they have
872 different licensing structures in place.
873 License evolution for both Open Source and Free Software has an
874 interesting history.
875 If you are interested in this history, you can find basic information
876 here:
877 <itemizedlist>
878 <listitem><para>
879 <ulink url='http://en.wikipedia.org/wiki/Open-source_license'>Open source license history</ulink>
880 </para></listitem>
881 <listitem><para>
882 <ulink url='http://en.wikipedia.org/wiki/Free_software_license'>Free software license history</ulink>
883 </para></listitem>
884 </itemizedlist>
885 </para>
886
887 <para>
888 In general, the Yocto Project is broadly licensed under the
889 Massachusetts Institute of Technology (MIT) License.
890 MIT licensing permits the reuse of software within proprietary
891 software as long as the license is distributed with that software.
892 MIT is also compatible with the GNU General Public License (GPL).
893 Patches to the Yocto Project follow the upstream licensing scheme.
894 You can find information on the MIT license
895 <ulink url='http://www.opensource.org/licenses/mit-license.php'>here</ulink>.
896 You can find information on the GNU GPL
897 <ulink url='http://www.opensource.org/licenses/LGPL-3.0'>here</ulink>.
898 </para>
899
900 <para>
901 When you build an image using the Yocto Project, the build process
902 uses a known list of licenses to ensure compliance.
903 You can find this list in the
904 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
905 at <filename>meta/files/common-licenses</filename>.
906 Once the build completes, the list of all licenses found and used
907 during that build are kept in the
908 <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
909 at <filename>tmp/deploy/licenses</filename>.
910 </para>
911
912 <para>
913 If a module requires a license that is not in the base list, the
914 build process generates a warning during the build.
915 These tools make it easier for a developer to be certain of the
916 licenses with which their shipped products must comply.
917 However, even with these tools it is still up to the developer to
918 resolve potential licensing issues.
919 </para>
920
921 <para>
922 The base list of licenses used by the build process is a combination
923 of the Software Package Data Exchange (SPDX) list and the Open
924 Source Initiative (OSI) projects.
925 <ulink url='http://spdx.org'>SPDX Group</ulink> is a working group of
926 the Linux Foundation that maintains a specification for a standard
927 format for communicating the components, licenses, and copyrights
928 associated with a software package.
929 <ulink url='http://opensource.org'>OSI</ulink> is a corporation
930 dedicated to the Open Source Definition and the effort for reviewing
931 and approving licenses that conform to the Open Source Definition
932 (OSD).
933 </para>
934
935 <para>
936 You can find a list of the combined SPDX and OSI licenses that the
937 Yocto Project uses in the
938 <filename>meta/files/common-licenses</filename> directory in your
939 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
940 </para>
941
942 <para>
943 For information that can help you maintain compliance with various
944 open source licensing during the lifecycle of a product created using
945 the Yocto Project, see the
946 "<ulink url='&YOCTO_DOCS_DEV_URL;#maintaining-open-source-license-compliance-during-your-products-lifecycle'>Maintaining Open Source License Compliance During Your Product's Lifecycle</ulink>"
947 section in the Yocto Project Development Tasks Manual.
948 </para>
949</section>
950</chapter>
951<!--
952vim: expandtab tw=80 ts=4
953-->