昔我往矣

搭建本地yum仓库

2012年03月24日

在rpm安装的时候,最怕见到的就是依赖:要想安装A软件包,请先安装B软件,要想安装B软件包,请先升级C软件包...最可恶的是,要想安装Z软件包,请先安装A软件包。有时候,某个软件的安装可能要依赖其他上百个软件包,实在不可能一个一个手工完成,虽然rpm可以使用参数忽略依赖,强制安装,但是难免会影响使用。

但是幸好,RedHat还提供了另外一种自动解决依赖问题的安装方式:yum(Yellow dog Updater, Modified)!!!
下面就来详细的讲解一次yum仓库的搭建过程!这次,我新安装了一个RedHat的虚拟机,只安装了最简单的桌面环境。现在想要安装VirtualBox的增强功能,安装失败。日志记录中说明缺乏gcc的编译环境,所以要先安装gcc。
先挂载RedHat的安装光盘。

#mount /dev/cdrom /mnt
#cd /mnt/Packages
#rpm -ivh rpm -ivh gcc-4.4.4-13.el6.i686.rpm 

安装失败,提示存在软件依赖关系。为了解决这个依赖,于是我先搭建一个yum仓库。
建立存放rpm包的目录,并把安装光盘里的rpm包拷贝到该目录下。

#mkdir -p /usr/local/src/yum
#cp -vrf /mnt/Packages /usr/local/src/yum/

根据自己的习惯,给Packages目录改个名字rpms。

#cd /usr/local/src/yum/
#mv Packages rpms

安装createrepo工具,稍候将用这个工具创建yum仓库。

#cd rpms/
#rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm 

存在依赖,于是先安装了另外的两个包:

#rpm -ivh deltarpm-3.5-0.5.20090913git.el6.i686.rpm 
#rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm 

安装成功createrepo之后5,重建仓库信息配置文件

#createrepo  /usr/local/src/yum(这个配置文件在/usr/local/src/yum/repodata/下)

在/etc/yum.repos.d下创建yum.repo文件输入:

[rpms]
  name=rpms
  baseurl=file:///usr/local/src/yum
  enabled=1
  gpgcheck=0
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release

  测试

#yum list | more
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Installed Packages
ConsoleKit.i686                        0.4.1-3.el6                         @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
ConsoleKit-libs.i686                   0.4.1-3.el6                         @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
ConsoleKit-x11.i686                    0.4.1-3.el6                         @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
DeviceKit-power.i686                   014-1.el6                           @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
GConf2.i686                            2.28.0-6.el6                        @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
GConf2-gtk.i686                        2.28.0-6.el6                        @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
MAKEDEV.i686                           3.24-6.el6                          @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
ModemManager.i686                      0.4.0-3.git20100628.el6             @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
NetworkManager.i686                    1:0.8.1-5.el6                       @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
NetworkManager-glib.i686               1:0.8.1-5.el6                       @anaconda-RedHatEnterpriseLi
nux-201009221732.i386/6.0
NetworkManager-gnome.i686              1:0.8.1-5.el6                       @anaconda-RedHatEnterpriseLi
more

安装gcc。激动人心的时刻到了!!!

# yum install gcc
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.i686 0:4.4.4-13.el6 set to be updated
--> Processing Dependency: cpp = 4.4.4-13.el6 for package: gcc-4.4.4-13.el6.i686
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.4-13.el6.i686
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.4-13.el6.i686
--> Running transaction check
---> Package cloog-ppl.i686 0:0.15.7-1.2.el6 set to be updated
--> Processing Dependency: libppl.so.7 for package: cloog-ppl-0.15.7-1.2.el6.i686
--> Processing Dependency: libppl_c.so.2 for package: cloog-ppl-0.15.7-1.2.el6.i686
---> Package cpp.i686 0:4.4.4-13.el6 set to be updated
--> Processing Dependency: libmpfr.so.1 for package: cpp-4.4.4-13.el6.i686
---> Package glibc-devel.i686 0:2.12-1.7.el6 set to be updated
--> Processing Dependency: glibc-headers = 2.12-1.7.el6 for package: glibc-devel-2.12-1.7.el6.i686
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.7.el6.i686
--> Running transaction check
---> Package glibc-headers.i686 0:2.12-1.7.el6 set to be updated
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.7.el6.i686
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.7.el6.i686
---> Package mpfr.i686 0:2.4.1-6.el6 set to be updated
---> Package ppl.i686 0:0.10.2-11.el6 set to be updated
--> Running transaction check
---> Package kernel-headers.i686 0:2.6.32-71.el6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch         Version                 Repository    Size
================================================================================
Installing:
 gcc                    i686         4.4.4-13.el6            rpms         8.1 M
Installing for dependencies:
 cloog-ppl              i686         0.15.7-1.2.el6          rpms          93 k
 cpp                    i686         4.4.4-13.el6            rpms         3.4 M
 glibc-devel            i686         2.12-1.7.el6            rpms         960 k
 glibc-headers          i686         2.12-1.7.el6            rpms         599 k
 kernel-headers         i686         2.6.32-71.el6           rpms         965 k
 mpfr                   i686         2.4.1-6.el6             rpms         153 k
 ppl                    i686         0.10.2-11.el6           rpms         1.3 M

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

Total download size: 15 M
Installed size: 34 M
Is this ok [y/N]: y
Downloading Packages:
--------------------------------------------------------------------------------
Total                                            32 MB/s |  15 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing     : kernel-headers-2.6.32-71.el6.i686                        1/8 
  Installing     : ppl-0.10.2-11.el6.i686                                   2/8 
  Installing     : cloog-ppl-0.15.7-1.2.el6.i686                            3/8 
  Installing     : mpfr-2.4.1-6.el6.i686                                    4/8 
  Installing     : glibc-headers-2.12-1.7.el6.i686                          5/8 
  Installing     : cpp-4.4.4-13.el6.i686                                    6/8 
  Installing     : glibc-devel-2.12-1.7.el6.i686                            7/8 
  Installing     : gcc-4.4.4-13.el6.i686                                    8/8 

Installed:
  gcc.i686 0:4.4.4-13.el6                                                       

Dependency Installed:
  cloog-ppl.i686 0:0.15.7-1.2.el6         cpp.i686 0:4.4.4-13.el6              
  glibc-devel.i686 0:2.12-1.7.el6         glibc-headers.i686 0:2.12-1.7.el6    
  kernel-headers.i686 0:2.6.32-71.el6     mpfr.i686 0:2.4.1-6.el6              
  ppl.i686 0:0.10.2-11.el6               

Complete!

成功安装好gcc之后,安装VirtualBox的增强功能也就一部搞定了!!!
  
以上过程,参考于http://blog.csdn.net/shenkxiao/article/details/7079722

当前暂无评论 »

添加新评论 »