2016-07-16 60 views
-1

背景:工具,該工具計算出順序補丁應適用?

我想讓Ubuntu在FIPS模式下工作。一,我需要FIPSify是OpenSSH的軟件包。據CentOS的OpenSSH的*的.spec文件,他們對OpenSSH的源代碼頂層是openssh-6.6-fips.patch應用補丁的一個。然而,Debian包裝代碼沒有這個補丁在所有的,所以我想從CentOS的「借用」,並在Ubuntu上使用。

問題:

不幸的是,這openssh-6.6-fips.patch補丁不乾淨的上ubuntu的OpenSSH的源代碼頂部由於該CentOS的產生之前施加其他補丁應用。我擁有所有的修補程序,但要應用它們並不容易,因爲我不知道修補程序依賴關係。

是否有一個工具可以自動執行此過程,並且輸入的內容可能來自Ubuntu的openssh源代碼,CentOS的修補程序以及我想應用的「目標」修補程序。然後輸出它會告訴我是否可以應用這些CentOS補丁而不觸發衝突?

回答

1

使用這個工具是一個版本控制系統,我會告訴我會怎麼做(完全未經測試)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 

最後的命令會給你會乾淨的應用,您可以添加到包裝代碼補丁文件。

0

OpenSSH並非來自Ubuntu(或CentOS)。兩者都使用特定版本,並對其應用修補程序。 RPM規格文件按照它們的應用順序列出了這些補丁。這些補丁被調整爲與用作基本版本的特定版本的OpenSSH一起工作。

未安裝OpenSSH的一個很好的瞭解,你會發現它具有挑戰性的補丁的一部分,適應不同的版本(或不同的包裝系統)。

同樣,由於OpenSSH已經被其他的包,你會發現在重建一個包,並將其代入你的Ubuntu系統的問題。

可能使用規範文件爲指導,應用補丁的順序和配置OpenSSH的第二個副本在非系統目錄來安裝,例如,/usr/local/openssh-fips(使用配置腳本的--prefix選項)。