当前位置: 首页 > 工具软件 > Checkinstall > 使用案例 >

源码安装工具checkinstall使用

羊舌兴德
2023-12-01

每当从源码包编译程序时,安装过程很愉快,但当你想删除时,就很费脑筋了,你可能要去找你当时编译的目录执行make unistall,当然更可能的是,你早就把源码包给删除了,对于强迫症来说,这显然不能忍。
checkinstall工具就是来解决这个问题的:

NAME
checkinstall – Track installation of local software, and produce a binary manageable with your package management software.

SYNOPSIS
checkinstall [options] [install command]
DESCRIPTION
checkinstall is a program that monitors an installation procedure (such as make install, install.sh ), and creates a standard
package for your distribution (currently deb, rpm and tgz packages are supported) that you can install through your distribution’s
package management system (dpkg, rpm or installpkg).
Note that for most useful actions, checkinstall must be run as root.

这个命令可以生成一个软件包。
常用选项:
-D 生成Debian package.
-R 生成RPM package.
-S 生成Slackware Package.
–install 创建包时是否安装
-y 所有选项都默认选是
–pkgname 包名
–pkgversion 包版本
–pakdir 在哪保存包
–nodoc 不要包含文档
-si 交互式运行
–strip stripping可执行进程
–stripso stripping共享库
–addso 把共享库加到/etc/ld.so.conf
–exclude 去除文件或目录
–include 强制包含文件或目录
–inspect 检查包的文件列表

比如

checkinstall --install=no --nodoc --strip --stripso

指定不安装包,不包含文档,strop所有进程和库
执行后会交互的让你确定一些信息,默认配置是从 /etc/checkinstallrc 读取的。
结果如下:

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

 Done. The new package has been saved to

 /root/project/gdb-12.1/bentutubuild/aarch64-linux-gdb-utils_1.0-1_amd64.deb
 You can install it in your system anytime using:

      dpkg -i aarch64-linux-gdb-utils_1.0-1_amd64.deb

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

实际他还是执行了make install,只是没安装deb包。
需要注意的是,若不是常规的安装命令需要在最后指定,例如单独安装gdbserver:

 checkinstall --install=no --nodoc --strip --stripso make install-gdbserver

使用dpkg查看包中文件内容:

root@bentutu:~/project/gdb-12.1/linkbuild# dpkg -c gdbserver_1.0-1_arm64.deb
drwxr-xr-x root/root         0 2023-05-02 01:41 ./
drwxr-xr-x root/root         0 2023-05-02 01:41 ./opt/
drwxr-xr-x root/root         0 2023-05-02 01:41 ./opt/linkcopy/
drwxr-xr-x root/root         0 2023-05-02 01:41 ./opt/linkcopy/bin/
-rwxr-xr-x root/root   8465040 2023-05-02 01:41 ./opt/linkcopy/bin/gdbserver
drwxr-xr-x root/root         0 2023-05-02 01:41 ./opt/linkcopy/lib/
-rwxr-xr-x root/root   2311320 2023-05-02 01:41 ./opt/linkcopy/lib/libinproctrace.so

可以看到路径就是安装的路径。
制作好deb包之后就可以通过 apt-get install -fdpkg -i来安装了.
下面是先安装后删除的实例:

root@bentutu:~/project/gdb-12.1/bentutubuild# dpkg -i aarch64-linux-gdb-utils_1.0-1_amd64.deb
(Reading database ... 36525 files and directories currently installed.)
Preparing to unpack aarch64-linux-gdb-utils_1.0-1_amd64.deb ...
Unpacking aarch64-linux-gdb-utils (1.0-1) ...
Setting up aarch64-linux-gdb-utils (1.0-1) ...
root@bentutu:~/project/gdb-12.1/bentutubuild# ls /opt/
bentutucopy  xwd

root@bentutu:~/project/gdb-12.1/bentutubuild# dpkg -l|grep gdb
ii  aarch64-linux-gdb-utils            1.0-1                              amd64        an gdb tools for connect to arm64 gdbserver
ii  cgdb                               0.6.7-2build6                      amd64        curses-based interface to the GNU Debugger (GDB)
ii  gdb                                9.2-0ubuntu1~20.04.1               amd64        GNU Debugger
ii  gdbserver                          9.2-0ubuntu1~20.04.1               amd64        GNU Debugger (remote server)
ii  libgdbm-compat4:amd64              1.18.1-5                           amd64        GNU dbm database routines (legacy support runtime version)
ii  libgdbm6:amd64                     1.18.1-5                           amd64        GNU dbm database routines (runtime version)

root@bentutu:~/project/gdb-12.1/bentutubuild# sudo apt-get remove aarch64-linux-gdb-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  aarch64-linux-gdb-utils
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 41.2 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 36661 files and directories currently installed.)
Removing aarch64-linux-gdb-utils (1.0-1) ...
dpkg: warning: while removing aarch64-linux-gdb-utils, directory '/opt' not empty so not removed
root@bentutu:~/project/gdb-12.1/bentutubuild# ls /opt/
xwd

root@bentutu:~/project/gdb-12.1/bentutubuild# dpkg -l|grep gdb
ii  cgdb                               0.6.7-2build6                      amd64        curses-based interface to the GNU Debugger (GDB)
ii  gdb                                9.2-0ubuntu1~20.04.1               amd64        GNU Debugger
ii  gdbserver                          9.2-0ubuntu1~20.04.1               amd64        GNU Debugger (remote server)
ii  libgdbm-compat4:amd64              1.18.1-5                           amd64        GNU dbm database routines (legacy support runtime version)
ii  libgdbm6:amd64                     1.18.1-5                           amd64        GNU dbm database routines (runtime version)
root@bentutu:~/project/gdb-12.1/bentutubuild#

至此,安装的文件可以较好的管理了。
其他的dpkg常用命令:

dpkg -i name.deb #安装软件包
dpkg -I name.deb #从包里获取deb包的信息/gg
dpkg -c name.deb #查看包内的内容,看起来就跟压缩包一样
dpkg -s name #查看已安装的包裹信息
dpkg -r name #删除一个已安装的包裹
dpkg -P name #删除一个已安装的包裹,包括配置文件
 类似资料: