最近要给局域网linux机器安装一些rpm包,奈何依赖是个痛苦的问题。
搜索了很久还是决定采取修改本机yum为iso package的方法。实践成功,简要介绍如下:
准备工作:
1、已经安装好centos的系统主机一台
2、centos iso或光盘一张
**********************************************************
1、将主机base源及media源备份并将media源切换至iso mount目录
root权限操作:
cd /etc/yum.repos.d/mv CentOS-Base.repo CentOS-Base.repo.bakcp CentOS-Media.repo CentOS-Media.repo.bakvi CentOS-Media.repo
修改处见#之后的描述(实际修改无需#说明)
# CentOS-Media.repo## This repo can be used with mounted DVD media, verify the mount point for# CentOS-7. You can use this repo and yum to install items directly off the# DVD ISO that we release.## To use this repo, put in your DVD and use it with the other repos too:# yum --enablerepo=c7-media [command]## or for ONLY the media repo, do this:## yum --disablerepo=\* --enablerepo=c7-media [command][c7-media]name=CentOS-$releasever - Mediabaseurl=file:///media/CentOS/# file:///media/cdrom/ #这一行注释掉# file:///media/cdrecorder/ #这一行注释掉gpgcheck=1enabled=1 #结果由0改为1,表示配置生效gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
2、将iso光盘插入光驱或将iso包挂载到机器中(本次测试直接将iso挂载到虚拟机centos中)
执行命令:
注意:必须纯iso挂载,不可修改iso源文件,否则list会报错,不知道达人是否遇到此情况。本来想ultraiso加一点自己的脚本,但被阻碍,无奈...
# mkdir /media/CentOS# mount -t auto /dev/cdrom /media/CentOSmount: /dev/sr0 is write-protected, mounting read-only# yum clean allLoaded plugins: fastestmirrorCleaning repos: c7-mediaCleaning up everything# yum listLoaded plugins: fastestmirrorc7-media | 3.6 kB 00:00:00 (1/2): c7-media/group_gz | 155 kB 00:00:00 (2/2): c7-media/primary_db | 2.8 MB 00:00:00 Determining fastest mirrorsInstalled PackagesNetworkManager.x86_64 1:1.0.6-27.el7 @anacondaNetworkManager-libnm.x86_64 1:1.0.6-27.el7 @anacondaNetworkManager-team.x86_64 1:1.0.6-27.el7 @anaconda......zenity.x86_64 3.8.0-5.el7 c7-media zip.x86_64 3.0-10.el7 c7-media zlib-devel.x86_64 1.2.7-15.el7 c7-media zsh.x86_64 5.0.2-14.el7 c7-media zziplib.x86_64 0.13.62-5.el7 c7-media
测试安装policycoreutils-python,这个依赖我不说大家都懂的。。。很难搞定纯rpm
# yum install -y policycoreutils-pythonLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package policycoreutils-python.x86_64 0:2.2.5-20.el7 will be installed--> Processing Dependency: libsemanage-python >= 2.1.10-1 for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Processing Dependency: python-IPy for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Processing Dependency: libcgroup for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64--> Running transaction check---> Package audit-libs-python.x86_64 0:2.4.1-5.el7 will be installed---> Package checkpolicy.x86_64 0:2.1.12-6.el7 will be installed---> Package libcgroup.x86_64 0:0.41-8.el7 will be installed---> Package libsemanage-python.x86_64 0:2.1.10-18.el7 will be installed---> Package python-IPy.noarch 0:0.75-6.el7 will be installed---> Package setools-libs.x86_64 0:3.3.7-46.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved==================================================================================================================================================================================================== Package Arch Version Repository Size====================================================================================================================================================================================================Installing: policycoreutils-python x86_64 2.2.5-20.el7 c7-media 435 kInstalling for dependencies: audit-libs-python x86_64 2.4.1-5.el7 c7-media 69 k checkpolicy x86_64 2.1.12-6.el7 c7-media 247 k libcgroup x86_64 0.41-8.el7 c7-media 64 k libsemanage-python x86_64 2.1.10-18.el7 c7-media 94 k python-IPy noarch 0.75-6.el7 c7-media 32 k setools-libs x86_64 3.3.7-46.el7 c7-media 485 kTransaction Summary====================================================================================================================================================================================================Install 1 Package (+6 Dependent packages)Total download size: 1.4 MInstalled size: 4.5 MDownloading packages:warning: /media/CentOS/Packages/audit-libs-python-2.4.1-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPublic key for audit-libs-python-2.4.1-5.el7.x86_64.rpm is not installed----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total 2.9 MB/s | 1.4 MB 00:00:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key)" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@anaconda) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : audit-libs-python-2.4.1-5.el7.x86_64 1/7 Installing : libsemanage-python-2.1.10-18.el7.x86_64 2/7 Installing : python-IPy-0.75-6.el7.noarch 3/7 Installing : checkpolicy-2.1.12-6.el7.x86_64 4/7 Installing : libcgroup-0.41-8.el7.x86_64 5/7 Installing : setools-libs-3.3.7-46.el7.x86_64 6/7 Installing : policycoreutils-python-2.2.5-20.el7.x86_64 7/7 Verifying : setools-libs-3.3.7-46.el7.x86_64 1/7 Verifying : libcgroup-0.41-8.el7.x86_64 2/7 Verifying : checkpolicy-2.1.12-6.el7.x86_64 3/7 Verifying : python-IPy-0.75-6.el7.noarch 4/7 Verifying : libsemanage-python-2.1.10-18.el7.x86_64 5/7 Verifying : policycoreutils-python-2.2.5-20.el7.x86_64 6/7 Verifying : audit-libs-python-2.4.1-5.el7.x86_64 7/7 Installed: policycoreutils-python.x86_64 0:2.2.5-20.el7 Dependency Installed: audit-libs-python.x86_64 0:2.4.1-5.el7 checkpolicy.x86_64 0:2.1.12-6.el7 libcgroup.x86_64 0:0.41-8.el7 libsemanage-python.x86_64 0:2.1.10-18.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.7-46.el7 Complete!
最后安装成功
2016-2-3