submit-changes.rst 40 KB

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