我已尝试按照此处的说明安装 droidcam 来解决另一个问题:通过 PPA 在 Ubuntu 中安装 DroidCam(无线 Android 网络摄像头)客户端
安装失败,出现后脚本错误,发现完整日志这里。
现在,我想清理并彻底删除它。因此,我运行sudo apt-get purge droidcam
。但令我惊讶的是,我必须运行 3 次才能完全清理其安装。
$ sudo apt-get purge droidcam
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-3.19.0-15 linux-headers-3.19.0-15-generic linux-image-3.19.0-15-generic linux-image-extra-3.19.0-15-generic
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
droidcam*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 1,529 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 239094 files and directories currently installed.)
Removing droidcam (1.3-0ubuntu0) ...
rmmod: ERROR: Module v4l2loopback_dc is not currently loaded
dpkg: error processing package droidcam (--purge):
subprocess installed post-removal script returned error exit status 1
Processing triggers for gnome-menus (3.10.1-0ubuntu5) ...
Processing triggers for bamfdaemon (0.5.1+15.04.20150202-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...
Processing triggers for mime-support (3.58ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.14-0ubuntu1) ...
Errors were encountered while processing:
droidcam
E: Sub-process /usr/bin/dpkg returned an error code (1)
$ sudo apt-get purge droidcam
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-3.19.0-15 linux-headers-3.19.0-15-generic linux-image-3.19.0-15-generic linux-image-extra-3.19.0-15-generic
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
droidcam
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 1,529 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 239088 files and directories currently installed.)
Removing droidcam (1.3-0ubuntu0) ...
$ sudo apt-get purge droidcam
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-3.19.0-15 linux-headers-3.19.0-15-generic linux-image-3.19.0-15-generic linux-image-extra-3.19.0-15-generic
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
droidcam*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 239087 files and directories currently installed.)
Removing droidcam (1.3-0ubuntu0) ...
Purging configuration files for droidcam (1.3-0ubuntu0) ...
dpkg: warning: while removing droidcam, directory '/opt' not empty so not removed
$ sudo apt-get purge droidcam
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'droidcam' is not installed, so not removed
The following packages were automatically installed and are no longer required:
linux-headers-3.19.0-15 linux-headers-3.19.0-15-generic linux-image-3.19.0-15-generic linux-image-extra-3.19.0-15-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
我想知道的是:
- 为什么我需要运行多次?
- 怎么办
apt-get purge work
?我想apt-get purge
一次性删除所有已安装的文件。
我的第一个期望,可能是 droidcam 包装得不太好。
答案1
此软件包和许多其他软件包在安装过程中出现问题后需要删除。我的解决方案是,如果脚本失败,请查看文件夹/var/lib/dpkg/info/
。有四种类型的脚本
package_name.preinst
– 预安装脚本package_name.postinst
– 安装后脚本package_name.prerm
– 删除前脚本package_name.postrm
– 删除后脚本
查看脚本:通常很容易立即找到问题。通常只是无法启动或停止的服务。或者像您的情况一样,是一个未加载的模块。如果您只想删除包,请删除有问题的代码并重新开始删除。
在非常有问题的情况下,有时删除整个脚本的唯一方法是删除行exit 0
,目前例如nginx
:(
并作为@kos说,删除该行set -e
。但我从未测试过。
并发起请愿,要求提供更强大的脚本=)
一些例子