overview-manual-development-environment.xml 50 KB

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