submit-changes.rst 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  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 **a**\ ll 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 body 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 body of the commit message, 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 body
  139. of the commit message.
  140. .. note::
  141. If the single line summary is enough to describe a simple
  142. change, the body of the commit message 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 your
  145. detailed description. 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 detailed
  148. description. Be sure to use the actual bug-tracking ID from
  149. Bugzilla for bug-id::
  150. Fixes [YOCTO #bug-id]
  151. detailed description of change
  152. #. *Crediting contributors:* By using the ``git commit --amend`` command,
  153. you can add some tags to the commit description to credit other contributors
  154. 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. Test your changes
  173. -----------------
  174. For each contributions you make, you should test your changes as well.
  175. For this the Yocto Project offers several types of tests. Those tests cover
  176. different areas and it depends on your changes which are feasible. For example run:
  177. - For changes that affect the build environment:
  178. - ``bitbake-selftest``: for changes within BitBake
  179. - ``oe-selftest``: to test combinations of BitBake runs
  180. - ``oe-build-perf-test``: to test the performance of common build scenarios
  181. - For changes in a recipe:
  182. - ``ptest``: run package specific tests, if they exist
  183. - ``testimage``: build an image, boot it and run testcases on it
  184. - If applicable, ensure also the ``native`` and ``nativesdk`` variants builds
  185. - For changes relating to the SDK:
  186. - ``testsdk``: to build, install and run tests against a SDK
  187. - ``testsdk_ext``: to build, install and run tests against an extended SDK
  188. Note that this list just gives suggestions and is not exhaustive. More details can
  189. be found here: :ref:`test-manual/intro:Yocto Project Tests --- Types of Testing Overview`.
  190. Creating Patches
  191. ================
  192. Here is the general procedure on how to create patches to be sent through email:
  193. #. *Describe the Changes in your Branch:* If you have more than one commit
  194. in your branch, it's recommended to provide a cover letter describing
  195. the series of patches you are about to send.
  196. For this purpose, a good solution is to store the cover letter contents
  197. in the branch itself::
  198. git branch --edit-description
  199. This will open a text editor to fill in the description for your
  200. changes. This description can be updated when necessary and will
  201. be used by Git to create the cover letter together with the patches.
  202. It is recommended to start this description with a title line which
  203. will serve a the subject line for the cover letter.
  204. #. *Generate Patches for your Branch:* The ``git format-patch`` command will
  205. generate patch files for each of the commits in your branch. You need
  206. to pass the reference branch your branch starts from.
  207. If you branch didn't need a description in the previous step::
  208. $ git format-patch <ref-branch>
  209. If you filled a description for your branch, you will want to generate
  210. a cover letter too::
  211. $ git format-patch --cover-letter --cover-from-description=auto <ref-branch>
  212. After the command is run, the current directory contains numbered
  213. ``.patch`` files for the commits in your branch. If you have a cover
  214. letter, it will be in the ``0000-cover-letter.patch``.
  215. .. note::
  216. The ``--cover-from-description=auto`` option makes ``git format-patch``
  217. use the first paragraph of the branch description as the cover
  218. letter title. Another possibility, which is easier to remember, is to pass
  219. only the ``--cover-letter`` option, but you will have to edit the
  220. subject line manually every time you generate the patches.
  221. See the `git format-patch manual page <https://git-scm.com/docs/git-format-patch>`__
  222. for details.
  223. #. *Review each of the Patch Files:* This final review of the patches
  224. before sending them often allows to view your changes from a different
  225. perspective and discover defects such as typos, spacing issues or lines
  226. or even files that you didn't intend to modify. This review should
  227. include the cover letter patch too.
  228. If necessary, rework your commits as described in
  229. ":ref:`contributor-guide/submit-changes:taking patch review into account`".
  230. Validating Patches with Patchtest
  231. =================================
  232. ``patchtest`` is available in ``openembedded-core`` as a tool for making
  233. sure that your patches are well-formatted and contain important info for
  234. maintenance purposes, such as ``Signed-off-by`` and ``Upstream-Status``
  235. tags. Note that no functional testing of the changes will be performed by ``patchtest``.
  236. Currently, it only supports testing patches for ``openembedded-core`` branches.
  237. To setup, perform the following::
  238. pip install -r meta/lib/patchtest/requirements.txt
  239. source oe-init-build-env
  240. bitbake-layers add-layer ../meta-selftest
  241. Once these steps are complete and you have generated your patch files,
  242. you can run ``patchtest`` like so::
  243. patchtest --patch <patch_name>
  244. Alternatively, if you want ``patchtest`` to iterate over and test
  245. multiple patches stored in a directory, you can use::
  246. patchtest --directory <directory_name>
  247. By default, ``patchtest`` uses its own modules' file paths to determine what
  248. repository and test suite to check patches against. If you wish to test
  249. patches against a repository other than ``openembedded-core`` and/or use
  250. a different set of tests, you can use the ``--repodir`` and ``--testdir``
  251. flags::
  252. patchtest --patch <patch_name> --repodir <path/to/repo> --testdir <path/to/testdir>
  253. Finally, note that ``patchtest`` is designed to test patches in a standalone
  254. way, so if your patches are meant to apply on top of changes made by
  255. previous patches in a series, it is possible that ``patchtest`` will report
  256. false failures regarding the "merge on head" test.
  257. Using ``patchtest`` in this manner provides a final check for the overall
  258. quality of your changes before they are submitted for review by the
  259. maintainers.
  260. Sending the Patches via Email
  261. =============================
  262. Using Git to Send Patches
  263. -------------------------
  264. To submit patches through email, it is very important that you send them
  265. without any whitespace or HTML formatting that either you or your mailer
  266. introduces. The maintainer that receives your patches needs to be able
  267. to save and apply them directly from your emails, using the ``git am``
  268. command.
  269. Using the ``git send-email`` command is the only error-proof way of sending
  270. your patches using email since there is no risk of compromising whitespace
  271. in the body of the message, which can occur when you use your own mail
  272. client. It will also properly include your patches as *inline attachments*,
  273. which is not easy to do with standard e-mail clients without breaking lines.
  274. If you used your regular e-mail client and shared your patches as regular
  275. attachments, reviewers wouldn't be able to quote specific sections of your
  276. changes and make comments about them.
  277. Setting up Git to Send Email
  278. ----------------------------
  279. The ``git send-email`` command can send 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`` file.
  282. Here are the settings for letting ``git send-email`` send e-mail through your
  283. regular STMP server, using a Google Mail account as an example::
  284. git config --global sendemail.smtpserver smtp.gmail.com
  285. git config --global sendemail.smtpserverport 587
  286. git config --global sendemail.smtpencryption tls
  287. git config --global sendemail.smtpuser ada.lovelace@gmail.com
  288. git config --global sendemail.smtppass = XXXXXXXX
  289. These settings will appear in the ``.gitconfig`` file in your home directory.
  290. If you neither can use a local MTA nor SMTP, make sure you use an email client
  291. that does not touch the message (turning spaces in tabs, wrapping lines, etc.).
  292. A good mail client to do so is Pine (or Alpine) or Mutt. For more
  293. information about suitable clients, see `Email clients info for Linux
  294. <https://www.kernel.org/doc/html/latest/process/email-clients.html>`__
  295. in the Linux kernel sources.
  296. If you use such clients, just include the patch in the body of your email.
  297. Finding a Suitable Mailing List
  298. -------------------------------
  299. You should send patches to the appropriate mailing list so that they can be
  300. reviewed by the right contributors and merged by the appropriate maintainer.
  301. The specific mailing list you need to use depends on the location of the code
  302. you are changing.
  303. If people have concerns with any of the patches, they will usually voice
  304. their concern over the mailing list. If patches do not receive any negative
  305. reviews, the maintainer of the affected layer typically takes them, tests them,
  306. and then based on successful testing, merges them.
  307. In general, each component (e.g. layer) should have a ``README`` file
  308. that indicates where to send the changes and which process to follow.
  309. The "poky" repository, which is the Yocto Project's reference build
  310. environment, is a hybrid repository that contains several individual
  311. pieces (e.g. BitBake, Metadata, documentation, and so forth) built using
  312. the combo-layer tool. The upstream location used for submitting changes
  313. varies by component:
  314. - *Core Metadata:* Send your patches to the
  315. :oe_lists:`openembedded-core </g/openembedded-core>`
  316. mailing list. For example, a change to anything under the ``meta`` or
  317. ``scripts`` directories should be sent to this mailing list.
  318. - *BitBake:* For changes to BitBake (i.e. anything under the
  319. ``bitbake`` directory), send your patches to the
  320. :oe_lists:`bitbake-devel </g/bitbake-devel>`
  321. mailing list.
  322. - *meta-poky* and *meta-yocto-bsp* trees: These trees contain Metadata. Use the
  323. :yocto_lists:`poky </g/poky>` mailing list.
  324. - *Documentation*: For changes to the Yocto Project documentation, use the
  325. :yocto_lists:`docs </g/docs>` mailing list.
  326. For changes to other layers and tools hosted in the Yocto Project source
  327. repositories (i.e. :yocto_git:`git.yoctoproject.org <>`), use the
  328. :yocto_lists:`yocto-patches </g/yocto-patches/>` general mailing list.
  329. For changes to other layers hosted in the OpenEmbedded source
  330. repositories (i.e. :oe_git:`git.openembedded.org <>`), use
  331. the :oe_lists:`openembedded-devel </g/openembedded-devel>`
  332. mailing list, unless specified otherwise in the layer's ``README`` file.
  333. If you intend to submit a new recipe that neither fits into the core Metadata,
  334. nor into :oe_git:`meta-openembedded </meta-openembedded/>`, you should
  335. look for a suitable layer in https://layers.openembedded.org. If similar
  336. recipes can be expected, you may consider :ref:`dev-manual/layers:creating your own layer`.
  337. If in doubt, please ask on the :yocto_lists:`yocto </g/yocto/>` general mailing list
  338. or on the :oe_lists:`openembedded-devel </g/openembedded-devel>` mailing list.
  339. Subscribing to the Mailing List
  340. -------------------------------
  341. After identifying the right mailing list to use, you will have to subscribe to
  342. it if you haven't done it yet.
  343. If you attempt to send patches to a list you haven't subscribed to, your email
  344. will be returned as undelivered.
  345. However, if you don't want to be receive all the messages sent to a mailing list,
  346. you can set your subscription to "no email". You will still be a subscriber able
  347. to send messages, but you won't receive any e-mail. If people reply to your message,
  348. their e-mail clients will default to including your email address in the
  349. conversation anyway.
  350. Anyway, you'll also be able to access the new messages on mailing list archives,
  351. either through a web browser, or for the lists archived on https://lore.kernel.org,
  352. through an individual newsgroup feed or a git repository.
  353. Sending Patches via Email
  354. -------------------------
  355. At this stage, you are ready to send your patches via email. Here's the
  356. typical usage of ``git send-email``::
  357. git send-email --to <mailing-list-address> *.patch
  358. Then, review each subject line and list of recipients carefully, and then
  359. allow the command to send each message.
  360. You will see that ``git send-email`` will automatically copy the people listed
  361. in any commit tags such as ``Signed-off-by`` or ``Reported-by``.
  362. In case you are sending patches for :oe_git:`meta-openembedded </meta-openembedded/>`
  363. or any layer other than :oe_git:`openembedded-core </openembedded-core/>`,
  364. please add the appropriate prefix so that it is clear which layer the patch is intended
  365. to be applied to::
  366. git format-patch --subject-prefix="meta-oe][PATCH" ...
  367. .. note::
  368. It is actually possible to send patches without generating them
  369. first. However, make sure you have reviewed your changes carefully
  370. because ``git send-email`` will just show you the title lines of
  371. each patch.
  372. Here's a command you can use if you just have one patch in your
  373. branch::
  374. git send-email --to <mailing-list-address> -1
  375. If you have multiple patches and a cover letter, you can send
  376. patches for all the commits between the reference branch
  377. and the tip of your branch::
  378. git send-email --cover-letter --cover-from-description=auto --to <mailing-list-address> -M <ref-branch>
  379. See the `git send-email manual page <https://git-scm.com/docs/git-send-email>`__
  380. for details.
  381. Troubleshooting Email Issues
  382. ----------------------------
  383. Fixing your From identity
  384. ~~~~~~~~~~~~~~~~~~~~~~~~~
  385. We have a frequent issue with contributors whose patches are received through
  386. a ``From`` field which doesn't match the ``Signed-off-by`` information. Here is
  387. a typical example for people sending from a domain name with :wikipedia:`DMARC`::
  388. From: "Linus Torvalds via lists.openembedded.org <linus.torvalds=kernel.org@lists.openembedded.org>"
  389. This ``From`` field is used by ``git am`` to recreate commits with the right
  390. author name. The following will ensure that your e-mails have an additional
  391. ``From`` field at the beginning of the Email body, and therefore that
  392. maintainers accepting your patches don't have to fix commit author information
  393. manually::
  394. git config --global sendemail.from "linus.torvalds@kernel.org"
  395. The ``sendemail.from`` should match your ``user.email`` setting,
  396. which appears in the ``Signed-off-by`` line of your commits.
  397. Streamlining git send-email usage
  398. ---------------------------------
  399. If you want to save time and not be forced to remember the right options to use
  400. with ``git send-email``, you can use Git configuration settings.
  401. - To set the right mailing list address for a given repository::
  402. git config --local sendemail.to openembedded-devel@lists.openembedded.org
  403. - If the mailing list requires a subject prefix for the layer
  404. (this only works when the repository only contains one layer)::
  405. git config --local format.subjectprefix "meta-something][PATCH"
  406. Using Scripts to Push a Change Upstream and Request a Pull
  407. ==========================================================
  408. For larger patch series it is preferable to send a pull request which not
  409. only includes the patch but also a pointer to a branch that can be pulled
  410. from. This involves making a local branch for your changes, pushing this
  411. branch to an accessible repository and then using the ``create-pull-request``
  412. and ``send-pull-request`` scripts from openembedded-core to create and send a
  413. patch series with a link to the branch for review.
  414. Follow this procedure to push a change to an upstream "contrib" Git
  415. repository once the steps in
  416. ":ref:`contributor-guide/submit-changes:preparing changes for submission`"
  417. have been followed:
  418. .. note::
  419. You can find general Git information on how to push a change upstream
  420. in the
  421. `Git Community Book <https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows>`__.
  422. #. *Request Push Access to an "Upstream" Contrib Repository:* Send an email to
  423. ``helpdesk@yoctoproject.org``:
  424. - Attach your SSH public key which usually named ``id_rsa.pub.``.
  425. If you don't have one generate it by running ``ssh-keygen -t rsa -b 4096 -C "your_email@example.com"``.
  426. - List the repositories you're planning to contribute to.
  427. - Include your preferred branch prefix for ``-contrib`` repositories.
  428. #. *Push Your Commits to the "Contrib" Upstream:* Push your
  429. changes to that repository::
  430. $ git push upstream_remote_repo local_branch_name
  431. For example, suppose you have permissions to push
  432. into the upstream ``meta-intel-contrib`` repository and you are
  433. working in a local branch named `your_name`\ ``/README``. The following
  434. command pushes your local commits to the ``meta-intel-contrib``
  435. upstream repository and puts the commit in a branch named
  436. `your_name`\ ``/README``::
  437. $ git push meta-intel-contrib your_name/README
  438. #. *Determine Who to Notify:* Determine the maintainer or the mailing
  439. list that you need to notify for the change.
  440. Before submitting any change, you need to be sure who the maintainer
  441. is or what mailing list that you need to notify. Use either these
  442. methods to find out:
  443. - *Maintenance File:* Examine the ``maintainers.inc`` file, which is
  444. located in the :term:`Source Directory` at
  445. ``meta/conf/distro/include``, to see who is responsible for code.
  446. - *Search by File:* Using :ref:`overview-manual/development-environment:git`, you can
  447. enter the following command to bring up a short list of all
  448. commits against a specific file::
  449. git shortlog -- filename
  450. Just provide the name of the file for which you are interested. The
  451. information returned is not ordered by history but does include a
  452. list of everyone who has committed grouped by name. From the list,
  453. you can see who is responsible for the bulk of the changes against
  454. the file.
  455. - *Find the Mailing List to Use:* See the
  456. ":ref:`contributor-guide/submit-changes:finding a suitable mailing list`"
  457. section above.
  458. #. *Make a Pull Request:* Notify the maintainer or the mailing list that
  459. you have pushed a change by making a pull request.
  460. The Yocto Project provides two scripts that conveniently let you
  461. generate and send pull requests to the Yocto Project. These scripts
  462. are ``create-pull-request`` and ``send-pull-request``. You can find
  463. these scripts in the ``scripts`` directory within the
  464. :term:`Source Directory` (e.g.
  465. ``poky/scripts``).
  466. Using these scripts correctly formats the requests without
  467. introducing any whitespace or HTML formatting. The maintainer that
  468. receives your patches either directly or through the mailing list
  469. needs to be able to save and apply them directly from your emails.
  470. Using these scripts is the preferred method for sending patches.
  471. First, create the pull request. For example, the following command
  472. runs the script, specifies the upstream repository in the contrib
  473. directory into which you pushed the change, and provides a subject
  474. line in the created patch files::
  475. $ poky/scripts/create-pull-request -u meta-intel-contrib -s "Updated Manual Section Reference in README"
  476. Running this script forms ``*.patch`` files in a folder named
  477. ``pull-``\ `PID` in the current directory. One of the patch files is a
  478. cover letter.
  479. Before running the ``send-pull-request`` script, you must edit the
  480. cover letter patch to insert information about your change. After
  481. editing the cover letter, send the pull request. For example, the
  482. following command runs the script and specifies the patch directory
  483. and email address. In this example, the email address is a mailing
  484. list::
  485. $ poky/scripts/send-pull-request -p ~/meta-intel/pull-10565 -t meta-intel@lists.yoctoproject.org
  486. You need to follow the prompts as the script is interactive.
  487. .. note::
  488. For help on using these scripts, simply provide the ``-h``
  489. argument as follows::
  490. $ poky/scripts/create-pull-request -h
  491. $ poky/scripts/send-pull-request -h
  492. Submitting Changes to Stable Release Branches
  493. =============================================
  494. The process for proposing changes to a Yocto Project stable branch differs
  495. from the steps described above. Changes to a stable branch must address
  496. identified bugs or CVEs and should be made carefully in order to avoid the
  497. risk of introducing new bugs or breaking backwards compatibility. Typically
  498. bug fixes must already be accepted into the master branch before they can be
  499. backported to a stable branch unless the bug in question does not affect the
  500. master branch or the fix on the master branch is unsuitable for backporting.
  501. The list of stable branches along with the status and maintainer for each
  502. branch can be obtained from the
  503. :yocto_wiki:`Releases wiki page </Releases>`.
  504. .. note::
  505. Changes will not typically be accepted for branches which are marked as
  506. End-Of-Life (EOL).
  507. With this in mind, the steps to submit a change for a stable branch are as
  508. follows:
  509. #. *Identify the bug or CVE to be fixed:* This information should be
  510. collected so that it can be included in your submission.
  511. See :ref:`dev-manual/vulnerabilities:checking for vulnerabilities`
  512. for details about CVE tracking.
  513. #. *Check if the fix is already present in the master branch:* This will
  514. result in the most straightforward path into the stable branch for the
  515. fix.
  516. #. *If the fix is present in the master branch --- submit a backport request
  517. by email:* You should send an email to the relevant stable branch
  518. maintainer and the mailing list with details of the bug or CVE to be
  519. fixed, the commit hash on the master branch that fixes the issue and
  520. the stable branches which you would like this fix to be backported to.
  521. #. *If the fix is not present in the master branch --- submit the fix to the
  522. master branch first:* This will ensure that the fix passes through the
  523. project's usual patch review and test processes before being accepted.
  524. It will also ensure that bugs are not left unresolved in the master
  525. branch itself. Once the fix is accepted in the master branch a backport
  526. request can be submitted as above.
  527. #. *If the fix is unsuitable for the master branch --- submit a patch
  528. directly for the stable branch:* This method should be considered as a
  529. last resort. It is typically necessary when the master branch is using
  530. a newer version of the software which includes an upstream fix for the
  531. issue or when the issue has been fixed on the master branch in a way
  532. that introduces backwards incompatible changes. In this case follow the
  533. steps in ":ref:`contributor-guide/submit-changes:preparing changes for submission`"
  534. and in the following sections but modify the subject header of your patch
  535. email to include the name of the stable branch which you are
  536. targetting. This can be done using the ``--subject-prefix`` argument to
  537. ``git format-patch``, for example to submit a patch to the
  538. "&DISTRO_NAME_NO_CAP_MINUS_ONE;" branch use::
  539. git format-patch --subject-prefix='&DISTRO_NAME_NO_CAP_MINUS_ONE;][PATCH' ...
  540. Taking Patch Review into Account
  541. ================================
  542. You may get feedback on your submitted patches from other community members
  543. or from the automated patchtest service. If issues are identified in your
  544. patches then it is usually necessary to address these before the patches are
  545. accepted into the project. In this case you should your commits according
  546. to the feedback and submit an updated version to the relevant mailing list.
  547. In any case, never fix reported issues by fixing them in new commits
  548. on the tip of your branch. Always come up with a new series of commits
  549. without the reported issues.
  550. .. note::
  551. It is a good idea to send a copy to the reviewers who provided feedback
  552. to the previous version of the patch. You can make sure this happens
  553. by adding a ``CC`` tag to the commit description::
  554. CC: William Shakespeare <bill@yoctoproject.org>
  555. A single patch can be amended using ``git commit --amend``, and multiple
  556. patches can be easily reworked and reordered through an interactive Git rebase::
  557. git rebase -i <ref-branch>
  558. See `this tutorial <https://hackernoon.com/beginners-guide-to-interactive-rebasing-346a3f9c3a6d>`__
  559. for practical guidance about using Git interactive rebasing.
  560. You should also modify the ``[PATCH]`` tag in the email subject line when
  561. sending the revised patch to mark the new iteration as ``[PATCH v2]``,
  562. ``[PATCH v3]``, etc as appropriate. This can be done by passing the ``-v``
  563. argument to ``git format-patch`` with a version number::
  564. git format-patch -v2 <ref-branch>
  565. After generating updated patches (v2, v3, and so on) via ``git
  566. format-patch``, ideally developers will add a patch version changelog
  567. to each patch that describes what has changed between each revision of
  568. the patch. Add patch version changelogs after the ``---`` marker in the
  569. patch, indicating that this information is part of this patch, but is not
  570. suitable for inclusion in the commit message (i.e. the git history) itself.
  571. Providing a patch version changelog makes it easier for maintainers and
  572. reviewers to succinctly understand what changed in all versions of the
  573. patch, without having to consult alternate sources of information, such as
  574. searching through messages on a mailing list. For example::
  575. <patch title>
  576. <commit message>
  577. <Signed-off-by/other trailers>
  578. ---
  579. changes in v4:
  580. - provide a clearer commit message
  581. - fix spelling mistakes
  582. changes in v3:
  583. - replace func() to use other_func() instead
  584. changes in v2:
  585. - this patch was added in v2
  586. ---
  587. <diffstat output>
  588. <unified diff>
  589. Lastly please ensure that you also test your revised changes. In particular
  590. please don't just edit the patch file written out by ``git format-patch`` and
  591. resend it.
  592. Tracking the Status of Patches
  593. ==============================
  594. The Yocto Project uses a `Patchwork instance <https://patchwork.yoctoproject.org/>`__
  595. to track the status of patches submitted to the various mailing lists and to
  596. support automated patch testing. Each submitted patch is checked for common
  597. mistakes and deviations from the expected patch format and submitters are
  598. notified by ``patchtest`` if such mistakes are found. This process helps to
  599. reduce the burden of patch review on maintainers.
  600. .. note::
  601. This system is imperfect and changes can sometimes get lost in the flow.
  602. Asking about the status of a patch or change is reasonable if the change
  603. has been idle for a while with no feedback.
  604. If your patches have not had any feedback in a few days, they may have already
  605. been merged. You can run ``git pull`` branch to check this. Note that many if
  606. not most layer maintainers do not send out acknowledgement emails when they
  607. accept patches. Alternatively, if there is no response or merge after a few days
  608. the patch may have been missed or the appropriate reviewers may not currently be
  609. around. It is then perfectly fine to reply to it yourself with a reminder asking
  610. for feedback.
  611. .. note::
  612. Patch reviews for feature and recipe upgrade patches are likely be delayed
  613. during a feature freeze because these types of patches aren't merged during
  614. at that time --- you may have to wait until after the freeze is lifted.
  615. Maintainers also commonly use ``-next`` branches to test submissions prior to
  616. merging patches. Thus, you can get an idea of the status of a patch based on
  617. whether the patch has been merged into one of these branches. The commonly
  618. used testing branches for OpenEmbedded-Core are as follows:
  619. - *openembedded-core "master-next" branch:* This branch is part of the
  620. :oe_git:`openembedded-core </openembedded-core/>` repository and contains
  621. proposed changes to the core metadata.
  622. - *poky "master-next" branch:* This branch is part of the
  623. :yocto_git:`poky </poky/>` repository and combines proposed
  624. changes to BitBake, the core metadata and the poky distro.
  625. Similarly, stable branches maintained by the project may have corresponding
  626. ``-next`` branches which collect proposed changes. For example,
  627. ``&DISTRO_NAME_NO_CAP;-next`` and ``&DISTRO_NAME_NO_CAP_MINUS_ONE;-next``
  628. branches in both the "openembdedded-core" and "poky" repositories.
  629. Other layers may have similar testing branches but there is no formal
  630. requirement or standard for these so please check the documentation for the
  631. layers you are contributing to.
  632. Acceptance of AI Generated Code
  633. ===============================
  634. The Yocto Project and OpenEmbedded follow the guidance of the Linux Foundation
  635. in regards to the use of generative AI tools. See:
  636. https://www.linuxfoundation.org/legal/generative-ai.
  637. All of the existing guidelines in this document are expected to be followed,
  638. including in the :doc:`recipe-style-guide`, and contributing the changes with
  639. additional requirements to the items in section
  640. :ref:`contributor-guide/submit-changes:Implement and commit changes`.
  641. All AI Generated Code must be labeled as such in the commit message,
  642. prior to your ``Signed-off-by`` line. It is also strongly recommended,
  643. that any patches or code within the commit also have a comment or other
  644. indication that this code was AI generated.
  645. For example, here is a properly formatted commit message::
  646. component: Add the ability to ...
  647. AI-Generated: Uses GitHub Copilot
  648. Signed-off-by: Your Name <your.name@domain>
  649. The ``Signed-off-by`` line must be written by you, and not the AI helper.
  650. As a reminder, when contributing a change, your ``Signed-off-by`` line is
  651. required and the stipulations in the `Developer's Statement of Origin
  652. 1.1 <https://developercertificate.org/>`__ still apply.
  653. Additionally, you must stipulate AI contributions conform to the Linux
  654. Foundation policy, specifically:
  655. #. Contributors should ensure that the terms and conditions of the generative AI
  656. tool do not place any contractual restrictions on how the tool's output can
  657. be used that are inconsistent with the project's open source software
  658. license, the project's intellectual property policies, or the Open Source
  659. Definition.
  660. #. If any pre-existing copyrighted materials (including pre-existing open
  661. source code) authored or owned by third parties are included in the AI tool's
  662. output, prior to contributing such output to the project, the Contributor
  663. should confirm that they have permission from the third party
  664. owners -- such as the form of an open source license or public domain
  665. declaration that complies with the project's licensing policies -- to use and
  666. modify such pre-existing materials and contribute them to the project.
  667. Additionally, the contributor should provide notice and attribution of such
  668. third party rights, along with information about the applicable license
  669. terms, with their contribution.