diff --git a/sources/tech/20180821 A checklist for submitting your first Linux kernel patch.md b/sources/tech/20180821 A checklist for submitting your first Linux kernel patch.md deleted file mode 100644 index b6974cde0b..0000000000 --- a/sources/tech/20180821 A checklist for submitting your first Linux kernel patch.md +++ /dev/null @@ -1,171 +0,0 @@ -Translating by qhwdw -A checklist for submitting your first Linux kernel patch -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_penguin_green.png?itok=ENdVzW22) - -One of the biggest—and the fastest moving—open source projects, the Linux kernel, is composed of about 53,600 files and nearly 20-million lines of code. With more than 15,600 programmers contributing to the project worldwide, the Linux kernel follows a maintainer model for collaboration. - -![](https://opensource.com/sites/default/files/karnik_figure1.png) - -In this article, I'll provide a quick checklist of steps involved with making your first kernel contribution, and look at what you should know before submitting a patch. For a more in-depth look at the submission process for contributing your first patch, read the [KernelNewbies First Kernel Patch tutorial][1]. - -### Contributing to the kernel - -#### Step 1: Prepare your system. - -Steps in this article assume you have the following tools on your system: - -+ Text editor -+ Email client -+ Version control system (e.g., git) - -#### Step 2: Download the Linux kernel code repository`:` -``` -git clone -b staging-testing - -git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git - -``` - -### Copy your current config: ```` -``` -cp /boot/config-`uname -r`* .config - -``` - -### Step 3: Build/install your kernel. -``` -make -jX - -sudo make modules_install install - -``` - -### Step 4: Make a branch and switch to it. -``` -git checkout -b first-patch - -``` - -### Step 5: Update your kernel to point to the latest code base. -``` -git fetch origin - -git rebase origin/staging-testing - -``` - -### Step 6: Make a change to the code base. - -Recompile using `make` command to ensure that your change does not produce errors. - -### Step 7: Commit your changes and create a patch. -``` -git add - -git commit -s -v - -git format-patch -o /tmp/ HEAD^ - -``` - -![](https://opensource.com/sites/default/files/karnik_figure2.png) - -The subject consists of the path to the file name separated by colons, followed by what the patch does in the imperative tense. After a blank line comes the description of the patch and the mandatory signed off tag and, lastly, a diff of your patch. - -Here is another example of a simple patch: - -![](https://opensource.com/sites/default/files/karnik_figure3.png) - -Next, send the patch [using email from the command line][2] (in this case, Mutt): `` -``` -mutt -H /tmp/0001- - -``` - -To know the list of maintainers to whom to send the patch, use the [get_maintainer.pl script][11]. - - -### What to know before submitting your first patch - - * [Greg Kroah-Hartman][3]'s [staging tree][4] is a good place to submit your [first patch][1] as he accepts easy patches from new contributors. When you get familiar with the patch-sending process, you could send subsystem-specific patches with increased complexity. - - * You also could start with correcting coding style issues in the code. To learn more, read the [Linux kernel coding style documentation][5]. - - * The script [checkpatch.pl][6] detects coding style errors for you. For example, run: - ``` - perl scripts/checkpatch.pl -f drivers/staging/android/* | less - - ``` - - * You could complete TODOs left incomplete by developers: - ``` - find drivers/staging -name TODO - ``` - - * [Coccinelle][7] is a helpful tool for pattern matching. - - * Read the [kernel mailing archives][8]. - - * Go through the [linux.git log][9] to see commits by previous authors for inspiration. - - * Note: Do not top-post to communicate with the reviewer of your patch! Here's an example: - -**Wrong way:** - -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? - -(Notice that the last question was unintentionally left unanswered in the reply.) - -**Correct way:** - -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._ - -(All questions were answered, and this way saves reading time.) - - * The [Eudyptula challenge][10] is a great way to learn kernel basics. - - -To learn more, read the [KernelNewbies First Kernel Patch tutorial][1]. After that, if you still have any questions, ask on the [kernelnewbies mailing list][12] or in the [#kernelnewbies IRC channel][13]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/first-linux-kernel-patch - -作者:[Sayli Karnik][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/sayli -[1]:https://kernelnewbies.org/FirstKernelPatch -[2]:https://opensource.com/life/15/8/top-4-open-source-command-line-email-clients -[3]:https://twitter.com/gregkh -[4]:https://www.kernel.org/doc/html/v4.15/process/2.Process.html -[5]:https://www.kernel.org/doc/html/v4.10/process/coding-style.html -[6]:https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl -[7]:http://coccinelle.lip6.fr/ -[8]:linux-kernel@vger.kernel.org -[9]:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/ -[10]:http://eudyptula-challenge.org/ -[11]:https://github.com/torvalds/linux/blob/master/scripts/get_maintainer.pl -[12]:https://kernelnewbies.org/MailingList -[13]:https://kernelnewbies.org/IRC diff --git a/translated/tech/20180821 A checklist for submitting your first Linux kernel patch.md b/translated/tech/20180821 A checklist for submitting your first Linux kernel patch.md new file mode 100644 index 0000000000..bf23f20674 --- /dev/null +++ b/translated/tech/20180821 A checklist for submitting your first Linux kernel patch.md @@ -0,0 +1,173 @@ +提交你的第一个 Linux 内核补丁时的一个检查列表 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_penguin_green.png?itok=ENdVzW22) + +Linux 内核是最大的且变动最快的开源项目之一,它由大约 53,600 个文件和近 2,000 万行代码组成。在全世界范围内超过 15,600 位程序员为它贡献代码,Linux 内核项目的维护者使用了如下的协作模型。 + +![](https://opensource.com/sites/default/files/karnik_figure1.png) + +本文中,为了便于在 Linux 内核中提交你的第一个贡献,我将为你提供一个必需的快速检查列表,以告诉你在提交补丁时,应该去查看和了解的内容。对于你贡献的第一个补丁的提交流程方面的更多内容,请阅读 [KernelNewbies 第一个内核补丁教程][1]。 + +### 为内核作贡献 + +#### 第 1 步:准备你的系统 + +本文开始之前,假设你的系统已经具备了如下的工具: + ++ 文本编辑器 ++ Email 客户端 ++ 版本控制系统(即:git) + +#### 第 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 + +git commit -s -v + +git format-patch -o /tmp/ HEAD^ + +``` + +![](https://opensource.com/sites/default/files/karnik_figure2.png) + +主题是由冒号分隔的文件名组成,接下来是使用祈使语态来描述补丁做了什么。空行之后是强制规定的 `off` 标记,最后是你的补丁的 `diff` 信息。 + +下面是另外一个简单补丁的示例: + +![](https://opensource.com/sites/default/files/karnik_figure3.png) + +接下来,[使用 email 从命令行][2](在本例子中使用的是 Mutt)发送这个补丁: +``` +mutt -H /tmp/0001- + +``` + +使用 [get_maintainer.pl 脚本][11],去了解你的补丁应该发送给哪位维护者的列表。 + + +### 提交你的第一个补丁之前,你应该知道的事情 + + * [Greg Kroah-Hartman](3) 的 [staging tree][4] 是提交你的 [第一个补丁][1] 的最好的地方,因为他更容易接受新贡献者的补丁。在你熟悉了补丁发送流程以后,你就可以去发送复杂度更高的子系统专用的补丁。 + + * 你也可以从纠正代码中的编码风格开始。想学习更多关于这方面的内容,请阅读 [Linux 内核编码风格文档][5]。 + + * [checkpatch.pl][6] 脚本可以检测你的编码风格方面的错误。例如,运行如下的命令: + + ``` + perl scripts/checkpatch.pl -f drivers/staging/android/* | less + + ``` + + * 你可以去补全开发者留下的 TODO 注释中未完成的内容: + ``` + find drivers/staging -name TODO + ``` + + * [Coccinelle][7] 是一个模式匹配的有用工具。 + + * 阅读 [归档的内核邮件][8]。 + + * 为找到灵感,你可以去遍历 [linux.git log][9] 查看以前的作者的提交内容。 + + * 注意:不要为了评估你的补丁而在社区置顶帖子!下面就是一个这样的例子: + +**错误的方式:** + +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._ + +(所有问题全部回复,并且这种方式还保存了阅读的时间。) + + * [Eudyptula challenge][10] 是学习内核基础知识的非常好的方式。 + + +想学习更多内容,阅读 [KernelNewbies 第一个内核补丁教程][1]。之后如果你还有任何问题,可以在 [kernelnewbies 邮件列表][12] 或者 [#kernelnewbies IRC channel][13] 中提问。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/first-linux-kernel-patch + +作者:[Sayli Karnik][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/sayli +[1]:https://kernelnewbies.org/FirstKernelPatch +[2]:https://opensource.com/life/15/8/top-4-open-source-command-line-email-clients +[3]:https://twitter.com/gregkh +[4]:https://www.kernel.org/doc/html/v4.15/process/2.Process.html +[5]:https://www.kernel.org/doc/html/v4.10/process/coding-style.html +[6]:https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl +[7]:http://coccinelle.lip6.fr/ +[8]:linux-kernel@vger.kernel.org +[9]:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/ +[10]:http://eudyptula-challenge.org/ +[11]:https://github.com/torvalds/linux/blob/master/scripts/get_maintainer.pl +[12]:https://kernelnewbies.org/MailingList +[13]:https://kernelnewbies.org/IRC