在163.com镜像站点的时候,os下有个目录SRPMS,就下个src.rpm来安装学习。
以下是我的一些理解,不一定对,希望大虾们指正啊。
1、 下载释放rpm包
[fukeyun@heliy yumcentos]$ wget http://mirrors.163.com/centos/6.0/os/SRPMS/Packages/media-player-info-6-1.el6.src.rpm
释放:
[fukeyun@heliy yumcentos]$ $ rpm -i media-player-info-6-1.el6.src.rpm
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
提示这些错误是正常的,释放的位置有两个:
/usr/src/redhat(不同的发行版可能稍有不同)/下的SOURCE、SPECS REDHAT版本
$home/rpmbuild/ 下 新版本linux
另外注意:如果在终端在root权限下,会释放到/root/rpmbuild下,普通用户在自己的$home/rpmbuild下
[fukeyun@heliy rpmbuild]$ pwd
/home/fukeyun/rpmbuild
[fukeyun@heliy rpmbuild]$ ls
SOURCES SPECS
2、编译rpm包
我不是开发人员,所以源码包里的一些东西就基本不动,只是简单的重新生成可执行rpm包。
如果没有rpmbuild命令,先安装
[root@heliy yumcentos]# rpm /mnt/fat32/Packages/rpm-build-4.8.0-12.el6.i686.rpm -ivh
有三种方式生存rpm可执行包
方法一: rpmbuild --rebuild
rpmbuild --rebuild media-player-info-6-1.el6.src.rpm
Installing media-player-info-6-1.el6.src.rpm
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
error: Failed build dependencies:
libudev-devel is needed by media-player-info-6-1.el6.noarch
有些解决依赖问题用--nodeps,我建议不要这样做。按提示安装相应包即可,如果依赖包比较多,用yum或apt解决。
# rpm -ivh libudev-devel-147-2.29.el6.i686.rpm
Preparing... ########################################### [100%]
1:libudev-devel ########################################### [100%]
再重新生成rpm包$ rpmbuild --rebuild media-player-info-6-1.el6.src.rpm
[fukeyun@heliy ~]$ ls rpmbuild/RPMS/noarch/
media-player-info-6-1.el6.noarch.rpm
生存成功。即可安装
[root@heliy rpmbuild]# rpm -ivh ./RPMS/noarch/media-player-info-6-1.el6.noarch.rpm
Preparing... ########################################### [100%】
方法二: rpmbuild -bb
[fukeyun@heliy rpmbuild]$ cd ./SPECS/
[fukeyun@heliy SPECS]$ ls
media-player-info.spec
[fukeyun@heliy SPECS]$ rpmbuild -bb media-player-info.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.pS0htL
+ umask 022
+ cd /home/fukeyun/rpmbuild/BUILD
+ cd /home/fukeyun/rpmbuild/BUILD
.............
+ rm -rf /home/fukeyun/rpmbuild/BUILDROOT/media-player-info-6-1.el6.i386
+ exit 0
[fukeyun@heliy SPECS]$ ls ../RPMS/noarch/
media-player-info-6-1.el6.noarch.rpm
也生存可执行rpm包。
方法三: rpmbuild -bp
[fukeyun@heliy SPECS]$ rpmbuild -bp media-player-info.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.0QJe65
[fukeyun@heliy SPECS]$ cd ../BUILD/media-player-info-6/
[fukeyun@heliy media-player-info-6]$ ls
aclocal.m4 configure INSTALL Makefile.in NEWS
AUTHORS configure.ac install-sh media-players README
ChangeLog COPYING Makefile.am missing
[fukeyun@heliy media-player-info-6]$ ./configure
[fukeyun@heliy media-player-info-6]$ make
[fukeyun@heliy media-player-info-6]$ make install
[fukeyun@heliy SPECS]$ ls ../RPMS/noarch/
media-player-info-6-1.el6.noarch.rpm
3、在直接安装
在释放后,rpmbuild目录下的sourcesmul下有个文件
[root@heliy SOURCES]# ls
media-player-info-6.tar.gz
#rpm -xzf media-player-info-6.tar.gz
[root@heliy SOURCES]# ls
media-player-info-6 media-player-info-6.tar.gz
#cd ./media-player-info-6 后./configure && make && make install即可安装。
本文转自fuhaixiong 51CTO博客,原文链接:http://blog.51cto.com/heliy/707586,如需转载请自行联系原作者