Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
| 5 | <chapter id='dev-manual-newbie'> |
| 6 | |
| 7 | <title>The Yocto Project Open Source Development Environment</title> |
| 8 | |
| 9 | <para> |
| 10 | This chapter helps you understand the Yocto Project as an open source development project. |
| 11 | In general, working in an open source environment is very different from working in a |
| 12 | closed, proprietary environment. |
| 13 | Additionally, the Yocto Project uses specific tools and constructs as part of its development |
| 14 | environment. |
| 15 | This chapter specifically addresses open source philosophy, using the |
| 16 | Yocto Project in a team environment, source repositories, Yocto Project |
| 17 | terms, licensing, the open source distributed version control system Git, |
| 18 | workflows, bug tracking, and how to submit changes. |
| 19 | </para> |
| 20 | |
| 21 | <section id='open-source-philosophy'> |
| 22 | <title>Open Source Philosophy</title> |
| 23 | |
| 24 | <para> |
| 25 | Open source philosophy is characterized by software development directed by peer production |
| 26 | and collaboration through an active community of developers. |
| 27 | Contrast this to the more standard centralized development models used by commercial software |
| 28 | companies where a finite set of developers produces a product for sale using a defined set |
| 29 | of procedures that ultimately result in an end product whose architecture and source material |
| 30 | are closed to the public. |
| 31 | </para> |
| 32 | |
| 33 | <para> |
| 34 | Open source projects conceptually have differing concurrent agendas, approaches, and production. |
| 35 | These facets of the development process can come from anyone in the public (community) that has a |
| 36 | stake in the software project. |
| 37 | The open source environment contains new copyright, licensing, domain, and consumer issues |
| 38 | that differ from the more traditional development environment. |
| 39 | In an open source environment, the end product, source material, and documentation are |
| 40 | all available to the public at no cost. |
| 41 | </para> |
| 42 | |
| 43 | <para> |
| 44 | A benchmark example of an open source project is the Linux kernel, which was initially conceived |
| 45 | and created by Finnish computer science 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 <trademark class='registered'>Microsoft</trademark> Corporation. |
| 49 | </para> |
| 50 | |
| 51 | <para> |
| 52 | Wikipedia has a good historical description of the Open Source 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 Linux Community |
| 55 | <ulink url='http://ldn.linuxfoundation.org/book/how-participate-linux-community'>here</ulink>. |
| 56 | </para> |
| 57 | </section> |
| 58 | |
| 59 | <section id="usingpoky-changes-collaborate"> |
| 60 | <title>Using the Yocto Project in a Team Environment</title> |
| 61 | |
| 62 | <para> |
| 63 | It might not be immediately clear how you can use the Yocto |
| 64 | Project in a team environment, or scale it for a large team of |
| 65 | developers. |
| 66 | One of the strengths of the Yocto Project is that it is extremely |
| 67 | flexible. |
| 68 | Thus, you can adapt it to many different use cases and scenarios. |
| 69 | However, these characteristics can cause a struggle if you are trying |
| 70 | to create a working setup that scales across a large team. |
| 71 | </para> |
| 72 | |
| 73 | <para> |
| 74 | To help with these types of situations, this section presents |
| 75 | some of the project's most successful experiences, |
| 76 | practices, solutions, and available technologies that work well. |
| 77 | Keep in mind, the information here is a starting point. |
| 78 | You can build off it and customize it to fit any |
| 79 | particular working environment and set of practices. |
| 80 | </para> |
| 81 | |
| 82 | <section id='best-practices-system-configurations'> |
| 83 | <title>System Configurations</title> |
| 84 | |
| 85 | <para> |
| 86 | Systems across a large team should meet the needs of |
| 87 | two types of developers: those working on the contents of the |
| 88 | operating system image itself and those developing applications. |
| 89 | Regardless of the type of developer, their workstations must |
| 90 | be both reasonably powerful and run Linux. |
| 91 | </para> |
| 92 | |
| 93 | <section id='best-practices-application-development'> |
| 94 | <title>Application Development</title> |
| 95 | |
| 96 | <para> |
| 97 | For developers who mainly do application level work |
| 98 | on top of an existing software stack, |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 99 | the following list shows practices that work best. |
| 100 | For information on using a Software Development Kit (SDK), see |
| 101 | the |
| 102 | <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-intro'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | <itemizedlist> |
| 104 | <listitem><para>Use a pre-built toolchain that |
| 105 | contains the software stack itself. |
| 106 | Then, develop the application code on top of the |
| 107 | stack. |
| 108 | This method works well for small numbers of relatively |
| 109 | isolated applications.</para></listitem> |
| 110 | <listitem><para>When possible, use the Yocto Project |
| 111 | plug-in for the <trademark class='trade'>Eclipse</trademark> IDE |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 112 | and SDK development practices. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | For more information, see the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 114 | "<ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>". |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 115 | </para></listitem> |
| 116 | <listitem><para>Keep your cross-development toolchains |
| 117 | updated. |
| 118 | You can do this through provisioning either as new |
| 119 | toolchain downloads or as updates through a package |
| 120 | update mechanism using <filename>opkg</filename> |
| 121 | to provide updates to an existing toolchain. |
| 122 | The exact mechanics of how and when to do this are a |
| 123 | question for local policy.</para></listitem> |
| 124 | <listitem><para>Use multiple toolchains installed locally |
| 125 | into different locations to allow development across |
| 126 | versions.</para></listitem> |
| 127 | </itemizedlist> |
| 128 | </para> |
| 129 | </section> |
| 130 | |
| 131 | <section id='best-practices-core-system-development'> |
| 132 | <title>Core System Development</title> |
| 133 | |
| 134 | <para> |
| 135 | For core system development, it is often best to have the |
| 136 | build system itself available on the developer workstations |
| 137 | so developers can run their own builds and directly |
| 138 | rebuild the software stack. |
| 139 | You should keep the core system unchanged as much as |
| 140 | possible and do your work in layers on top of the core system. |
| 141 | Doing so gives you a greater level of portability when |
| 142 | upgrading to new versions of the core system or Board |
| 143 | Support Packages (BSPs). |
| 144 | You can share layers amongst the developers of a particular |
| 145 | project and contain the policy configuration that defines |
| 146 | the project. |
| 147 | </para> |
| 148 | |
| 149 | <para> |
| 150 | Aside from the previous best practices, there exists a number |
| 151 | of tips and tricks that can help speed up core development |
| 152 | projects: |
| 153 | <itemizedlist> |
| 154 | <listitem><para>Use a |
| 155 | <ulink url='&YOCTO_DOCS_REF_URL;#shared-state-cache'>Shared State Cache</ulink> |
| 156 | (sstate) among groups of developers who are on a |
| 157 | fast network. |
| 158 | The best way to share sstate is through a |
| 159 | Network File System (NFS) share. |
| 160 | The first user to build a given component for the |
| 161 | first time contributes that object to the sstate, |
| 162 | while subsequent builds from other developers then |
| 163 | reuse the object rather than rebuild it themselves. |
| 164 | </para> |
| 165 | <para>Although it is possible to use other protocols for the |
| 166 | sstate such as HTTP and FTP, you should avoid these. |
| 167 | Using HTTP limits the sstate to read-only and |
| 168 | FTP provides poor performance. |
| 169 | </para></listitem> |
| 170 | <listitem><para>Have autobuilders contribute to the sstate |
| 171 | pool similarly to how the developer workstations |
| 172 | contribute. |
| 173 | For information, see the |
| 174 | "<link linkend='best-practices-autobuilders'>Autobuilders</link>" |
| 175 | section.</para></listitem> |
| 176 | <listitem><para>Build stand-alone tarballs that contain |
| 177 | "missing" system requirements if for some reason |
| 178 | developer workstations do not meet minimum system |
| 179 | requirements such as latest Python versions, |
| 180 | <filename>chrpath</filename>, or other tools. |
| 181 | You can install and relocate the tarball exactly as you |
| 182 | would the usual cross-development toolchain so that |
| 183 | all developers can meet minimum version requirements |
| 184 | on most distributions.</para></listitem> |
| 185 | <listitem><para>Use a small number of shared, |
| 186 | high performance systems for testing purposes |
| 187 | (e.g. dual, six-core Xeons with 24 Gbytes of RAM |
| 188 | and plenty of disk space). |
| 189 | Developers can use these systems for wider, more |
| 190 | extensive testing while they continue to develop |
| 191 | locally using their primary development system. |
| 192 | </para></listitem> |
| 193 | <listitem><para>Enable the PR Service when package feeds |
| 194 | need to be incremental with continually increasing |
| 195 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'>PR</ulink> |
| 196 | values. |
| 197 | Typically, this situation occurs when you use or |
| 198 | publish package feeds and use a shared state. |
| 199 | You should enable the PR Service for all users who |
| 200 | use the shared state pool. |
| 201 | For more information on the PR Service, see the |
| 202 | "<link linkend='working-with-a-pr-service'>Working With a PR Service</link>". |
| 203 | </para></listitem> |
| 204 | </itemizedlist> |
| 205 | </para> |
| 206 | </section> |
| 207 | </section> |
| 208 | |
| 209 | <section id='best-practices-source-control-management'> |
| 210 | <title>Source Control Management (SCM)</title> |
| 211 | |
| 212 | <para> |
| 213 | Keeping your |
| 214 | <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink> |
| 215 | and any software you are developing under the |
| 216 | control of an SCM system that is compatible |
| 217 | with the OpenEmbedded build system is advisable. |
| 218 | Of the SCMs BitBake supports, the |
| 219 | Yocto Project team strongly recommends using |
| 220 | <link linkend='git'>Git</link>. |
| 221 | Git is a distributed system that is easy to backup, |
| 222 | allows you to work remotely, and then connects back to the |
| 223 | infrastructure. |
| 224 | <note> |
| 225 | For information about BitBake, see the |
| 226 | <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>. |
| 227 | </note> |
| 228 | </para> |
| 229 | |
| 230 | <para> |
| 231 | It is relatively easy to set up Git services and create |
| 232 | infrastructure like |
| 233 | <ulink url='&YOCTO_GIT_URL;'>http://git.yoctoproject.org</ulink>, |
| 234 | which is based on server software called |
| 235 | <filename>gitolite</filename> with <filename>cgit</filename> |
| 236 | being used to generate the web interface that lets you view the |
| 237 | repositories. |
| 238 | The <filename>gitolite</filename> software identifies users |
| 239 | using SSH keys and allows branch-based |
| 240 | access controls to repositories that you can control as little |
| 241 | or as much as necessary. |
| 242 | </para> |
| 243 | |
| 244 | <note> |
| 245 | The setup of these services is beyond the scope of this manual. |
| 246 | However, sites such as these exist that describe how to perform |
| 247 | setup: |
| 248 | <itemizedlist> |
| 249 | <listitem><para><ulink url='http://git-scm.com/book/ch4-8.html'>Git documentation</ulink>: |
| 250 | Describes how to install <filename>gitolite</filename> |
| 251 | on the server.</para></listitem> |
| 252 | <listitem><para><ulink url='http://sitaramc.github.com/gitolite/master-toc.html'>The <filename>gitolite</filename> master index</ulink>: |
| 253 | All topics for <filename>gitolite</filename>. |
| 254 | </para></listitem> |
| 255 | <listitem><para><ulink url='https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools'>Interfaces, frontends, and tools</ulink>: |
| 256 | Documentation on how to create interfaces and frontends |
| 257 | for Git.</para></listitem> |
| 258 | </itemizedlist> |
| 259 | </note> |
| 260 | </section> |
| 261 | |
| 262 | <section id='best-practices-autobuilders'> |
| 263 | <title>Autobuilders</title> |
| 264 | |
| 265 | <para> |
| 266 | Autobuilders are often the core of a development project. |
| 267 | It is here that changes from individual developers are brought |
| 268 | together and centrally tested and subsequent decisions about |
| 269 | releases can be made. |
| 270 | Autobuilders also allow for "continuous integration" style |
| 271 | testing of software components and regression identification |
| 272 | and tracking. |
| 273 | </para> |
| 274 | |
| 275 | <para> |
| 276 | See "<ulink url='http://autobuilder.yoctoproject.org'>Yocto Project Autobuilder</ulink>" |
| 277 | for more information and links to buildbot. |
| 278 | The Yocto Project team has found this implementation |
| 279 | works well in this role. |
| 280 | A public example of this is the Yocto Project |
| 281 | Autobuilders, which we use to test the overall health of the |
| 282 | project. |
| 283 | </para> |
| 284 | |
| 285 | <para> |
| 286 | The features of this system are: |
| 287 | <itemizedlist> |
| 288 | <listitem><para>Highlights when commits break the build. |
| 289 | </para></listitem> |
| 290 | <listitem><para>Populates an sstate cache from which |
| 291 | developers can pull rather than requiring local |
| 292 | builds.</para></listitem> |
| 293 | <listitem><para>Allows commit hook triggers, |
| 294 | which trigger builds when commits are made. |
| 295 | </para></listitem> |
| 296 | <listitem><para>Allows triggering of automated image booting |
| 297 | and testing under the QuickEMUlator (QEMU). |
| 298 | </para></listitem> |
| 299 | <listitem><para>Supports incremental build testing and |
| 300 | from-scratch builds.</para></listitem> |
| 301 | <listitem><para>Shares output that allows developer |
| 302 | testing and historical regression investigation. |
| 303 | </para></listitem> |
| 304 | <listitem><para>Creates output that can be used for releases. |
| 305 | </para></listitem> |
| 306 | <listitem><para>Allows scheduling of builds so that resources |
| 307 | can be used efficiently.</para></listitem> |
| 308 | </itemizedlist> |
| 309 | </para> |
| 310 | </section> |
| 311 | |
| 312 | <section id='best-practices-policies-and-change-flow'> |
| 313 | <title>Policies and Change Flow</title> |
| 314 | |
| 315 | <para> |
| 316 | The Yocto Project itself uses a hierarchical structure and a |
| 317 | pull model. |
| 318 | Scripts exist to create and send pull requests |
| 319 | (i.e. <filename>create-pull-request</filename> and |
| 320 | <filename>send-pull-request</filename>). |
| 321 | This model is in line with other open source projects where |
| 322 | maintainers are responsible for specific areas of the project |
| 323 | and a single maintainer handles the final "top-of-tree" merges. |
| 324 | </para> |
| 325 | |
| 326 | <note> |
| 327 | You can also use a more collective push model. |
| 328 | The <filename>gitolite</filename> software supports both the |
| 329 | push and pull models quite easily. |
| 330 | </note> |
| 331 | |
| 332 | <para> |
| 333 | As with any development environment, it is important |
| 334 | to document the policy used as well as any main project |
| 335 | guidelines so they are understood by everyone. |
| 336 | It is also a good idea to have well structured |
| 337 | commit messages, which are usually a part of a project's |
| 338 | guidelines. |
| 339 | Good commit messages are essential when looking back in time and |
| 340 | trying to understand why changes were made. |
| 341 | </para> |
| 342 | |
| 343 | <para> |
| 344 | If you discover that changes are needed to the core layer of the |
| 345 | project, it is worth sharing those with the community as soon |
| 346 | as possible. |
| 347 | Chances are if you have discovered the need for changes, someone |
| 348 | else in the community needs them also. |
| 349 | </para> |
| 350 | </section> |
| 351 | |
| 352 | <section id='best-practices-summary'> |
| 353 | <title>Summary</title> |
| 354 | |
| 355 | <para> |
| 356 | This section summarizes the key recommendations described in the |
| 357 | previous sections: |
| 358 | <itemizedlist> |
| 359 | <listitem><para>Use <link linkend='git'>Git</link> |
| 360 | as the source control system.</para></listitem> |
| 361 | <listitem><para>Maintain your Metadata in layers that make sense |
| 362 | for your situation. |
| 363 | See the "<link linkend='understanding-and-creating-layers'>Understanding |
| 364 | and Creating Layers</link>" section for more information on |
| 365 | layers.</para></listitem> |
| 366 | <listitem><para> |
| 367 | Separate the project's Metadata and code by using |
| 368 | separate Git repositories. |
| 369 | See the |
| 370 | "<link linkend='yocto-project-repositories'>Yocto Project Source Repositories</link>" |
| 371 | section for information on these repositories. |
| 372 | See the |
| 373 | "<link linkend='getting-setup'>Getting Set Up</link>" |
| 374 | section for information on how to set up local Git |
| 375 | repositories for related upstream Yocto Project |
| 376 | Git repositories. |
| 377 | </para></listitem> |
| 378 | <listitem><para>Set up the directory for the shared state cache |
| 379 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>) |
| 380 | where it makes sense. |
| 381 | For example, set up the sstate cache on a system used |
| 382 | by developers in the same organization and share the |
| 383 | same source directories on their machines. |
| 384 | </para></listitem> |
| 385 | <listitem><para>Set up an Autobuilder and have it populate the |
| 386 | sstate cache and source directories.</para></listitem> |
| 387 | <listitem><para>The Yocto Project community encourages you |
| 388 | to send patches to the project to fix bugs or add features. |
| 389 | If you do submit patches, follow the project commit |
| 390 | guidelines for writing good commit messages. |
| 391 | See the "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" |
| 392 | section.</para></listitem> |
| 393 | <listitem><para>Send changes to the core sooner than later |
| 394 | as others are likely to run into the same issues. |
| 395 | For some guidance on mailing lists to use, see the list in the |
| 396 | "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" |
| 397 | section. |
| 398 | For a description of the available mailing lists, see the |
| 399 | "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing Lists</ulink>" |
| 400 | section in the Yocto Project Reference Manual. |
| 401 | </para></listitem> |
| 402 | </itemizedlist> |
| 403 | </para> |
| 404 | </section> |
| 405 | </section> |
| 406 | |
| 407 | <section id='yocto-project-repositories'> |
| 408 | <title>Yocto Project Source Repositories</title> |
| 409 | |
| 410 | <para> |
| 411 | The Yocto Project team maintains complete source repositories for all |
| 412 | Yocto Project files at |
| 413 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'></ulink>. |
| 414 | This web-based source code browser is organized into categories by |
| 415 | function such as IDE Plugins, Matchbox, Poky, Yocto Linux Kernel, and |
| 416 | so forth. |
| 417 | From the interface, you can click on any particular item in the "Name" |
| 418 | column and see the URL at the bottom of the page that you need to clone |
| 419 | a Git repository for that particular item. |
| 420 | Having a local Git repository of the |
| 421 | <link linkend='source-directory'>Source Directory</link>, which is |
| 422 | usually named "poky", allows |
| 423 | you to make changes, contribute to the history, and ultimately enhance |
| 424 | the Yocto Project's tools, Board Support Packages, and so forth. |
| 425 | </para> |
| 426 | |
| 427 | <para> |
| 428 | For any supported release of Yocto Project, you can also go to the |
| 429 | <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink> and |
| 430 | select the "Downloads" tab and get a released tarball of the |
| 431 | <filename>poky</filename> repository or any supported BSP tarballs. |
| 432 | Unpacking these tarballs gives you a snapshot of the released |
| 433 | files. |
| 434 | <note><title>Notes</title> |
| 435 | <itemizedlist> |
| 436 | <listitem><para> |
| 437 | The recommended method for setting up the Yocto Project |
| 438 | <link linkend='source-directory'>Source Directory</link> |
| 439 | and the files for supported BSPs |
| 440 | (e.g., <filename>meta-intel</filename>) is to use |
| 441 | <link linkend='git'>Git</link> to create a local copy of |
| 442 | the upstream repositories. |
| 443 | </para></listitem> |
| 444 | <listitem><para> |
| 445 | Be sure to always work in matching branches for both |
| 446 | the selected BSP repository and the |
| 447 | <link linkend='source-directory'>Source Directory</link> |
| 448 | (i.e. <filename>poky</filename>) repository. |
| 449 | For example, if you have checked out the "master" branch |
| 450 | of <filename>poky</filename> and you are going to use |
| 451 | <filename>meta-intel</filename>, be sure to checkout the |
| 452 | "master" branch of <filename>meta-intel</filename>. |
| 453 | </para></listitem> |
| 454 | </itemizedlist> |
| 455 | </note> |
| 456 | </para> |
| 457 | |
| 458 | <para> |
| 459 | In summary, here is where you can get the project files needed for development: |
| 460 | <itemizedlist> |
| 461 | <listitem><para id='source-repositories'><emphasis><ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Source Repositories:</ulink></emphasis> |
| 462 | This area contains IDE Plugins, Matchbox, Poky, Poky Support, Tools, Yocto Linux Kernel, and Yocto |
| 463 | Metadata Layers. |
| 464 | You can create local copies of Git repositories for each of these areas.</para> |
| 465 | <para> |
| 466 | <imagedata fileref="figures/source-repos.png" align="center" width="6in" depth="4in" /> |
| 467 | </para></listitem> |
| 468 | <listitem><para><anchor id='index-downloads' /><emphasis><ulink url='&YOCTO_DL_URL;/releases/'>Index of /releases:</ulink></emphasis> |
| 469 | This is an index of releases such as |
| 470 | the <trademark class='trade'>Eclipse</trademark> |
| 471 | Yocto Plug-in, miscellaneous support, Poky, Pseudo, installers for cross-development toolchains, |
| 472 | and all released versions of Yocto Project in the form of images or tarballs. |
| 473 | Downloading and extracting these files does not produce a local copy of the |
| 474 | Git repository but rather a snapshot of a particular release or image.</para> |
| 475 | <para> |
| 476 | <imagedata fileref="figures/index-downloads.png" align="center" width="6in" depth="3.5in" /> |
| 477 | </para></listitem> |
| 478 | <listitem><para><emphasis>"Downloads" page for the |
| 479 | <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>:</emphasis> |
| 480 | Access this page by going to the website and then selecting |
| 481 | the "Downloads" tab. |
| 482 | This page allows you to download any Yocto Project |
| 483 | release or Board Support Package (BSP) in tarball form. |
| 484 | The tarballs are similar to those found in the |
| 485 | <ulink url='&YOCTO_DL_URL;/releases/'>Index of /releases:</ulink> area.</para> |
| 486 | <para> |
| 487 | <imagedata fileref="figures/yp-download.png" align="center" width="6in" depth="4in" /> |
| 488 | </para></listitem> |
| 489 | </itemizedlist> |
| 490 | </para> |
| 491 | </section> |
| 492 | |
| 493 | <section id='yocto-project-terms'> |
| 494 | <title>Yocto Project Terms</title> |
| 495 | |
| 496 | <para> |
| 497 | Following is a list of terms and definitions users new to the Yocto Project development |
| 498 | environment might find helpful. |
| 499 | While some of these terms are universal, the list includes them just in case: |
| 500 | <itemizedlist> |
| 501 | <listitem><para><emphasis>Append Files:</emphasis> Files that append build information to |
| 502 | a recipe file. |
| 503 | Append files are known as BitBake append files and <filename>.bbappend</filename> files. |
| 504 | The OpenEmbedded build system expects every append file to have a corresponding |
| 505 | recipe (<filename>.bb</filename>) file. |
| 506 | Furthermore, the append file and corresponding recipe file |
| 507 | must use the same root filename. |
| 508 | The filenames can differ only in the file type suffix used (e.g. |
| 509 | <filename>formfactor_0.0.bb</filename> and <filename>formfactor_0.0.bbappend</filename>). |
| 510 | </para> |
| 511 | <para>Information in append files extends or overrides the |
| 512 | information in the similarly-named recipe file. |
| 513 | For an example of an append file in use, see the |
| 514 | "<link linkend='using-bbappend-files'>Using .bbappend Files</link>" section. |
| 515 | <note> |
| 516 | Append files can also use wildcard patterns in their version numbers |
| 517 | so they can be applied to more than one version of the underlying recipe file. |
| 518 | </note> |
| 519 | </para></listitem> |
| 520 | <listitem><para id='bitbake-term'><emphasis>BitBake:</emphasis> |
| 521 | The task executor and scheduler used by the OpenEmbedded build |
| 522 | system to build images. |
| 523 | For more information on BitBake, see the |
| 524 | <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>. |
| 525 | </para></listitem> |
| 526 | <listitem> |
| 527 | <para id='build-directory'><emphasis>Build Directory:</emphasis> |
| 528 | This term refers to the area used by the OpenEmbedded build |
| 529 | system for builds. |
| 530 | The area is created when you <filename>source</filename> the |
| 531 | setup environment script that is found in the Source Directory |
| 532 | (i.e. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 533 | or |
| 534 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>). |
| 535 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-TOPDIR'><filename>TOPDIR</filename></ulink> |
| 536 | variable points to the Build Directory.</para> |
| 537 | |
| 538 | <para> |
| 539 | You have a lot of flexibility when creating the Build |
| 540 | Directory. |
| 541 | Following are some examples that show how to create the |
| 542 | directory. |
| 543 | The examples assume your |
| 544 | <link linkend='source-directory'>Source Directory</link> is |
| 545 | named <filename>poky</filename>: |
| 546 | <itemizedlist> |
| 547 | <listitem><para>Create the Build Directory inside your |
| 548 | Source Directory and let the name of the Build |
| 549 | Directory default to <filename>build</filename>: |
| 550 | <literallayout class='monospaced'> |
| 551 | $ cd $HOME/poky |
| 552 | $ source &OE_INIT_FILE; |
| 553 | </literallayout></para></listitem> |
| 554 | <listitem><para>Create the Build Directory inside your |
| 555 | home directory and specifically name it |
| 556 | <filename>test-builds</filename>: |
| 557 | <literallayout class='monospaced'> |
| 558 | $ cd $HOME |
| 559 | $ source poky/&OE_INIT_FILE; test-builds |
| 560 | </literallayout></para></listitem> |
| 561 | <listitem><para> |
| 562 | Provide a directory path and |
| 563 | specifically name the Build Directory. |
| 564 | Any intermediate folders in the pathname must |
| 565 | exist. |
| 566 | This next example creates a Build Directory named |
| 567 | <filename>YP-&POKYVERSION;</filename> |
| 568 | in your home directory within the existing |
| 569 | directory <filename>mybuilds</filename>: |
| 570 | <literallayout class='monospaced'> |
| 571 | $cd $HOME |
| 572 | $ source $HOME/poky/&OE_INIT_FILE; $HOME/mybuilds/YP-&POKYVERSION; |
| 573 | </literallayout></para></listitem> |
| 574 | </itemizedlist> |
| 575 | <note> |
| 576 | By default, the Build Directory contains |
| 577 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>, |
| 578 | which is a temporary directory the build system uses for |
| 579 | its work. |
| 580 | <filename>TMPDIR</filename> cannot be under NFS. |
| 581 | Thus, by default, the Build Directory cannot be under NFS. |
| 582 | However, if you need the Build Directory to be under NFS, |
| 583 | you can set this up by setting <filename>TMPDIR</filename> |
| 584 | in your <filename>local.conf</filename> file |
| 585 | to use a local drive. |
| 586 | Doing so effectively separates <filename>TMPDIR</filename> |
| 587 | from <filename>TOPDIR</filename>, which is the Build |
| 588 | Directory. |
| 589 | </note> |
| 590 | </para></listitem> |
| 591 | <listitem><para><emphasis>Classes:</emphasis> Files that provide for logic encapsulation |
| 592 | and inheritance so that commonly used patterns can be defined once and then easily used |
| 593 | in multiple recipes. |
| 594 | For reference information on the Yocto Project classes, see the |
| 595 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes'>Classes</ulink>" chapter of the |
| 596 | Yocto Project Reference Manual. |
| 597 | Class files end with the <filename>.bbclass</filename> filename extension. |
| 598 | </para></listitem> |
| 599 | <listitem><para><emphasis>Configuration File:</emphasis> |
| 600 | Configuration information in various <filename>.conf</filename> |
| 601 | files provides global definitions of variables. |
| 602 | The <filename>conf/local.conf</filename> configuration file in |
| 603 | the |
| 604 | <link linkend='build-directory'>Build Directory</link> |
| 605 | contains user-defined variables that affect every build. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 606 | The <filename>meta-poky/conf/distro/poky.conf</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 607 | configuration file defines Yocto "distro" configuration |
| 608 | variables used only when building with this policy. |
| 609 | Machine configuration files, which |
| 610 | are located throughout the |
| 611 | <link linkend='source-directory'>Source Directory</link>, define |
| 612 | variables for specific hardware and are only used when building |
| 613 | for that target (e.g. the |
| 614 | <filename>machine/beaglebone.conf</filename> configuration |
| 615 | file defines variables for the Texas Instruments ARM Cortex-A8 |
| 616 | development board). |
| 617 | Configuration files end with a <filename>.conf</filename> |
| 618 | filename extension. |
| 619 | </para></listitem> |
| 620 | <listitem><para id='cross-development-toolchain'> |
| 621 | <emphasis>Cross-Development Toolchain:</emphasis> |
| 622 | In general, a cross-development toolchain is a collection of |
| 623 | software development tools and utilities that run on one |
| 624 | architecture and allow you to develop software for a |
| 625 | different, or targeted, architecture. |
| 626 | These toolchains contain cross-compilers, linkers, and |
| 627 | debuggers that are specific to the target architecture. |
| 628 | </para> |
| 629 | |
| 630 | <para>The Yocto Project supports two different cross-development |
| 631 | toolchains: |
| 632 | <itemizedlist> |
| 633 | <listitem><para>A toolchain only used by and within |
| 634 | BitBake when building an image for a target |
| 635 | architecture.</para></listitem> |
| 636 | <listitem><para>A relocatable toolchain used outside of |
| 637 | BitBake by developers when developing applications |
| 638 | that will run on a targeted device. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 639 | </para></listitem> |
| 640 | </itemizedlist> |
| 641 | </para> |
| 642 | |
| 643 | <para> |
| 644 | Creation of these toolchains is simple and automated. |
| 645 | For information on toolchain concepts as they apply to the |
| 646 | Yocto Project, see the |
| 647 | "<ulink url='&YOCTO_DOCS_REF_URL;#cross-development-toolchain-generation'>Cross-Development Toolchain Generation</ulink>" |
| 648 | section in the Yocto Project Reference Manual. |
| 649 | You can also find more information on using the |
| 650 | relocatable toolchain in the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 651 | <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 652 | </para></listitem> |
| 653 | <listitem><para><emphasis>Image:</emphasis> |
| 654 | An image is an artifact of the BitBake build process given |
| 655 | a collection of recipes and related Metadata. |
| 656 | Images are the binary output that run on specific hardware or |
| 657 | QEMU and are used for specific use-cases. |
| 658 | For a list of the supported image types that the Yocto Project provides, see the |
| 659 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" |
| 660 | chapter in the Yocto Project Reference Manual.</para></listitem> |
| 661 | <listitem><para id='layer'><emphasis>Layer:</emphasis> A collection of recipes representing the core, |
| 662 | a BSP, or an application stack. |
| 663 | For a discussion specifically on BSP Layers, see the |
| 664 | "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" |
| 665 | section in the Yocto Project Board Support Packages (BSP) |
| 666 | Developer's Guide.</para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 667 | <listitem><para id='metadata'><emphasis>Metadata:</emphasis> |
| 668 | The files that BitBake parses when building an image. |
| 669 | In general, Metadata includes recipes, classes, and |
| 670 | configuration files. |
| 671 | In the context of the kernel ("kernel Metadata"), |
| 672 | it refers to Metadata in the <filename>meta</filename> |
| 673 | branches of the kernel source Git repositories. |
| 674 | </para></listitem> |
| 675 | <listitem><para id='oe-core'><emphasis>OE-Core:</emphasis> A core set of Metadata originating |
| 676 | with OpenEmbedded (OE) that is shared between OE and the Yocto Project. |
| 677 | This Metadata is found in the <filename>meta</filename> directory of the |
| 678 | <link linkend='source-directory'>Source Directory</link>.</para></listitem> |
| 679 | <listitem><para id='build-system-term'><emphasis>OpenEmbedded Build System:</emphasis> |
| 680 | The build system specific to the Yocto Project. |
| 681 | The OpenEmbedded build system is based on another project known |
| 682 | as "Poky", which uses |
| 683 | <link linkend='bitbake-term'>BitBake</link> as the task |
| 684 | executor. |
| 685 | Throughout the Yocto Project documentation set, the |
| 686 | OpenEmbedded build system is sometimes referred to simply |
| 687 | as "the build system". |
| 688 | If other build systems, such as a host or target build system |
| 689 | are referenced, the documentation clearly states the |
| 690 | difference. |
| 691 | <note> |
| 692 | For some historical information about Poky, see the |
| 693 | <link linkend='poky'>Poky</link> term. |
| 694 | </note> |
| 695 | </para></listitem> |
| 696 | <listitem><para><emphasis>Package:</emphasis> |
| 697 | In the context of the Yocto Project, this term refers to a |
| 698 | recipe's packaged output produced by BitBake (i.e. a |
| 699 | "baked recipe"). |
| 700 | A package is generally the compiled binaries produced from the |
| 701 | recipe's sources. |
| 702 | You "bake" something by running it through BitBake.</para> |
| 703 | <para>It is worth noting that the term "package" can, in general, have subtle |
| 704 | meanings. For example, the packages referred to in the |
| 705 | "<ulink url='&YOCTO_DOCS_QS_URL;#packages'>The Build Host Packages</ulink>" section are |
| 706 | compiled binaries that, when installed, add functionality to your Linux |
| 707 | distribution.</para> |
| 708 | <para>Another point worth noting is that historically within the Yocto Project, |
| 709 | recipes were referred to as packages - thus, the existence of several BitBake |
| 710 | variables that are seemingly mis-named, |
| 711 | (e.g. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>, |
| 712 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and |
| 713 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>). |
| 714 | </para></listitem> |
| 715 | <listitem><para><emphasis>Package Groups:</emphasis> |
| 716 | Arbitrary groups of software Recipes. |
| 717 | You use package groups to hold recipes that, when built, |
| 718 | usually accomplish a single task. |
| 719 | For example, a package group could contain the recipes for a |
| 720 | company’s proprietary or value-add software. |
| 721 | Or, the package group could contain the recipes that enable |
| 722 | graphics. |
| 723 | A package group is really just another recipe. |
| 724 | Because package group files are recipes, they end with the |
| 725 | <filename>.bb</filename> filename extension.</para></listitem> |
| 726 | <listitem><para id='poky'><emphasis>Poky:</emphasis> |
| 727 | The term "poky" can mean several things. |
| 728 | In its most general sense, it is an open-source |
| 729 | project that was initially developed by OpenedHand. |
| 730 | With OpenedHand, poky was developed off of the existing |
| 731 | OpenEmbedded build system becoming a commercially |
| 732 | supportable build system for embedded Linux. |
| 733 | After Intel Corporation acquired OpenedHand, the |
| 734 | project poky became the basis for the Yocto Project's |
| 735 | build system.</para> |
| 736 | <para>Within the Yocto Project source repositories, |
| 737 | <filename>poky</filename> exists as a separate Git |
| 738 | repository you can clone to yield a local copy on your |
| 739 | host system. |
| 740 | Thus, "poky" can refer to the local copy of the Source |
| 741 | Directory used for development within the Yocto |
| 742 | Project.</para> |
| 743 | <para>Finally, "poky" can refer to the default |
| 744 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 745 | (i.e. distribution) created when you use the Yocto |
| 746 | Project in conjunction with the |
| 747 | <filename>poky</filename> repository to build an image. |
| 748 | </para></listitem> |
| 749 | <listitem><para><emphasis>Recipe:</emphasis> |
| 750 | A set of instructions for building packages. |
| 751 | A recipe describes where you get source code, which patches |
| 752 | to apply, how to configure the source, how to compile it and so on. |
| 753 | Recipes also describe dependencies for libraries or for other |
| 754 | recipes. |
| 755 | Recipes represent the logical unit of execution, the software |
| 756 | to build, the images to build, and use the |
| 757 | <filename>.bb</filename> file extension. |
| 758 | </para></listitem> |
| 759 | <listitem> |
| 760 | <para id='source-directory'><emphasis>Source Directory:</emphasis> |
| 761 | This term refers to the directory structure created as a result |
| 762 | of creating a local copy of the <filename>poky</filename> Git |
| 763 | repository <filename>git://git.yoctoproject.org/poky</filename> |
| 764 | or expanding a released <filename>poky</filename> tarball. |
| 765 | <note> |
| 766 | Creating a local copy of the <filename>poky</filename> |
| 767 | Git repository is the recommended method for setting up |
| 768 | your Source Directory. |
| 769 | </note> |
| 770 | Sometimes you might hear the term "poky directory" used to refer |
| 771 | to this directory structure. |
| 772 | <note> |
| 773 | The OpenEmbedded build system does not support file or |
| 774 | directory names that contain spaces. |
| 775 | Be sure that the Source Directory you use does not contain |
| 776 | these types of names. |
| 777 | </note></para> |
| 778 | |
| 779 | <para>The Source Directory contains BitBake, Documentation, |
| 780 | Metadata and other files that all support the Yocto Project. |
| 781 | Consequently, you must have the Source Directory in place on |
| 782 | your development system in order to do any development using |
| 783 | the Yocto Project.</para> |
| 784 | |
| 785 | <para>When you create a local copy of the Git repository, you |
| 786 | can name the repository anything you like. |
| 787 | Throughout much of the documentation, "poky" |
| 788 | is used as the name of the top-level folder of the local copy of |
| 789 | the poky Git repository. |
| 790 | So, for example, cloning the <filename>poky</filename> Git |
| 791 | repository results in a local Git repository whose top-level |
| 792 | folder is also named "poky".</para> |
| 793 | |
| 794 | <para>While it is not recommended that you use tarball expansion |
| 795 | to set up the Source Directory, if you do, the top-level |
| 796 | directory name of the Source Directory is derived from the |
| 797 | Yocto Project release tarball. |
| 798 | For example, downloading and unpacking |
| 799 | <filename>&YOCTO_POKY_TARBALL;</filename> results in a |
| 800 | Source Directory whose root folder is named |
| 801 | <filename>&YOCTO_POKY;</filename>.</para> |
| 802 | |
| 803 | <para>It is important to understand the differences between the |
| 804 | Source Directory created by unpacking a released tarball as |
| 805 | compared to cloning |
| 806 | <filename>git://git.yoctoproject.org/poky</filename>. |
| 807 | When you unpack a tarball, you have an exact copy of the files |
| 808 | based on the time of release - a fixed release point. |
| 809 | Any changes you make to your local files in the Source Directory |
| 810 | are on top of the release and will remain local only. |
| 811 | On the other hand, when you clone the <filename>poky</filename> |
| 812 | Git repository, you have an active development repository with |
| 813 | access to the upstream repository's branches and tags. |
| 814 | In this case, any local changes you make to the local |
| 815 | Source Directory can be later applied to active development |
| 816 | branches of the upstream <filename>poky</filename> Git |
| 817 | repository.</para> |
| 818 | |
| 819 | <para>For more information on concepts related to Git |
| 820 | repositories, branches, and tags, see the |
| 821 | "<link linkend='repositories-tags-and-branches'>Repositories, Tags, and Branches</link>" |
| 822 | section.</para></listitem> |
| 823 | <listitem><para><emphasis>Task:</emphasis> |
| 824 | A unit of execution for BitBake (e.g. |
| 825 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>, |
| 826 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>, |
| 827 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>, |
| 828 | and so forth). |
| 829 | </para></listitem> |
| 830 | <listitem><para><emphasis>Upstream:</emphasis> A reference to source code or repositories |
| 831 | that are not local to the development system but located in a master area that is controlled |
| 832 | by the maintainer of the source code. |
| 833 | For example, in order for a developer to work on a particular piece of code, they need to |
| 834 | first get a copy of it from an "upstream" source.</para></listitem> |
| 835 | </itemizedlist> |
| 836 | </para> |
| 837 | </section> |
| 838 | |
| 839 | <section id='licensing'> |
| 840 | <title>Licensing</title> |
| 841 | |
| 842 | <para> |
| 843 | Because open source projects are open to the public, they have different licensing structures in place. |
| 844 | License evolution for both Open Source and Free Software has an interesting history. |
| 845 | If you are interested in this history, you can find basic information here: |
| 846 | <itemizedlist> |
| 847 | <listitem><para><ulink url='http://en.wikipedia.org/wiki/Open-source_license'>Open source license history</ulink> |
| 848 | </para></listitem> |
| 849 | <listitem><para><ulink url='http://en.wikipedia.org/wiki/Free_software_license'>Free software license |
| 850 | history</ulink></para></listitem> |
| 851 | </itemizedlist> |
| 852 | </para> |
| 853 | |
| 854 | <para> |
| 855 | In general, the Yocto Project is broadly licensed under the Massachusetts Institute of Technology |
| 856 | (MIT) License. |
| 857 | MIT licensing permits the reuse of software within proprietary software as long as the |
| 858 | license is distributed with that software. |
| 859 | MIT is also compatible with the GNU General Public License (GPL). |
| 860 | Patches to the Yocto Project follow the upstream licensing scheme. |
| 861 | You can find information on the MIT license |
| 862 | <ulink url='http://www.opensource.org/licenses/mit-license.php'>here</ulink>. |
| 863 | You can find information on the GNU GPL <ulink url='http://www.opensource.org/licenses/LGPL-3.0'> |
| 864 | here</ulink>. |
| 865 | </para> |
| 866 | |
| 867 | <para> |
| 868 | When you build an image using the Yocto Project, the build process uses a |
| 869 | known list of licenses to ensure compliance. |
| 870 | You can find this list in the |
| 871 | <link linkend='source-directory'>Source Directory</link> at |
| 872 | <filename>meta/files/common-licenses</filename>. |
| 873 | Once the build completes, the list of all licenses found and used during that build are |
| 874 | kept in the |
| 875 | <link linkend='build-directory'>Build Directory</link> at |
| 876 | <filename>tmp/deploy/licenses</filename>. |
| 877 | </para> |
| 878 | |
| 879 | <para> |
| 880 | If a module requires a license that is not in the base list, the build process |
| 881 | generates a warning during the build. |
| 882 | These tools make it easier for a developer to be certain of the licenses with which |
| 883 | their shipped products must comply. |
| 884 | However, even with these tools it is still up to the developer to resolve potential licensing issues. |
| 885 | </para> |
| 886 | |
| 887 | <para> |
| 888 | The base list of licenses used by the build process is a combination of the Software Package |
| 889 | Data Exchange (SPDX) list and the Open Source Initiative (OSI) projects. |
| 890 | <ulink url='http://spdx.org'>SPDX Group</ulink> is a working group of the Linux Foundation |
| 891 | that maintains a specification |
| 892 | for a standard format for communicating the components, licenses, and copyrights |
| 893 | associated with a software package. |
| 894 | <ulink url='http://opensource.org'>OSI</ulink> is a corporation dedicated to the Open Source |
| 895 | Definition and the effort for reviewing and approving licenses that |
| 896 | conform to the Open Source Definition (OSD). |
| 897 | </para> |
| 898 | |
| 899 | <para> |
| 900 | You can find a list of the combined SPDX and OSI licenses that the |
| 901 | Yocto Project uses in the |
| 902 | <filename>meta/files/common-licenses</filename> directory in your |
| 903 | <link linkend='source-directory'>Source Directory</link>. |
| 904 | </para> |
| 905 | |
| 906 | <para> |
| 907 | For information that can help you maintain compliance with various |
| 908 | open source licensing during the lifecycle of a product created using |
| 909 | the Yocto Project, see the |
| 910 | "<link linkend='maintaining-open-source-license-compliance-during-your-products-lifecycle'>Maintaining Open Source License Compliance During Your Product's Lifecycle</link>" |
| 911 | section. |
| 912 | </para> |
| 913 | </section> |
| 914 | |
| 915 | <section id='git'> |
| 916 | <title>Git</title> |
| 917 | |
| 918 | <para> |
| 919 | The Yocto Project makes extensive use of Git, |
| 920 | which is a free, open source distributed version control system. |
| 921 | Git supports distributed development, non-linear development, and can handle large projects. |
| 922 | It is best that you have some fundamental understanding of how Git tracks projects and |
| 923 | how to work with Git if you are going to use the Yocto Project for development. |
| 924 | This section provides a quick overview of how Git works and provides you with a summary |
| 925 | of some essential Git commands. |
| 926 | </para> |
| 927 | |
| 928 | <para> |
| 929 | For more information on Git, see |
| 930 | <ulink url='http://git-scm.com/documentation'></ulink>. |
| 931 | If you need to download Git, go to <ulink url='http://git-scm.com/download'></ulink>. |
| 932 | </para> |
| 933 | |
| 934 | <section id='repositories-tags-and-branches'> |
| 935 | <title>Repositories, Tags, and Branches</title> |
| 936 | |
| 937 | <para> |
| 938 | As mentioned earlier in the section |
| 939 | "<link linkend='yocto-project-repositories'>Yocto Project Source Repositories</link>", |
| 940 | the Yocto Project maintains source repositories at |
| 941 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>. |
| 942 | If you look at this web-interface of the repositories, each item is a separate |
| 943 | Git repository. |
| 944 | </para> |
| 945 | |
| 946 | <para> |
| 947 | Git repositories use branching techniques that track content change (not files) |
| 948 | within a project (e.g. a new feature or updated documentation). |
| 949 | Creating a tree-like structure based on project divergence allows for excellent historical |
| 950 | information over the life of a project. |
| 951 | This methodology also allows for an environment from which you can do lots of |
| 952 | local experimentation on projects as you develop changes or new features. |
| 953 | </para> |
| 954 | |
| 955 | <para> |
| 956 | A Git repository represents all development efforts for a given project. |
| 957 | For example, the Git repository <filename>poky</filename> contains all changes |
| 958 | and developments for Poky over the course of its entire life. |
| 959 | That means that all changes that make up all releases are captured. |
| 960 | The repository maintains a complete history of changes. |
| 961 | </para> |
| 962 | |
| 963 | <para> |
| 964 | You can create a local copy of any repository by "cloning" it with the Git |
| 965 | <filename>clone</filename> command. |
| 966 | When you clone a Git repository, you end up with an identical copy of the |
| 967 | repository on your development system. |
| 968 | Once you have a local copy of a repository, you can take steps to develop locally. |
| 969 | For examples on how to clone Git repositories, see the |
| 970 | "<link linkend='getting-setup'>Getting Set Up</link>" section. |
| 971 | </para> |
| 972 | |
| 973 | <para> |
| 974 | It is important to understand that Git tracks content change and |
| 975 | not files. |
| 976 | Git uses "branches" to organize different development efforts. |
| 977 | For example, the <filename>poky</filename> repository has |
| 978 | several branches that include the current |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 979 | <filename>&DISTRO_NAME_NO_CAP;</filename> branch, the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 980 | <filename>master</filename> branch, and many branches for past |
| 981 | Yocto Project releases. |
| 982 | You can see all the branches by going to |
| 983 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and |
| 984 | clicking on the |
| 985 | <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/heads'>[...]</ulink></filename> |
| 986 | link beneath the "Branch" heading. |
| 987 | </para> |
| 988 | |
| 989 | <para> |
| 990 | Each of these branches represents a specific area of development. |
| 991 | The <filename>master</filename> branch represents the current or most recent |
| 992 | development. |
| 993 | All other branches represent offshoots of the <filename>master</filename> |
| 994 | branch. |
| 995 | </para> |
| 996 | |
| 997 | <para> |
| 998 | When you create a local copy of a Git repository, the copy has the same set |
| 999 | of branches as the original. |
| 1000 | This means you can use Git to create a local working area (also called a branch) |
| 1001 | that tracks a specific development branch from the source Git repository. |
| 1002 | in other words, you can define your local Git environment to work on any development |
| 1003 | branch in the repository. |
| 1004 | To help illustrate, here is a set of commands that creates a local copy of the |
| 1005 | <filename>poky</filename> Git repository and then creates and checks out a local |
| 1006 | Git branch that tracks the Yocto Project &DISTRO; Release (&DISTRO_NAME;) development: |
| 1007 | <literallayout class='monospaced'> |
| 1008 | $ cd ~ |
| 1009 | $ git clone git://git.yoctoproject.org/poky |
| 1010 | $ cd poky |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1011 | $ git checkout -b &DISTRO_NAME_NO_CAP; origin/&DISTRO_NAME_NO_CAP; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1012 | </literallayout> |
| 1013 | In this example, the name of the top-level directory of your local |
| 1014 | <link linkend='source-directory'>Source Directory</link> |
| 1015 | is "poky" and the name of that local working area (local branch) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1016 | you just created and checked out is "&DISTRO_NAME_NO_CAP;". |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1017 | The files in your local repository now reflect the same files that |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1018 | are in the "&DISTRO_NAME_NO_CAP;" development branch of the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1019 | Yocto Project's "poky" upstream repository. |
| 1020 | It is important to understand that when you create and checkout a |
| 1021 | local working branch based on a branch name, |
| 1022 | your local environment matches the "tip" of that development branch |
| 1023 | at the time you created your local branch, which could be |
| 1024 | different from the files at the time of a similarly named release. |
| 1025 | In other words, creating and checking out a local branch based on |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1026 | the "&DISTRO_NAME_NO_CAP;" branch name is not the same as |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1027 | cloning and checking out the "master" branch. |
| 1028 | Keep reading to see how you create a local snapshot of a Yocto |
| 1029 | Project Release. |
| 1030 | </para> |
| 1031 | |
| 1032 | <para> |
| 1033 | Git uses "tags" to mark specific changes in a repository. |
| 1034 | Typically, a tag is used to mark a special point such as the final |
| 1035 | change before a project is released. |
| 1036 | You can see the tags used with the <filename>poky</filename> Git |
| 1037 | repository by going to |
| 1038 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and |
| 1039 | clicking on the |
| 1040 | <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/tags'>[...]</ulink></filename> |
| 1041 | link beneath the "Tag" heading. |
| 1042 | </para> |
| 1043 | |
| 1044 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1045 | Some key tags are |
| 1046 | <filename>dizzy-12.0.0</filename>, |
| 1047 | <filename>fido-13.0.0</filename>, |
| 1048 | <filename>jethro-14.0.0</filename>, and |
| 1049 | <filename>&DISTRO_NAME_NO_CAP;-&POKYVERSION;</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1050 | These tags represent Yocto Project releases. |
| 1051 | </para> |
| 1052 | |
| 1053 | <para> |
| 1054 | When you create a local copy of the Git repository, you also have access to all the |
| 1055 | tags. |
| 1056 | Similar to branches, you can create and checkout a local working Git branch based |
| 1057 | on a tag name. |
| 1058 | When you do this, you get a snapshot of the Git repository that reflects |
| 1059 | the state of the files when the change was made associated with that tag. |
| 1060 | The most common use is to checkout a working branch that matches a specific |
| 1061 | Yocto Project release. |
| 1062 | Here is an example: |
| 1063 | <literallayout class='monospaced'> |
| 1064 | $ cd ~ |
| 1065 | $ git clone git://git.yoctoproject.org/poky |
| 1066 | $ cd poky |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1067 | $ git checkout -b my-&DISTRO_NAME_NO_CAP;-&POKYVERSION; &DISTRO_NAME_NO_CAP;-&POKYVERSION; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1068 | </literallayout> |
| 1069 | In this example, the name of the top-level directory of your local Yocto Project |
| 1070 | Files Git repository is <filename>poky</filename>. |
| 1071 | And, the name of the local branch you have created and checked out is |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1072 | <filename>my-&DISTRO_NAME_NO_CAP;-&POKYVERSION;</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1073 | The files in your repository now exactly match the Yocto Project &DISTRO; |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1074 | Release tag (<filename>&DISTRO_NAME_NO_CAP;-&POKYVERSION;</filename>). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1075 | It is important to understand that when you create and checkout a local |
| 1076 | working branch based on a tag, your environment matches a specific point |
| 1077 | in time and not the entire development branch. |
| 1078 | </para> |
| 1079 | </section> |
| 1080 | |
| 1081 | <section id='basic-commands'> |
| 1082 | <title>Basic Commands</title> |
| 1083 | |
| 1084 | <para> |
| 1085 | Git has an extensive set of commands that lets you manage changes and perform |
| 1086 | collaboration over the life of a project. |
| 1087 | Conveniently though, you can manage with a small set of basic operations and workflows |
| 1088 | once you understand the basic philosophy behind Git. |
| 1089 | You do not have to be an expert in Git to be functional. |
| 1090 | A good place to look for instruction on a minimal set of Git commands is |
| 1091 | <ulink url='http://git-scm.com/documentation'>here</ulink>. |
| 1092 | If you need to download Git, you can do so |
| 1093 | <ulink url='http://git-scm.com/download'>here</ulink>, although |
| 1094 | any reasonably current Linux distribution should already have an |
| 1095 | installable package for Git. |
| 1096 | </para> |
| 1097 | |
| 1098 | <para> |
| 1099 | If you do not know much about Git, you should educate |
| 1100 | yourself by visiting the links previously mentioned. |
| 1101 | </para> |
| 1102 | |
| 1103 | <para> |
| 1104 | The following list briefly describes some basic Git operations as a way to get started. |
| 1105 | As with any set of commands, this list (in most cases) simply shows the base command and |
| 1106 | omits the many arguments they support. |
| 1107 | See the Git documentation for complete descriptions and strategies on how to use these commands: |
| 1108 | <itemizedlist> |
| 1109 | <listitem><para><emphasis><filename>git init</filename>:</emphasis> Initializes an empty Git repository. |
| 1110 | You cannot use Git commands unless you have a <filename>.git</filename> repository.</para></listitem> |
| 1111 | <listitem><para><emphasis><filename>git clone</filename>:</emphasis> |
| 1112 | Creates a local clone of a Git repository. |
| 1113 | During collaboration, this command allows you to create a |
| 1114 | local Git repository that is on equal footing with a fellow |
| 1115 | developer’s Git repository. |
| 1116 | </para></listitem> |
| 1117 | <listitem><para><emphasis><filename>git add</filename>:</emphasis> Stages updated file contents |
| 1118 | to the index that |
| 1119 | Git uses to track changes. |
| 1120 | You must stage all files that have changed before you can commit them.</para></listitem> |
| 1121 | <listitem><para><emphasis><filename>git commit</filename>:</emphasis> Creates a "commit" that documents |
| 1122 | the changes you made. |
| 1123 | Commits are used for historical purposes, for determining if a maintainer of a project |
| 1124 | will allow the change, and for ultimately pushing the change from your local Git repository |
| 1125 | into the project’s upstream (or master) repository.</para></listitem> |
| 1126 | <listitem><para><emphasis><filename>git status</filename>:</emphasis> Reports any modified files that |
| 1127 | possibly need to be staged and committed.</para></listitem> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1128 | <listitem><para><emphasis><filename>git checkout</filename> <replaceable>branch-name</replaceable>:</emphasis> Changes |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1129 | your working branch. |
| 1130 | This command is analogous to "cd".</para></listitem> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1131 | <listitem><para><emphasis><filename>git checkout –b</filename> <replaceable>working-branch</replaceable>:</emphasis> Creates |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1132 | a working branch on your local machine where you can isolate work. |
| 1133 | It is a good idea to use local branches when adding specific features or changes. |
| 1134 | This way if you do not like what you have done you can easily get rid of the work.</para></listitem> |
| 1135 | <listitem><para><emphasis><filename>git branch</filename>:</emphasis> Reports |
| 1136 | existing local branches and |
| 1137 | tells you the branch in which you are currently working.</para></listitem> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1138 | <listitem><para><emphasis><filename>git branch -D</filename> <replaceable>branch-name</replaceable>:</emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1139 | Deletes an existing local branch. |
| 1140 | You need to be in a local branch other than the one you are deleting |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1141 | in order to delete <replaceable>branch-name</replaceable>.</para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1142 | <listitem><para><emphasis><filename>git pull</filename>:</emphasis> Retrieves information |
| 1143 | from an upstream Git |
| 1144 | repository and places it in your local Git repository. |
| 1145 | You use this command to make sure you are synchronized with the repository |
| 1146 | from which you are basing changes (.e.g. the master branch).</para></listitem> |
| 1147 | <listitem><para><emphasis><filename>git push</filename>:</emphasis> |
| 1148 | Sends all your committed local changes to an upstream Git |
| 1149 | repository (e.g. a contribution repository). |
| 1150 | The maintainer of the project draws from these repositories |
| 1151 | when adding changes to the project’s master repository or |
| 1152 | other development branch. |
| 1153 | </para></listitem> |
| 1154 | <listitem><para><emphasis><filename>git merge</filename>:</emphasis> Combines or adds changes from one |
| 1155 | local branch of your repository with another branch. |
| 1156 | When you create a local Git repository, the default branch is named "master". |
| 1157 | A typical workflow is to create a temporary branch for isolated work, make and commit your |
| 1158 | changes, switch to your local master branch, merge the changes from the temporary branch into the |
| 1159 | local master branch, and then delete the temporary branch.</para></listitem> |
| 1160 | <listitem><para><emphasis><filename>git cherry-pick</filename>:</emphasis> Choose and apply specific |
| 1161 | commits from one branch into another branch. |
| 1162 | There are times when you might not be able to merge all the changes in one branch with |
| 1163 | another but need to pick out certain ones.</para></listitem> |
| 1164 | <listitem><para><emphasis><filename>gitk</filename>:</emphasis> Provides a GUI view of the branches |
| 1165 | and changes in your local Git repository. |
| 1166 | This command is a good way to graphically see where things have diverged in your |
| 1167 | local repository.</para></listitem> |
| 1168 | <listitem><para><emphasis><filename>git log</filename>:</emphasis> Reports a history of your changes to the |
| 1169 | repository.</para></listitem> |
| 1170 | <listitem><para><emphasis><filename>git diff</filename>:</emphasis> Displays line-by-line differences |
| 1171 | between your local working files and the same files in the upstream Git repository that your |
| 1172 | branch currently tracks.</para></listitem> |
| 1173 | </itemizedlist> |
| 1174 | </para> |
| 1175 | </section> |
| 1176 | </section> |
| 1177 | |
| 1178 | <section id='workflows'> |
| 1179 | <title>Workflows</title> |
| 1180 | |
| 1181 | <para> |
| 1182 | This section provides some overview on workflows using Git. |
| 1183 | In particular, the information covers basic practices that describe roles and actions in a |
| 1184 | collaborative development environment. |
| 1185 | Again, if you are familiar with this type of development environment, you might want to just |
| 1186 | skip this section. |
| 1187 | </para> |
| 1188 | |
| 1189 | <para> |
| 1190 | The Yocto Project files are maintained using Git in a "master" branch whose Git history |
| 1191 | tracks every change and whose structure provides branches for all diverging functionality. |
| 1192 | Although there is no need to use Git, many open source projects do so. |
| 1193 | For the Yocto Project, a key individual called the "maintainer" is responsible for the "master" |
| 1194 | branch of a given Git repository. |
| 1195 | The "master" branch is the “upstream” repository where the final builds of the project occur. |
| 1196 | The maintainer is responsible for accepting changes from other developers and for |
| 1197 | organizing the underlying branch structure to reflect release strategies and so forth. |
| 1198 | <note>For information on finding out who is responsible for (maintains) |
| 1199 | a particular area of code, see the |
| 1200 | "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" |
| 1201 | section. |
| 1202 | </note> |
| 1203 | </para> |
| 1204 | |
| 1205 | <para> |
| 1206 | The project also has an upstream contribution Git repository named |
| 1207 | <filename>poky-contrib</filename>. |
| 1208 | You can see all the branches in this repository using the web interface |
| 1209 | of the |
| 1210 | <ulink url='&YOCTO_GIT_URL;'>Source Repositories</ulink> organized |
| 1211 | within the "Poky Support" area. |
| 1212 | These branches temporarily hold changes to the project that have been |
| 1213 | submitted or committed by the Yocto Project development team and by |
| 1214 | community members who contribute to the project. |
| 1215 | The maintainer determines if the changes are qualified to be moved |
| 1216 | from the "contrib" branches into the "master" branch of the Git |
| 1217 | repository. |
| 1218 | </para> |
| 1219 | |
| 1220 | <para> |
| 1221 | Developers (including contributing community members) create and maintain cloned repositories |
| 1222 | of the upstream "master" branch. |
| 1223 | These repositories are local to their development platforms and are used to develop changes. |
| 1224 | When a developer is satisfied with a particular feature or change, they "push" the changes |
| 1225 | to the appropriate "contrib" repository. |
| 1226 | </para> |
| 1227 | |
| 1228 | <para> |
| 1229 | Developers are responsible for keeping their local repository up-to-date with "master". |
| 1230 | They are also responsible for straightening out any conflicts that might arise within files |
| 1231 | that are being worked on simultaneously by more than one person. |
| 1232 | All this work is done locally on the developer’s machines before anything is pushed to a |
| 1233 | "contrib" area and examined at the maintainer’s level. |
| 1234 | </para> |
| 1235 | |
| 1236 | <para> |
| 1237 | A somewhat formal method exists by which developers commit changes and push them into the |
| 1238 | "contrib" area and subsequently request that the maintainer include them into "master" |
| 1239 | This process is called “submitting a patch” or "submitting a change." |
| 1240 | For information on submitting patches and changes, see the |
| 1241 | "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" section. |
| 1242 | </para> |
| 1243 | |
| 1244 | <para> |
| 1245 | To summarize the environment: a single point of entry exists for |
| 1246 | changes into the project’s "master" branch of the Git repository, |
| 1247 | which is controlled by the project’s maintainer. |
| 1248 | And, a set of developers exist who independently develop, test, and |
| 1249 | submit changes to "contrib" areas for the maintainer to examine. |
| 1250 | The maintainer then chooses which changes are going to become a |
| 1251 | permanent part of the project. |
| 1252 | </para> |
| 1253 | |
| 1254 | <para> |
| 1255 | <imagedata fileref="figures/git-workflow.png" width="6in" depth="3in" align="left" scalefit="1" /> |
| 1256 | </para> |
| 1257 | |
| 1258 | <para> |
| 1259 | While each development environment is unique, there are some best practices or methods |
| 1260 | that help development run smoothly. |
| 1261 | The following list describes some of these practices. |
| 1262 | For more information about Git workflows, see the workflow topics in the |
| 1263 | <ulink url='http://book.git-scm.com'>Git Community Book</ulink>. |
| 1264 | <itemizedlist> |
| 1265 | <listitem><para><emphasis>Make Small Changes:</emphasis> It is best to keep the changes you commit |
| 1266 | small as compared to bundling many disparate changes into a single commit. |
| 1267 | This practice not only keeps things manageable but also allows the maintainer |
| 1268 | to more easily include or refuse changes.</para> |
| 1269 | <para>It is also good practice to leave the repository in a state that allows you to |
| 1270 | still successfully build your project. In other words, do not commit half of a feature, |
| 1271 | then add the other half as a separate, later commit. |
| 1272 | Each commit should take you from one buildable project state to another |
| 1273 | buildable state.</para></listitem> |
| 1274 | <listitem><para><emphasis>Use Branches Liberally:</emphasis> It is very easy to create, use, and |
| 1275 | delete local branches in your working Git repository. |
| 1276 | You can name these branches anything you like. |
| 1277 | It is helpful to give them names associated with the particular feature or change |
| 1278 | on which you are working. |
| 1279 | Once you are done with a feature or change and have merged it |
| 1280 | into your local master branch, simply discard the temporary |
| 1281 | branch.</para></listitem> |
| 1282 | <listitem><para><emphasis>Merge Changes:</emphasis> The <filename>git merge</filename> |
| 1283 | command allows you to take the |
| 1284 | changes from one branch and fold them into another branch. |
| 1285 | This process is especially helpful when more than a single developer might be working |
| 1286 | on different parts of the same feature. |
| 1287 | Merging changes also automatically identifies any collisions or "conflicts" |
| 1288 | that might happen as a result of the same lines of code being altered by two different |
| 1289 | developers.</para></listitem> |
| 1290 | <listitem><para><emphasis>Manage Branches:</emphasis> Because branches are easy to use, you should |
| 1291 | use a system where branches indicate varying levels of code readiness. |
| 1292 | For example, you can have a "work" branch to develop in, a "test" branch where the code or |
| 1293 | change is tested, a "stage" branch where changes are ready to be committed, and so forth. |
| 1294 | As your project develops, you can merge code across the branches to reflect ever-increasing |
| 1295 | stable states of the development.</para></listitem> |
| 1296 | <listitem><para><emphasis>Use Push and Pull:</emphasis> The push-pull workflow is based on the |
| 1297 | concept of developers "pushing" local commits to a remote repository, which is |
| 1298 | usually a contribution repository. |
| 1299 | This workflow is also based on developers "pulling" known states of the project down into their |
| 1300 | local development repositories. |
| 1301 | The workflow easily allows you to pull changes submitted by other developers from the |
| 1302 | upstream repository into your work area ensuring that you have the most recent software |
| 1303 | on which to develop. |
| 1304 | The Yocto Project has two scripts named <filename>create-pull-request</filename> and |
| 1305 | <filename>send-pull-request</filename> that ship with the release to facilitate this |
| 1306 | workflow. |
| 1307 | You can find these scripts in the <filename>scripts</filename> |
| 1308 | folder of the |
| 1309 | <link linkend='source-directory'>Source Directory</link>. |
| 1310 | For information on how to use these scripts, see the |
| 1311 | "<link linkend='pushing-a-change-upstream'>Using Scripts to Push a Change Upstream and Request a Pull</link>" section. |
| 1312 | </para></listitem> |
| 1313 | <listitem><para><emphasis>Patch Workflow:</emphasis> This workflow allows you to notify the |
| 1314 | maintainer through an email that you have a change (or patch) you would like considered |
| 1315 | for the "master" branch of the Git repository. |
| 1316 | To send this type of change, you format the patch and then send the email using the Git commands |
| 1317 | <filename>git format-patch</filename> and <filename>git send-email</filename>. |
| 1318 | For information on how to use these scripts, see the |
| 1319 | "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" |
| 1320 | section. |
| 1321 | </para></listitem> |
| 1322 | </itemizedlist> |
| 1323 | </para> |
| 1324 | </section> |
| 1325 | |
| 1326 | <section id='tracking-bugs'> |
| 1327 | <title>Tracking Bugs</title> |
| 1328 | |
| 1329 | <para> |
| 1330 | The Yocto Project uses its own implementation of |
| 1331 | <ulink url='http://www.bugzilla.org/about/'>Bugzilla</ulink> to track bugs. |
| 1332 | Implementations of Bugzilla work well for group development because they track bugs and code |
| 1333 | changes, can be used to communicate changes and problems with developers, can be used to |
| 1334 | submit and review patches, and can be used to manage quality assurance. |
| 1335 | The home page for the Yocto Project implementation of Bugzilla is |
| 1336 | <ulink url='&YOCTO_BUGZILLA_URL;'>&YOCTO_BUGZILLA_URL;</ulink>. |
| 1337 | </para> |
| 1338 | |
| 1339 | <para> |
| 1340 | Sometimes it is helpful to submit, investigate, or track a bug against the Yocto Project itself |
| 1341 | such as when discovering an issue with some component of the build system that acts contrary |
| 1342 | to the documentation or your expectations. |
| 1343 | Following is the general procedure for submitting a new bug using the Yocto Project |
| 1344 | Bugzilla. |
| 1345 | You can find more information on defect management, bug tracking, and feature request |
| 1346 | processes all accomplished through the Yocto Project Bugzilla on the |
| 1347 | <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>wiki page</ulink>. |
| 1348 | <orderedlist> |
| 1349 | <listitem><para>Always use the Yocto Project implementation of Bugzilla to submit |
| 1350 | a bug.</para></listitem> |
| 1351 | <listitem><para>When submitting a new bug, be sure to choose the appropriate |
| 1352 | Classification, Product, and Component for which the issue was found. |
| 1353 | Defects for the Yocto Project fall into one of seven classifications: |
| 1354 | Yocto Project Components, Infrastructure, Build System & Metadata, |
| 1355 | Documentation, QA/Testing, Runtime and Hardware. |
| 1356 | Each of these Classifications break down into multiple Products and, in some |
| 1357 | cases, multiple Components.</para></listitem> |
| 1358 | <listitem><para>Use the bug form to choose the correct Hardware and Architecture |
| 1359 | for which the bug applies.</para></listitem> |
| 1360 | <listitem><para>Indicate the Yocto Project version you were using when the issue |
| 1361 | occurred.</para></listitem> |
| 1362 | <listitem><para>Be sure to indicate the Severity of the bug. |
| 1363 | Severity communicates how the bug impacted your work.</para></listitem> |
| 1364 | <listitem><para>Select the appropriate "Documentation change" item |
| 1365 | for the bug. |
| 1366 | Fixing a bug may or may not affect the Yocto Project |
| 1367 | documentation.</para></listitem> |
| 1368 | <listitem><para>Provide a brief summary of the issue. |
| 1369 | Try to limit your summary to just a line or two and be sure to capture the |
| 1370 | essence of the issue.</para></listitem> |
| 1371 | <listitem><para>Provide a detailed description of the issue. |
| 1372 | You should provide as much detail as you can about the context, behavior, output, |
| 1373 | and so forth that surrounds the issue. |
| 1374 | You can even attach supporting files for output from logs by |
| 1375 | using the "Add an attachment" button.</para></listitem> |
| 1376 | <listitem><para>Be sure to copy the appropriate people in the |
| 1377 | "CC List" for the bug. |
| 1378 | See the "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" |
| 1379 | section for information about finding out who is responsible |
| 1380 | for code.</para></listitem> |
| 1381 | <listitem><para>Submit the bug by clicking the "Submit Bug" button.</para></listitem> |
| 1382 | </orderedlist> |
| 1383 | </para> |
| 1384 | </section> |
| 1385 | |
| 1386 | <section id='how-to-submit-a-change'> |
| 1387 | <title>How to Submit a Change</title> |
| 1388 | |
| 1389 | <para> |
| 1390 | Contributions to the Yocto Project and OpenEmbedded are very welcome. |
| 1391 | Because the system is extremely configurable and flexible, we recognize that developers |
| 1392 | will want to extend, configure or optimize it for their specific uses. |
| 1393 | You should send patches to the appropriate mailing list so that they |
| 1394 | can be reviewed and merged by the appropriate maintainer. |
| 1395 | </para> |
| 1396 | |
| 1397 | <para> |
| 1398 | Before submitting any change, be sure to find out who you should be |
| 1399 | notifying. |
| 1400 | Several methods exist through which you find out who you should be copying |
| 1401 | or notifying: |
| 1402 | <itemizedlist> |
| 1403 | <listitem><para><emphasis>Maintenance File:</emphasis> |
| 1404 | Examine the <filename>maintainers.inc</filename> file, which is |
| 1405 | located in the |
| 1406 | <link linkend='source-directory'>Source Directory</link> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1407 | at <filename>meta-poky/conf/distro/include</filename>, to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1408 | see who is responsible for code. |
| 1409 | </para></listitem> |
| 1410 | <listitem><para><emphasis>Board Support Package (BSP) README Files:</emphasis> |
| 1411 | For BSP maintainers of supported BSPs, you can examine |
| 1412 | individual BSP <filename>README</filename> files. |
| 1413 | In addition, some layers (such as the <filename>meta-intel</filename> layer), |
| 1414 | include a <filename>MAINTAINERS</filename> file which contains |
| 1415 | a list of all supported BSP maintainers for that layer. |
| 1416 | </para></listitem> |
| 1417 | <listitem><para><emphasis>Search by File:</emphasis> |
| 1418 | Using <link linkend='git'>Git</link>, you can enter the |
| 1419 | following command to bring up a short list of all commits |
| 1420 | against a specific file: |
| 1421 | <literallayout class='monospaced'> |
| 1422 | git shortlog -- <replaceable>filename</replaceable> |
| 1423 | </literallayout> |
| 1424 | Just provide the name of the file for which you are interested. |
| 1425 | The information returned is not ordered by history but does |
| 1426 | include a list of all committers grouped by name. |
| 1427 | From the list, you can see who is responsible for the bulk of |
| 1428 | the changes against the file. |
| 1429 | </para></listitem> |
| 1430 | </itemizedlist> |
| 1431 | </para> |
| 1432 | |
| 1433 | <para> |
| 1434 | For a list of the Yocto Project and related mailing lists, see the |
| 1435 | "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing lists</ulink>" section in |
| 1436 | the Yocto Project Reference Manual. |
| 1437 | </para> |
| 1438 | |
| 1439 | <para> |
| 1440 | Here is some guidance on which mailing list to use for what type of change: |
| 1441 | <itemizedlist> |
| 1442 | <listitem><para>For changes to the core |
| 1443 | <link linkend='metadata'>Metadata</link>, send your patch to the |
| 1444 | <ulink url='&OE_LISTS_URL;/listinfo/openembedded-core'>openembedded-core</ulink> mailing list. |
| 1445 | For example, a change to anything under the <filename>meta</filename> or |
| 1446 | <filename>scripts</filename> directories |
| 1447 | should be sent to this mailing list.</para></listitem> |
| 1448 | <listitem><para>For changes to BitBake (anything under the <filename>bitbake</filename> |
| 1449 | directory), send your patch to the |
| 1450 | <ulink url='&OE_LISTS_URL;/listinfo/bitbake-devel'>bitbake-devel</ulink> mailing list.</para></listitem> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1451 | <listitem><para>For changes to <filename>meta-poky</filename>, send your patch to the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1452 | <ulink url='&YOCTO_LISTS_URL;/listinfo/poky'>poky</ulink> mailing list.</para></listitem> |
| 1453 | <listitem><para>For changes to other layers hosted on |
| 1454 | <filename>yoctoproject.org</filename> (unless the |
| 1455 | layer's documentation specifies otherwise), tools, and Yocto Project |
| 1456 | documentation, use the |
| 1457 | <ulink url='&YOCTO_LISTS_URL;/listinfo/yocto'>yocto</ulink> mailing list.</para></listitem> |
| 1458 | <listitem><para>For additional recipes that do not fit into the core Metadata, |
| 1459 | you should determine which layer the recipe should go into and submit the |
| 1460 | change in the manner recommended by the documentation (e.g. README) supplied |
| 1461 | with the layer. If in doubt, please ask on the |
| 1462 | <ulink url='&YOCTO_LISTS_URL;/listinfo/yocto'>yocto</ulink> or |
| 1463 | <ulink url='&OE_LISTS_URL;/listinfo/openembedded-devel'>openembedded-devel</ulink> |
| 1464 | mailing lists.</para></listitem> |
| 1465 | </itemizedlist> |
| 1466 | </para> |
| 1467 | |
| 1468 | <para> |
| 1469 | When you send a patch, be sure to include a "Signed-off-by:" |
| 1470 | line in the same style as required by the Linux kernel. |
| 1471 | Adding this line signifies that you, the submitter, have agreed to the Developer's Certificate of Origin 1.1 |
| 1472 | as follows: |
| 1473 | <literallayout class='monospaced'> |
| 1474 | Developer's Certificate of Origin 1.1 |
| 1475 | |
| 1476 | By making a contribution to this project, I certify that: |
| 1477 | |
| 1478 | (a) The contribution was created in whole or in part by me and I |
| 1479 | have the right to submit it under the open source license |
| 1480 | indicated in the file; or |
| 1481 | |
| 1482 | (b) The contribution is based upon previous work that, to the best |
| 1483 | of my knowledge, is covered under an appropriate open source |
| 1484 | license and I have the right under that license to submit that |
| 1485 | work with modifications, whether created in whole or in part |
| 1486 | by me, under the same open source license (unless I am |
| 1487 | permitted to submit under a different license), as indicated |
| 1488 | in the file; or |
| 1489 | |
| 1490 | (c) The contribution was provided directly to me by some other |
| 1491 | person who certified (a), (b) or (c) and I have not modified |
| 1492 | it. |
| 1493 | |
| 1494 | (d) I understand and agree that this project and the contribution |
| 1495 | are public and that a record of the contribution (including all |
| 1496 | personal information I submit with it, including my sign-off) is |
| 1497 | maintained indefinitely and may be redistributed consistent with |
| 1498 | this project or the open source license(s) involved. |
| 1499 | </literallayout> |
| 1500 | </para> |
| 1501 | |
| 1502 | <para> |
| 1503 | In a collaborative environment, it is necessary to have some sort of standard |
| 1504 | or method through which you submit changes. |
| 1505 | Otherwise, things could get quite chaotic. |
| 1506 | One general practice to follow is to make small, controlled changes. |
| 1507 | Keeping changes small and isolated aids review, makes merging/rebasing easier |
| 1508 | and keeps the change history clean when anyone needs to refer to it in future. |
| 1509 | </para> |
| 1510 | |
| 1511 | <para> |
| 1512 | When you make a commit, you must follow certain standards established by the |
| 1513 | OpenEmbedded and Yocto Project development teams. |
| 1514 | For each commit, you must provide a single-line summary of the change and you |
| 1515 | should almost always provide a more detailed description of what you did (i.e. |
| 1516 | the body of the commit message). |
| 1517 | The only exceptions for not providing a detailed description would be if your |
| 1518 | change is a simple, self-explanatory change that needs no further description |
| 1519 | beyond the summary. |
| 1520 | Here are the guidelines for composing a commit message: |
| 1521 | <itemizedlist> |
| 1522 | <listitem><para>Provide a single-line, short summary of the change. |
| 1523 | This summary is typically viewable in the "shortlist" of changes. |
| 1524 | Thus, providing something short and descriptive that gives the reader |
| 1525 | a summary of the change is useful when viewing a list of many commits. |
| 1526 | This short description should be prefixed by the recipe name (if changing a recipe), or |
| 1527 | else the short form path to the file being changed. |
| 1528 | </para></listitem> |
| 1529 | <listitem><para>For the body of the commit message, provide detailed information |
| 1530 | that describes what you changed, why you made the change, and the approach |
| 1531 | you used. It may also be helpful if you mention how you tested the change. |
| 1532 | Provide as much detail as you can in the body of the commit message. |
| 1533 | </para></listitem> |
| 1534 | <listitem><para> |
| 1535 | If the change addresses a specific bug or issue that is |
| 1536 | associated with a bug-tracking ID, include a reference to that |
| 1537 | ID in your detailed description. |
| 1538 | For example, the Yocto Project uses a specific convention for |
| 1539 | bug references - any commit that addresses a specific bug should |
| 1540 | use the following form for the detailed description: |
| 1541 | <literallayout class='monospaced'> |
| 1542 | Fixes [YOCTO #<replaceable>bug-id</replaceable>] |
| 1543 | |
| 1544 | <replaceable>detailed description of change</replaceable> |
| 1545 | </literallayout></para></listitem> |
| 1546 | Where <replaceable>bug-id</replaceable> is replaced with the |
| 1547 | specific bug ID from the Yocto Project Bugzilla instance. |
| 1548 | </itemizedlist> |
| 1549 | </para> |
| 1550 | |
| 1551 | <para> |
| 1552 | You can find more guidance on creating well-formed commit messages at this OpenEmbedded |
| 1553 | wiki page: |
| 1554 | <ulink url='&OE_HOME_URL;/wiki/Commit_Patch_Message_Guidelines'></ulink>. |
| 1555 | </para> |
| 1556 | |
| 1557 | <para> |
| 1558 | The next two sections describe general instructions for both pushing |
| 1559 | changes upstream and for submitting changes as patches. |
| 1560 | </para> |
| 1561 | |
| 1562 | <section id='pushing-a-change-upstream'> |
| 1563 | <title>Using Scripts to Push a Change Upstream and Request a Pull</title> |
| 1564 | |
| 1565 | <para> |
| 1566 | The basic flow for pushing a change to an upstream "contrib" Git repository is as follows: |
| 1567 | <itemizedlist> |
| 1568 | <listitem><para>Make your changes in your local Git repository.</para></listitem> |
| 1569 | <listitem><para>Stage your changes by using the <filename>git add</filename> |
| 1570 | command on each file you changed.</para></listitem> |
| 1571 | <listitem><para> |
| 1572 | Commit the change by using the |
| 1573 | <filename>git commit</filename> command. |
| 1574 | Be sure to provide a commit message that follows the |
| 1575 | project’s commit message standards as described earlier. |
| 1576 | </para></listitem> |
| 1577 | <listitem><para> |
| 1578 | Push the change to the upstream "contrib" repository by |
| 1579 | using the <filename>git push</filename> command. |
| 1580 | </para></listitem> |
| 1581 | <listitem><para>Notify the maintainer that you have pushed a change by making a pull |
| 1582 | request. |
| 1583 | The Yocto Project provides two scripts that conveniently let you generate and send |
| 1584 | pull requests to the Yocto Project. |
| 1585 | These scripts are <filename>create-pull-request</filename> and |
| 1586 | <filename>send-pull-request</filename>. |
| 1587 | You can find these scripts in the <filename>scripts</filename> directory |
| 1588 | within the <link linkend='source-directory'>Source Directory</link>.</para> |
| 1589 | <para>Using these scripts correctly formats the requests without introducing any |
| 1590 | whitespace or HTML formatting. |
| 1591 | The maintainer that receives your patches needs to be able to save and apply them |
| 1592 | directly from your emails. |
| 1593 | Using these scripts is the preferred method for sending patches.</para> |
| 1594 | <para>For help on using these scripts, simply provide the |
| 1595 | <filename>-h</filename> argument as follows: |
| 1596 | <literallayout class='monospaced'> |
| 1597 | $ poky/scripts/create-pull-request -h |
| 1598 | $ poky/scripts/send-pull-request -h |
| 1599 | </literallayout></para></listitem> |
| 1600 | </itemizedlist> |
| 1601 | </para> |
| 1602 | |
| 1603 | <para> |
| 1604 | You can find general Git information on how to push a change upstream in the |
| 1605 | <ulink url='http://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows'>Git Community Book</ulink>. |
| 1606 | </para> |
| 1607 | </section> |
| 1608 | |
| 1609 | <section id='submitting-a-patch'> |
| 1610 | <title>Using Email to Submit a Patch</title> |
| 1611 | |
| 1612 | <para> |
| 1613 | You can submit patches without using the <filename>create-pull-request</filename> and |
| 1614 | <filename>send-pull-request</filename> scripts described in the previous section. |
| 1615 | However, keep in mind, the preferred method is to use the scripts. |
| 1616 | </para> |
| 1617 | |
| 1618 | <para> |
| 1619 | Depending on the components changed, you need to submit the email to a specific |
| 1620 | mailing list. |
| 1621 | For some guidance on which mailing list to use, see the list in the |
| 1622 | "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" |
| 1623 | section. |
| 1624 | For a description of the available mailing lists, see the |
| 1625 | "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing Lists</ulink>" |
| 1626 | section in the Yocto Project Reference Manual. |
| 1627 | </para> |
| 1628 | |
| 1629 | <para> |
| 1630 | Here is the general procedure on how to submit a patch through email without using the |
| 1631 | scripts: |
| 1632 | <itemizedlist> |
| 1633 | <listitem><para>Make your changes in your local Git repository.</para></listitem> |
| 1634 | <listitem><para>Stage your changes by using the <filename>git add</filename> |
| 1635 | command on each file you changed.</para></listitem> |
| 1636 | <listitem><para>Commit the change by using the |
| 1637 | <filename>git commit --signoff</filename> command. |
| 1638 | Using the <filename>--signoff</filename> option identifies you as the person |
| 1639 | making the change and also satisfies the Developer's Certificate of |
| 1640 | Origin (DCO) shown earlier.</para> |
| 1641 | <para>When you form a commit, you must follow certain standards established by the |
| 1642 | Yocto Project development team. |
| 1643 | See the earlier section |
| 1644 | "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" |
| 1645 | for Yocto Project commit message standards.</para></listitem> |
| 1646 | <listitem><para>Format the commit into an email message. |
| 1647 | To format commits, use the <filename>git format-patch</filename> command. |
| 1648 | When you provide the command, you must include a revision list or a number of patches |
| 1649 | as part of the command. |
| 1650 | For example, either of these two commands takes your most |
| 1651 | recent single commit and formats it as an email message in |
| 1652 | the current directory: |
| 1653 | <literallayout class='monospaced'> |
| 1654 | $ git format-patch -1 |
| 1655 | </literallayout> |
| 1656 | or |
| 1657 | <literallayout class='monospaced'> |
| 1658 | $ git format-patch HEAD~ |
| 1659 | </literallayout></para> |
| 1660 | <para>After the command is run, the current directory contains a |
| 1661 | numbered <filename>.patch</filename> file for the commit.</para> |
| 1662 | <para>If you provide several commits as part of the command, |
| 1663 | the <filename>git format-patch</filename> command produces a |
| 1664 | series of numbered files in the current directory – one for each commit. |
| 1665 | If you have more than one patch, you should also use the |
| 1666 | <filename>--cover</filename> option with the command, which generates a |
| 1667 | cover letter as the first "patch" in the series. |
| 1668 | You can then edit the cover letter to provide a description for |
| 1669 | the series of patches. |
| 1670 | For information on the <filename>git format-patch</filename> command, |
| 1671 | see <filename>GIT_FORMAT_PATCH(1)</filename> displayed using the |
| 1672 | <filename>man git-format-patch</filename> command.</para> |
| 1673 | <note>If you are or will be a frequent contributor to the Yocto Project |
| 1674 | or to OpenEmbedded, you might consider requesting a contrib area and the |
| 1675 | necessary associated rights.</note></listitem> |
| 1676 | <listitem><para>Import the files into your mail client by using the |
| 1677 | <filename>git send-email</filename> command. |
| 1678 | <note>In order to use <filename>git send-email</filename>, you must have the |
| 1679 | the proper Git packages installed. |
| 1680 | For Ubuntu, Debian, and Fedora the package is <filename>git-email</filename>.</note></para> |
| 1681 | <para>The <filename>git send-email</filename> command sends email by using a local |
| 1682 | or remote Mail Transport Agent (MTA) such as |
| 1683 | <filename>msmtp</filename>, <filename>sendmail</filename>, or through a direct |
| 1684 | <filename>smtp</filename> configuration in your Git <filename>config</filename> |
| 1685 | file. |
| 1686 | If you are submitting patches through email only, it is very important |
| 1687 | that you submit them without any whitespace or HTML formatting that |
| 1688 | either you or your mailer introduces. |
| 1689 | The maintainer that receives your patches needs to be able to save and |
| 1690 | apply them directly from your emails. |
| 1691 | A good way to verify that what you are sending will be applicable by the |
| 1692 | maintainer is to do a dry run and send them to yourself and then |
| 1693 | save and apply them as the maintainer would.</para> |
| 1694 | <para>The <filename>git send-email</filename> command is the preferred method |
| 1695 | for sending your patches since there is no risk of compromising whitespace |
| 1696 | in the body of the message, which can occur when you use your own mail client. |
| 1697 | The command also has several options that let you |
| 1698 | specify recipients and perform further editing of the email message. |
| 1699 | For information on how to use the <filename>git send-email</filename> command, |
| 1700 | see <filename>GIT-SEND-EMAIL(1)</filename> displayed using |
| 1701 | the <filename>man git-send-email</filename> command. |
| 1702 | </para></listitem> |
| 1703 | </itemizedlist> |
| 1704 | </para> |
| 1705 | </section> |
| 1706 | </section> |
| 1707 | </chapter> |
| 1708 | <!-- |
| 1709 | vim: expandtab tw=80 ts=4 |
| 1710 | --> |