OK. Here's the solution to a really annoying problem relating to the Debian APT tool - that package that just won't uninstall for love nor money. I eventually solved it with a little bit of thinking... when I was thinking in the right way about it!
The scenario
Firstly, you get a fairly standard error message, e.g. referring to a non-existent file (typically the init.d file). Then, it triggers the subprocess pre-removal script returned error exit status 1 error. Thus, you get the wonderful E: Sub-process /usr/bin/dpkg returned an error code (1) to top it off. My problem, as the example above suggests, was that I accidentally deleted the init.d script.
What is happening is that the Debian package manager (dkpg) is running the "pre-removal script" found in the /var/lib/dkpg/info/ folder. This will be named [package].prerm. Typically, this is a brief script which manages the stopping of processes, chmod instructions, and deletes/renames certain package files. By all means, have a look in the file.
The solution
To resolve this problem (at your own risk), simply edit the /var/lib/dkpg/info/[package].prerm file, removing troublesome lines, or even, if necessary, simply emptying (but not deleting) the whole file. This allows the process to continue, and the files to be removed.
Having allowed the package to be removed, you may have problems with re-installation - so even if you do not plan on doing so, you may be well advised to tidy up the files - this is simply done by renaming (rather than deleting, for safety) the remaining [package]. files in the /var/lib/dkpg/info/ folder, to, for example, [package].postrm.old. The files likely to be left behind are the .postrm (post-removal script) and the .list (file list) files. These can safely be renamed, since any re-installation will simply replace them with fresh files.
A footnote
If you want a motto, try "everything Linux does makes sense". The script files are easily reachable to ensure you can fix any little bugs you find or create.
And something else I learned recently relating to APT - if you want to search repositories from the command-line, try "apt-cache search ...".
Comments
Commenting is closed.
There are no comments.