{"code":200,"data":{"id":"ao5abk14my","slug":"sending-a-kernel-patch-with-b4-part-1","appearance":"norm","language":"en","rtl":false,"created":"2022-12-21T22:13:04Z","updated":"2022-12-22T17:30:29Z","title":"Sending a kernel patch with b4 (part 1)","body":"While b4 started out as a way for maintainers to retrieve patches from mailing lists, it also has contributor-oriented features. Starting with version 0.10 b4 can:\n\n* create and manage patch series and cover letters\n* track and auto-reroll series revisions\n* display range-diffs between revisions\n* apply trailers received from reviewers and maintainers\n* submit patches without needing a valid SMTP gateway\n\nThese features are still considered experimental, but they should be stable for most work and I'd be happy to receive further feedback from occasional contributors.\n\nIn this article, we'll go through the process of submitting an actual typo fix patch to the upstream kernel. This bug was identified a few years ago and submitted via bugzilla, but never fixed:\n\n* https://bugzilla.kernel.org/show_bug.cgi?id=205891\n\n## Accompanying video\n\nThis article has an accompanying video where I go through all the steps and submit the actual patch at the end:\n\n* https://www.youtube.com/watch?v=QBR06ml2YLQ\n\n## Installing the latest b4 version\n\nStart by installing b4. The easiest is to do it via pip, as this would grab the latest stable version:\n```\n$ pip install --user b4\n[...]\n$ b4 --version\n0.11.1\n```\nIf you get an error or an older version of b4, please check that your ``$PATH`` contains ``$HOME/.local/bin`` where pip installs the binaries.\n\n## Preparing the tree\n\n* ``b4 prep -n [name-of-branch] -f [nearest-tag]``\n\nNext, prepare a topical branch where you will be doing your work. We'll be fixing a typo in ``arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts``, and we'll base this work on tag ``v6.1``:\n```\n$ b4 prep -n lanyang-dts-typo -f v6.1\nCreated new branch b4/lanyang-dts-typo\nCreated the default cover letter, you can edit with --edit-cover.\n```\nThis is just a regular branch prepended with \"b4/\":\n```\n$ git branch\n* b4/lanyang-dts-typo\n  master\n```\nYou can do all the normal operations with it, and the only special thing about it is that it has an \"empty commit\" at the start of the series containing the template of our cover letter.\n\n## Editing the cover letter\n\n* ``b4 prep --edit-cover``\n\nIf you plan to submit a single patch, then the cover letter is not that necessary and will only be used to track the destination addresses and changelog entries. You can delete most of the template content and leave just the title and sign-off. The tracking information json will always be appended to the end automatically -- you don't need to worry about it.\n\nHere's what the commit looks like after I edited it:\n```\n$ git cat-file -p HEAD\ntree c7c1b7db9ced3eba518cfc1f711e9d89f73f8667\nparent 830b3c68c1fb1e9176028d02ef86f3cf76aa2476\nauthor Konstantin Ryabitsev \u003cicon@mricon.com\u003e 1671656701 -0500\ncommitter Konstantin Ryabitsev \u003cicon@mricon.com\u003e 1671656701 -0500\n\nSimple typo fix for the lanyang dts\n\nSigned-off-by: Konstantin Ryabitsev \u003cicon@mricon.com\u003e\n\n--- b4-submit-tracking ---\n# This section is used internally by b4 prep for tracking purposes.\n{\n  \"series\": {\n    \"revision\": 1,\n    \"change-id\": \"20221221-lanyang-dts-typo-8509e8ffccd4\",\n    \"base-branch\": \"master\",\n    \"prefixes\": []\n  }\n}\n```\n## Committing your work\n\nYou can add commits to this branch as you normally would with any other git work. I am going to fix two obvious typos in a single file and make a single commit:\n```\n$ git show HEAD\ncommit 820ce2d9bc7c88e1515642cf3fc4005a52e4c490 (HEAD -\u003e b4/lanyang-dts-typo)\nAuthor: Konstantin Ryabitsev \u003cicon@mricon.com\u003e\nDate:   Wed Dec 21 16:17:21 2022 -0500\n\n    arm: lanyang: fix lable-\u003elabel typo for lanyang dts\n\n    Fix an obvious spelling error in the dts file for Lanyang BMC.\n    This was reported via bugzilla a few years ago but never fixed.\n\n    Reported-by: Jens Schleusener \u003cJens.Schleusener@fossies.org\u003e\n    Link: https://bugzilla.kernel.org/show_bug.cgi?id=205891\n    Signed-off-by: Konstantin Ryabitsev \u003cicon@mricon.com\u003e\n\ndiff --git a/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts b/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts\nindex c0847636f20b..e72e8ef5bff2 100644\n--- a/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts\n+++ b/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts\n@@ -52,12 +52,12 @@ hdd_fault {\n                        gpios = \u003c\u0026gpio ASPEED_GPIO(B, 3) GPIO_ACTIVE_HIGH\u003e;\n                };\n                bmc_err {\n-                       lable = \"BMC_fault\";\n+                       label = \"BMC_fault\";\n                        gpios = \u003c\u0026gpio ASPEED_GPIO(H, 6) GPIO_ACTIVE_HIGH\u003e;\n                };\n\n                sys_err {\n-                       lable = \"Sys_fault\";\n+                       label = \"Sys_fault\";\n                        gpios = \u003c\u0026gpio ASPEED_GPIO(H, 7) GPIO_ACTIVE_HIGH\u003e;\n                };\n        };\n```\n## Collecting To: and Cc: addresses\n\n* ``b4 prep --auto-to-cc``\n\nAfter you've committed your work, you will want to collect the addresses of people who should be the ones reviewing it. Running ``b4 prep --auto-to-cc`` will invoke ``scripts/get_maintainer.pl`` with the default recommended flags to find out who should go into the ``To:`` and ``Cc:`` headers:\n```\n$ b4 prep --auto-to-cc\nWill collect To: addresses using get_maintainer.pl\nWill collect Cc: addresses using get_maintainer.pl\nCollecting To/Cc addresses\n    + To: Rob Herring \u003c...\u003e\n    + To: Krzysztof Kozlowski \u003c...\u003e\n    + To: Joel Stanley \u003c...\u003e\n    + To: Andrew Jeffery \u003c...\u003e\n    + Cc: devicetree@vger.kernel.org\n    + Cc: linux-arm-kernel@lists.infradead.org\n    + Cc: linux-aspeed@lists.ozlabs.org\n    + Cc: linux-kernel@vger.kernel.org\n    + Cc: Jens Schleusener \u003c...\u003e\n---\nYou can trim/expand this list with: b4 prep --edit-cover\nInvoking git-filter-repo to update the cover letter.\nNew history written in 0.06 seconds...\nCompletely finished after 0.33 seconds.\n```\nThese addresses will be added to the cover letter and you can edit them to add/remove destinations using the usual ``b4 prep --edit-cover`` command.\n\n## Creating your patatt keypair for web endpoint submission\n\n(This needs to be done only once.)\n\n* ``patatt genkey``\n\nNote: if you already have a PGP key and it's set as ``user.signingKey``, then you can skip this section entirely.\n\nBefore we submit the patch, let's set up the keypair to sign our contributions. This is not strictly necessary if you are going to be using your own SMTP server to submit the patches, but it's a required step if you will use the kernel.org patch submission endpoint (which is what b4 will use in the absence of any ``[sendemail]`` sections in your git config).\n\nThe process is very simple. Run ``patatt genkey`` and add the resulting ``[patatt]`` section to your ``~/.gitconfig`` as instructed by the output.\n\nNOTE: You will want to back up the contents of your ``~/.local/share/patatt`` so you don't lose access to your private key.\n\n## Dry-run and checkpatch\n\n* ``b4 send -o /tmp/tosend``\n* ``./scripts/checkpatch.pl /tmp/tosend/*``\n\nNext, generate the patches and look at their contents to make sure that everything is looking sane. Good things to check are:\n\n* the From: address\n* the To: and Cc: addresses\n* general patch formatting\n* cover letter formatting (if more than 1 patch in the series)\n\nIf everything looks sane, one more recommended step is to run ``checkpatch.pl`` from the top of the kernel tree:\n```\n$ ./scripts/checkpatch.pl /tmp/tosend/*\ntotal: 0 errors, 0 warnings, 14 lines checked\n\n/tmp/tosend/0001-arm-lanyang-fix-lable-label-typo-for-lanyang-dts.eml has no obvious style problems and is ready for submission.\n```\n## Register your key with the web submission endpoint\n\n(This needs to be done only once, unless you change your keys.)\n\n* ``b4 send --web-auth-new``\n* ``b4 send --web-auth-verify [challenge]``\n\nIf you're not going to use your own SMTP server to send the patch, you should register your new keypair with the endpoint:\n```\n$ b4 send --web-auth-new\nWill submit a new email authorization request to:\n  Endpoint: https://lkml.kernel.org/_b4_submit\n      Name: Konstantin Ryabitsev\n  Identity: icon@mricon.com\n  Selector: 20221221\n    Pubkey: ed25519:24L8+ejW6PwbTbrJ/uT8HmSM8XkvGGtjTZ6NftSSI6I=\n---\nPress Enter to confirm or Ctrl-C to abort\nSubmitting new auth request to https://lkml.kernel.org/_b4_submit\n---\nChallenge generated and sent to icon@mricon.com\nOnce you receive it, run b4 send --web-auth-verify [challenge-string]\n```\nThe challenge is a UUID4 string and this step is a simple verification that you are able to receive email at the address you want associated with this key. Once you receive the challenge, complete the process as described:\n```\n$ b4 send --web-auth-verify 897851db-9b84-4117-9d82-1d970f9df5f8\nSigning challenge\nSubmitting verification to https://lkml.kernel.org/_b4_submit\n---\nChallenge successfully verified for icon@mricon.com\nYou may now use this endpoint for submitting patches.\n```\n## OR, set up your [sendemail] section\n\nYou don't *have* to use the web endpoint -- it exists primarily for people who are not able or not willing to set up their SMTP information with git. Setting up a SMTP gateway is not a straightforward process for many:\n\n* platforms using OAuth require setting up \"application-specific passwords\"\n* some companies only provide Exchange or browser-based access to email and don't offer any other way to send mail\n* some company SMTP gateways rewrite messages to add lengthy disclaimers or rewrite links to quarantine them\n\nHowever, if you have access to a functional SMTP gateway, then you are encouraged to use it instead of submitting via the web endpoint, as this ensures that the development process remains distributed and not dependent on any central services. Just follow instructions in ``man git-send-email`` and add a valid ``[sendemail]`` section to your git config. If b4 finds it, it will use it instead of relying on the web endpoint.\n```\n[sendemail]\n    smtpEncryption = tls\n    smtpServer = smtp.gmail.com\n    smtpServerPort = 465\n    smtpEncryption = ssl\n    smtpUser = yourname@gmail.com\n    smtpPass = your-gmail-app-password\n```\n## Reflect the email to yourself\n\n* ``b4 send --reflect``\n\nThis is the last step to use before sending off your contribution. Note, that it will fill out the ``To:`` and ``Cc:`` headers of all messages with actual recipients, but it will **NOT actually send mail to them, just to yourself**. Mail servers don't actually pay any attention to those headers -- the only thing that matters to them is what was specified in the ``RCPT TO`` outer envelope of the negotiation.\n\nThis step is particularly useful if you're going to send your patches via the web endpoint. Unless your email address is from one of the following domains, the ``From:`` header will be rewritten in order to not violate DMARC policies:\n\n* @kernel.org\n* @linuxfoundation.org\n* @linux.dev\n\nIf your email domain doesn't match the above, the ``From:`` header will be rewritten to be a kernel.org dummy address. Your actual ``From:`` will be added to the body of the message where git expects to find it, and the ``Reply-To:`` header will be set so anyone replying to your message will be sending it to the right place.\n\n## Send it off!\n\n* ``b4 send``\n\nIf all your tests are looking good, then you are ready to send your work. Fire off \"``b4 send``\", review the \"``Ready to:``\" section for one final check and either ``Ctrl-C`` to get out of it, or hit ``Enter`` to submit your work upstream.\n\n## Coming up next\n\nIn the next post, I will go over:\n\n* making changes to your patches using: ``git rebase -i``\n* retrieving and applying follow-up trailers using: ``b4 trailers -u``\n* comparing v2 and v1 to see what changes you made using: ``b4 prep --compare-to v1``\n* adding changelog entries using: ``b4 prep --edit-cover``\n\n## Documentation\n\nAll contributor-oriented features of b4 are documented on the following site:\n\n* https://b4.docs.kernel.org/en/stable-0.11.y/contributor/overview.html","tags":[],"paid":false,"views":10424,"likes":0}}