overview-manual-development-environment.rst 32 KB

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