send-pr (Problem Report)

使用freebsd快一年了,今天在使用thunar這個file manager的時候發現了一個問題,當建立目錄的時候用所建出來的權限一直都是777,明明我的umask是設為022怎麼建出來是有問題的,因此追了一下程式加上問google,才發現這是一個bug,但是在freebsd ports tree裡面還沒有加入,因此也是第一次機會可以送出屬於自己的PR。

1. 複製一個原始port,還沒有加入patch的
# cd /usr/ports/x11-fm/
# cp -rfv thunar thunar.orig

2. 開始修改加入patch
# cd /usr/ports/x11-fm/thunar
# make patch (先讓此ports先patch網上存在的修正檔)
# cd work/Thunar-1.0.1/thunar-vfs/
# cp thunar-vfs-io-jobs.c thunar-vfs-io-jobs.c.orig

3. 修改thunar-vfs-io-jobs.c
把檔案修改完之後存檔

4. 輸出與原始檔案比對之後相異處的patch檔
# cd /usr/ports/x11-fm/thunar/work/Thunar-1.0.1 (主程式src的根目錄)
# diff -u thunar-vfs/thunar-vfs-io-jobs.c.orig thunar-vfs/thunar-vfs-io-jobs.c > patch-thunar-vfs-io-jobs.c
# mv patch-thunar-vfs-io-jobs.c ../../files/ (移到ports修正檔目錄中)
此看我們可以看到在/usr/ports/x11-fm/thunar/files/裡面存在patch-thunar-vfs-io-jobs.c
--- thunar-vfs/thunar-vfs-io-jobs.c.orig 2009-04-04 17:03:02.000000000 +0800
+++ thunar-vfs/thunar-vfs-io-jobs.c 2010-04-21 21:51:09.000000000 +0800
@@ -433,7 +433,7 @@

again:
/* try to create the file at the given path */
- fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, DEFFILEMODE);
+ fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, 0666);
if (G_UNLIKELY (fd < 0))
{
/* check if the file already exists */
@@ -708,7 +708,7 @@
_thunar_vfs_job_process_path (job, lp);

/* try to create the target directory */
- if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777 & ~umask(0), THUNAR_VFS_IO_OPS_NONE, error))
+ if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777, THUNAR_VFS_IO_OPS_NONE, error))
return FALSE;
}

以上是我們做完patch之後的內容

5. 驗證patch是否正確修正
# make clean (將整個port工作目錄清掉)
# make patch (重做一次patch看是否有套用自己有修改的部份)

6. 比對原始未修正的port與目前已修正的port
# cd /usr/ports/x11-fm/thunar (不是thunar.orig喔thunar.orig是原始未修改目錄)
# make clean (清掉驗證時的工作目錄,目前整個目錄除了多了一個patch-thunar-io-jobs.c整個目錄應該和原本的一樣了)
# port diff -d .orig > /tmp/thunar.patch
.orig是剛剛複製目錄時候所加的結尾,目的就是要讓port這個工具幫我們比對整個新的thunar目錄與原始的thunar.orig目錄有何差異,並輸出差異內容,我們把差異內容放在/tmp下面,最後這個在/tmp下的thunar.patch就是我們要send-pr的附加檔,內容為
===> Generating patch
===> Viewing diff with more
diff -ruN --exclude=CVS /usr/ports/x11-fm/thunar.orig/files/patch-thunar-vfs-io-jobs.c /usr/ports/x11-fm/thunar/files/patch-thunar-vfs-io-jobs.c
--- /usr/ports/x11-fm/thunar.orig/files/patch-thunar-vfs-io-jobs.c 1970-01-01 08:00:00.000000000 +0800
+++ /usr/ports/x11-fm/thunar/files/patch-thunar-vfs-io-jobs.c 2010-04-21 22:01:36.000000000 +0800
@@ -0,0 +1,20 @@
+--- thunar-vfs/thunar-vfs-io-jobs.c.orig 2009-04-04 17:03:02.000000000 +0800
++++ thunar-vfs/thunar-vfs-io-jobs.c 2010-04-21 21:51:09.000000000 +0800
+@@ -433,7 +433,7 @@
+
+ again:
+ /* try to create the file at the given path */
+- fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, DEFFILEMODE);
++ fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, 0666);
+ if (G_UNLIKELY (fd < 0))
+ {
+ /* check if the file already exists */
+@@ -708,7 +708,7 @@
+ _thunar_vfs_job_process_path (job, lp);
+
+ /* try to create the target directory */
+- if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777 & ~umask(0), THUNAR_VFS_IO_OPS_NONE, error))
++ if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777, THUNAR_VFS_IO_OPS_NONE, error))
+ return FALSE;
+ }
+
===> Done

※ports這個工具是在/usr/ports/ports-mgmt/porttools/沒有的話自行安裝

7. send-pr
# setenv EDITOR vim (設定pr的編輯器為vim)
# send-pr -a /tmp/thunar.patch (-a為附加檔案)
接下來就是要填入pr裡面許多的欄位了,這裡列出需要修改的部份
From: Clockwork Box 
Reply-To: Clockwork Box
Originator: Clockwork Box
Synopsis: [PATCH] x11-fm/thunar: fix umask handling
Serverity: non-critical
Priority: low
Category: ports
Class: update
Description:
Fix umask handling, when create directory.

填完離開存檔,它就會問你要不要send送出,選擇送出就完成了

8. 等待郵送過去之後就會收到一封由FreeBSD-gnats-submit@freebsd.org所寄過來的信
Thank you very much for your problem report.
It has the internal identification `ports/145916'.
The individual assigned to look at your
report is: freebsd-ports-bugs.

You can access the state of your problem report at any time
via this link:

http://www.freebsd.org/cgi/query-pr.cgi?pr=145916

>Category: ports
>Responsible: freebsd-ports-bugs
>Synopsis: [PATCH] x11-fm/thunar: fix umask handling
>Arrival-Date: Wed Apr 21 12:50:04 UTC 2010

透過這封信就可以追蹤到目前送出的patch有沒有被accept

0 意見: