opensource流程

有幸能够参与公司的开源项目,第一次感受到了开源的魅力,相信这是每个热爱技术人的共同追求,但是在加入开源项目之前对开源的规则以及运行模式的了解是必要的,无论是聊天方式还是review代码的流程对开源工作者都是必要的:

二、安装msmtp和git-email

点击左边栏的“软件中心”,在搜索框中输入msmtp,选择安装即可,如下图所示。

git-email”安装同理

三、配置msmtp

1、请按照如下步骤配置msmtp:

root@-VirtualBox:~# cd ~/

root@-VirtualBox:~# vi .msmtp.log   //创建log文件,然后直接退出

root@-VirtualBox:~# vi .msmtprc      //键入如下内容

defaults

 

logfile ~/.msmtp.log

 

# samsung

account samsung

protocol smtp

host smtp.samsung.com

from [email protected]

user [email protected]

password xxxxxx      // single的密码,由于single密码3个月一换,注意同步更新此处

port 25

auth plain

tls off

#tls_starttls on

#tls_trust_file /etc/ssl/certs/ca-certificates.crt

#syslog LOG_MAIL

 

# Set a default account

account default : samsung

 

root@-VirtualBox:~# chmod 600 .msmtprc      //这个执行下否则会报错

 

2、验证msmtp是否可以使用

使用如下命令向自己的single邮箱发送一个邮件,确认是否可以使用。

root@-VirtualBox:~# msmtp [email protected]

nihao                           //输入任意内容,然后按ctrl+D退出

root@-VirtualBox:~#

如果自己的single邮箱收到了本邮件说明配置成功,若没有,请检查虚拟机的网络配置。

 

3、关于single邮箱服务器(了解即可)

root@-VirtualBox:~# msmtp --serverinfo --host=smtp.samsung.com

SMTP server at smtp.samsung.com ([203.254.227.15]), port 25:

    mmp1.samsung.com -- Server ESMTP (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011))

Capabilities:

    SIZE 0:

        Maximum message size is unlimited

    PIPELINING:

        Support for command grouping for faster transmission

    ETRN:

        Support for RMQS (Remote Message Queue Starting)

    DSN:

        Support for Delivery Status Notifications

    AUTH:

        Supported authentication methods:

        PLAIN LOGIN

root@-VirtualBox:~#

root@-VirtualBox:~# msmtp --serverinfo --host=smtp.samsung.com --tls=on --tls-certcheck=off

msmtp: the server does not support TLS via the STARTTLS command

四、配置git

$git config --global user.name 'Changbing Xiong'

$git config --global user.email ' [email protected]'

$git config --global sendemail.chainreplyto false

$git config --global sendemail.smtpserver /usr/bin/msmtp

查看配置结果是否正确:

# cat ~/.gitconfig

[user]

                name = Changbing Xiong

                email = [email protected]

[color]

                ui = auto

[core]

                editor = vim

[sendemail]

                chainreplyto = false

                smtpserver = /usr/bin/msmtp

root@-VirtualBox:

五、订阅mailinglist

Linux开源分支要求开发者上传patch或者driver时,需要将邮件抄送给mailinglist、maintainer和其他人,首先需要订阅相关子系统的mailinglist。

订阅邮件列表mailing list://改成自己所要提交代码所在子系统的mailing list,详见linux代码根目录下的MAINTAINERS文档

 

To: [email protected]

邮件内容:

subscribe linux-media

 

取消订阅邮件列表mailing list:

To: [email protected]

邮件内容:

unsubscribe linux-media

注意:订阅mailinglist的邮件不需要标题,请参考如下方式:

# vi subscrible

Subject: //冒号后面保留一个空格

               //必须空一行,并且该行不要有空格

subscribe linux-media  //在这里加个回车,然后退出并保存文件

 

#git send-email --from [email protected] --to [email protected] ./subscrible  //验证一下

#git send-email --from [email protected] --to [email protected] ./subscrible  

注意:发送完subscribe邮件后,你会收到一封确认邮件,比如我的确认邮件标题为“Confirmationfor subscribe linux-media”,里面有认证信息,请按照邮件内容,再发一个认证邮件给[email protected],如下:

# vi subscrible_auth

Subject:

 

auth xxxxxxxx subscribe linux-media [email protected]

 

# git send-email --from [email protected] --to [email protected] ./subscrible_auth

 

六、生成patch

                本章介绍如何生成符合开源社区要求的patch格式。

1、在git分支上修改代码

2、gitadd 修改后的代码

3、gitcommit -s

    第一次commit时使用-s,后面修改下面内容时,用—amend即可。

au0828: fix logic of tuner disconnection                     //标题,带上模块名称,如au0828

                                                                                             //此处必须空一行

The driver crashed when the tuner was disconnected while restart stream

operations are still being performed. Fixed by adding a flag in struct

au0828_dvb to indicate whether restart stream operations can be performed.

 

If the stream gets misaligned, the work of restart stream operations are

 usually scheduled for many times in a row. If tuner is disconnected at

this time and some of restart stream operations are still not flushed,

then the driver crashed due to accessing the resource which used in

restart stream operations has been released.

                                                                                             //此处必须空一行

Signed-off-by: Changbing Xiong <[email protected]>    //通过git commit –s 自动生成

 

# Please enter the commit message for your changes. Lines starting  //从这往下都是自动生成,勿动

# with '#' will be ignored, and an empty message aborts the commit.

# On branch tizen

# Your branch is ahead of 'origin/tizen' by 1 commit.

#

# Changes to be committed:

#   (use "git reset HEAD^1 <file>..." to unstage)

#

#       modified:   drivers/media/usb/au0828/au0828-dvb.c

#       modified:   drivers/media/usb/au0828/au0828.h

 

4、gitformat-patch HEAD^

将最近一次的修改生成一个patch

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# git format-patch HEAD^

0001-au0828-fix-logic-of-tuner-disconnection.patch

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# cat 0001-au0828-fix-logic-of-tuner-disconnection.patch

From cc4f6646ae5eb0d75d56cca62e2d60c1ac8cad66 Mon Sep 17 00:00:00 2001

From: Changbing Xiong <[email protected]>

Date: Tue, 22 Apr 2014 16:10:29 +0800

Subject: [PATCH] au0828: fix logic of tuner disconnection //此处的[PATCH]是工具自动加上的

 

The driver crashed when the tuner was disconnected while restart stream

。。。。。。。

restart stream operations has been released.

 

Change-Id: Iaa1b93f4d5b08652921069182cdd682aba151dbf //需要通过vim删除此行

Signed-off-by: Changbing Xiong <[email protected]>

---

 drivers/media/usb/au0828/au0828-dvb.c |   13 +++++++++++++

。。。。。。。

root@-VirtualBox:/home/samba/odroidx2/linux-3.10#

注:如果patch中有Change-Id行,需要删除;用 branch和master 比较产生patch的方法:

git format-patch -C -n master ..$dev_branch 

将最近两次的修改的内容生成两个独立的patch

其中patch2是在patch1的基础上修改的,这种情况下,patch1和patch2是连续的,patch的标题上面有规范要求,见下:

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# git log 

commit cb94983b105c9fe89c39727dfb2b072ca40cb686                    //查看已commit的两次连续修改

Author: Changbing Xiong <[email protected]>

Date:   Thu May 8 11:10:54 2014 +0800

 

    au0828: Cancel stream-restart operation if frontend is disconnected    //注意标题开头没有[PATCH]

   

    If the tuner is already disconnected, It is meaningless to go on doing the

    stream-restart operation, It is better to cancel this operation.

   

    Change-Id: Ib392c3fc6b3ec9085821e1a43a0b1273d3326cb9

    Signed-off-by: Changbing Xiong <[email protected]>

 

commit fdf7c9031295bed3ba4e1f3362361983b66aa399

Author: Changbing Xiong <[email protected]>

Date:   Thu May 8 10:45:51 2014 +0800

 

    au0828: Fix disconnection bug of tuner  //注意标题开头没有[PATCH]

   

    The driver crashed when the tuner was disconnected while restart stream

    operations are still being performed. Fixed by adding a flag in struct

    au0828_dvb to indicate whether restart stream operations can be performed.

        

    Change-Id: I0642e154472680484bfed80cd5adb1d782412758

    Signed-off-by: Changbing Xiong <[email protected]>

 

# git format-patch HEAD~2   //制作连续patchgit format-patch HEAD^^也可以

0001-au0828-Fix-disconnection-bug-of-tuner.patch

0002-au0828-Cancel-stream-restart-operation-if-frontend-i.patch

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# ls -l *.patch

-rw-r--r-- 1 root root 2658  5月  8 14:01 0001-au0828-Fix-disconnection-bug-of-tuner.patch

-rw-r--r-- 1 root root 1112  5月  8 14:01 0002-au0828-Cancel-stream-restart-operation-if-frontend-i.patch

# cat 0001-au0828-Fix-disconnection-bug-of-tuner.patch

From fdf7c9031295bed3ba4e1f3362361983b66aa399 Mon Sep 17 00:00:00 2001

From: Changbing Xiong <[email protected]>

Date: Thu, 8 May 2014 10:45:51 +0800

Subject: [PATCH 1/2] au0828: Fix disconnection bug of tuner  //瞧,自动添加了[PATCH 1/2]

 

The driver crashed when the tuner was disconnected while restart stream

operations are still being performed. Fixed by adding a flag in struct

au0828_dvb to indicate whether restart stream operations can be performed.

 

Change-Id: I0642e154472680484bfed80cd5adb1d782412758   //注意后面处理时去掉这行

Signed-off-by: Changbing Xiong <[email protected]>

---

 drivers/media/usb/au0828/au0828-dvb.c |   11 +++++++++++

 drivers/media/usb/au0828/au0828.h     |    1 +

 2 files changed, 12 insertions(+)

 mode change 100644 => 100755 drivers/media/usb/au0828/au0828-dvb.c

 mode change 100644 => 100755 drivers/media/usb/au0828/au0828.h

 

diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c

。。。。。。

--

1.7.9.5

 

# cat 0002-au0828-Cancel-stream-restart-operation-if-frontend-i.patch

From cb94983b105c9fe89c39727dfb2b072ca40cb686 Mon Sep 17 00:00:00 2001

From: Changbing Xiong <[email protected]>

Date: Thu, 8 May 2014 11:10:54 +0800

Subject: [PATCH 2/2] au0828: Cancel stream-restart operation if frontend is

 disconnected   //瞧,自动添加了[PATCH 2/2]

 

If the tuner is already disconnected, It is meaningless to go on doing the

stream-restart operation, It is better to cancel this operation.

 

Change-Id: Ib392c3fc6b3ec9085821e1a43a0b1273d3326cb9    //注意后面处理时去掉这行

Signed-off-by: Changbing Xiong <[email protected]>

---

 drivers/media/usb/au0828/au0828-dvb.c |    2 ++

 1 file changed, 2 insertions(+)

 

diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c

index 878f66f..6995309 100755

--- a/drivers/media/usb/au0828/au0828-dvb.c

+++ b/drivers/media/usb/au0828/au0828-dvb.c

@@ -422,6 +422,8 @@ void au0828_dvb_unregister(struct au0828_dev *dev)

                dvb_unregister_frontend(dvb->frontend);

                dvb_frontend_detach(dvb->frontend);

                dvb_unregister_adapter(&dvb->adapter);

+

+             cancel_work_sync(&dev->restart_streaming);

 }

 

 /* All the DVB attach calls go here, this function get's modified

--

1.7.9.5

 

root@-VirtualBox:/home/samba/odroidx2/linux-3.10#

 

 

5、检查patch

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# ./scripts/checkpatch.pl -f 0001-au0828-fix-logic-of-tuner-disconnection.patch -terse

0001-au0828-fix-logic-of-tuner-disconnection.patch:31: ERROR: trailing whitespace

0001-au0828-fix-logic-of-tuner-disconnection.patch:33: ERROR: trailing whitespace

0001-au0828-fix-logic-of-tuner-disconnection.patch:43: ERROR: trailing whitespace

0001-au0828-fix-logic-of-tuner-disconnection.patch:45: ERROR: trailing whitespace

0001-au0828-fix-logic-of-tuner-disconnection.patch:49: ERROR: trailing whitespace

0001-au0828-fix-logic-of-tuner-disconnection.patch:54: ERROR: trailing whitespace

0001-au0828-fix-logic-of-tuner-disconnection.patch:69: ERROR: trailing whitespace

0001-au0828-fix-logic-of-tuner-disconnection.patch:83: ERROR: trailing whitespace

0001-au0828-fix-logic-of-tuner-disconnection.patch:85: ERROR: trailing whitespace

total: 9 errors, 0 warnings, 87 lines checked

root@-VirtualBox:/home/samba/odroidx2/linux-3.10#

行未有空格(原文件中没有,不知道为什么生成的patch中有了空格),可以用sed工具删除

#sed -e 's/[ ]*$//g' 0001-au0828-fix-logic-of-tuner-disconnection.patch>1.patch     //保存到新patch

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# ./scripts/checkpatch.pl -f 1.patch –terse

root@-VirtualBox:/home/samba/odroidx2/linux-3.10#

 

6、发送patch

注意:

邮件外发需要申请“邮件外发”权限;

强烈建议下发一个邮件给自己,看些收到的邮件格式是否符合linux要求;

已经订阅了mailinglist;

patch经过相关的专利、lincense检查;

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# git send-email  --to [email protected] 1.patch      //先自己验证下

 

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# git send-email --no-chain-reply-to \

--suppress-from --no-signed-off-by-cc \

--to [email protected] \

--cc [email protected] \

--cc [email protected] 1.patch

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# git send-email --no-chain-reply-to \

--suppress-from --no-signed-off-by-cc \

--to [email protected] \

--cc [email protected] \

--cc [email protected] 2.patch

 

 

git send-email --no-chain-reply-to--suppress-from --no-signed-off-by-cc --to [email protected] your.patch

                               不要嵌套                  发给自己     不要发送给signed-off-by的人    

效果如下:

另外也可以在http://www.spinics.net/lists/linux-media/中看到自己提交的patch

 

Adding Patch Version Information

By default the patch mails will have"[PATCH]" in the subject (or "[PATCH n/m]", where n is thesequence number of the patch and m is the total number of patches in the patchset).When sending updated versions ofpatches, the version should be indicated:"[PATCH v2]" or "[PATCH v2 n/m]". To do this, usethe --annotate option发送前编辑邮件内容 and edit the "Subject" header of the mails.

Adding Extra Notes to Patch Mails

Sometimes it's convenient to annotate patches withsome notes that are not meant to be included in the commit message. Forexample, one might want to write "I'm not sure if this should be committedyet, because..." in a patch, but the text doesn't make sense in the commitmessage. Such messages can be written below the three dashes "---"that are in every patch after the commit message.Use the --annotate option with git send-email to be ableto edit the mails before they are sent.

 

7、回复别人的comments

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# vi reply

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# cat reply

Subject:

 

Thanks for your comments, and I have resubmit this according Mr. Chehab's

comments, please check.

 

Thanks.

 

Changbing Xiong.

root@-VirtualBox:/home/samba/odroidx2/linux-3.10#

root@-VirtualBox:/home/samba/odroidx2/linux-3.10# git send-email --in-reply-to="<[email protected]>" \

--thread=deep --chain-reply-to   \

[email protected] \

--cc [email protected] reply

reply

Who should the emails appear to be from? [Changbing Xiong <[email protected]>]

Emails will be sent from: Changbing Xiong <[email protected]>

OK. Log says:

Sendmail: /usr/bin/msmtp -i [email protected] [email protected]

From: Changbing Xiong <[email protected]>

To: [email protected]

Cc: [email protected]

Subject:

Date: Fri,  9 May 2014 13:06:14 +0800

Message-Id: <[email protected]>

X-Mailer: git-send-email 1.7.9.5

In-Reply-To: <[email protected]>

References: <[email protected]>

 

Result: OK

 

七、工具介绍

https://www.kernel.org/pub/software/scm/git/docs/git-send-email.html

https://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html

 

你可能感兴趣的:(opensource流程)