linux架设YUM源实现RPM包的自动化安装--彻底摆脱依赖性
架设YUM源实现RPM包的自动化安装--彻底摆脱依赖性

--转载请标明出处:http://hi.baidu.com/zgqin0

在RedHat系统的实际应用中.安装RPM包是一项必不可少的工序!但在安装过程中我们会遇到各种各样的程序依赖关系,所以我们在无奈之下选择强制安装的话那出错的几率会很高!如何实现RPM包的自动化流畅安装呐!以下将通过架设自己的YUM源来实现.linux软件包的自动化安装,彻底摆脱烦人的依赖性关系!
[root@localhost ~]# mkdir /media/zidong    //首先建立一个属于我们自己的仓库文件夹
[root@localhost ~]# cd /media/
[root@localhost media]# mount /dev/cdrom /media/zidong/
[root@localhost media]# cd /media/zidong/Server/
首先我们也得需要安装一个软件包来实现以下的架设源任务
[root@localhost Server]# rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm   //安装架设源软件包
[root@localhost zidong]# cd /media
[root@localhost media]# createrepo .
[root@localhost media]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv rhel-debuginfo.repo cc.repo             //为了方便我重新命名配置文件名字随意我就用cc.repo
[root@localhost yum.repos.d]# vim cc.repo
-----------------------------------------
[cc]                                                      //文件里面的内容修改成这个样子就可以
name=cc
baseurl=file:///media
enabled=1
gpgcheck=0
-----------------------------------------

其实到此我们已经搭建完毕下面我们测试一下
[root@localhost yum.repos.d]# rpm -qa | grep bind                            //先查看一下系统中已经安装的DNS有关的软件包
ypbind-1.19-7.el5
bind-libs-9.3.3-7.el5
bind-utils-9.3.3-7.el5
[root@localhost yum.repos.d]# rpm -e `rpm -qa | grep bind` --nodeps         //我们强制删除

安装时我们使用以下命令然后系统会自动辨别依赖性关系.自动安装过程如下:
[root@localhost yum.repos.d]# yum install bind* -y
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
Repository 'cc' is missing name in configuration, using id
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for bind-chroot to pack into transaction set.
bind-chroot-9.3.3-7.el5.i 100% |=========================| 38 kB    00:00
---> Package bind-chroot.i386 30:9.3.3-7.el5 set to be updated
---> Downloading header for bind-sdb to pack into transaction set.
bind-sdb-9.3.3-7.el5.i386 100% |=========================| 40 kB    00:00
---> Package bind-sdb.i386 30:9.3.3-7.el5 set to be updated
---> Downloading header for bind-libbind-devel to pack into transaction set.
bind-libbind-devel-9.3.3- 100% |=========================| 41 kB    00:00
---> Package bind-libbind-devel.i386 30:9.3.3-7.el5 set to be updated
---> Downloading header for bind-devel to pack into transaction set.
bind-devel-9.3.3-7.el5.i3 100% |=========================| 82 kB    00:00
---> Package bind-devel.i386 30:9.3.3-7.el5 set to be updated
---> Downloading header for bind-libs to pack into transaction set.
bind-libs-9.3.3-7.el5.i38 100% |=========================| 38 kB    00:00
---> Package bind-libs.i386 30:9.3.3-7.el5 set to be updated
---> Downloading header for bind-utils to pack into transaction set.
bind-utils-9.3.3-7.el5.i3 100% |=========================| 37 kB    00:00
---> Package bind-utils.i386 30:9.3.3-7.el5 set to be updated
---> Downloading header for bind to pack into transaction set.
bind-9.3.3-7.el5.i386.rpm 100% |=========================| 49 kB    00:00
---> Package bind.i386 30:9.3.3-7.el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
bind                    i386       30:9.3.3-7.el5   cc                954 k
bind-chroot             i386       30:9.3.3-7.el5   cc                 38 k
bind-devel              i386       30:9.3.3-7.el5   cc                2.6 M
bind-libbind-devel      i386       30:9.3.3-7.el5   cc                440 k
bind-libs               i386       30:9.3.3-7.el5   cc                834 k
bind-sdb                i386       30:9.3.3-7.el5   cc                223 k
bind-utils              i386       30:9.3.3-7.el5   cc                162 k

Transaction Summary
=============================================================================
Install      7 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 5.1 M
Downloading Packages:
Running Transaction Test
warning: bind-chroot-9.3.3-7.el5: Header V3 DSA signature: NOKEY, key ID 37017186
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: bind-libs                    ######################### [1/7]
Installing: bind                         ######################### [2/7]
Installing: bind-utils                   ######################### [3/7]
Installing: bind-chroot                  ######################### [4/7]
Locating /var/named/chroot//etc/named.conf failed:
[FAILED]
Installing: bind-sdb                     ######################### [5/7]
Installing: bind-libbind-devel           ######################### [6/7]
Installing: bind-devel                   ######################### [7/7]

Installed: bind.i386 30:9.3.3-7.el5 bind-chroot.i386 30:9.3.3-7.el5 bind-devel.i386 30:9.3.3-7.el5 bind-libbind-devel.i386 30:9.3.3-7.el5 bind-libs.i386 30:9.3.3-7.el5 bind-sdb.i386 30:9.3.3-7.el5 bind-utils.i386 30:9.3.3-7.el5
Complete!
[root@localhost yum.repos.d]# rpm -qa | grep bind                //我们再次查看一下自动安装的结果如何(看看安装的够全面吧.最主要的是它是完全符合依赖性关系的)
bind-9.3.3-7.el5
bind-libbind-devel-9.3.3-7.el5
bind-libs-9.3.3-7.el5
bind-utils-9.3.3-7.el5
bind-sdb-9.3.3-7.el5
bind-devel-9.3.3-7.el5
bind-chroot-9.3.3-7.el5