解决安装rpm包依赖关系的烦恼(2)

--安装gcc-c++包,提示因为依赖关系缺少包而无法安装
--若采用手工安装,在安装提示的rpm包过程中,可能还存在其他需要的依赖关系包
[root@sunny Desktop]# rpm -ivh gcc-c++-4.1.2-52.el5.x86_64.rpm
warning: gcc-c++-4.1.2-52.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
        gcc = 4.1.2-52.el5 is needed by gcc-c++-4.1.2-52.el5.x86_64
        libstdc++-devel = 4.1.2-52.el5 is needed by gcc-c++-4.1.2-52.el5.x86_64

--下面开始通过配置本地源yum的方法从镜像光盘安装

--查看文件系统,此时未挂载cdrom
[root@sunny ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      16G  6.1G  8.7G  42% /
/dev/sda1              99M  13M  81M  14% /boot
tmpfs                1004M    0 1004M  0% /dev/shm

--创建cdrom的挂载点目录
--挂载点目录名随意,此处作者创建目录名为cdrom的目录作为挂载点
[root@sunny ~]# mkdir /cdrom

--挂载cdrom,并查看挂载情况
[root@sunny ~]# mount /dev/cdrom /cdrom
[root@sunny ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      16G  6.1G  8.7G  42% /
/dev/sda1              99M  13M  81M  14% /boot
tmpfs                1004M    0 1004M  0% /dev/shm
/dev/sr0              3.9G  3.9G    0 100% /cdrom

--进入cdrom目录,确定rpm包的位置
--需要注意,rpm包所在的目录绝对路径将作为后面yum的url源路径
[root@sunny Server]# pwd
/cdrom/Server

--创建filename.repo文件,此处作者定义filename.repo名为newyum.repo
--需要注意,由于是baseurl以及gpgkey均是本地位置,因此采用file://协议
--需要注意,file://后面是文件所在的绝对路径,因此file://后面会以/开头,因此是file:///(三个/)
[root@sunny yum.repos.d]# vi /etc/yum.repos.d/newyum.repo
[redhatcdrom]
name=local resource
baseurl=fill:///cdrom/Server
enabled=1
gpgcheck=1
gpgkey=https://www.linuxidc.com/file:/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

--查询此时可用的软件仓库,显示刚刚配置的库可用
[root@sunny yum.repos.d]# yum repolist
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
redhatcdrom                                          | 1.5 kB    00:00   
redhatcdrom/primary                                  | 920 kB    00:00   
redhatcdrom                                                        3285/3285
repo id                repo name                                  status
redhatcdrom            local resource                            3,285
repolist: 3,285

--利用yum安装刚才的gcc-c++包
--可以看到,安装过程中,yum处理了依赖关系,并将相应的包进行了安装
[root@sunny yum.repos.d]# yum install gcc-c++ -y
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
redhatcdrom                                                        | 1.5 kB    00:00   
redhatcdrom/primary                                                | 920 kB    00:00   
redhatcdrom                                                                  3285/3285
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.1.2-52.el5 set to be updated
--> Processing Dependency: libstdc++-devel = 4.1.2-52.el5 for package: gcc-c++
--> Processing Dependency: gcc = 4.1.2-52.el5 for package: gcc-c++
--> Running transaction check
---> Package gcc.x86_64 0:4.1.2-52.el5 set to be updated
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
---> Package libstdc++-devel.x86_64 0:4.1.2-52.el5 set to be updated
redhatcdrom/filelists                                                | 2.8 MB    00:00   
--> Running transaction check
---> Package glibc-devel.x86_64 0:2.5-81 set to be updated
--> Processing Dependency: glibc-headers = 2.5-81 for package: glibc-devel
--> Processing Dependency: glibc-headers for package: glibc-devel
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.5-81 set to be updated
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers
--> Processing Dependency: kernel-headers for package: glibc-headers
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.18-308.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12201.html