如何使用checkInstall从源中构建软件包
CheckInstall是一个程序,该程序从源代码中编译程序,并为Linux发行版创建本机包。
这样我们就可以使用分发程序包管理系统(DPKG,RPM或者InstallPKG)安装包。
目前,CheckInstall为基于Deb的系统,基于RPM的系统和Slackware创建本机包。
在这篇简短的教程中,我们将讨论如何使用CheckInstall程序从源中构建软件包。
安装checkinstall.
CheckInstall在最具Linux发行版的默认存储库中提供。
因此,我们可以使用包管理器安装它。
例如,在基于Debian的系统中,我们可以使用以下命令安装它:
$sudo apt-get install checkinstall
在SUSE/OpenSUSE上:
$sudo zypper install checkinstall
在CentOS,Rhel,Fedora:
从此链接下载并安装CheckInstall RPM文件。
# 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 checkinstall-1.6.2-3.el6.1.x86_64.rpm
下载 - 免费电子书:"Linux®补丁管理:保持Linux®系统最新"
使用checkInstall从源构建包
以下是创建"Hello"程序的DEB包的简单步骤。
我在Ubuntu 16.04 LTS中测试了以下步骤。
首先下载'Hello'程序的tar包。
$wget http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
使用命令提取tar包:
$tar -zxvf hello-2.10.tar.gz
the,转到提取的目录:
$cd hello-2.10/
逐个运行以下命令以编译它。
$./configure
$make
现在,而不是键入"make install"命令安装程序,我们键入以下命令:
$sudo checkinstall --install=no
此命令将创建.deb包,但不会安装它。
按Y创建名为"doc-pak"的包文档目录。
checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. The package documentation directory ./doc-pak does not exist. Should I create a default set of package docs? [y]: y Preparing package documentation...OK Please write a description for the package. End your description with an empty line or EOF. >> Simple Hello Program ## Type your Program name and hit ENTER key. >> * Debian package creation selected *** * This package will be built according to these values: 0 - Maintainer: [ Hyman@theitroad ] 1 - Summary: [ Simple Hello Program ] 2 - Name: [ hello ] 3 - Version: [ 2.10 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ hello-2.10 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ hello ] 12 - Conflicts: [ ] 13 - Replaces: [ ] Enter a number to change any of them or press ENTER to continue: ## Hit ENTER key [...] Building file list...OK Building Debian package...OK NOTE: The package will not be installed Erasing temporary files...OK Deleting temp dir...OK ** Done. The new package has been saved to /home/sk/hello-2.10/hello_2.10-1_amd64.deb You can install it in your system anytime using: dpkg -i hello_2.10-1_amd64.deb **
现在,我们可以使用命令安装新创建的.deb包:
$sudo dpkg -i hello_2.10-1_amd64.deb
如果在没有"--install =否"标志的情况下执行上述命令,则会自动创建DED包并在系统上安装它。
$sudo checkinstall
示例输出:
checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. * Debian package creation selected *** * This package will be built according to these values: 0 - Maintainer: [ Hyman@theitroad ] 1 - Summary: [ Simple Hello Program ] 2 - Name: [ hello ] 3 - Version: [ 2.10 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ hello-2.10 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ hello ] 12 - Conflicts: [ ] 13 - Replaces: [ ] Enter a number to change any of them or press ENTER to continue: ##Press ENTER [...] Installing Debian package...OK Erasing temporary files...OK Writing backup package...OK OK Deleting temp dir...OK ** Done. The new package has been installed and saved to /home/sk/hello-2.10/hello_2.10-1_amd64.deb You can remove it from your system anytime using: dpkg -r hello **
此命令将创建.deb文件并自动在系统上安装它。
我们可以使用命令随时删除安装包:
$sudo dpkg -r hello
CheckInstall将自动创建.rpm或者.deb包,具体取决于我们使用的当前Linux发行版的类型。
如果我们需要创建.rpm包,只需遵循基于RPM的系统中的上述步骤。
对于Slackware软件包,请在Slackware系统上执行此操作。
有关更多详细信息,请参阅man 页面:
$man checkinstall
或者,检查帮助部分。
$checkinstall --help