使用這個工具是一個版本控制系統,我會告訴我會怎麼做(完全未經測試)Git命令。
## Create repository ##
$ mkdir workdir
$ cd workdir
$ git init
$ touch .gitignore # \ Creates a first commit
$ git add .gitignore # > for the branches to
$ git commit -m .gitignore #/ have in common
## Import debian source code ##
$ git checkout -b debian master
$ tar zxvf /the/debian/source/code.tgz
$ git add .
$ git commit -m "Base debian source code"
## Import centos source code ##
$ git checkout -b centos master
$ tar zxvf /the/centos/source/code.tgz
$ git add .
$ git commit -m "Base centos source code"
## Apply centos rpm patches ##
$ pacth -p1 < /the/file/listed/as/patch1/in/spec/file
$ git add .
$ git commit -m the_pacth1_file_name
$ pacth -p1 < /the/file/listed/as/patch2/in/spec/file
$ git add .
$ git commit -m the_pacth2_file_name
$ # repeat for all the patches up till, including openssh-6.6-fips.patch
到目前爲止,除了包含構建包時使用的最終源代碼的git存儲庫以外,該命令已獲得任何東西。然而,由於補丁存儲爲不同的提交(這是關鍵),我們可以做標準的版本控制操作和包含/排除分支的部分,因爲我們想要的。
因此,假設openssh-6.6-fips.patch是patch number 5只是選擇一個數字,你的問題是,它不會乾淨地應用到Ubuntu的源,因爲補丁1到4做了一些額外的變化建立在最上面,對嗎?
一個合適的版本控制系統跟蹤版本的父關係,運氣好的話它會找出如何自行解決衝突,或者它可能會放棄並且需要手動解決它,但是在任何情況下,版本控制系統是處理這種情況的最佳工具。
所以,如果你從CentOS的源代碼中唯一想要的補丁的openssh-6.6-fips.patch,然後創建一個僅包含在基礎CentOS的源代碼提交的頂這個補丁一個新的分支,然後變基分支到Ubuntu分支上。這衍合犯然後會給你會乾淨的應用到ubuntu的源代碼
$ git checkout -b fips centos
$ git rebase -i master # Pick only the first base commit
# and the openssh-6.6-fips.patch
$ # Resolve conflicts if any and check in
補丁現在你有一個分支fips
只包含CentOS的基礎源代碼和FIPS提交。然後你想把它重新放到Ubuntu分支上。
# Rebase from (excluding) one behind the top of fips branch,
# to (including) the tip of the fips branch
$ git rebase --onto ubuntu fips^ fips
# Resolve and check in any conflicts should there be any
$ git format-patch ubuntu..fips
最後的命令會給你會乾淨的應用,您可以添加到包裝代碼補丁文件。