overview-manual-development-environment.xml 49 KB

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