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