2

I've tried installing droidcam to solve another question following instruction here: Install DroidCam (Wireless Android Webcam) Client In Ubuntu Via PPA

The installation fails with post-script error, full log found here.

Now, I want to clean it up and remove it completely. So, I run sudo apt-get purge droidcam. But I was surprised that I have to run it 3 times to fully clean its installation.

$ 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.

What I want to know:

  • Why, I need to run it multiple times?
  • How does apt-get purge work? I though apt-get purge will remove all installed files with one pass.

My first expectation, may be droidcam is not well packaged.

3

This and many other packages have problems to be removed after a problem during the installation. My solution, if a script fails, look into the folder /var/lib/dpkg/info/. There are four types of scripts

  1. package_name.preinst – pre-installation script
  2. package_name.postinst – post-installation script
  3. package_name.prerm – pre-removal script
  4. package_name.postrm – post-removal script

Look into the scripts: It is usually very easy to find the problem immediately. Often it is just a service that can not be started or stopped. Or as in your case, an unloaded module. If you want to only remove the package, remove the offending code and start deleting again.

At very problematic cases Sometimes the only way to delete the entire script down to the line exit 0, currently e.g. nginx :(

And as @kos says, remove the line set -e. But I've never tested.

And start a petition for more robust scripts =)


Some examples

How can I remove a dpkg broken by the Brother MFC-8840 deb driver?

AVG Error (reinstall ubuntu)

Failing to install doc-base

  • 2
    Maybe removing set -e from the top of the script is better instead of deleting everything, at least what can be done will be done, and what can't be done...won't be done – kos Oct 19 '15 at 13:52
  • @kos Oh yes, thank you, but I've never tested =) – A.B. Oct 19 '15 at 13:53
  • Thank you all, both ways work. commenting set -e or instruction dealing with module. – user.dz Oct 19 '15 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.