checkinstall的安裝與使用

                        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安裝與使用

輸入一個數字以修改下面的任何值或ENTER繼續:

checkinstall安裝與使用 

然後checkinstall將自動地創建一個.rpm或者.deb包,根據你的linux系統是什麼:

在CentOS6.5:

checkinstall安裝與使用

檢查:到文件目錄

cd /root/rpmbuild/RPMS/x86_64

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

checkinstall安裝與使用

 

 

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章