checkinstall的安装与使用



介绍:checkinstall 是一款可以讲源代码包根据自己需求编译为我们自己需要的二进制包的一个软件

红色部分为上网搜(fu)索(zhi)的资料,因为

         

 

 

一、checkinstall的安装

1、源代码安装:由于过程相当复杂,而且小工具没必要浪费太多时间,不推荐

可以按下面的方式下载安装。

#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上安装时,并不像上面写的那么简单就可以使用,在安装过程中可能会遇到如下的问题,需要解决。

问题1makemsgfmt报错

报错内容为:

/bin/sh: line 5: msgfmt: command not found

make: *** [all] Error 1

这里可以通过安装gettext包解决:

[root@localhost ~]#yum install gettext

[root@localhost ~]# rpm -qf /usr/bin/msgfmt

gettext-0.17-16.el6.x86_64

问题2makeinstallwatch报错

报错内容如下:

 代码如下复制代码

[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进行安装,所以没有遇到上面所说的问题

2、二进制包安装:

# wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/ikoinoba/CentOS_CentOS-6/x86_64/checkinstall-1.6.2-3.el6.1.x86_64.rpm

# yum install rpm-build gcc rpm-build pcre-devel rpmdevtools tree

# rpm -ivh checkinstall-1.6.2-3.el6.1.x86_64

3、使用前,安装必须的依赖

#rpmdev-setuptree

#cd /root

#tree -L 1 rpmbuild/

会有如下:

rpmbuild/

├—— BUILD

├—— RPMS

├—— SOURCES

├—— SPECS

└—— SRPMS


二、checkinstall使用

这里以zabbix为例,制作一个tengine的rpm包,具体步骤如下:

1、正常安装过程

(1)在已有的LAMP或者LNMP的基础上安装zabbix,安装一些依赖包:

yum -y install mysql-devel libcurl-devel net-snmp-devel curl-devel

(2)添加用户:

groupadd zabbix

useradd zabbix -g zabbix

(3)创建数据库,添加授权账号

create database zabbix character set utf8;

use zabbix;

grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';

(4)编译安装zabbix

   下载地址:wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.0/zabbix-2.2.0.tar.gz

tar zxf zabbix-2.2.0.tar.gz

cd zabbix-2.2.0

./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl

make install

 

2、因此,要创建一个zabbix安装包,我们可以不带任何参数的调用checkinstall,这将使用“make install”命令创建一个包。在这个过程中, checkinstall命令会问你几个问题。

简而言之,如下命令会创建一个zabbix包:

./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl

# checkinstall 

“Should I create a default set of package docs?(我会创建一个默认设置的包文件?)”,回答“Y”

然后,你可以输入一个包的简短描述,然后按回车:

checkinstall的安装与使用_checkinstall  

输入一个数字以修改下面的任何值或ENTER继续:

checkinstall的安装与使用_checkinstall   _02 

然后checkinstall将自动地创建一个.rpm或者.deb包,根据你的linux系统是什么:

在CentOS6.5:

checkinstall的安装与使用_checkinstall   _03

检查:到文件目录

cd /root/rpmbuild/RPMS/x86_64

rpm -qpi zabbix-2.2.0-1.x86_64.rpm

checkinstall的安装与使用_checkinstall   _04