centos编译安装checkinstall

一、确保你的系统安装了rpm-build和rpmdevtools,没有的话按下面安装(root权限)

yum install rpm-build rpmdevtools

二、下载源代码,地址:点击

三、解压

tar -zxvf checkinstall-1.6.2.tar.gz
cd checkinstall-1.6.2

四、make编译

  可能会出现下面错误

  

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
installwatch.c:3692: error: conflicting types for 'scandir64'
/usr/include/dirent.h:275: note: previous declaration of 'scandir64' was here

  解决办法:(红色部分是要改的)

  在第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安装

五、修改源文件夹下的checkinstall文件

  行495:

CHECKINSTALLRC=${CHECKINSTALLRC:-${INSTALLDIR}/checkinstallrc}

  改成

CHECKINSTALLRC=${CHECKINSTALLRC:-${INSTALLDIR}/lib/checkinstall/checkinstallrc}

  行2466:

$RPMBUILD -bb ${RPM_TARGET_FLAG}${ARCHITECTURE} "$SPEC_PATH" &> ${TMP_DIR}/rpmbuild.log

  改成

$RPMBUILD -bb ${RPM_TARGET_FLAG}${ARCHITECTURE} --buildroot $BROOTPATH "$SPEC_PATH" &> ${TMP_DIR}/rpmbuild.log

六、最后执行:make install

七、使用可能会出现的错误

  1、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

八、待定

posted on 2015-11-03 15:04  MoceanLiu  阅读(862)  评论(0编辑  收藏  举报

导航