Checkinstall 是一個能從 tar.gz類的源代碼自動生成RPM/Debian或Slackware安裝包的程序。這樣使你能用幾乎全部的 tar.gz 類的源代碼生成「乾淨」的安裝或者卸載包。html
簡介 node
常常出現這樣的問題:你很想試用的程序只有 tar.gz的源代碼可用(沒人提供 rpm 或者 Debian包)。這樣,你只好下載回源代碼,解壓,而後手動編譯。到目前爲止,一切正常。然而,當你想刪掉它的時候呢?編程
Makefile文件只包括了不多狀況下的卸載例程。固然,你能夠把程序安裝到臨時文件夾,而後記下全部由程序生成或修改的文件,最後刪除他們。可是若是這個程序要常常從新編譯,那樣作是很是痛苦的,工做量也是至關大的。 Felipe Eduardo所寫的 CheckInstall [1] Sánchez Díaz Durán 就是用來解決這個問題的。 ide
通常說來,咱們編譯安 裝一個由GNU Autoconf配置的程序是採用以下的步驟: 學習
./configure && make && make install.測試
這個 configure 腳本文件是用來「猜」出一系列系統相關的變量,這些變量是在後面的編譯過程要用到的。它將檢查系統變量值是否知足編譯要求,而後使用這些變量在程序包內每一個文件夾下生成 Makefile .此外,configure 腳本還會生成其餘文件,他們是:ui
* 每一個文件夾/子文件夾下的一個或多個Makefile(s)this
* 一個名叫config.status的腳本
* 一個文本文件config.log
* 另外一個名叫config.cache的腳本(可選的)
* 帶有系統特殊定義的C頭文件(*.h)(可選項)
configure腳本文件成功運行以後, 你會輸入make來編譯程序,獲得你須要的可執行文件。你也可能在make以後立刻使用make check來運行測試。可是這只是可選的步驟,由於這須要這個程序包的支持。若是 make成功的完成了,你可使用make install來安裝這個程序了——很明顯,完成這步你須要一些相關權限。程序安裝好了,你能夠在源代碼的文件夾下輸入make clean來清除這些生成的可執行文件和目標文件。若是你還想刪除由configure生成的文件,那麼輸入 then typemake distclean.後兩步同make check同樣(是可選的),它們一般是開發者在開發和測試階段所使用,也能夠被通常使用者用來節省硬盤空間或者保持文件夾的結構簡潔明快。另外make distclean使得咱們在不一樣類型的電腦上編譯程序成爲可能。
關於GNU Autoconf的詳細資料能夠在在線文檔[2]上找到。在基本介紹以外,你能夠經過寫你本身的configure腳本、用M4編程和建立本身的宏等方式來學習更多有關GNU Build System的知識。
CheckInstall
前面提到,咱們採用GNU Autoconf經過一系列以下指令來編譯程序:
./configure && make && make install
如今該是換一種方式的時候了,你可使用CheckInstall.它採用本身的指令checkinstall來代替make install.其餘兩個指令保留下來跟之前同樣,所以,如今這個指令序列使用 CheckInstall變成了:
./configure && make && checkinstall
CheckInstall也有本身的侷限之處。它不能處理靜態鏈接的程序,由於這樣Installwatch就不能監測到安裝過程當中修改過文件了。整體說來,有兩類鏈接庫:動態的和靜態的。這些鏈接庫經過include-指令整合到程序中。靜態鏈接過的程序已經包含了全部須要的庫文件,運行時也就不須要再將這些庫載入內存中。這種程序與安裝在系統中的鏈接庫無關,由於所謂的鏈接器(Linker)已經在編譯時把這些庫內置到可執行程序裏了。
安裝
$ tar xzf checkinstall-1.6.0beta4.tgz
This software is released under the GNU GPL.
Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? R
*************************************
*** RPM package creation selected ***
*************************************
This package will be built according to these values:
1 - Summary: [ CheckInstall installations tracker, version 1.6.0beta4 ]
2 - Name: [ checkinstall ]
3 - Version: [ 1.6.0beta4 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ checkinstall-1.6.0beta4 ]
9 - Alternate source location: [ ]
10 - Provides: [ checkinstall ]
11 - Requires: [ ]
Enter a number to change any of them or press ENTER to continue:
Installing with make install...
========================= Installation results =========================
[...]
========================= Installation successful ======================
Copying documentation directory...
./
./NLS_SUPPORT
./README
./FAQ
./TODO
./CREDITS
./INSTALL
./Changelog
./BUGS
./installwatch-0.7.0beta4/
./installwatch-0.7.0beta4/README
./installwatch-0.7.0beta4/TODO/usr/src/redhat/RPMS/i386/checkinstall-1.6.0beta4-1.i386.rpm
./installwatch-0.7.0beta4/VERSION
./installwatch-0.7.0beta4/INSTALL
./installwatch-0.7.0beta4/CHANGELOG
./installwatch-0.7.0beta4/BUGS
./installwatch-0.7.0beta4/COPYING
./RELNOTES
./COPYING
Copying files to the temporary directory...OK
Striping ELF binaries and libraries...OK
Compressing man pages...OK
Building file list...OK
Building RPM package...OK
NOTE: The package will not be installed
Erasing temporary files...OK
Writing backup package...OK
Deleting temp dir...OK
Packager : checkinstall-1.6.0beta4
Summary : CheckInstall installations tracker, version 1.6.0beta4
Description :
CheckInstall installations tracker, version 1.6.0beta4
CheckInstall keeps track of all the files created or
modified by your installation script (&make install&
&make install_modules&, &setup&, etc), builds a
standard binary package and installs it in your
system giving you the ability to uninstall it with your
distribution's standard package management utilities.
# Debug level
# 0: No debug
# 1: Keep all temp files except the package's files
# 2: Keep the package's files too
DEBUG=0
# Location of the &installwatch& program
INSTALLWATCH_PREFIX=&/usr/local&
RESET_UIDS=0
# Use the new (8.1+) Slackware description file format?
NEW_SLACK=1
# Comma delimited list of files/directories to be ignored
EXCLUDE=&&
# Accept default values for all questions?
ACCEPT_DEFAULT=0
# Use &-U& flag in rpm by default when installing a rpm package
# This tells rpm to (U)pdate the package instead of (i)nstalling it.
RPM_IU=U
# Inspect the file list before creating the package
CK_INSPECT=0
# Review the .spec file before creating a .rpm
REVIEW_SPEC=0
# Review the control file before creating a .deb
REVIEW_CONTROL=0
# Install the package or just create it?
INSTALL=0