如何提交你的第一个 Linux 内核补丁 | LinuxCN Mirror
Skip to content
返回

如何提交你的第一个 Linux 内核补丁

学习如何做出你的首个 Linux 内核贡献,以及在开始之前你应该知道什么。

Linux 内核是最大且变动最快的开源项目之一,它由大约 53,600 个文件和近 2,000 万行代码组成。在全世界范围内超过 15,600 位程序员为它贡献代码,Linux 内核项目的维护者使用了如下的协作模型。

本文中,为了便于在 Linux 内核中提交你的第一个贡献,我将为你提供一个必需的快速检查列表,以告诉你在提交补丁时,应该去查看和了解的内容。对于你贡献的第一个补丁的提交流程方面的更多内容,请阅读 KernelNewbies 的第一个内核补丁教程

为内核作贡献

第 1 步:准备你的系统。

本文开始之前,假设你的系统已经具备了如下的工具:

第 2 步:下载 Linux 内核代码仓库。

git clone -b staging-testing
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git

复制你的当前配置:

cp /boot/config-`uname -r`* .config

第 3 步:构建/安装你的内核。

make -jX
sudo make modules_install install

第 4 步:创建一个分支并切换到该分支。

git checkout -b first-patch

第 5 步:更新你的内核并指向到最新的代码。

git fetch origin
git rebase origin/staging-testing

第 6 步:在最新的代码库上产生一个变更。

使用 make 命令重新编译,确保你的变更没有错误。

第 7 步:提交你的变更并创建一个补丁。

git add <file>
git commit -s -v
git format-patch -o /tmp/ HEAD^

主题是由冒号分隔的文件名组成,跟着是使用祈使语态来描述补丁做了什么。空行之后是强制的 signed off 标记,最后是你的补丁的 diff 信息。

下面是另外一个简单补丁的示例:

接下来,从命令行使用邮件(在本例子中使用的是 Mutt)发送这个补丁:

mutt -H /tmp/0001-<whatever your filename is>

使用 get_maintainer.pl 脚本,去了解你的补丁应该发送给哪位维护者的列表。

提交你的第一个补丁之前,你应该知道的事情

错误的方式:

Chris,
Yes let’s schedule the meeting tomorrow, on the second floor.

> On Fri, Apr 26, 2013 at 9:25 AM, Chris wrote:
> Hey John, I had some questions:
> 1. Do you want to schedule the meeting tomorrow?
> 2. On which floor in the office?
> 3. What time is suitable to you?

(注意那最后一个问题,在回复中无意中落下了。)

正确的方式:

Chris,
See my answers below...

> On Fri, Apr 26, 2013 at 9:25 AM, Chris wrote:
> Hey John, I had some questions:
> 1. Do you want to schedule the meeting tomorrow?
Yes tomorrow is fine.
> 2. On which floor in the office?
Let's keep it on the second floor.
> 3. What time is suitable to you?
09:00 am would be alright.

(所有问题全部回复,并且这种方式还保存了阅读的时间。)

想学习更多内容,阅读 KernelNewbies 的第一个内核补丁教程。之后如果你还有任何问题,可以在 kernelnewbies 邮件列表 或者 #kernelnewbies IRC channel 中提问。


via: https://opensource.com/article/18/8/first-linux-kernel-patch

作者:Sayli Karnik 选题:lujun9972 译者:qhwdw 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出



Previous Post
如何在 Ubuntu 上安装 pip
Next Post
使用 Chrome 扩展将 YouTube 播放器控件添加到 Linux 桌面