升级 RPM 包

既然已经了解了如何安装和删除 RPM,我们来看看如何把 RPM 包升级到更高级别。可以使用 yum update 更新整个系统,还可以指定单一包或通配符。清单 8 说明如何更新所有名称以 “gr” 开头的包。注意,这里使用撇号防止 shell 展开 “*”。

清单 8. 使用 yum update 执行更新


[root@echidna ~]# yum update 'gr*'
Loaded plugins: presto, refresh-packagekit
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package grep.x86_64 0:2.6.3-1.fc12 set to be updated
---> Package groff.x86_64 0:1.18.1.4-20.fc12 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================
 Package         Arch             Version                    Repository         Size
=====================================================================================
Updating:
 grep            x86_64           2.6.3-1.fc12               updates           228 k
 groff           x86_64           1.18.1.4-20.fc12           updates           1.5 M

Transaction Summary
=====================================================================================
Install       0 Package(s)
Upgrade       2 Package(s)

Total download size: 1.7 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Download delta size: 854 k
http://fedora.fastsoft.net/pub/linux/fedora/linux/updates/12/x86_64/drpms/grep-2.5.3-
6.fc12_2.6.3-1.fc12.x86_64.drpm: [Errno 14] HTTP Error 404 : http://fedora.fastsoft.n
et/pub/linux/fedora/linux/updates/12/x86_64/drpms/grep-2.5.3-6.fc12_2.6.3-1.fc12.x86_
64.drpm 
Trying other mirror.
(1/2): grep-2.5.3-6.fc12_2.6.3-1.fc12.x86_64.drpm             | 214 kB     00:00     
(2/2): groff-1.18.1.4-18.fc12_1.18.1.4-20.fc12.x86_64.drpm    | 640 kB     00:00     
Finishing rebuild of rpms, from deltarpms
<delta rebuild>                                               | 1.7 MB     00:02     
Presto reduced the update size by 52% (from 1.7 M to 854 k).
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : grep-2.6.3-1.fc12.x86_64                                      1/4 
  Updating       : groff-1.18.1.4-20.fc12.x86_64                                 2/4 
  Cleanup        : grep-2.5.3-6.fc12.x86_64                                      3/4 
  Cleanup        : groff-1.18.1.4-18.fc12.x86_64                                 4/4 

Updated:
  grep.x86_64 0:2.6.3-1.fc12             groff.x86_64 0:1.18.1.4-20.fc12            

Complete!

如果知道 RPM 文件的位置,或者已经下载了它们,那么也可以使用 rpm 命令执行更新。这与安装相似,只是要使用 -U 或 -F 选项而不是 -i 选项。这两个选项的差异是, -U 选项更新现有的包,如果这个包还没有安装,就安装它;而 -F 选项只升级或刷新 已经安装的包。因此,经常使用 -U 选项,尤其是在命令行包含 RPM 列表的情况下。这样的话,就会安装未安装的包,升级已经安装的包。常常使用另外两个选项 -v详细)和 -h# 标志)提供进度显示。清单 9 说明如何使用 rpm 命令更新 vim-common、vim-enhanced 和 vim-minimal 包。我们已经把 vim-common 和 vim-enhanced 包下载到根用户的主目录中,而 vim-minimal 包要从一个更新镜像获取。

清单 9. 用 rpm 更新包


[root@echidna ~]# ls *.rpm
vim-common-7.2.411-1.fc12.x86_64.rpm  vim-enhanced-7.2.411-1.fc12.x86_64.rpm
[root@echidna ~]# rpm -Uvh *.rpm http://mirrors.usc.edu/pub/linux/distributions\
> /fedora/linux/updates/12/x86_64/vim-minimal-7.2.411-1.fc12.x86_64.rpm
Retrieving http://mirrors.usc.edu/pub/linux/distributions/fedora/linux/updates/12/x86
_64/vim-minimal-7.2.411-1.fc12.x86_64.rpm
Preparing...                ########################################### [100%]
   1:vim-common             ########################################### [ 33%]
   2:vim-enhanced           ########################################### [ 67%]
   3:vim-minimal            ########################################### [100%]


相关内容