52

I have a custom package installed on my Ubuntu 10.10, and trying to remove it, I got:

$ sudo dpkg -r package
sub-process script post-installation installed returne an error state 127

(the message returned from the command was translated from portuguese(br).

So, I noted that on the installation script of this package, what it did was create an entry on my startup, create a folder on /opt and create a user.

I removed all it created. But now, I just want to remove it from dpkg list, because I want to make my linux like if I never installed this package.

How can I do this?

Braiam
  • 67,791
  • 32
  • 179
  • 269

2 Answers2

65

You may need to manually remove the package using:

sudo dpkg --purge --force-all package

Replace package with the name of the package.

Do note: its recommended to report a bug if the package is not yours or is unknown to you what the script does.

Braiam
  • 67,791
  • 32
  • 179
  • 269
41

trying to remove xmail with dpkg --purge --force-all xmail failed because the pre-removal script was exiting with a failure attempting to stop the xmail daemon. I found the solution here:

specifically, I edited /var/lib/dpkg/info/xmail.prerm and changed || exit $! to || true

Manuel Jordan
  • 1,768
  • 7
  • 30
  • 50
  • 1
    I don't understand the downvote. the other solution doesn't cover all cases, and this provides some help for the remainder. – jcomeau_ictx Apr 07 '16 at 13:47
  • 1
    If I have to guess, you answer "failed because the pre-removal script", this questions is about the "post-installation" script. You aren't answering the currently asked question. – Braiam Apr 07 '16 at 23:34
  • 2
    I had a problem with the pre-removal script and this helped me. – Bogdan Calmac Dec 08 '17 at 19:32
  • 3
    As one can expect, if editing *.prerm files is too tedious, you can delete them as well - uninstallation process works with them missing – psukys Jan 24 '18 at 10:30
  • thanks, didn't know that! that's worth a separate answer, if you want to do so. – jcomeau_ictx Jan 25 '18 at 04:04
  • This solved my problem: I edited /var/lib/dpkg/info/[packagename].prerm and changed || exit $! to || true! Thanks – Basj Nov 16 '20 at 16:23