如何从社区邮件列表获取完整的补丁
我们看邮件列表时,经常会对没有进入社区的patch,感兴趣。但是邮件列表里的补丁并不是完整的git仓库可用的补丁。对于少量的补丁,可以用复制和粘贴来获取patch。
但是如果patch是几十个的话,粘贴复制比较麻烦。有一个工具可以完成从邮件列表获取patch,并应用这个patch到代码里。
这个工具叫pwclient,下面是具体的步骤
-
下载pwelient:
git clone https://github.com/getpatchwork/pwclient
-
编译(参见代码里的README):
pip install --user .
-
配置.pwclientrc文件,主要是从哪个邮件列表下载补丁的配置
[root]#vim ~/.pwclientrc
# Sample .pwclientrc file for the patchwork project,
# running on patchwork.ozlabs.org.
#
# Just append this file to your existing ~/.pwclientrc
# If you do not already have a ~/.pwclientrc, then copy this file to
# ~/.pwclientrc, and uncomment the following two lines:
[options]
default=lkml
[lkml]
url = https://lore.kernel.org/patchwork/xmlrpc/
上面的配置,是Linux kernel的邮件列表的补丁,其它常用的邮件列表如下。
https://patchwork.kernel.org/ Linux kernel
https://patchwork.ozlabs.org/project/qemu-devel/list/ QEMU
https://patchwork.ozlabs.org/project/gcc/list/ GCC, which includes GDB which is your original use case
https://patchwork.ozlabs.org/project/glibc/list/ glibc
-
如何使用pwclient
1 获取lkml补丁的patch id. 比如,我们看到邮件有一个[RFC 08/60] sched: Move init_entity_runnable_average() into init_tg_cfs_entry()这个标题的补丁。我们用pwclient search来获取这个补丁的id
root@yxf-ubuntu:~# pwclient search "sched: Move init_entity_runnable_average() into init_tg_cfs_entry()"
ID State Name
-- ----- ----
983638 New [RFC,08/60] sched: Move init_entity_runnable_average() into init_tg_cfs_entry()
可以看到ID为983638,这个就是patch id
2 获取邮件列表的完整的补丁
root@yxf-ubuntu:~# pwclient get 983638
Saved patch to RFC-08-60-sched-Move-init_entity_runnable_average-into-init_tg_cfs_entry.patch
这个步骤完成补丁的下载。
3 将补丁打入git 代码仓库
root@yxf-ubuntu:~# cd linux
root@yxf-ubuntu:~# pwclient git-am 983638
执行完这个命令patch id为983638的补丁,就打入到了本地源码里