summaryrefslogtreecommitdiffstats
path: root/documentation/contributor-guide/submit-changes.rst
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/contributor-guide/submit-changes.rst')
-rw-r--r--documentation/contributor-guide/submit-changes.rst505
1 files changed, 505 insertions, 0 deletions
diff --git a/documentation/contributor-guide/submit-changes.rst b/documentation/contributor-guide/submit-changes.rst
new file mode 100644
index 0000000000..3f6d2db96c
--- /dev/null
+++ b/documentation/contributor-guide/submit-changes.rst
@@ -0,0 +1,505 @@
1.. 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
51Finding a Suitable Mailing List
52===============================
53
54The Yocto Project and OpenEmbedded use a mailing list and a patch-based
55workflow that is similar to the Linux kernel but contains important
56differences. In general, there is a mailing list through which you can submit
57patches. You should send patches to the appropriate mailing list so that they
58can be reviewed and merged by the appropriate maintainer. The specific mailing
59list you need to use depends on the location of the code you are
60changing. Each component (e.g. layer) should have a ``README`` file that
61indicates where to send the changes and which process to follow.
62
63You can send the patches to the mailing list using whichever approach you
64feel comfortable with to generate the patches. Once sent, the patches are
65usually reviewed by the community at large. If somebody has concerns
66any of the the patches, they will usually voice their concern over the mailing
67list. If patches do not receive any negative reviews, the maintainer
68of the affected layer typically takes them, tests them, and then
69based on successful testing, merges them.
70
71The "poky" repository, which is the Yocto Project's reference build
72environment, is a hybrid repository that contains several individual
73pieces (e.g. BitBake, Metadata, documentation, and so forth) built using
74the combo-layer tool. The upstream location used for submitting changes
75varies by component:
76
77- *Core Metadata:* Send your patches to the
78 :oe_lists:`openembedded-core </g/openembedded-core>`
79 mailing list. For example, a change to anything under the ``meta`` or
80 ``scripts`` directories should be sent to this mailing list.
81
82- *BitBake:* For changes to BitBake (i.e. anything under the
83 ``bitbake`` directory), send your patches to the
84 :oe_lists:`bitbake-devel </g/bitbake-devel>`
85 mailing list.
86
87- *"meta-\*" trees:* These trees contain Metadata. Use the
88 :yocto_lists:`poky </g/poky>` mailing list.
89
90- *Documentation*: For changes to the Yocto Project documentation, use the
91 :yocto_lists:`docs </g/docs>` mailing list.
92
93For changes to other layers hosted in the Yocto Project source
94repositories (i.e. ``yoctoproject.org``) and tools use the
95:yocto_lists:`yocto </g/yocto/>` general mailing list.
96
97.. note::
98
99 Sometimes a layer's documentation specifies to use a particular
100 mailing list. If so, use that list.
101
102For additional recipes that do not fit into the core Metadata, you
103should determine which layer the recipe should go into and submit the
104changes in the manner recommended by the documentation (e.g. the
105``README`` file) supplied with the layer. If in doubt, please ask on the
106:yocto_lists:`yocto </g/yocto/>` general mailing list or on the
107:oe_lists:`openembedded-devel </g/openembedded-devel>` mailing list.
108
109You can also push changes upstream and request a maintainer to pull the
110changes into the component's upstream repository. You do this by pushing
111to a contribution repository that is upstream. See the
112":ref:`overview-manual/development-environment:git workflows and the yocto project`"
113section in the Yocto Project Overview and Concepts Manual for additional
114concepts on working in the Yocto Project development environment.
115
116Maintainers commonly use ``-next`` branches to test submissions prior to
117merging patches. Thus, you can get an idea of the status of a patch based on
118whether the patch has been merged into one of these branches. The commonly
119used testing branches for OpenEmbedded-Core are as follows:
120
121- *openembedded-core "master-next" branch:* This branch is part of the
122 :oe_git:`openembedded-core </openembedded-core/>` repository and contains
123 proposed changes to the core metadata.
124
125- *poky "master-next" branch:* This branch is part of the
126 :yocto_git:`poky </poky/>` repository and combines proposed
127 changes to BitBake, the core metadata and the poky distro.
128
129Similarly, stable branches maintained by the project may have corresponding
130``-next`` branches which collect proposed changes. For example,
131``&DISTRO_NAME_NO_CAP;-next`` and ``&DISTRO_NAME_NO_CAP_MINUS_ONE;-next``
132branches in both the "openembdedded-core" and "poky" repositories.
133
134Other layers may have similar testing branches but there is no formal
135requirement or standard for these so please check the documentation for the
136layers you are contributing to.
137
138The following sections provide procedures for submitting changes.
139
140Preparing Changes for Submission
141================================
142
143The first thing to do is to create a new branch in your local Git repository
144for your changes, starting from the reference branch in the upstream
145repository (often called ``master``)::
146
147 $ git checkout <ref-branch>
148 $ git checkout -b my-changes
149
150If you have completely unrelated sets of changes to submit, you should even
151create one branch for each set.
152
153Then, in each branch, you should group your changes into small, controlled and
154isolated ones. Keeping changes small and isolated aids review, makes
155merging/rebasing easier and keeps the change history clean should anyone need
156to refer to it in future.
157
158To this purpose, you should create *one Git commit per change*,
159corresponding to each of the patches you will eventually submit.
160So, for each identified change:
161
162#. *Stage Your Change:* Stage your change by using the ``git add``
163 command on each file you modified.
164
165#. *Commit Your Change:* Commit the change by using the ``git commit``
166 command. Make sure your commit information follows standards by
167 following these accepted conventions:
168
169 - Be sure to include a "Signed-off-by:" line in the same style as
170 required by the Linux kernel. This can be done by using the
171 ``git commit -s`` command. Adding this line signifies that you,
172 the submitter, have agreed to the `Developer's Certificate of Origin 1.1
173 <https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin>`__
174 as follows:
175
176 .. code-block:: none
177
178 Developer's Certificate of Origin 1.1
179
180 By making a contribution to this project, I certify that:
181
182 (a) The contribution was created in whole or in part by me and I
183 have the right to submit it under the open source license
184 indicated in the file; or
185
186 (b) The contribution is based upon previous work that, to the best
187 of my knowledge, is covered under an appropriate open source
188 license and I have the right under that license to submit that
189 work with modifications, whether created in whole or in part
190 by me, under the same open source license (unless I am
191 permitted to submit under a different license), as indicated
192 in the file; or
193
194 (c) The contribution was provided directly to me by some other
195 person who certified (a), (b) or (c) and I have not modified
196 it.
197
198 (d) I understand and agree that this project and the contribution
199 are public and that a record of the contribution (including all
200 personal information I submit with it, including my sign-off) is
201 maintained indefinitely and may be redistributed consistent with
202 this project or the open source license(s) involved.
203
204 - Provide a single-line summary of the change and, if more
205 explanation is needed, provide more detail in the body of the
206 commit. This summary is typically viewable in the "shortlist" of
207 changes. Thus, providing something short and descriptive that
208 gives the reader a summary of the change is useful when viewing a
209 list of many commits. You should prefix this short description
210 with the recipe name (if changing a recipe), or else with the
211 short form path to the file being changed.
212
213 .. note::
214
215 To find a suitable prefix for the commit summary, a good idea
216 is to look for prefixes used in previous commits touching the
217 same files or directories::
218
219 git log --oneline <paths>
220
221 - For the body of the commit message, provide detailed information
222 that describes what you changed, why you made the change, and the
223 approach you used. It might also be helpful if you mention how you
224 tested the change. Provide as much detail as you can in the body
225 of the commit message.
226
227 .. note::
228
229 You do not need to provide a more detailed explanation of a
230 change if the change is minor to the point of the single line
231 summary providing all the information.
232
233 - If the change addresses a specific bug or issue that is associated
234 with a bug-tracking ID, include a reference to that ID in your
235 detailed description. For example, the Yocto Project uses a
236 specific convention for bug references --- any commit that addresses
237 a specific bug should use the following form for the detailed
238 description. Be sure to use the actual bug-tracking ID from
239 Bugzilla for bug-id::
240
241 Fixes [YOCTO #bug-id]
242
243 detailed description of change
244
245Using Email to Submit Patches
246=============================
247
248Depending on the components changed, you need to submit the email to a
249specific mailing list. For some guidance on which mailing list to use,
250see the ":ref:`contributor-guide/submit-changes:finding a suitable mailing list`"
251section above.
252
253Here is the general procedure on how to create and submit patches through email:
254
255#. *Generate Patches for your Branch:* The ``git format-patch`` command for
256 generate patch files for each of the commits in your branch. You need
257 to pass the reference branch your branch starts from::
258
259 $ git format-patch <ref-branch>
260
261 After the command is run, the current directory contains numbered
262 ``.patch`` files for the commits in your branch.
263
264 If you have more than one patch, you should also use the ``--cover``
265 option with the command, which generates a cover letter as the first
266 "patch" in the series. You can then edit the cover letter to provide
267 a description for the series of patches. Run ``man git-format-patch``
268 for details about this command.
269
270#. *Send the patches via email:* Send the patches to the recipients and
271 relevant mailing lists by using the ``git send-email`` command.
272
273 .. note::
274
275 In order to use ``git send-email``, you must have the proper Git packages
276 installed on your host.
277 For Ubuntu, Debian, and Fedora the package is ``git-email``.
278
279 The ``git send-email`` command sends email by using a local or remote
280 Mail Transport Agent (MTA) such as ``msmtp``, ``sendmail``, or
281 through a direct ``smtp`` configuration in your Git ``~/.gitconfig``
282 file. If you are submitting patches through email only, it is very
283 important that you submit them without any whitespace or HTML
284 formatting that either you or your mailer introduces. The maintainer
285 that receives your patches needs to be able to save and apply them
286 directly from your emails. A good way to verify that what you are
287 sending will be applicable by the maintainer is to do a dry run and
288 send them to yourself and then save and apply them as the maintainer
289 would.
290
291 The ``git send-email`` command is the preferred method for sending
292 your patches using email since there is no risk of compromising
293 whitespace in the body of the message, which can occur when you use
294 your own mail client. The command also has several options that let
295 you specify recipients and perform further editing of the email
296 message. Here's a typical usage of this command::
297
298 git send-email --to <mailing-list-address> *.patch
299
300 Run ``man git-send-email`` for more details about this command.
301
302The Yocto Project uses a `Patchwork instance <https://patchwork.yoctoproject.org/>`__
303to track the status of patches submitted to the various mailing lists and to
304support automated patch testing. Each submitted patch is checked for common
305mistakes and deviations from the expected patch format and submitters are
306notified by ``patchtest`` if such mistakes are found. This process helps to
307reduce the burden of patch review on maintainers.
308
309.. note::
310
311 This system is imperfect and changes can sometimes get lost in the flow.
312 Asking about the status of a patch or change is reasonable if the change
313 has been idle for a while with no feedback.
314
315Using Scripts to Push a Change Upstream and Request a Pull
316==========================================================
317
318For larger patch series it is preferable to send a pull request which not
319only includes the patch but also a pointer to a branch that can be pulled
320from. This involves making a local branch for your changes, pushing this
321branch to an accessible repository and then using the ``create-pull-request``
322and ``send-pull-request`` scripts from openembedded-core to create and send a
323patch series with a link to the branch for review.
324
325Follow this procedure to push a change to an upstream "contrib" Git
326repository once the steps in
327":ref:`contributor-guide/submit-changes:preparing changes for submission`"
328have been followed:
329
330.. note::
331
332 You can find general Git information on how to push a change upstream
333 in the
334 `Git Community Book <https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows>`__.
335
336#. *Push Your Commits to a "Contrib" Upstream:* If you have arranged for
337 permissions to push to an upstream contrib repository, push the
338 change to that repository::
339
340 $ git push upstream_remote_repo local_branch_name
341
342 For example, suppose you have permissions to push
343 into the upstream ``meta-intel-contrib`` repository and you are
344 working in a local branch named `your_name`\ ``/README``. The following
345 command pushes your local commits to the ``meta-intel-contrib``
346 upstream repository and puts the commit in a branch named
347 `your_name`\ ``/README``::
348
349 $ git push meta-intel-contrib your_name/README
350
351#. *Determine Who to Notify:* Determine the maintainer or the mailing
352 list that you need to notify for the change.
353
354 Before submitting any change, you need to be sure who the maintainer
355 is or what mailing list that you need to notify. Use either these
356 methods to find out:
357
358 - *Maintenance File:* Examine the ``maintainers.inc`` file, which is
359 located in the :term:`Source Directory` at
360 ``meta/conf/distro/include``, to see who is responsible for code.
361
362 - *Search by File:* Using :ref:`overview-manual/development-environment:git`, you can
363 enter the following command to bring up a short list of all
364 commits against a specific file::
365
366 git shortlog -- filename
367
368 Just provide the name of the file for which you are interested. The
369 information returned is not ordered by history but does include a
370 list of everyone who has committed grouped by name. From the list,
371 you can see who is responsible for the bulk of the changes against
372 the file.
373
374 - *Find the Mailing List to Use:* See the
375 ":ref:`contributor-guide/submit-changes:finding a suitable mailing list`"
376 section above.
377
378#. *Make a Pull Request:* Notify the maintainer or the mailing list that
379 you have pushed a change by making a pull request.
380
381 The Yocto Project provides two scripts that conveniently let you
382 generate and send pull requests to the Yocto Project. These scripts
383 are ``create-pull-request`` and ``send-pull-request``. You can find
384 these scripts in the ``scripts`` directory within the
385 :term:`Source Directory` (e.g.
386 ``poky/scripts``).
387
388 Using these scripts correctly formats the requests without
389 introducing any whitespace or HTML formatting. The maintainer that
390 receives your patches either directly or through the mailing list
391 needs to be able to save and apply them directly from your emails.
392 Using these scripts is the preferred method for sending patches.
393
394 First, create the pull request. For example, the following command
395 runs the script, specifies the upstream repository in the contrib
396 directory into which you pushed the change, and provides a subject
397 line in the created patch files::
398
399 $ poky/scripts/create-pull-request -u meta-intel-contrib -s "Updated Manual Section Reference in README"
400
401 Running this script forms ``*.patch`` files in a folder named
402 ``pull-``\ `PID` in the current directory. One of the patch files is a
403 cover letter.
404
405 Before running the ``send-pull-request`` script, you must edit the
406 cover letter patch to insert information about your change. After
407 editing the cover letter, send the pull request. For example, the
408 following command runs the script and specifies the patch directory
409 and email address. In this example, the email address is a mailing
410 list::
411
412 $ poky/scripts/send-pull-request -p ~/meta-intel/pull-10565 -t meta-intel@lists.yoctoproject.org
413
414 You need to follow the prompts as the script is interactive.
415
416 .. note::
417
418 For help on using these scripts, simply provide the ``-h``
419 argument as follows::
420
421 $ poky/scripts/create-pull-request -h
422 $ poky/scripts/send-pull-request -h
423
424Responding to Patch Review
425==========================
426
427You may get feedback on your submitted patches from other community members
428or from the automated patchtest service. If issues are identified in your
429patch then it is usually necessary to address these before the patch will be
430accepted into the project. In this case you should amend the patch according
431to the feedback and submit an updated version to the relevant mailing list,
432copying in the reviewers who provided feedback to the previous version of the
433patch.
434
435The patch should be amended using ``git commit --amend`` or perhaps ``git
436rebase`` for more expert git users. You should also modify the ``[PATCH]``
437tag in the email subject line when sending the revised patch to mark the new
438iteration as ``[PATCH v2]``, ``[PATCH v3]``, etc as appropriate. This can be
439done by passing the ``-v`` argument to ``git format-patch`` with a version
440number.
441
442Lastly please ensure that you also test your revised changes. In particular
443please don't just edit the patch file written out by ``git format-patch`` and
444resend it.
445
446Submitting Changes to Stable Release Branches
447=============================================
448
449The process for proposing changes to a Yocto Project stable branch differs
450from the steps described above. Changes to a stable branch must address
451identified bugs or CVEs and should be made carefully in order to avoid the
452risk of introducing new bugs or breaking backwards compatibility. Typically
453bug fixes must already be accepted into the master branch before they can be
454backported to a stable branch unless the bug in question does not affect the
455master branch or the fix on the master branch is unsuitable for backporting.
456
457The list of stable branches along with the status and maintainer for each
458branch can be obtained from the
459:yocto_wiki:`Releases wiki page </Releases>`.
460
461.. note::
462
463 Changes will not typically be accepted for branches which are marked as
464 End-Of-Life (EOL).
465
466With this in mind, the steps to submit a change for a stable branch are as
467follows:
468
469#. *Identify the bug or CVE to be fixed:* This information should be
470 collected so that it can be included in your submission.
471
472 See :ref:`dev-manual/vulnerabilities:checking for vulnerabilities`
473 for details about CVE tracking.
474
475#. *Check if the fix is already present in the master branch:* This will
476 result in the most straightforward path into the stable branch for the
477 fix.
478
479 #. *If the fix is present in the master branch --- submit a backport request
480 by email:* You should send an email to the relevant stable branch
481 maintainer and the mailing list with details of the bug or CVE to be
482 fixed, the commit hash on the master branch that fixes the issue and
483 the stable branches which you would like this fix to be backported to.
484
485 #. *If the fix is not present in the master branch --- submit the fix to the
486 master branch first:* This will ensure that the fix passes through the
487 project's usual patch review and test processes before being accepted.
488 It will also ensure that bugs are not left unresolved in the master
489 branch itself. Once the fix is accepted in the master branch a backport
490 request can be submitted as above.
491
492 #. *If the fix is unsuitable for the master branch --- submit a patch
493 directly for the stable branch:* This method should be considered as a
494 last resort. It is typically necessary when the master branch is using
495 a newer version of the software which includes an upstream fix for the
496 issue or when the issue has been fixed on the master branch in a way
497 that introduces backwards incompatible changes. In this case follow the
498 steps in ":ref:`contributor-guide/submit-changes:preparing changes for submission`" and
499 ":ref:`contributor-guide/submit-changes:using email to submit patches`"
500 but modify the subject header of your patch
501 email to include the name of the stable branch which you are
502 targetting. This can be done using the ``--subject-prefix`` argument to
503 ``git format-patch``, for example to submit a patch to the dunfell
504 branch use
505 ``git format-patch --subject-prefix='&DISTRO_NAME_NO_CAP_MINUS_ONE;][PATCH' ...``.