Centos使用checkinstall制作RPM包的方法

一、checkinstall的安装
目前最新版本是1.6.2,可以按下面的方式下载安装。

 代码如下 复制代码
wget http://asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1.6.2.tar.gz
tar  zxvf checkinstall-1.6.2.tar.gz
cd checkinstall-1.6.2
make  && make install

不过我在centos6.5 X64上安装时,并不像上面写的那么简单就可以使用,在安装过程中可能会遇到如下的问题,需要解决。

问题1、make时msgfmt报错

报错内容为:

/bin/sh: line 5: msgfmt: command not found
make: *** [all] Error 1
这里可以通过安装gettext包解决:

 代码如下 复制代码
[root@localhost ~]# rpm -qf /usr/bin/msgfmt
gettext-0.17-16.el6.x86_64

问题2、make时installwatch报错

报错内容如下:

 代码如下 复制代码
[root@localhost checkinstall-1.6.2]# make
for file in locale/checkinstall-*.po ; do
                case ${file} in
                        locale/checkinstall-template.po)  ;;
                        *)
                                out=`echo $file | sed -s 's/po/mo/'` ;
                                msgfmt -o ${out} ${file} ;
                                if [ $? != 0 ] ; then
                                        exit 1 ;
                                fi ;
                        ;;
                esac ;
        done
make -C installwatch
make[1]: Entering directory `/usr/local/src/checkinstall-1.6.2/installwatch'
gcc -Wall -c -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT -DVERSION="0.7.0beta7" installwatch.c
installwatch.c:2942: error: conflicting types for ‘readlink’
/usr/include/unistd.h:828: note: previous declaration of ‘readlink’ was here
installwatch.c:3080: error: conflicting types for ‘scandir’
/usr/include/dirent.h:252: note: previous declaration of ‘scandir’ was here
make[1]: *** [installwatch.o] Error 1
make[1]: Leaving directory `/usr/local/src/checkinstall-1.6.2/installwatch'
make: *** [all] Error 2

出现该错误需要修改installwatch/installwatch.c文件,具体需要修改的部分如下:

将101行处修改

 代码如下 复制代码

static int (*true_scandir)( const char *,struct dirent ***,
int (*)(const struct dirent *),
int (*)(const void *,const void *));
改为:
static int (*true_scandir)( const char *,struct dirent ***,
int (*)(const struct dirent *),
int (*)(const struct dirent **,const struct dirent **));
将121行处修改:

static int (*true_scandir64)( const char *,struct dirent64 ***,
int (*)(const struct dirent64 *),
int (*)(const void *,const void *));
改为:
static int (*true_scandir64)( const char *,struct dirent64 ***,
int (*)(const struct dirent64 *),
int (*)(const struct dirent64 **,const struct dirent64 **));
将2941行修改:

#if (GLIBC_MINOR <= 4)
改为
#if (0)
将3080行修改:

int scandir( const char *dir,struct dirent ***namelist,
int (*select)(const struct dirent *),
int (*compar)(const void *,const void *) ) {
改为:
int scandir( const char *dir,struct dirent ***namelist,
int (*select)(const struct dirent *),
int (*compar)(const struct dirent **,const struct dirent **) ) {
将3692行修改:

int scandir64( const char *dir,struct dirent64 ***namelist,
int (*select)(const struct dirent64 *),
int (*compar)(const void *,const void *) ) {
改为:
int scandir64( const char *dir,struct dirent64 ***namelist,
int (*select)(const struct dirent64 *),
int (*compar)(const struct dirent64 **,const struct dirent64 **) ) {

完成后再进行make即可。

在ubuntu上安装时,由于可以直接使用apt进行安装,所以没有遇到上面所说的问题,在centos上遇到的问题参考了:http://www.patrickmin.com/linux/tip.php?name=checkinstall_fedora_13

问题3、rpmbuild报错

前面两个问题解决完成后,checkinstall看起来已经正常,不过在使用过程中还会遇到如下的报错。

/root/rpmbuild has no SOURCES directory. Please write the path to
the RPM source directory tree:
出现该问题的原因,是因为checkinstall还是需要rpmbuild做底层支撑,如果没有安装rpmbuild时,会出现上面的报错。解决方法如下:

 代码如下 复制代码
yum install gcc rpm-build pcre-devel rpmdevtools

安装完成后,需要再运行rpmdev-setuptree命令创建目录查看,具体如下:

#rpmdev-setuptree
#cd /root
#tree -L 1 rpmbuild/
rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS
问题4、ld.so报错

该出错是出现在x64系统下的,x86系统下没有该问题。此处的报错也是在checkinstall生成rpm包的过程中,报错内容为:

ERROR: ld.so: object '/usr/local/lib64/installwatch.so' from LD_PRELOAD cannot be preloaded: ignored.
解决方法如下:

[root@localhost ~]# echo "/usr/local/lib64" >/etc/ld.so.conf.d/installwatch.conf
[root@localhost ~]# ln -s /usr/local/lib/installwatch.so /usr/local/lib64/installwatch.so
[root@localhost ~]# ldconfig
二、checkinstall制作rpm包
这里以tengine为例,制作一个tengine的rpm包,具体步骤如下:

 代码如下 复制代码
[root@localhost src]tar zxvf tengine-2.0.1.tar.gz
[root@localhost src]cd tengine-2.0.1
[root@localhost tengine-2.0.1]# ./configure --prefix=/usr/local --sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--user=nginx --group=nginx
--with-http_ssl_module --with-http_flv_module
--with-http_stub_status_module
--with-http_gzip_static_module
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--with-pcre --with-http_realip_module
--with-http_addition_module
--with-http_sub_module --with-http_dav_module
--with-http_mp4_module --with-http_random_index_module
--with-http_secure_link_module --with-file-aio --with-http_upstream_check_module
--with-http_limit_conn_module=shared
--with-http_limit_req_module=shared
[root@localhost tengine-2.0.1]#make
[root@localhost tengine-2.0.1]# checkinstall
checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.
The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs?  [y]: y
Preparing package documentation...OK
Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? R
Please write a description for the package.
End your description with an empty line or EOF.
>> tengine for 361way.com order by yang
>>
**************************************
**** RPM package creation selected ***
**************************************
This package will be built according to these values:
1 -  Summary: [ tengine for 361way.com order by yang ]
2 -  Name:    [ tengine ]
3 -  Version: [ 2.0.1 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ Applications/System ]
7 -  Architecture: [ x86_64 ]
8 -  Source location: [ tengine-2.0.1 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ tengine ]
Enter a number to change any of them or press ENTER to continue:
Installing with make install...
========================= Installation results ===========================
make -f objs/Makefile install
make[1]: Entering directory `/usr/local/src/tengine-2.0.1'
test -d '/usr/local' || mkdir -p '/usr/local'
……………………………………………………省略
**********************************************************************
 Done. The new package has been saved to
 /root/rpmbuild/RPMS/x86_64/tengine-2.0.1-1.x86_64.rpm
 You can install it in your system anytime using:
      rpm -i tengine-2.0.1-1.x86_64.rpm
**********************************************************************

完成后就可以取刚刚生成的rpm包到相同系统的主机上安装使用,安装前也可以通过以下命令查看详细的rpm包信息:

 代码如下 复制代码
[root@kvm ~]# rpm -qpi tengine-2.0.1-1.x86_64.rpm
Name        : tengine                      Relocations: (not relocatable)
Version     : 2.0.1                             Vendor: (none)
Release     : 1                             Build Date: Tue 06 May 2014 10:39:02 AM CST
Install Date: (not installed)               Build Host: localhost
Group       : Applications/System           Source RPM: tengine-2.0.1-1.src.rpm
Size        : 2345906                          License: GPL
Signature   : (none)
Packager    : checkinstall-1.6.2
Summary     : tengine for 361way.com order by yang
Description :
tengine for 361way.com order by yang

注:此时的rpm包在其他主机上通过rpm -i 安装使用时可能会遇到错误,因为在编译的时候我们自定义了很多参数。例出上面的tengine rpm 在使用时就会报错如下:

#nginx
nginx: [emerg] getpwnam("nginx") failed
报错原因很简单,因为我们编译的时候使用了--user=nginx --group=nginx 参数,而在新的主机上因为不存在该用户所以会报错 。如果想完会解决此类问题,可以在编译前修改下install文件或make文件,将新建用户,新建一些自定义目录都添加下,再编译生成rpm包就OK了。

时间: 2024-09-18 18:03:38

Centos使用checkinstall制作RPM包的方法的相关文章

CentOS 6.6 x86_64 RPM包制作教程

一.RPM包介绍 对RPM包有五种基本的操作功能:安装.卸载.升级.查询和验证.linux软件包分为两大类:    1. 二进制类包:包括rpm安装包(一般分为i386和x86_64这几种)     2. 源码类包:源码包和开发包(.src.rpm)都是属于此类 有时候为了方便源码包的安装,和我们自己订制软件包的需求,我们会把一些源码包按照我们的需求来做成rpm包,当有源码包就可以直接编译得到二进制安装和其他任意包,另外,我们也可以使用rpm包来打包一些文件或者自己开发的一套软件,使用rpm有数

linux下制作安装rpm包的方法

  一.制作rpm包  以rp-pppoe-3.10为列进行制作过程. 1.下载rp-pppoe-3.10.tar.gz [root@localhost home]# pwd /home [root@localhost home]# 2.解压 # tar zxvf rp-pppoe-3.10.tar.gz 3. # cp /home/rp-pppoe-3.10/rp-pppoe.spec /usr/src/redhat/SOURCES/ # cp /home/rp-pppoe-3.10.tar.

怎样制作RPM包

怎样制作RPM包   Mr. Neo Chen (netkiller), 陈景峰(BG7NYT) 中国广东省深圳市龙华新区民之街道溪山美地518109+86 13113668890+86 755 29812080<netkiller@msn.com> 版权 2011, 2012, 2013 http://netkiller.github.com 摘要 我在网上找RPM包的制作例子几乎都是C源码编译安装然后生成RPM包, 而我的程序不是C写的很多时候是脚本语言如Python, PHP 甚至是 H

怎么制作rpm包

最近有好多朋友问到怎么制作rpm包,可不可把其它服务器上编译好的软件目录复杂到其它服务器上直接应用等等...这里做个简单的介绍,高级复杂的不会. 此方法是通过编写spec文件,使用rpmbuild来完成一个rpm的打包. 以nginx为例进行介绍 制作平台:centos 5.x X86_64 四步走: 第一步:建立目录结构 mkdir /usr/src/redhat/{SOURCES,SPECS,BUILD,RPMS,SRPMS} -p 相关目录介绍: /usr/src/redhat/SOURC

Linux源码包制作RPM包之Apache

公司服务器比较多,需要把apache源码包制作成rpm包,然后放到公司内网yum源上进行下载安装.apache的rpm包安装方式比源码安装方式比较快,这能节约不少的时间. 有关内网yum源的搭建,可以参考<烂泥:yum的使用及配置>这篇文章. 一.安装rpm-build 查阅相关资料得知,要把源码包制作成rpm包需要使用rpm打包工具rpm-build. rpm-build通过rpmbuild命令根据本地源码包,通过spec文件中的规则就可以把源码包制作成rpm包. 现在我们来安装rpm-bu

教你如何在Fedora,CentOS,RHEL中检查RPM包的依赖性

教你如何在Fedora,CentOS,RHEL中检查RPM包的依赖性 我们都知道,在基于红帽的Linux系统中,一个RPM包,需要把先将它依赖的其他包安装好才能正常的工作.对于终端用户,RPM的安装.更新.删除中存在的依赖关系已经被工具透明化了(如 yum或 DNF等).但如果你是系统管理员或者RPM包的管理员,你需要谙熟RPM包的依赖关系,以便及时更新.删除适当的包来保证系统的正常运行. 在本教程中,我将教大家如何检查RPM包的依赖关系.无论这个包是否已经安装进操作系统中,我们都有一些办法来检

CentOS 6.X使用RPM包升级GLIBC的例子

之前一段时间经常被 "libc.so.6: version `GLIBC_2.14′ not found" 这个报错信息折腾,出现这个报错的原因就是当前系统安装的 GLIBC 版本低于软件编译时使用的 GLIBC 版本. 这也是 CentOS 非常不适合折腾的原因之一,一些软件经常用到的底层 API 或编译器版本都非常低. CentOS 7.X 倒还好,GLIBC Version 2.17,GCC Version 4.8.5,基本满足需要,但是 CentOS 6.X 的 GLIBC V

详解Linux 操作系统下安装rpm包的方法步骤_linux shell

第2代Linux操作系统在安装软件方面相当简单:第一步,搜索你要的软件,比如你要找一个游戏软件,它的名称叫myward,这个游戏软件的说明是:myown war game.Linux操作系统搜索这个软件包就只需要输入命令apt-cache searchmyward,或者输入软件名称的一部分apt-cache searchwar,或者你不知道软件名称. 下面有一张图可以清晰地表示linux软件应用的架构关系: 在Linux启动的时候.首先会启动内核(kernel),内核是一段计算机程序,这个程序直

强制删除rpm包的方法_linux shell

删除软件 要删除软件非常简单,只要执行下面的命令就行: 复制代码 代码如下: # rpm –e xanim 这时,用户要注意使用的是软件的名称xanim,而不是软件包的名称xanim-27.64-3.i386.rpm. 如果要删除的软件是其它软件所需要的,用户会得到类似下面的错误信息: 复制代码 代码如下: # rpm –e xanim error: xanim is needed by mtv-1.0-1 这表明如果用户删除了xanim,则mtv就不能运行了,因为xanim里的一些软件是mtv