源码安装yum

 
  

有兴趣参考,想自己装着试试,请做好吐血准备 首先介绍下我使用的系统是:redhat6.0.一开始是有安装yum的.所以要卸载旧版本的yum 检测命令: rpm -qa |grep yum 删除命令: rpm -e yum* --nodeps 再检查一遍是否已经完全删除yum了 准备工具: iso安装包一个,里面提供了基本的lib,这样就不需要我们一个一个到网上找了. 我使用的是redhat6.0的iso 下载yum的最新版源码包:目前是yum-3.4.3.tar.gz 下载链接 http://yum.baseurl.org/ 1.挂载光驱

		[liaoque@localhost ~]$ mount -o loop /dev/dvdrw /media
			mount: only root can do that	//如果提示这个请示用su命令切换到root权限
		[liaoque@localhost ~]$ su
		密码:
		[root@localhost liaoque]# mount -o loop /dev/dvdrw /media

2.进入lib文件夹

[root@localhost liaoque]#  cd /media/Server/Packages

3.打开另外一个控制台

[root@localhost liaoque]#  tar -zxvf yum-3.4.3.tar.gz //解压源码包
 这个源码包必须先编译成rpm包能安装,并没有.configure这个文件,所以不能直接编译安装 
  
好吧,服务器上一般都不会装rpm的软件制作包,所以我们要自己安装
4.按照惯例先检测下rpmbuild是否存在  
[root@localhost liaoque]#rpm -qa |grep rpmbuild  //不出所料,就不存在rpmbuild

5.使用第一个终端

rpm -ivh rpm连按两下tab,查看rpm的安装包
		[root@localhost Packages]# rpm -ivh rpm
		rpm-4.8.0-12.el6.i686.rpm         rpm-libs-4.8.0-12.el6.i686.rpm
		rpm-build-4.8.0-12.el6.i686.rpm   rpmlint-0.94-2.el6.noarch.rpm
		rpm-devel-4.8.0-12.el6.i686.rpm   rpm-python-4.8.0-12.el6.i686.rpm
		rpmdevtools-7.5-1.el6.noarch.rpm  
		
		顾名思义,安装 rpm-build-4.8.0-12.el6.i686.rpm;
		[root@localhost Packages]# rpm -ivh rpm-build-4.8.0-12.el6.i686.rpm
		warning: rpm-build-4.8.0-12.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
		Preparing...                ########################################### [100%]
		   1:rpm-build              ########################################### [100%]
		
		提示:	warning: rpm-build-4.8.0-12.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
		原因:	yum安装了旧版本的GPG keys
		解决:	rpm --import /etc/pki/rpm-gpg/RPM*
		
		//rpmdevtools也是必须安装的,里面用到rpmdev-setuptree 会自动帮你创建一些必要的文件夹和配置
		//从这里痛苦也就开始了
		[root@localhost Packages]# rpm -ivh rpmdevtools-7.5-1.el6.noarch.rpm 
			error: Failed dependencies:
			fakeroot is needed by rpmdevtools-7.5-1.el6.noarch
			//安装错误提示依赖 fakeroot
		[root@localhost Packages]# rpm -ivh fakeroot-
		fakeroot-1.12.2-22.2.el6.i686.rpm
		fakeroot-libs-1.12.2-22.2.el6.i686.rpm
		[root@localhost Packages]# rpm -ivh fakeroot-libs-1.12.2-22.2.el6.i686.rpm 
		Preparing...                ########################################### [100%]
		   1:fakeroot-libs          ########################################### [100%]
		[root@localhost Packages]# rpm -ivh fakeroot-1.12.2-22.2.el6.i686.rpm 
		Preparing...                ########################################### [100%]
		   1:fakeroot               ########################################### [100%]
		[root@localhost Packages]# rpm -ivh rpmdevtools-7.5-1.el6.noarch.rpm 
		Preparing...                ########################################### [100%]
		   1:rpmdevtools            ########################################### [100%]


6.使用rpmdev-setuptree 配置rpm软件打包环境

		[root@localhost Packages]# su liaoque
		使用su liaoque回到当前用户
		[liaoque@localhost Packages]$ rpmdev-setuptree

7.使用第二个终端

		[root@localhost 桌面]# ls
			yum-3.4.3  yum-3.4.3.tar.gz	//yum-3.4.3是我解压出来的文件夹
		[root@localhost 桌面]# cd yum-3.4.3
		[root@localhost yum-3.4.3]# mv yum-3.4.3/* /home/liaoque/rpmbuild/SOURCES/
		[root@localhost 桌面]# cp yum-3.4.3.tar.gz  /home/liaoque/rpmbuild/SOURCES/
		//移动解压出来的文件夹里面的所有文件到/home/liaoque/rpmbuild/SOURCES/
		//复制yum-3.4.3.tar.gz到/home/liaoque/rpmbuild/SOURCES/
		[root@localhost 桌面]#cd /home/liaoque/rpmbuild/SOURCES
 
  

8.使用 rpmbuild -bb yum.spec

		[root@localhost SOURCES]# rpmbuild -bb yum.spec 
		error: File /root/rpmbuild/SOURCES/yum-3.4.2.tar.gz: 没有那个文件或目录
		[root@localhost SOURCES]#  vi yum.spec 
		Version: 3.4.2 替换成我们源码包的版本Version: 3.4.3
		:wq 保存退出
		还有我现在使用的是root用户
		但是操作我是在liaoque的家目录里面操作的,所以要换成liaoque这个用户进行编译

		[liaoque@localhost SOURCES]$ rpmbuild -bb yum.spec
			error: Failed build dependencies:
			gettext is needed by yum-3.4.3-0.noarch
			intltool is needed by yum-3.4.3-0.noarch
		提示依赖这两个文件
		
		使用第一个终端安装吧,
		[root@localhost Packages]# rpm -ivh gettext-
			gettext-0.17-16.el6.i686.rpm        gettext-libs-0.17-16.el6.i686.rpm
			gettext-devel-0.17-16.el6.i686.rpm  
		[root@localhost Packages]# rpm -ivh gettext-libs-0.17-16.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			1:gettext-libs           ########################################### [100%]
		[root@localhost Packages]# rpm -ivh gettext-0.17-16.el6.i686.rpm 
			error: Failed dependencies:
				cvs is needed by gettext-0.17-16.el6.i686
		提示依赖cvs
		[root@localhost Packages]# rpm -ivh cvs-1.11.23-11.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:cvs                    ########################################### [100%]
		[root@localhost Packages]# rpm -ivh gettext-0.17-16.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			1:gettext                ########################################### [100%]
		[root@localhost Packages]# rpm -ivh gettext-devel-0.17-16.el6.i686.rpm 
			error: Failed dependencies:
				libgcj_bc.so.1 is needed by gettext-devel-0.17-16.el6.i686
		[root@localhost Packages]# rpm -ivh libgcj-4.4.4-13.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:libgcj                 ########################################### [100%]
		[root@localhost Packages]# rpm -ivh gettext-devel-0.17-16.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:gettext-devel          ########################################### [100%]
		gettext安装结束
		
		[root@localhost Packages]# rpm -ivh intltool-0.41.0-1.1.el6.noarch.rpm 
			error: Failed dependencies:
				automake is needed by intltool-0.41.0-1.1.el6.noarch
				perl(XML::Parser) is needed by intltool-0.41.0-1.1.el6.noarch
		[root@localhost Packages]# rpm -ivh automake-1.11.1-1.2.el6.noarch.rpm 
			error: Failed dependencies:
				autoconf >= 2.62 is needed by automake-1.11.1-1.2.el6.noarch
		
		[root@localhost Packages]# rpm -ivh autoconf-2.63-5.1.el6.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:autoconf               ########################################### [100%]
			[root@localhost Packages]# rpm -ivh automake-1.11.1-1.2.el6.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:automake               ########################################### [100%]
		
		[root@localhost Packages]# rpm -ivh perl-XML-Parser-2.36-7.el6.i686.rpm 
			error: Failed dependencies:
				perl(LWP) is needed by perl-XML-Parser-2.36-7.el6.i686
				perl(URI) is needed by perl-XML-Parser-2.36-7.el6.i686
				perl(URI::file) is needed by perl-XML-Parser-2.36-7.el6.i686
				perl(LWP) 的真正名字是 perl-libwww-perl
				perl(URI) 只需要安装perl-URI, perl(URI::file)也就存在了
		[root@localhost Packages]# rpm -ivh perl-URI-1.40-2.el6.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:perl-URI               ########################################### [100%]
		[root@localhost Packages]# rpm -ivh perl-libwww-perl-5.833-2.el6.noarch.rpm 
			error: Failed dependencies:
				perl(Compress::Zlib) is needed by perl-libwww-perl-5.833-2.el6.noarch
				perl(HTML::Entities) is needed by perl-libwww-perl-5.833-2.el6.noarch
				perl-HTML-Parser >= 3.33 is needed by perl-libwww-perl-5.833-2.el6.noarch
		这里很多文件互相依赖,我是选择的安装顺序
				
		[root@localhost Packages]# rpm -ivh perl-HTML-Parser-3.64-2.el6.i686.rpm 
			error: Failed dependencies:
				perl(HTML::Tagset) >= 3.03 is needed by perl-HTML-Parser-3.64-2.el6.i686
				perl(HTML::Tagset) is needed by perl-HTML-Parser-3.64-2.el6.i686

		[root@localhost Packages]# rpm -ivh perl-HTML-Tagset-3.20-4.el6.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:perl-HTML-Tagset       ########################################### [100%]
			[root@localhost Packages]# rpm -ivh perl-HTML-Parser-3.64-2.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:perl-HTML-Parser       ########################################### [100%]
		[root@localhost Packages]# rpm -ivh perl-Compress-Zlib-2.020-115.el6.i686.rpm 
			error: Failed dependencies:
				perl(Compress::Raw::Zlib) >= 2.020 is needed by perl-Compress-Zlib-0:2.020-115.el6.i686
				perl(IO::Compress::Base::Common) >= 2.020 is needed by perl-Compress-Zlib-0:2.020-115.el6.i686
				perl(IO::Compress::Gzip) >= 2.020 is needed by perl-Compress-Zlib-0:2.020-115.el6.i686
				perl(IO::Compress::Gzip::Constants) >= 2.020 is needed by perl-Compress-Zlib-0:2.020-115.el6.i686
				perl(IO::Uncompress::Gunzip) >= 2.020 is needed by perl-Compress-Zlib-0:2.020-115.el6.i686
		[root@localhost Packages]# rpm -ivh perl-IO-Compress-Base-2.020-115.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:perl-IO-Compress-Base  ########################################### [100%]
		[root@localhost Packages]# rpm -ivh perl-Compress-Raw-Zlib-2.023-115.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:perl-Compress-Raw-Zlib ########################################### [100%]	
		[root@localhost Packages]# rpm -ivh perl-IO-Compress-Zlib-2.020-115.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:perl-IO-Compress-Zlib  ########################################### [100%]
		[root@localhost Packages]# rpm -ivh perl-Compress-Zlib-2.020-115.el6.i686.rpm 
			Preparing...                ########################################### [100%]
				1:perl-Compress-Zlib     ########################################### [100%]
		[root@localhost Packages]# rpm -ivh perl-libwww-perl-5.833-2.el6.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:perl-libwww-perl       ########################################### [100%]
		[root@localhost Packages]# rpm -ivh perl-XML-Parser-2.36-7.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:perl-XML-Parser        ########################################### [100%]
		[root@localhost Packages]# rpm -ivh intltool-0.41.0-1.1.el6.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:intltool               ########################################### [100%]
		安装结束


9.切换到之前的终端

		[liaoque@localhost SOURCES]$ rpmbuild -bb yum.spec
			Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.CnFcXL
			+ umask 022
			+ cd /home/liaoque/rpmbuild/BUILD
			+ cd /home/liaoque/rpmbuild/BUILD
			....
			这样rpm包就打包完成啦
		完成后的文件存放在
			/home/liaoque/rpmbuild/RPMS这个文件夹下面,也可能是在其子文件夹下面
		[liaoque@localhost noarch]$ ls
		yum-3.4.3-0.noarch.rpm       yum-updatesd-3.4.3-0.noarch.rpm
		yum-cron-3.4.3-0.noarch.rpm
		[liaoque@localhost noarch]$ pwd
		/home/liaoque/rpmbuild/RPMS/noarch
	
10.安装yum
		[liaoque@localhost noarch]$ rpm -ivh yum-3.4.3-0.noarch.rpm 
			error: Failed dependencies:
				urlgrabber >= 3.9.2 is needed by yum-3.4.3-0.noarch
				yum-metadata-parser >= 1.1.0 is needed by yum-3.4.3-0.noarch
		//又提示有依赖
		//切换第一个终端继续安装
		[root@localhost Packages]# rpm -ivh yum-metadata-parser-1.1.2-14.1.el6.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:yum-metadata-parser    ########################################### [100%]
		[root@localhost Packages]# find ./ -name '*urlgr*'
			./python-urlgrabber-3.9.1-7.el6.noarch.rpm
		[root@localhost Packages]# rpm -ivh python-urlgrabber-3.9.1-7.el6.noarch.rpm 
		Preparing...                ########################################### [100%]
			package python-urlgrabber-3.9.1-7.el6.noarch is already installed
		/*
			提示我们已经安装了urlgrabber.
			urlgrabber >= 3.9.2 而我的版本是3.9.1好吧先卸载这个版本吧
			从网上下载新的版本
			步骤省略:
			下载地址 http://rpmfind.net/linux/rpm2html/search.php?query=urlgrabber&submit=Search+...&system=&arch=
		
		*/
		[root@localhost 桌面]# rpm -e python-urlgrabber --nodeps
		[root@localhost 桌面]# rpm -ivh urlgrabber-3.9.2-4mgc25.i686.rpm 
			Preparing...                ########################################### [100%]
			   1:urlgrabber             ########################################### [100%]

		
		//切换到第二个终端
		[root@localhost noarch]# rpm -ivh yum-3.4.3-0.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:yum                    ########################################### [100%]
		[root@localhost noarch]# rpm -ivh yum-updatesd-3.4.3-0.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:yum-updatesd           ########################################### [100%]
		[root@localhost noarch]# rpm -ivh yum-cron-3.4.3-0.noarch.rpm 
			error: Failed dependencies:
				yum-plugin-downloadonly is needed by yum-cron-3.4.3-0.noarch
		//第一个终端
		[root@localhost Packages]# rpm -ivh yum-plugin-downloadonly-1.1.26-11.el6.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:yum-plugin-downloadonly########################################### [100%]
		//第二个终端
		[root@localhost noarch]# rpm -ivh yum-cron-3.4.3-0.noarch.rpm 
			Preparing...                ########################################### [100%]
			   1:yum-cron               ########################################### [100%]
		//安装完成,测试下
		[root@localhost noarch]# yum install mysql
			没有已启用的仓库。
			执行 "yum repolist all" 查看您拥有的仓库。
			您可以用 yum-config-manager --enable <仓库名> 来启用仓库
		
11.提示没有启动仓库, 其实就是没有配置安装源
		[root@localhost noarch]# cd /etc
		[root@localhost etc]# mkdir yum.repos.d //新建目录
		[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
		使用vi 修改CentOS6-Base-163.repo中的$releasever替换成6
		使用vi的替换功能 %s/$releasever/6/g 
		[root@localhost yum.repos.d]# yum clean all
		清理一切
		[root@localhost yum.repos.d]# yum makecache

 
  

12.安装过程很痛苦,不过到此就结束了

		[root@localhost yum.repos.d]#  yum install tree
			设置安装进程
			解决依赖关系
			--> 执行事务检查
			---> Package tree.i686 0:1.5.3-2.el6 will be 安装
			....


 
 

你可能感兴趣的:(linux软件安装)