使用 checkinstall 代替 make install 编译安装

在 Linux 上编译安装时,我总会有这样一个感觉,make install 放了很多文件到我的系统里,如果我哪天想把这些东西删掉,该怎么做。有人可能会说,make uninstall 不就好了,但是在绝大多数情况下,并没有人会去写这些卸载程序。

这时候就轮到 checkinstall 这个小程序出场了,它可以跟踪 make install 执行的步骤,并且生成相应的 deb/rpm 包,然后就可以使用包管理器愉快地卸载掉编译安装的程序。

以安装 qbittorrent 3.3.16 为例,简要介绍一下流程。

系统环境

Ubuntu 16.04, qbittorrent 3.3.16

准备

首先需要安装 checkinstall,在 apt 的帮助下,这件事并不难,apt install checkinstall 即可。

安装 qbittorrent

首先按照之前的一篇文章处理一下源码和依赖,之后只需要做一个很小的改动,将 make install 这个命令换成 checkinstall,之后它会自动调用 make install 并进行跟踪,完成安装操作。

之后会让你输入该程序包的描述,照做就好:

root@server:~/Software/qbittorrent-3.3.16# checkinstall

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.
>> qbittorrent 3.3.16
>> 

*****************************************
**** Debian package creation selected ***
*****************************************

This package will be built according to these values: 

0 -  Maintainer: [ root@ns3284041 ]
1 -  Summary: [ qbittorrent 3.3.16 ]
2 -  Name:    [ qbittorrent ]
3 -  Version: [ 3.3.16 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ amd64 ]
8 -  Source location: [ qbittorrent-3.3.16 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ qbittorrent ]
12 - Conflicts: [  ]
13 - Replaces: [  ]

Enter a number to change any of them or press ENTER to continue: 

Installing with make install...

然后进行的就是标准的 make install 操作,安装完成之后,会输出一些日志,告诉你可以用 dpkg 将它卸载。

======================== Installation successful ==========================

Copying documentation directory...
./
./Changelog
./COPYING
./README.os2
./AUTHORS
./README.md
./INSTALL
./TODO
./NEWS
./doc/
./doc/qbittorrent-nox.1
./doc/qbittorrent.1

Copying files to the temporary directory...OK

Stripping ELF binaries and libraries...OK

Compressing man pages...OK

Building file list...OK

Building Debian package...OK

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

 /root/Software/qbittorrent-3.3.16/qbittorrent_3.3.16-1_amd64.deb

 You can remove it from your system anytime using: 

      dpkg -r qbittorrent

**********************************************************************

然后我们来看一看 dpkg 中是否已经有了 qbittorrent

root@server:~/Software/qbittorrent-3.3.16# dpkg -l|grep qbit
ii  qbittorrent                          3.3.16-1                                   amd64        qbittorrent 3.3.16

之后如果要卸载,执行 dpkg -r qbittorrent 即可,干净又方便。

参考资料

https://help.ubuntu.com/community/CheckInstall

其实 Ubuntu 还有两个更激进的工具,AutoDebAutoApt,有兴趣也可以了解一下

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注