How to submit a patch to OpenEmbedded: Difference between revisions

From Openembedded.org
Jump to navigation Jump to search
(→‎A task-oriented guide to creating a patch: Further clarification of e-mail configuration instructions)
(Moved to YP docs)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
OpenEmbedded welcomes contributions. Before submitting a patch however there are a few things to keep in mind.
This page has moved to the [https://docs.yoctoproject.org/dev/contributor-guide/submit-changes.html Yocto Documentation Contributors Guide]
 
== Finding the right place for your patch ==
 
OpenEmbedded is now split up into separate layers: OpenEmbedded-Core (OE-Core) which is a small set of core recipes, and other layers for recipes beyond that. For most layers, patches are sent to a mailing list for review before being merged. For further information specific to the layer you're working on, please see the README file in the layer.
 
New recipes in particular should be added to the appropriate layer. See the [http://layers.openembedded.org layer index] for the list of public layers. If your new recipe doesn't seem to fit anywhere it can be added to the meta-oe layer in the meta-openembedded repository, although if it is likely to be followed by numbers of similar recipes then you may wish to consider [[Creating a new Layer|creating a new layer]].
 
== A task-oriented guide to creating a patch ==
 
Let's say you have made a fix to a recipe, you've tested that it works and you'd like to submit it for merging.
 
=== Set up git ===
 
Properly configuring git (using ada.lovelace@gmail.com as an example user)
 
On Debian / Ubuntu (Note: Fedora uses `yum` OpenSuse uses zypper or yast)
 
sudo aptitude install git-core git-email
 
These are important to the commit meta-data
 
git config --global user.name "Ada Lovelace"
git config --global user.email "ada.lovelace@gmail.com"
 
=== Subscribe to the mailing list ===
 
You must subscribe to the appropriate mailing-list in order to be able to send your patch(es) to mailing lists. <u>If you attempt to send a patch to a list where you are not a member then the patch will be returned as undeliverable</u>.
 
* For patches against '''OE-Core''' the mailing list is '''openembedded-core@lists.openembedded.org'''.
* For patches against '''meta-oe''' (and many others) the list is '''openembedded-devel@lists.openembedded.org'''.
 
See [[Mailing lists]] for subscription and further details.
 
=== Committing your patch ===
 
Commit with a concise and descriptive message - one that explains your changes in a way others get a short overview without looking at the code.
 
cd oe-core/ # or whereever you keep your clone of the repo
git add meta/recipes-devtools/flex
git commit -s # don't use the -m option but include my signature
 
    flex: backport Debian patches to fix generated code warnings
   
    The generated parser had warnings regarding signess and return check
    which makes Linux Kernel's perf tool from 3.4 release to fail without
    those patches.
 
All commit messages must include Signed-off-by (-s option to commit as above). For more guidelines on messages please see [[Commit Patch Message Guidelines]].
 
Note that when adding multiple new recipes, each recipe should be added in a separate commit. For upgrades of existing recipes, the previous version should usually be deleted as part of the same commit to add the upgraded version.
 
=== Sending patches ===
 
There are two possible methods for submitting patches. Either one is acceptable; for a series containing a number of patches the pull request method is preferred although not mandatory.
 
==== Fixing your From identity ====
 
If you choose the first method: submitting your patches via e-mail.
 
We have a frequent issue with contributors whose patches are received through a <code>From</code> field which doesn't match the <code>Signed-off-by</code> information. Here is a typical example for people sending from a domain name with [https://begriffs.com/posts/2018-09-18-dmarc-mailing-list.html DMARC]:
 
From: "Linus Torvalds via lists.openembedded.org <linus.torvalds=kernel.org@lists.openembedded.org>"
 
This field <code>From</code> field is used by <code>git am</code> to recreate commits with the right author name.
The following will ensure that your e-mails have a correct <code>From</code> field, and that maintainers accepting your patches don't have to fix commit author information manually:
 
git config --global sendemail.from "linus.torvalds@kernel.org"
 
==== Configuring git send-email ====
 
You need to let git send-email know how to send e-mail from your domain, that is, how to connect to your SMTP server.
 
For example, here are settings for sending your e-mails through Google Mail's SMTP server:
 
git config --global sendemail.smtpserver smtp.gmail.com
git config --global sendemail.smtpserverport 587
git config --global sendemail.smtpencryption tls
git config --global sendemail.smtpuser ada.lovelace@gmail.com
git config --global sendemail.smtppass = XXXXXXXX
 
Of course, the above should match the e-mail address you used to subscribe to the mailing list.
 
==== Sending using git-send-email ====
 
To send just the top commit on your current branch (substitute mailing list address as appropriate):
 
git send-email --to=openembedded-core@lists.openembedded.org --confirm=always -M -1
 
For multiple commits you can substitute -1 above with -N (where N is the number of commits) or instead specify a revision before which to start e.g. HEAD~3, master etc.
 
Note: in either case if you are submitting a patch for meta-oe or any layer other than OE-Core, please add the appropriate prefix so that it is clear which layer the patch is intended to be applied to:
--subject-prefix="meta-oe][PATCH"
 
Please substitute "PATCH" with "PATCH v2" if you are submitting a revised version after addressing feedback (or v3, v4 etc.)
 
==== Sending via a pull request ====
 
Alternatively, for larger patch series it is preferable to send a pull request which not only includes the patch but also a pointer to a branch that can be pulled from. This involves making a local branch for your changes, pushing this branch to an accessible repository and then using the <code>create-pull-request</code> and <code>send-pull-request</code> scripts (supplied with OE-Core) to create and send a patch series with a link to the branch for review. Step-by-step instructions:
 
# Find a repository to push your changes to, and add this as a remote to your git working tree. If you're going to be submitting a lot of changes, some of the repositories have a corresponding <code>-contrib</code> repository which you can use for this purpose - access to these for OE-related work is open to anyone who requests it. Otherwise github or some other public git hosting service can suffice.
# Create a branch for your changes if you haven't already. Other than backports from master or fixing bugs that only occur in an older branch, this should be on top of the master branch.
# Push the branch to the remote.
# Run <code>scripts/create-pull-request -u remote-name</code> (where <code>remote-name</code> is the name of the remote where you'll be pushing the branch). For meta-oe and other layers where a single mailing list covers more than one layer you'll need to add <code>-p "layername][PATCH"</code> replacing layername with the name of the layer so that it is clear which layer the patches are intended for.
# The script will report that it has created a <code>pull-XXXXX</code> directory has been created. Edit the <code>pull-XXXXX/0000-cover-letter.patch</code> with your favourite text editor and change the title and top of the body as appropriate.
# Run <code>scripts/send-pull-request -p pull-XXXXX -t openembedded-core@lists.openembedded.org</code> (replacing openembedded-core@lists.openembedded.org with the appropriate mailing list address for layers other than OE-Core). Where there is a clear maintainer for the area you're changing it may also help to add <code>-C maintainer@example.com</code>.
 
===== Request OE contrib Write Access =====
 
Please send an email to [mailto:mhalstead@linuxfoundation.org Michael Halstead] and:
# Attach your ssh '''public''' key which usually named id_rsa.pub. If you don't have one generate it by running <tt>ssh-keygen -t rsa -b 4096 -C "your_email@example.com"</tt>.
# List the repositories you're planning to contribute to.
# Include your preferred branch prefix for *-contrib repositories.
 
=== Backporting fixes to stable releases ===
 
When a bug is present on a stable branch of OE yet has been fixed in master one can request that the stable branch's maintainer accept the fix into the stable branch.
The best way to do this is generate a patch with the backport and submit it to the openembedded-core@lists.openembedded.org mailing list (CC'ing the maintainer may help the patch be reviewed for inclusion more quickly).
 
Patches for stable branches should be prefixed with the branch name (which is the same as the release series name), for example morty, pyro, etc.
Once you've identified the commit hash of the patch you'd like to see accepted as a backport you can generate the patch with:
 
git format-patch <COMMIT_HASH> -1 --subject-prefix="<BRANCH_NAME>][PATCH"
 
The generated patch can then be sent using the procedure described above.
 
== Community review ==
 
Your patch will be sent to the mailing list and for some layers should be immediately visible on https://patchwork.yoctoproject.org/
 
If you get feedback in reply to your patch, you should make changes according to the feedback and submit the next version. Please remember to use <code>--subject-prefix="PATCH v2"</code>, v3, v4 etc. to mark the patch iteration. Please also '''test your revised changes''' - in particular don't just edit the patch file written out by git-format-patch and resend it.
 
If your patch has not had any feedback after a few days it may have been missed or the appropriate reviewers may not currently be around; it is perfectly fine to reply to it yourself with a "ping" / reminder request for feedback. NOTE: patch review for feature / recipe upgrade patches will likely be delayed during a feature freeze because these types of patches aren't merged during this time - you may have to wait until after the freeze is lifted.
 
== Appendix ==
 
=== Steps for people which don't have SMTP access for git ===
 
Patches should not be sent as attachment but inline.
 
If you do not have SMTP access to your email account you have two options:
 
1. Use a different account (e.g. gmail). you can make one especially for this. Note that the account may differ from the one in signed-off (although that is inconvenient)
 
2. Just include the patch in the body of your email. Make sure you use an email client that does not touch the message (turn spaces in tabs,
wrap lines etc etc).
 
A good mail client to do so is '''pine''' (or '''alpine''') or '''mutt'''. For more information refer to [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/email-clients.txt  Documentation/email-clients.txt] in linux kernel sources.
 
=== Streamlining git-send-email with configuration ===
 
Don't want to have to remember to specify the right options when using git-send-email (or the pull request script)? You can actually set these in git's configuration and save yourself a lot of hassle.
 
<ul>
  <li>Always confirm sending (for all repositories):
    <pre>git config --global sendemail.confirm always</pre></li>
  <li>Set send-to email address for the repository (don't forget to specify the right address!):
    <pre>git config --local sendemail.to openembedded-devel@lists.openembedded.org</pre>
  </li>
  <li>If the mailing list requires a subject prefix for the layer (only works when the repository only contains one layer; set layer name as appropriate):
    <pre>git config --local format.subjectprefix "meta-something][PATCH"</pre>
  </li>
</ul>
 
==See also==
* [[Commit Patch Message Guidelines]]
* [[Styleguide]]
 
[[Category:FAQ]]
[[Category:User]]

Latest revision as of 15:31, 30 August 2023

This page has moved to the Yocto Documentation Contributors Guide