為redhat增加apt軟體包管理工具(轉)

post0發表於2007-08-09
為redhat增加apt軟體包管理工具(轉)[@more@]

一、 簡介

redhat採用了RPM軟體包管理系統,RPM軟體包管理系統具有強大的編譯安裝功能,但是由於歷史原因,RPM軟體包管理系統對軟體之間的依存關係沒有內部定義,造成安裝RPM軟體時經常出現令人無法理解的軟體依賴問題。

debian系統則基於apt(Advanced Packaging Tool)工具進行軟體包管理,可以自動解決並安裝倚賴軟體包,因此debian linux被認為是最容易管理和升級的系統,apt工具也被認為是目前最好的軟體包管理工具之一。為了解決redhat包管理系統的致命問題, Conectiva Linux將apt系統移植到了使用rpm軟體包管理系統的Linux系統下,使得基於RPM軟體包的系統可以利用apt工具提供的自動解決倚賴關係的能力。目前已經有很多為redhat linux提供apt方式升級管理軟體包的站點,如 , 等等,使得redhat也成為可以利用apt工具的發行版之一,本文介紹如何在redhat linux系統安裝和使用apt軟體包管理工具。

為了對apt工具的特性有一個大致的瞭解,下面先介紹幾個使用apt with rpm管理系統的例項:

(1)刪除一個軟體包時自動刪除相關軟體包:

[root@linux root]# apt-get remove nessus-common

Processing File Dependencies... Done

Reading Package Lists... Done

Building Dependency Tree... Done

The following packages will be REMOVED:

nessus-client nessus-common nessus-server

0 packages upgraded, 0 newly installed, 3 to remove(replace) and 0 not upgraded.Need to get 0B of archives. After unpacking 4863kB will be freed.

Do you want to continue? [Y/n]

Executing RPM (-e)...

warning: /etc/nessus/nessusd.conf saved as /etc/nessus/nessusd.conf.rpmsave

[root@linux root]#

(2)自動下載安裝依賴包:

[root@linux root]# apt-get install nessus-server

Processing File Dependencies... Done

Reading Package Lists... Done

Building Dependency Tree... Done

The following extra packages will be installed:

nessus-common nmap

The following NEW packages will be installed:

nessus-common nessus-server nmap

0 packages upgraded, 3 newly installed, 0 to remove(replace) and 0 not upgraded.Need to get 1239kB of archives. After unpacking 4889kB will be used.

Do you want to continue? [Y/n]

Get:1 freshrpms/7.2/freshrpms nessus-common 1:1.1.12-fr1 [101kB]

Get:2 freshrpms/7.2/freshrpms nessus-server 1:1.1.12-fr1 [895kB]

Get:3 redhat/i386/7.2/os nmap 2.54BETA22-3 [243kB]

Fetched 1239kB in 54s (22.8kB/s)

Executing RPM (-U)...

Preparing... ########################################### [100%]

1:nessus-common ########################################### [ 33%]

2:nmap ########################################### [ 66%]

3:nessus-server ########################################### [100%]

[root@linux root]#

(3)維護系統軟體,自動更新系統 :

[root@linux root]# apt-get upgrade

Processing File Dependencies... Done

Reading Package Lists... Done

Building Dependency Tree... Done

The following packages will be upgraded

at libxml2 libxml2-devel openldap openldap-clients openldap-devel rsync

7 packages upgraded, 0 newly installed, 0 to remove(replace) and 0 not upgraded.Need to get 2132kB of archives. After unpacking 560kB will be freed.

Do you want to continue? [Y/n]

Get:1 redhat-updates-7.2/redhat/os at 3.1.8-23 [42.6kB]

Get:2 redhat-updates-7.2/redhat/os libxml2 2.4.10-0.7x.2 [360kB]

Get:3 redhat-updates-7.2/redhat/os libxml2-devel 2.4.10-0.7x.2 [617kB]

Get:4 redhat-updates-7.2/redhat/os openldap 2.0.21-1 [424kB]

Get:5 redhat-updates-7.2/redhat/os openldap-clients 2.0.21-1 [114kB]

Get:6 redhat-updates-7.2/redhat/os openldap-devel 2.0.21-1 [462kB]

Get:7 redhat-updates-7.2/redhat/os rsync 2.4.6-8 [112kB]

Fetched 2132kB in 3m8s (11.3kB/s)

Executing RPM (-U)...

Preparing... ########################################### [100%]

1:libxml2 ########################################### [ 14%]

2:rsync ########################################### [ 28%]

3:openldap ########################################### [ 42%]

4:openldap-clients ########################################### [ 57%]

5:openldap-devel ########################################### [ 71%]

6:at ########################################### [ 85%]

7:libxml2-devel ########################################### [100%]

[root@linux root]#

二、安裝apt with rpm及其圖形介面前端Synaptic

下面簡單介紹一下如何下載和安裝apt with rpm

apt with rpm可以直接到 [url][/url] 下載安裝,目前該站點提供了redhat 6.2, 7.x和8.0的軟體升級服務,下面是幾個常用redhat版本的apt下載地址:

redhat 6.2

redhat 7.2

redhat 7.3

redhat 8.0

下載後使用rpm命令安裝:

[root@linux root]# rpm -ihv apt-0.5.4cnc9-fr1.i386.rpm

freshrpms.net同時提供了一個圖形介面的apt-rpm介面Synaptic,使用圖形介面的apt更加方便,安裝了apt後,可以直接利用apt安裝Synaptic:

[root@linux root]# apt-get update

[root@linux root]# apt-get install synaptic

在幾行提示之後Synaptic就安裝好了,進入Xwindow,Synaptic會出現在“系統設定”選單裡面。[Fixme: redhat 7.x版本Synaptic出現在哪裡?]

三、使用apt

在redhat上面使用apt和在debian下面使用幾乎完全一樣,配置檔案在/etc/apt/,按照前面介紹安裝好apt之後就可以使用並可以更新redhat提供的RPM更新以及freshrpms.net提供的更新了。主要執行命令如下:

(1)更新軟體列表,獲取遠端rpm伺服器上的軟體列表和相互依賴關係列表,所有可用軟體的下載地址都在/etc/apt/sources.list裡面定義,下面的多數下載操作地址也是在這裡定義的。

[root@linux root]# apt-get update

(2)檢查本地軟體依賴關係合法性,由於rpm系統的問題,很多系統會存在一些依賴問題,用下面命令檢查依賴關係,同時apt-get會提供一些修復方案,只有本機沒有依賴關係問題了才能良好地使用apt-rpm。一個新安裝的乾淨系統不會有依賴關係問題。

[root@linux root]# apt-get check

(3)安裝或升級一個新軟體

[root@linux root]# apt-get install package-name

package-name是rpm包的名字的前面部分,不包含版本號,如果選擇不同的處理器型別,可以在後面新增@i686等標識。

(4)升級所有系統軟體

[root@linux root]# apt-get upgrade

(5)全面升級,比upgrade更加智慧化的升級,同時解決升級時的一些依賴關係

[root@linux root]# apt-get dist-upgrade

(6)解除安裝軟體,同時解除安裝依賴軟體

[root@linux root]# apt-get remove package-name

(7)清除本地下載的rpm包,rpm包下載後儲存在/var/cache/apt/archieves下面,本命令清除已下載安裝過的rpm檔案

[root@linux root]# apt-get clean

以上所有命令都可以透過圖形介面的前端軟體Synaptic完成,圖形化的軟體使用起來更加直觀,理解了前面幾個主要命令,就可以毫無困難地使用Synaptic了,所以本文不再贅述Synaptic的使用方法了。

四 定製apt-rpm

(1)新增軟體資源列表

在apt-rpm系統裡面新增軟體資源非常容易,只需要按照提供apt服務的伺服器的說明在/etc/apt/sources.list裡面加入對網站的描述即可。

這一行引數的格式為:

rpm uri distribution [component1] [componenent2] [...]

其中,uri為軟體資源的地址,可以是http,ftp,file等URL地址,distribution是redhat發行版本,如 7.2,7.3,8.0等等,後面的component可以忽略。有時候可能只對某軟體資源的一或幾部分部分感興趣,那麼可以在這裡明確指出。

例如新增/ 提供的redhat KDE 3.1的測試軟體包,只需要在sources.list裡面新增一行:

rpm ftp://apt.unl.edu/apt/ 8.0 kde3-test

就將該網站的kde3部分加入了列表。

下面是一些目前可以用於redhat 的apt-rpm軟體資源列表,把它們加入你的 /etc/apt/sources.list 檔案就可以透過apt-rpm使用他們提供的redhat軟體更新和維護了,參看網站說明。(前面是網站名,後面是適用redhat版本和簡介)

/ [/url] - Red Hat Linux 6.2, 7.x and 8.0 repositories (with all freshrpms included of course!)

[/url] - Red Hat Linux 7.x repositories (with all freshrpms included too!)

/ - Red Hat Linux 6.2, 7.x and 8.0 repositories

- Red Hat Linux 6.2, 7.x and Rawhide repositories

- Red Hat Linux 6.2, 7.x, 8.0 and Rawhide repositories

- Red Hat Linux 7.2, 7.3 and 8.0 repositories

ftp://mirror.pa.msu.edu/apt/ - Red Hat Linux 7.2, 7.3 and 8.0 repositories

- Red Hat Linux 7.2, 7.3 and 8.0 and gnomehide repositories

- Red Hat Linux 7.2, 7.3 and 8.0 repositories

- A few Red Hat Linux 7.2 custom packages

~matt/repository.html - Lots of custom Red Hat Linux 8.0 GNOME 2 and related packages

[url] - Red Hat Linux 7.x, 8.x and rawhide

[url]/ - Red Hat Linux 7.3 and 8.0

[url] - KDE for Red Hat project

(2)把redhat安裝盤新增到軟體源

有的時候需要從redhat安裝光碟或者iso檔案安裝、解除安裝軟體,這時可以把redhat安裝光碟設定為軟體源。這種工作方式需要首先掃面安裝光碟上的軟體包,並在 /var/lib/apt/cdroms.list檔案中建立光碟軟體列表。

如果使用redhat光碟,只需要把光碟插入光碟機,下面命令會自動mount光碟並建立列表

[root@linux root]# apt-cdrom add

如果是使用ISO檔案安裝,首先mount ISO檔案到mount-point,把mount point輸入,就可以自動搜尋RPM軟體列表了。

[root@linux root]# apt-cdrom -m -d mount-point add

如果是解開的硬碟映像安裝,只需要把路徑輸入,就可以自動搜尋RPM軟體列表了。

[root@linux root]# apt-cdrom -m -d path add

五 例項

(1)安裝mplayer

[root@linux root]# apt-get install mplayer

Reading Package Lists... Done

Collecting File Provides... Done

Building Dependency Tree... Done

The following extra packages will be installed:

aalib libdv libdvdcss libdvdcss-devel libdvdread libdvdread-devel lirc

xvidcore

The following packages will be upgraded

libdvdcss libdvdcss-devel libdvdread libdvdread-devel

The following NEW packages will be installed:

aalib libdv lirc mplayer xvidcore

4 packages upgraded, 5 newly installed, 0 removed and 14 not upgraded.

Need to get 5417kB/5471kB of archives.

After unpacking 15.3MB of additional disk space will be used.

Do you want to continue? [Y/n]

Get:1 redhat/8.0/en/i386/freshrpms aalib 1.4rc5-fr1 [104kB]

Get:2 redhat/8.0/en/i386/freshrpms libdv 0.99-fr1 [240kB]

Get:3 redhat/8.0/en/i386/freshrpms libdvdread-devel 0.9.4-fr2 [63.4kB]

Get:4 redhat/8.0/en/i386/freshrpms libdvdread 0.9.4-fr2 [56.3kB]

Get:5 redhat/8.0/en/i386/freshrpms lirc 0.6.5-fr3 [373kB]

Get:6 redhat/8.0/en/i386/freshrpms xvidcore 0.9.0-fr3 [159kB]

Get:7 redhat/8.0/en/i386/freshrpms mplayer 0.90-fr0.5rc4 [4422kB]

Fetched 5417kB in 31s (174kB/s)

Executing RPM (-Uvh)...

warning: /var/cache/apt/archives/aalib_1.4rc5-fr1_i386.rpm: V3 DSA signature: NOKEY, key ID e42d547b

Preparing... ########################################### [100%]

1:aalib ########################################### [ 11%]

2:libdv ########################################### [ 22%]

3:libdvdcss-devel ########################################### [ 33%]

4:libdvdcss ########################################### [ 44%]

5:libdvdread-devel ########################################### [ 56%]

6:libdvdread ########################################### [ 67%]

7:lirc ########################################### [ 78%]

8:xvidcore ########################################### [ 89%]

9:mplayer ########################################### [100%]

注:有兩個包曾經下載過,所以本次不再下載。

(2)安裝kde 3.1 for redhat 的測試包

定義資源:為了簡單,把下面一行加入/etc/apt/sources.list,並暫時把其它資源列表註釋掉

rpm ftp://apt.unl.edu/apt/ 8.0 kde3-test

執行完整升級:

[root@linux root]# apt-get dist-upgrade

OK, 體驗一下KDE 3.1的新特性吧!

六 其它資源

- General information and scripts to create repositories (focused initially on SuSE)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-939149/,如需轉載,請註明出處,否則將追究法律責任。

相關文章