blob: 59f3c1e4066404312c29af68e1ce671ee07e09a3 [file] [log] [blame]
Andrew Geissler5082cc72023-09-11 08:41:39 -04001.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
2
3Contributing Changes to a Component
4************************************
5
6Contributions to the Yocto Project and OpenEmbedded are very welcome.
7Because the system is extremely configurable and flexible, we recognize
8that developers will want to extend, configure or optimize it for their
9specific uses.
10
11.. _ref-why-mailing-lists:
12
13Contributing through mailing lists --- Why not using web-based workflows?
14=========================================================================
15
16Both Yocto Project and OpenEmbedded have many key components that are
17maintained by patches being submitted on mailing lists. We appreciate this
18approach does look a little old fashioned when other workflows are available
19through web technology such as GitHub, GitLab and others. Since we are often
20asked this question, we’ve decided to document the reasons for using mailing
21lists.
22
23One significant factor is that we value peer review. When a change is proposed
24to many of the core pieces of the project, it helps to have many eyes of review
25go over them. Whilst there is ultimately one maintainer who needs to make the
26final call on accepting or rejecting a patch, the review is made by many eyes
27and the exact people reviewing it are likely unknown to the maintainer. It is
28often the surprise reviewer that catches the most interesting issues!
29
30This is in contrast to the "GitHub" style workflow where either just a
31maintainer makes that review, or review is specifically requested from
32nominated people. We believe there is significant value added to the codebase
33by this peer review and that moving away from mailing lists would be to the
34detriment of our code.
35
36We also need to acknowledge that many of our developers are used to this
37mailing list workflow and have worked with it for years, with tools and
38processes built around it. Changing away from this would result in a loss
39of key people from the project, which would again be to its detriment.
40
41The projects are acutely aware that potential new contributors find the
42mailing list approach off-putting and would prefer a web-based GUI.
43Since we don’t believe that can work for us, the project is aiming to ensure
44`patchwork <https://patchwork.yoctoproject.org/>`__ is available to help track
45patch status and also looking at how tooling can provide more feedback to users
46about patch status. We are looking at improving tools such as ``patchtest`` to
47test user contributions before they hit the mailing lists and also at better
48documenting how to use such workflows since we recognise that whilst this was
49common knowledge a decade ago, it might not be as familiar now.
50
51Preparing Changes for Submission
52================================
53
54Set up Git
55----------
56
57The first thing to do is to install Git packages. Here is an example
58on Debian and Ubuntu::
59
Patrick Williams705982a2024-01-12 09:51:57 -060060 sudo apt install git-core git-email
Andrew Geissler5082cc72023-09-11 08:41:39 -040061
62Then, you need to set a name and e-mail address that Git will
63use to identify your commits::
64
65 git config --global user.name "Ada Lovelace"
66 git config --global user.email "ada.lovelace@gmail.com"
67
68Clone the Git repository for the component to modify
69----------------------------------------------------
70
71After identifying the component to modify as described in the
72":doc:`../contributor-guide/identify-component`" section, clone the
73corresponding Git repository. Here is an example for OpenEmbedded-Core::
74
75 git clone https://git.openembedded.org/openembedded-core
76 cd openembedded-core
77
78Create a new branch
79-------------------
80
81Then, create a new branch in your local Git repository
82for your changes, starting from the reference branch in the upstream
83repository (often called ``master``)::
84
85 $ git checkout <ref-branch>
86 $ git checkout -b my-changes
87
88If you have completely unrelated sets of changes to submit, you should even
89create one branch for each set.
90
91Implement and commit changes
92----------------------------
93
94In each branch, you should group your changes into small, controlled and
95isolated ones. Keeping changes small and isolated aids review, makes
96merging/rebasing easier and keeps the change history clean should anyone need
97to refer to it in future.
98
99To this purpose, you should create *one Git commit per change*,
100corresponding to each of the patches you will eventually submit.
101See `further guidance <https://www.kernel.org/doc/html/latest/process/submitting-patches.html#separate-your-changes>`__
102in the Linux kernel documentation if needed.
103
104For example, when you intend to add multiple new recipes, each recipe
105should be added in a separate commit. For upgrades to existing recipes,
106the previous version should usually be deleted as part of the same commit
107to add the upgraded version.
108
109#. *Stage Your Changes:* Stage your changes by using the ``git add``
110 command on each file you modified. If you want to stage all the
111 files you modified, you can even use the ``git add -A`` command.
112
113#. *Commit Your Changes:* This is when you can create separate commits. For
114 each commit to create, use the ``git commit -s`` command with the files
115 or directories you want to include in the commit::
116
117 $ git commit -s file1 file2 dir1 dir2 ...
118
119 To include **a**\ ll staged files::
120
121 $ git commit -sa
122
123 - The ``-s`` option of ``git commit`` adds a "Signed-off-by:" line
124 to your commit message. There is the same requirement for contributing
125 to the Linux kernel. Adding such a line signifies that you, the
126 submitter, have agreed to the `Developer's Certificate of Origin 1.1
127 <https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin>`__
128 as follows:
129
130 .. code-block:: none
131
132 Developer's Certificate of Origin 1.1
133
134 By making a contribution to this project, I certify that:
135
136 (a) The contribution was created in whole or in part by me and I
137 have the right to submit it under the open source license
138 indicated in the file; or
139
140 (b) The contribution is based upon previous work that, to the best
141 of my knowledge, is covered under an appropriate open source
142 license and I have the right under that license to submit that
143 work with modifications, whether created in whole or in part
144 by me, under the same open source license (unless I am
145 permitted to submit under a different license), as indicated
146 in the file; or
147
148 (c) The contribution was provided directly to me by some other
149 person who certified (a), (b) or (c) and I have not modified
150 it.
151
152 (d) I understand and agree that this project and the contribution
153 are public and that a record of the contribution (including all
154 personal information I submit with it, including my sign-off) is
155 maintained indefinitely and may be redistributed consistent with
156 this project or the open source license(s) involved.
157
158 - Provide a single-line summary of the change and, if more
159 explanation is needed, provide more detail in the body of the
160 commit. This summary is typically viewable in the "shortlist" of
161 changes. Thus, providing something short and descriptive that
162 gives the reader a summary of the change is useful when viewing a
163 list of many commits. You should prefix this short description
164 with the recipe name (if changing a recipe), or else with the
165 short form path to the file being changed.
166
167 .. note::
168
169 To find a suitable prefix for the commit summary, a good idea
170 is to look for prefixes used in previous commits touching the
171 same files or directories::
172
173 git log --oneline <paths>
174
175 - For the body of the commit message, provide detailed information
176 that describes what you changed, why you made the change, and the
177 approach you used. It might also be helpful if you mention how you
178 tested the change. Provide as much detail as you can in the body
179 of the commit message.
180
181 .. note::
182
183 If the single line summary is enough to describe a simple
184 change, the body of the commit message can be left empty.
185
186 - If the change addresses a specific bug or issue that is associated
187 with a bug-tracking ID, include a reference to that ID in your
188 detailed description. For example, the Yocto Project uses a
189 specific convention for bug references --- any commit that addresses
190 a specific bug should use the following form for the detailed
191 description. Be sure to use the actual bug-tracking ID from
192 Bugzilla for bug-id::
193
194 Fixes [YOCTO #bug-id]
195
196 detailed description of change
197
198#. *Crediting contributors:* By using the ``git commit --amend`` command,
199 you can add some tags to the commit description to credit other contributors
200 to the change:
201
202 - ``Reported-by``: name and email of a person reporting a bug
203 that your commit is trying to fix. This is a good practice
204 to encourage people to go on reporting bugs and let them
205 know that their reports are taken into account.
206
207 - ``Suggested-by``: name and email of a person to credit for the
208 idea of making the change.
209
210 - ``Tested-by``, ``Reviewed-by``: name and email for people having
211 tested your changes or reviewed their code. These fields are
212 usually added by the maintainer accepting a patch, or by
213 yourself if you submitted your patches to early reviewers,
214 or are submitting an unmodified patch again as part of a
215 new iteration of your patch series.
216
217 - ``CC:`` Name and email of people you want to send a copy
218 of your changes to. This field will be used by ``git send-email``.
219
220 See `more guidance about using such tags
221 <https://www.kernel.org/doc/html/latest/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes>`__
222 in the Linux kernel documentation.
223
Patrick Williamsb58112e2024-03-07 11:16:36 -0600224Test your changes
225-----------------
226
227For each contributions you make, you should test your changes as well.
228For this the Yocto Project offers several types of tests. Those tests cover
229different areas and it depends on your changes which are feasible. For example run:
230
231 - For changes that affect the build environment:
232
233 - ``bitbake-selftest``: for changes within BitBake
234
235 - ``oe-selftest``: to test combinations of BitBake runs
236
237 - ``oe-build-perf-test``: to test the performance of common build scenarios
238
239 - For changes in a recipe:
240
241 - ``ptest``: run package specific tests, if they exist
242
243 - ``testimage``: build an image, boot it and run testcases on it
244
245 - If applicable, ensure also the ``native`` and ``nativesdk`` variants builds
246
247 - For changes relating to the SDK:
248
249 - ``testsdk``: to build, install and run tests against a SDK
250
251 - ``testsdk_ext``: to build, install and run tests against an extended SDK
252
253Note that this list just gives suggestions and is not exhaustive. More details can
254be found here: :ref:`test-manual/intro:Yocto Project Tests --- Types of Testing Overview`.
255
Andrew Geissler5082cc72023-09-11 08:41:39 -0400256Creating Patches
257================
258
259Here is the general procedure on how to create patches to be sent through email:
260
261#. *Describe the Changes in your Branch:* If you have more than one commit
262 in your branch, it's recommended to provide a cover letter describing
263 the series of patches you are about to send.
264
265 For this purpose, a good solution is to store the cover letter contents
266 in the branch itself::
267
268 git branch --edit-description
269
270 This will open a text editor to fill in the description for your
271 changes. This description can be updated when necessary and will
272 be used by Git to create the cover letter together with the patches.
273
274 It is recommended to start this description with a title line which
275 will serve a the subject line for the cover letter.
276
277#. *Generate Patches for your Branch:* The ``git format-patch`` command will
278 generate patch files for each of the commits in your branch. You need
279 to pass the reference branch your branch starts from.
280
281 If you branch didn't need a description in the previous step::
282
283 $ git format-patch <ref-branch>
284
285 If you filled a description for your branch, you will want to generate
286 a cover letter too::
287
288 $ git format-patch --cover-letter --cover-from-description=auto <ref-branch>
289
290 After the command is run, the current directory contains numbered
291 ``.patch`` files for the commits in your branch. If you have a cover
292 letter, it will be in the ``0000-cover-letter.patch``.
293
294 .. note::
295
296 The ``--cover-from-description=auto`` option makes ``git format-patch``
297 use the first paragraph of the branch description as the cover
298 letter title. Another possibility, which is easier to remember, is to pass
299 only the ``--cover-letter`` option, but you will have to edit the
300 subject line manually every time you generate the patches.
301
302 See the `git format-patch manual page <https://git-scm.com/docs/git-format-patch>`__
303 for details.
304
305#. *Review each of the Patch Files:* This final review of the patches
306 before sending them often allows to view your changes from a different
307 perspective and discover defects such as typos, spacing issues or lines
308 or even files that you didn't intend to modify. This review should
309 include the cover letter patch too.
310
311 If necessary, rework your commits as described in
312 ":ref:`contributor-guide/submit-changes:taking patch review into account`".
313
Patrick Williamsac13d5f2023-11-24 18:59:46 -0600314Validating Patches with Patchtest
315=================================
316
317``patchtest`` is available in ``openembedded-core`` as a tool for making
318sure that your patches are well-formatted and contain important info for
319maintenance purposes, such as ``Signed-off-by`` and ``Upstream-Status``
Patrick Williamsb58112e2024-03-07 11:16:36 -0600320tags. Note that no functional testing of the changes will be performed by ``patchtest``.
321Currently, it only supports testing patches for ``openembedded-core`` branches.
322To setup, perform the following::
Patrick Williamsac13d5f2023-11-24 18:59:46 -0600323
324 pip install -r meta/lib/patchtest/requirements.txt
325 source oe-init-build-env
326 bitbake-layers add-layer ../meta-selftest
327
328Once these steps are complete and you have generated your patch files,
329you can run ``patchtest`` like so::
330
331 patchtest --patch <patch_name>
332
333Alternatively, if you want ``patchtest`` to iterate over and test
334multiple patches stored in a directory, you can use::
335
336 patchtest --directory <directory_name>
337
338By default, ``patchtest`` uses its own modules' file paths to determine what
339repository and test suite to check patches against. If you wish to test
340patches against a repository other than ``openembedded-core`` and/or use
341a different set of tests, you can use the ``--repodir`` and ``--testdir``
342flags::
343
344 patchtest --patch <patch_name> --repodir <path/to/repo> --testdir <path/to/testdir>
345
346Finally, note that ``patchtest`` is designed to test patches in a standalone
347way, so if your patches are meant to apply on top of changes made by
348previous patches in a series, it is possible that ``patchtest`` will report
349false failures regarding the "merge on head" test.
350
351Using ``patchtest`` in this manner provides a final check for the overall
352quality of your changes before they are submitted for review by the
353maintainers.
354
Andrew Geissler5082cc72023-09-11 08:41:39 -0400355Sending the Patches via Email
356=============================
357
358Using Git to Send Patches
359-------------------------
360
361To submit patches through email, it is very important that you send them
362without any whitespace or HTML formatting that either you or your mailer
363introduces. The maintainer that receives your patches needs to be able
364to save and apply them directly from your emails, using the ``git am``
365command.
366
367Using the ``git send-email`` command is the only error-proof way of sending
368your patches using email since there is no risk of compromising whitespace
369in the body of the message, which can occur when you use your own mail
370client. It will also properly include your patches as *inline attachments*,
371which is not easy to do with standard e-mail clients without breaking lines.
372If you used your regular e-mail client and shared your patches as regular
373attachments, reviewers wouldn't be able to quote specific sections of your
374changes and make comments about them.
375
376Setting up Git to Send Email
377----------------------------
378
379The ``git send-email`` command can send email by using a local or remote
380Mail Transport Agent (MTA) such as ``msmtp``, ``sendmail``, or
381through a direct SMTP configuration in your Git ``~/.gitconfig`` file.
382
383Here are the settings for letting ``git send-email`` send e-mail through your
384regular STMP server, using a Google Mail account as an example::
385
386 git config --global sendemail.smtpserver smtp.gmail.com
387 git config --global sendemail.smtpserverport 587
388 git config --global sendemail.smtpencryption tls
389 git config --global sendemail.smtpuser ada.lovelace@gmail.com
390 git config --global sendemail.smtppass = XXXXXXXX
391
392These settings will appear in the ``.gitconfig`` file in your home directory.
393
394If you neither can use a local MTA nor SMTP, make sure you use an email client
395that does not touch the message (turning spaces in tabs, wrapping lines, etc.).
396A good mail client to do so is Pine (or Alpine) or Mutt. For more
397information about suitable clients, see `Email clients info for Linux
398<https://www.kernel.org/doc/html/latest/process/email-clients.html>`__
399in the Linux kernel sources.
400
401If you use such clients, just include the patch in the body of your email.
402
403Finding a Suitable Mailing List
404-------------------------------
405
406You should send patches to the appropriate mailing list so that they can be
407reviewed by the right contributors and merged by the appropriate maintainer.
408The specific mailing list you need to use depends on the location of the code
409you are changing.
410
411If people have concerns with any of the patches, they will usually voice
412their concern over the mailing list. If patches do not receive any negative
413reviews, the maintainer of the affected layer typically takes them, tests them,
414and then based on successful testing, merges them.
415
416In general, each component (e.g. layer) should have a ``README`` file
417that indicates where to send the changes and which process to follow.
418
419The "poky" repository, which is the Yocto Project's reference build
420environment, is a hybrid repository that contains several individual
421pieces (e.g. BitBake, Metadata, documentation, and so forth) built using
422the combo-layer tool. The upstream location used for submitting changes
423varies by component:
424
425- *Core Metadata:* Send your patches to the
426 :oe_lists:`openembedded-core </g/openembedded-core>`
427 mailing list. For example, a change to anything under the ``meta`` or
428 ``scripts`` directories should be sent to this mailing list.
429
430- *BitBake:* For changes to BitBake (i.e. anything under the
431 ``bitbake`` directory), send your patches to the
432 :oe_lists:`bitbake-devel </g/bitbake-devel>`
433 mailing list.
434
435- *"meta-\*" trees:* These trees contain Metadata. Use the
436 :yocto_lists:`poky </g/poky>` mailing list.
437
438- *Documentation*: For changes to the Yocto Project documentation, use the
439 :yocto_lists:`docs </g/docs>` mailing list.
440
441For changes to other layers and tools hosted in the Yocto Project source
442repositories (i.e. :yocto_git:`git.yoctoproject.org <>`), use the
443:yocto_lists:`yocto </g/yocto/>` general mailing list.
444
445For changes to other layers hosted in the OpenEmbedded source
446repositories (i.e. :oe_git:`git.openembedded.org <>`), use
447the :oe_lists:`openembedded-devel </g/openembedded-devel>`
448mailing list, unless specified otherwise in the layer's ``README`` file.
449
450If you intend to submit a new recipe that neither fits into the core Metadata,
451nor into :oe_git:`meta-openembedded </meta-openembedded/>`, you should
452look for a suitable layer in https://layers.openembedded.org. If similar
453recipes can be expected, you may consider :ref:`dev-manual/layers:creating your own layer`.
454
455If in doubt, please ask on the :yocto_lists:`yocto </g/yocto/>` general mailing list
456or on the :oe_lists:`openembedded-devel </g/openembedded-devel>` mailing list.
457
458Subscribing to the Mailing List
459-------------------------------
460
461After identifying the right mailing list to use, you will have to subscribe to
462it if you haven't done it yet.
463
464If you attempt to send patches to a list you haven't subscribed to, your email
465will be returned as undelivered.
466
467However, if you don't want to be receive all the messages sent to a mailing list,
468you can set your subscription to "no email". You will still be a subscriber able
469to send messages, but you won't receive any e-mail. If people reply to your message,
470their e-mail clients will default to including your email address in the
471conversation anyway.
472
473Anyway, you'll also be able to access the new messages on mailing list archives,
Patrick Williams73bd93f2024-02-20 08:07:48 -0600474either through a web browser, or for the lists archived on https://lore.kernel.org,
Andrew Geissler5082cc72023-09-11 08:41:39 -0400475through an individual newsgroup feed or a git repository.
476
477Sending Patches via Email
478-------------------------
479
480At this stage, you are ready to send your patches via email. Here's the
481typical usage of ``git send-email``::
482
483 git send-email --to <mailing-list-address> *.patch
484
485Then, review each subject line and list of recipients carefully, and then
486and then allow the command to send each message.
487
488You will see that ``git send-email`` will automatically copy the people listed
489in any commit tags such as ``Signed-off-by`` or ``Reported-by``.
490
491In case you are sending patches for :oe_git:`meta-openembedded </meta-openembedded/>`
492or any layer other than :oe_git:`openembedded-core </openembedded-core/>`,
493please add the appropriate prefix so that it is clear which layer the patch is intended
494to be applied to::
495
Patrick Williamsda295312023-12-05 16:48:56 -0600496 git format-patch --subject-prefix="meta-oe][PATCH" ...
Andrew Geissler5082cc72023-09-11 08:41:39 -0400497
498.. note::
499
500 It is actually possible to send patches without generating them
501 first. However, make sure you have reviewed your changes carefully
502 because ``git send-email`` will just show you the title lines of
503 each patch.
504
505 Here's a command you can use if you just have one patch in your
506 branch::
507
508 git send-email --to <mailing-list-address> -1
509
510 If you have multiple patches and a cover letter, you can send
511 patches for all the commits between the reference branch
512 and the tip of your branch::
513
514 git send-email --cover-letter --cover-from-description=auto --to <mailing-list-address> -M <ref-branch>
515
516See the `git send-email manual page <https://git-scm.com/docs/git-send-email>`__
517for details.
518
519Troubleshooting Email Issues
520----------------------------
521
522Fixing your From identity
523~~~~~~~~~~~~~~~~~~~~~~~~~
524
525We have a frequent issue with contributors whose patches are received through
526a ``From`` field which doesn't match the ``Signed-off-by`` information. Here is
527a typical example for people sending from a domain name with :wikipedia:`DMARC`::
528
529 From: "Linus Torvalds via lists.openembedded.org <linus.torvalds=kernel.org@lists.openembedded.org>"
530
531This ``From`` field is used by ``git am`` to recreate commits with the right
532author name. The following will ensure that your e-mails have an additional
533``From`` field at the beginning of the Email body, and therefore that
534maintainers accepting your patches don't have to fix commit author information
535manually::
536
537 git config --global sendemail.from "linus.torvalds@kernel.org"
538
539The ``sendemail.from`` should match your ``user.email`` setting,
540which appears in the ``Signed-off-by`` line of your commits.
541
542Streamlining git send-email usage
543---------------------------------
544
545If you want to save time and not be forced to remember the right options to use
546with ``git send-email``, you can use Git configuration settings.
547
548- To set the right mailing list address for a given repository::
549
550 git config --local sendemail.to openembedded-devel@lists.openembedded.org
551
552- If the mailing list requires a subject prefix for the layer
553 (this only works when the repository only contains one layer)::
554
555 git config --local format.subjectprefix "meta-something][PATCH"
556
557Using Scripts to Push a Change Upstream and Request a Pull
558==========================================================
559
560For larger patch series it is preferable to send a pull request which not
561only includes the patch but also a pointer to a branch that can be pulled
562from. This involves making a local branch for your changes, pushing this
563branch to an accessible repository and then using the ``create-pull-request``
564and ``send-pull-request`` scripts from openembedded-core to create and send a
565patch series with a link to the branch for review.
566
567Follow this procedure to push a change to an upstream "contrib" Git
568repository once the steps in
569":ref:`contributor-guide/submit-changes:preparing changes for submission`"
570have been followed:
571
572.. note::
573
574 You can find general Git information on how to push a change upstream
575 in the
576 `Git Community Book <https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows>`__.
577
578#. *Request Push Access to an "Upstream" Contrib Repository:* Send an email to
579 ``helpdesk@yoctoproject.org``:
580
581 - Attach your SSH public key which usually named ``id_rsa.pub.``.
582 If you don't have one generate it by running ``ssh-keygen -t rsa -b 4096 -C "your_email@example.com"``.
583
584 - List the repositories you're planning to contribute to.
585
586 - Include your preferred branch prefix for ``-contrib`` repositories.
587
588#. *Push Your Commits to the "Contrib" Upstream:* Push your
589 changes to that repository::
590
591 $ git push upstream_remote_repo local_branch_name
592
593 For example, suppose you have permissions to push
594 into the upstream ``meta-intel-contrib`` repository and you are
595 working in a local branch named `your_name`\ ``/README``. The following
596 command pushes your local commits to the ``meta-intel-contrib``
597 upstream repository and puts the commit in a branch named
598 `your_name`\ ``/README``::
599
600 $ git push meta-intel-contrib your_name/README
601
602#. *Determine Who to Notify:* Determine the maintainer or the mailing
603 list that you need to notify for the change.
604
605 Before submitting any change, you need to be sure who the maintainer
606 is or what mailing list that you need to notify. Use either these
607 methods to find out:
608
609 - *Maintenance File:* Examine the ``maintainers.inc`` file, which is
610 located in the :term:`Source Directory` at
611 ``meta/conf/distro/include``, to see who is responsible for code.
612
613 - *Search by File:* Using :ref:`overview-manual/development-environment:git`, you can
614 enter the following command to bring up a short list of all
615 commits against a specific file::
616
617 git shortlog -- filename
618
619 Just provide the name of the file for which you are interested. The
620 information returned is not ordered by history but does include a
621 list of everyone who has committed grouped by name. From the list,
622 you can see who is responsible for the bulk of the changes against
623 the file.
624
625 - *Find the Mailing List to Use:* See the
626 ":ref:`contributor-guide/submit-changes:finding a suitable mailing list`"
627 section above.
628
629#. *Make a Pull Request:* Notify the maintainer or the mailing list that
630 you have pushed a change by making a pull request.
631
632 The Yocto Project provides two scripts that conveniently let you
633 generate and send pull requests to the Yocto Project. These scripts
634 are ``create-pull-request`` and ``send-pull-request``. You can find
635 these scripts in the ``scripts`` directory within the
636 :term:`Source Directory` (e.g.
637 ``poky/scripts``).
638
639 Using these scripts correctly formats the requests without
640 introducing any whitespace or HTML formatting. The maintainer that
641 receives your patches either directly or through the mailing list
642 needs to be able to save and apply them directly from your emails.
643 Using these scripts is the preferred method for sending patches.
644
645 First, create the pull request. For example, the following command
646 runs the script, specifies the upstream repository in the contrib
647 directory into which you pushed the change, and provides a subject
648 line in the created patch files::
649
650 $ poky/scripts/create-pull-request -u meta-intel-contrib -s "Updated Manual Section Reference in README"
651
652 Running this script forms ``*.patch`` files in a folder named
653 ``pull-``\ `PID` in the current directory. One of the patch files is a
654 cover letter.
655
656 Before running the ``send-pull-request`` script, you must edit the
657 cover letter patch to insert information about your change. After
658 editing the cover letter, send the pull request. For example, the
659 following command runs the script and specifies the patch directory
660 and email address. In this example, the email address is a mailing
661 list::
662
663 $ poky/scripts/send-pull-request -p ~/meta-intel/pull-10565 -t meta-intel@lists.yoctoproject.org
664
665 You need to follow the prompts as the script is interactive.
666
667 .. note::
668
669 For help on using these scripts, simply provide the ``-h``
670 argument as follows::
671
672 $ poky/scripts/create-pull-request -h
673 $ poky/scripts/send-pull-request -h
674
675Submitting Changes to Stable Release Branches
676=============================================
677
678The process for proposing changes to a Yocto Project stable branch differs
679from the steps described above. Changes to a stable branch must address
680identified bugs or CVEs and should be made carefully in order to avoid the
681risk of introducing new bugs or breaking backwards compatibility. Typically
682bug fixes must already be accepted into the master branch before they can be
683backported to a stable branch unless the bug in question does not affect the
684master branch or the fix on the master branch is unsuitable for backporting.
685
686The list of stable branches along with the status and maintainer for each
687branch can be obtained from the
688:yocto_wiki:`Releases wiki page </Releases>`.
689
690.. note::
691
692 Changes will not typically be accepted for branches which are marked as
693 End-Of-Life (EOL).
694
695With this in mind, the steps to submit a change for a stable branch are as
696follows:
697
698#. *Identify the bug or CVE to be fixed:* This information should be
699 collected so that it can be included in your submission.
700
701 See :ref:`dev-manual/vulnerabilities:checking for vulnerabilities`
702 for details about CVE tracking.
703
704#. *Check if the fix is already present in the master branch:* This will
705 result in the most straightforward path into the stable branch for the
706 fix.
707
708 #. *If the fix is present in the master branch --- submit a backport request
709 by email:* You should send an email to the relevant stable branch
710 maintainer and the mailing list with details of the bug or CVE to be
711 fixed, the commit hash on the master branch that fixes the issue and
712 the stable branches which you would like this fix to be backported to.
713
714 #. *If the fix is not present in the master branch --- submit the fix to the
715 master branch first:* This will ensure that the fix passes through the
716 project's usual patch review and test processes before being accepted.
717 It will also ensure that bugs are not left unresolved in the master
718 branch itself. Once the fix is accepted in the master branch a backport
719 request can be submitted as above.
720
721 #. *If the fix is unsuitable for the master branch --- submit a patch
722 directly for the stable branch:* This method should be considered as a
723 last resort. It is typically necessary when the master branch is using
724 a newer version of the software which includes an upstream fix for the
725 issue or when the issue has been fixed on the master branch in a way
726 that introduces backwards incompatible changes. In this case follow the
727 steps in ":ref:`contributor-guide/submit-changes:preparing changes for submission`"
728 and in the following sections but modify the subject header of your patch
729 email to include the name of the stable branch which you are
730 targetting. This can be done using the ``--subject-prefix`` argument to
731 ``git format-patch``, for example to submit a patch to the
732 "&DISTRO_NAME_NO_CAP_MINUS_ONE;" branch use::
733
734 git format-patch --subject-prefix='&DISTRO_NAME_NO_CAP_MINUS_ONE;][PATCH' ...
735
736Taking Patch Review into Account
737================================
738
739You may get feedback on your submitted patches from other community members
740or from the automated patchtest service. If issues are identified in your
741patches then it is usually necessary to address these before the patches are
742accepted into the project. In this case you should your commits according
743to the feedback and submit an updated version to the relevant mailing list.
744
745In any case, never fix reported issues by fixing them in new commits
746on the tip of your branch. Always come up with a new series of commits
747without the reported issues.
748
749.. note::
750
751 It is a good idea to send a copy to the reviewers who provided feedback
752 to the previous version of the patch. You can make sure this happens
753 by adding a ``CC`` tag to the commit description::
754
755 CC: William Shakespeare <bill@yoctoproject.org>
756
757A single patch can be amended using ``git commit --amend``, and multiple
758patches can be easily reworked and reordered through an interactive Git rebase::
759
760 git rebase -i <ref-branch>
761
762See `this tutorial <https://hackernoon.com/beginners-guide-to-interactive-rebasing-346a3f9c3a6d>`__
763for practical guidance about using Git interactive rebasing.
764
765You should also modify the ``[PATCH]`` tag in the email subject line when
766sending the revised patch to mark the new iteration as ``[PATCH v2]``,
767``[PATCH v3]``, etc as appropriate. This can be done by passing the ``-v``
768argument to ``git format-patch`` with a version number::
769
770 git format-patch -v2 <ref-branch>
771
772Lastly please ensure that you also test your revised changes. In particular
773please don't just edit the patch file written out by ``git format-patch`` and
774resend it.
775
776Tracking the Status of Patches
777==============================
778
779The Yocto Project uses a `Patchwork instance <https://patchwork.yoctoproject.org/>`__
780to track the status of patches submitted to the various mailing lists and to
781support automated patch testing. Each submitted patch is checked for common
782mistakes and deviations from the expected patch format and submitters are
783notified by ``patchtest`` if such mistakes are found. This process helps to
784reduce the burden of patch review on maintainers.
785
786.. note::
787
788 This system is imperfect and changes can sometimes get lost in the flow.
789 Asking about the status of a patch or change is reasonable if the change
790 has been idle for a while with no feedback.
791
792If your patches have not had any feedback in a few days, they may have already
793been merged. You can run ``git pull`` branch to check this. Note that many if
794not most layer maintainers do not send out acknowledgement emails when they
795accept patches. Alternatively, if there is no response or merge after a few days
796the patch may have been missed or the appropriate reviewers may not currently be
797around. It is then perfectly fine to reply to it yourself with a reminder asking
798for feedback.
799
800.. note::
801
802 Patch reviews for feature and recipe upgrade patches are likely be delayed
803 during a feature freeze because these types of patches aren't merged during
804 at that time --- you may have to wait until after the freeze is lifted.
805
806Maintainers also commonly use ``-next`` branches to test submissions prior to
807merging patches. Thus, you can get an idea of the status of a patch based on
808whether the patch has been merged into one of these branches. The commonly
809used testing branches for OpenEmbedded-Core are as follows:
810
811- *openembedded-core "master-next" branch:* This branch is part of the
812 :oe_git:`openembedded-core </openembedded-core/>` repository and contains
813 proposed changes to the core metadata.
814
815- *poky "master-next" branch:* This branch is part of the
816 :yocto_git:`poky </poky/>` repository and combines proposed
817 changes to BitBake, the core metadata and the poky distro.
818
819Similarly, stable branches maintained by the project may have corresponding
820``-next`` branches which collect proposed changes. For example,
821``&DISTRO_NAME_NO_CAP;-next`` and ``&DISTRO_NAME_NO_CAP_MINUS_ONE;-next``
822branches in both the "openembdedded-core" and "poky" repositories.
823
824Other layers may have similar testing branches but there is no formal
825requirement or standard for these so please check the documentation for the
826layers you are contributing to.
827