Linux 的源碼安裝工具 CheckInstall
Checkinstall 是一個能從 tar.gz 類的
https://www.ibm.com/developerworks/cn/linux/l-cn-checkinstall/
Linux 的源碼安裝工具 CheckInstall
Checkinstall 是一個能從 tar.gz 類的源代碼自動生成 RPM/Debian 或Slackware 安裝包的程序。通過 CheckInstall,你就能用幾乎所有的 tar.gz 類的源代碼來生成“干凈”的安裝或者卸載包。
2 評論
引言
經常出現這樣的問題:很想試用的程序只有源代碼(比如 tar.gz )可用,沒人提供 RPM 或者Debian 包。你只好下載源代碼,解壓,然后手動編譯。到目前為止,一切正常。然而,當你想刪除它的時候呢?
Makefile 文件只包括了很少情況下的卸載例程。當然,你可以把程序安裝到臨時文件夾,然后記下所有由程序生成或修改的文件,最后刪除他們。但是如果這個程序要經常重新編譯,這樣做是非常痛苦的,工作量也相當大。Felipe Eduardo 所寫的 CheckInstall 就是用來解決這個問題的。
用 GNU Autoconf 安裝程序
一般說來,我們編譯安裝一個由 GNU Autoconf 配置的程序是采用如下的步驟:
./configure && make && make install
這個 configure 腳本文件是用來“猜”出一系列系統相關的變量,這些變量是在后面的編譯過程要用到的。它將檢查系統變量值是否滿足編譯要求,然后使用這些變量在程序包內每個文件夾下生成 Makefile。此外,configure 腳本還會生成其它文件:
- 每個文件夾/子文件夾下的一個或多個 Makefile(s)
- 一個名叫 config.status 的腳本
- 一個文本文件 config.log
Configure 腳本文件成功運行之后, 你會輸入 make 來編譯程序,得到你需要的可執行文件。如果 make 成功的完成,你可以使用 make install 來安裝這個程序。
用 CheckInstall 安裝程序
上節我們采用 GNU Autoconf 來編譯程序,現在該是換一種方式的時候了。你可以使用CheckInstall 工具。它采用自己的指令 checkinstall 來代替 make install。其他兩個指令保留下來跟以前一樣,因此,現在這個指令序列使用 CheckInstall 變成:
./configure && make && checkinstall
指令 checkinstall 不僅默認運行了 make install,而且還監測所有安裝過程中的寫操作。為此,CheckInstall 使用了 Pancrazio de Mauro 所寫的程序 Installwatch。在 make install 成功完成之后,CheckInstall 會產生一個 Slackware-,Debian- 或RPM- 安裝包,然后按照軟件包的默認配置來安裝程序,並在當前目錄(或標准安裝包存儲目錄)留下一個生成的安裝包。你可以通過修改變量 PAK_DIR 來修改這個保存目錄。
CheckInstall 並不只是使用 make install,它還可以與其他安裝指令相協調。例如,如果安裝指令為 setup.sh,那么安裝指令序列變成:
./configure && make && checkinstall setup.sh
我們還可以讓 CheckInstall 帶着很多參數運行。
圖 1. 運行命令“checkinstall –h”顯示所有可用的子參數

這些子參數大致分為:
- 安裝選項(Install options)
- 腳本處理選項(Scripting options)
- 信息顯示選項(Info display options)
- 安裝包選項(Package tuning options)
- 清除選項(Cleanup options)
- 關於 CheckInstall (About CheckInstall)。
如果 CheckInstall 帶着這些參數運行,它會使用這些參數值來代替配置文件 checkinstallrc 中相應的值。
CheckInstall 也有自己的局限之處。它不能處理靜態連接的程序,因為這樣 Installwatch 就不能監測到安裝過程中修改過文件了。總體說來,有兩類連接庫:動態的和靜態的。這些連接庫通過 include 指令整合到程序中。靜態連接過的程序已經包含了所有需要的庫文件,運行時也就不需要再將這些庫載入內存中。這種程序與安裝在系統中的連接庫無關,因為所謂的連接器(Linker)已經在編譯時把這些庫內置到可執行程序里了。
CheckInstall 的安裝
我們可以在 CheckInstall 的主頁上下載各種預編譯好的安裝包或者合適的源碼包。下面將展示安裝最新的源代碼 checkinstall-1.6.1.tgz 的全過程。這會安裝上 CheckInstall、Installwatch和 makepak,其中 makepak 是 makepkg 的修改版。如果你對新版本的改進感興趣,請參看Release Notes 和 Changelog。
清單 1. 生成 checkinstall 的 rpm 安裝包
# tar xzf checkinstall-1.6.1.tgz # cd checkinstall-1.6.1 checkinstall-1.6.1# make checkinstall-1.6.1# make install checkinstall-1.6.1# checkinstall
圖 2. 運行命令“checkinstall”生成 rpm 包的圖示過程

圖 2.1. 過程一

圖 2.2. 過程二

圖 2.3. 過程三

checkinstall-1.6.1 的 rpm 包已經生成,我們用 rpm 來安裝它。
清單 2. 用生成的 rpm 包安裝 checkinstall
checkinstall-1.6.1# cd /usr/src/redhat/RPMS/i386/ i386# rpm -i checkinstall-1.6.1.rpm
checkinstall-1.6.1 安裝完畢。使用包管理程序的查詢語句,你可以檢查安裝包中文件是否完全在程序庫中記錄了,還可以查看安裝包頭部的一些額外信息。
圖 3. 檢查 checkinstall 的 RPM 包

CheckInstall 的配置
你可以通過修改配置文件 /usr/local/lib/checkinstall/checkinstallrc 來改變 CheckInstall 的默認配置。
文件值得注意的變量有 INSTYPE,INSTALL 和 PAK_DIR。
INSTYPE 變量決定生成何種類型安裝包。
圖 4. 查看變量 INSTYPE

PAK_DIR 變量決定安裝包的存儲目錄。
圖 5. 查看變量 PAK_DIR

INSTALL 變量決定是只生成安裝包還是一起將這個包馬上安裝。
0-只生成安裝包
1-不僅生成安裝包,還將包立即安裝
圖 6. 查看變量 INSTALL

用 CheckInstall 制作 RPM 包實例
上兩節我們把 Checkinstall 安裝配置完成,這節以 squid-2.6.STABLE12.tar.bz2 為例,說明用checkinstall 制作編譯成 squid-2.6.STABLE12-1.i386.rpm 包的具體方法。
清單 3. 生成 squid-2.6.STABLE12 的 rpm 安裝包
# tar jxvf squid-2.6.STABLE12.tar.bz2 # cd squid-2.6.STABLE12 squid-2.6.STABLE12# ./configure --prefix=/usr/local/squid --sysconfdir=/etc \ --enable-arp-acl --enable-linux-netfilter -enable-err-language="Simplify_Chinese" \ --enable-storeio=ufs --enable-default-err-language="Simplify_Chinese" \ --enable-auth="basic" --enable-baisc-auth-helpers="NCSA" --enable-underscore squid-2.6.STABLE12# make squid-2.6.STABLE12# checkinstall
生成 rpm 包期間會出現一些選項,選擇默認的即可。
圖 7. 運行命令“checkinstall”生成 rpm 包的圖示過程

圖 7.1. 過程一

圖 7.2. 過程二

圖 7.3. 過程三

圖 7.4. 過程四

清單 4. 用生成的 rpm 包安裝 squid-2.6.STABLE12
squid-2.6.STABLE12# cd /usr/src/redhat/RPMS/i386/ i386# rpm -ivh squid-2.6.STABLE12-1.i386.rpm
圖 8. 檢查 squid-2.6.STABLE12 的 RPM 包

結束
CheckInstall 是一款優秀的源碼安裝軟件,它使得 Linux 軟件管理更加方便。特別是在源碼需要經常重復編譯的情況下,CheckInstall 可以讓你絲毫不破壞系統一致性的前提下完全的卸載程序。而且,你還可以使用這些編譯好的安裝包直接在其他的機器上安裝無須再重新編譯。
使用checkinstall 生成rpm報錯
http://shugao.blog.51cto.com/2396914/1360193/
1編譯報 msgfmt not found,解決方法
此問題的解決方法:只需要安裝gettext包即可
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
vim installwatch/installwatch.c
at line 101, change:
static int (*true_scandir)( const char *,struct dirent ***,
int (*)(const struct dirent *),
int (*)(const void *,const void *));
to:
static int (*true_scandir)( const char *,struct dirent ***,
int (*)(const struct dirent *),
int (*)(const struct dirent **,const struct dirent **));
at line 121, change:
static int (*true_scandir64)( const char *,struct dirent64 ***,
int (*)(const struct dirent64 *),
int (*)(const void *,const void *));
to:
static int (*true_scandir64)( const char *,struct dirent64 ***,
int (*)(const struct dirent64 *),
int (*)(const struct dirent64 **,const struct dirent64 **));
at line 2941, change:
#if (GLIBC_MINOR <= 4)
to:
#if (0)
at line 3080, change:
int scandir( const char *dir,struct dirent ***namelist,
int (*select)(const struct dirent *),
int (*compar)(const void *,const void *) ) {
to:
int scandir( const char *dir,struct dirent ***namelist,
int (*select)(const struct dirent *),
int (*compar)(const struct dirent **,const struct dirent **) ) {
at line 3692, change:
int scandir64( const char *dir,struct dirent64 ***namelist,
int (*select)(const struct dirent64 *),
int (*compar)(const void *,const void *) ) {
to:
int scandir64( const char *dir,struct dirent64 ***namelist,
int (*select)(const struct dirent64 *),
int (*compar)(const struct dirent64 **,const struct dirent64 **) ) {
完成后make
直接make install 雖然不會報錯但是在使用checkinstall 的時候,會報錯
“checkinstall error: File not found: /root/rpmbuild/BUILDROOT/”這種蛋疼的錯誤;
vim checkinstall
at line 495, change: CHECKINSTALLRC=${CHECKINSTALLRC:-${INSTALLDIR}/checkinstallrc}
to:
CHECKINSTALLRC=${CHECKINSTALLRC:-${INSTALLDIR}/lib/checkinstall/checkinstallrc}
at line 2466, change: $RPMBUILD -bb ${RPM_TARGET_FLAG}${ARCHITECTURE} "$SPEC_PATH" &> ${TMP_DIR}/rpmbuild.log
to:
$RPMBUILD -bb ${RPM_TARGET_FLAG}${ARCHITECTURE} --buildroot $BROOTPATH "$SPEC_PATH" &> ${TMP_DIR}/rpmbuild.log
Now, as root, run:
make install
在使用makeinstall 的時候如果報“/root/rpmbuild has no SOURCES driectory”的錯誤,執行mkdir -p /root/rpmbuild/SOURCES命令;
轉載:http://thinkman.blog.51cto.com/4217028/1135049
rpm-build安裝以及打包
http://blog.csdn.net/wisgood/article/details/42988235
1,查找rpm-build,並安裝
參考:
CheckInstall安裝與使用指南
https://www.aliyun.com/zixun/content/3_12_513777.html
Centos使用checkinstall制作RPM包的方法
http://www.111cn.net/sys/CentOS/61169.htm
Linux下輕松實現源碼打包安裝
本篇文章來源於 Linux公社網站(www.linuxidc.com) 原文鏈接:http://www.linuxidc.com/Linux/2011-04/34144.htm
http://www.cnblogs.com/pudao/p/5129513.html
Linux 環境下源碼打包RPM過程記錄
http://blog.sina.com.cn/s/blog_4535337e0102v43t.html
CentOS下將軟件源碼打包為RPM的方法
詳細請參考:http://www.codesky.net/article/201703/182431.html
源碼下載url:
checkinstall-1.6.2-8.1 RPM for x86_64
http://rpmfind.net/linux/RPM/opensuse/11.4/x86_64/checkinstall-1.6.2-8.1.x86_64.html
rpm-build-5.4.10-10 RPM for x86_64
http://rpmfind.net/linux/RPM/mandriva/devel/cooker/x86_64/media/main/release/rpm-build-5.4.10-10.x86_64.html
http://asic-linux.com.mx/~izto/checkinstall/download.php
http://www.slackware.com/~alien/slackbuilds/checkinstall/build/