apt-get purge如何工作? 为什么它不能一次性删除破损的包裹?

我已经尝试安装droidcam来解决另一个问题,按照以下说明操作: 在Ubuntu中通过PPA安装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 work ? 我虽然apt-get purge会一次性删除所有已安装的文件。

我的第一个期望,可能是droidcam包装不好。

在安装过程中出现问题后,此软件包和许多其他软件包都有问题需要删除。 我的解决方案,如果脚本失败,请查看文件夹/var/lib/dpkg/info/ 。 有四种类型的脚本

  1. package_name.preinst – 安装前脚本
  2. package_name.postinst – 安装后脚本
  3. package_name.prerm – 删除前脚本
  4. package_name.postrm – 删除后脚本

查看脚本:通常很容易立即找到问题。 通常它只是一种无法启动或停止的服务。 或者在您的情况下,卸载模块。 如果您只想删除软件包,请删除有问题的代码并再次开始删除。

在非常有问题的情况下有时删除整个脚本到线exit 0的唯一方法,目前例如nginx 🙁

正如@kos所说,删除行set -e 。 但我从未测试过。

并开始请求更强大的脚本=)


一些例子

如何删除Brother MFC-8840 deb驱动程序坏掉的dpkg?

AVG错误(重新安装ubuntu)

无法安装doc-base