You might want to rename your question. It makes your problem sound a bit too generic. You're real question isn't how to reinstall just any local deb, but how to handle a very specific problem.
–
andrewsomethingOct 6 '10 at 4:41

5 Answers
5

In order to make a "clean room" installation, you can first purge the package and then install it again:

dpkg --purge brmfc7340lpr
dpkg --install brmfc7340lpr*.deb

You might need to add option --force-depends during purge, if some other package depends on brmfc7340lpr.

Update: Based on the transcript you posted, it seems that the
brmfc7340lpr package cannot be (re)installed because its
post-removal script is erroring out.

Those files are stored in directory /var/lib/dpkg/info; for each
package X, there can be any one of these scripts:

X.postinst run after the package has been installed, e.g., to
start services provided by the package.

X.prerm run before removing/purging the package, e.g., to
ensure that daemons provided by the package are stopped.

X.postrm run after the package has been removed, e.g., to
signal any service optionally using the package that it is no
longer available. (For instance, a printer driver package might
want to signal cpus/lpr to remove printers depending on that
specific driver.)

Now, this brmfc7340lpr package seems to try to (re)start the lpd
printer daemon upon removal, which won't work as Ubuntu uses CUPS
instead: you should definitely look for a CUPS-compatible printer
driver -- see the link in Jorge Castro's answer. (I think this is a
bug in the package, as it should not restart the lpd service
unconditionally, but just reload it if it's already running.)

This will effectively (re)start CUPS when the lpd service is instead
searched for.

Otherwise, I only see two options, both rather unpleasant:

Either edit the /var/lib/dpkg/info/brmfc7340lpr.postrm script,
and comment out the line that is invoking /etc/init.d/lpd start
(or restart or stop), (e.g., just replace it with /bin/true).
Another option is to just place exit 0 as the first non-comment
line in the script. This would be my favorite, but requires a bit
of confidence with editing shell scripts.

Install lpr, purge the brmfc6340lpr package, purge lpr: this
requires a bit of attention as lpr conflicts with the default
Ubuntu printer spooling system CUPS:

a. sudo aptitude install lpr (this will remove cups-bsd and
ubuntu-desktop as a side effect)

b. sudo aptitude purge brmfc7340lpr lpr (should work now)

c. sudo aptitude install cups-bsd ubuntu-desktop (restore system
to its original state)

@Roman What error message do you get? Does --purge first and then --install work?
–
Riccardo MurriOct 3 '10 at 9:57

@Roman updated with some specific instructions that might help. I agree with andrewsomething's comment that this no longer looks a generic question and should be renamed.
–
Riccardo MurriOct 6 '10 at 10:27

Guess 1: It looks like the deb is trying to restart a service which isn't running and erroring out. Try installing the lpr package from the repositories and then installing the deb and see if that works.

Guess 2: It sounds like you're trying to install a deb from a website for a brother 7340 printer: This page might be a good starting point if you want to split it off into another question.

The problem here appears to be that the package has managed to get itself half-installed, but now its maintainer scripts are all faililng (due to being unable to start the lpd service).

You should be able to resolve this by editing the /var/lib/dpkg/info/brmfc7340lpr.postrm file and commenting out (by adding # to the start of the line) the line which is trying to start lpd (or just comment out everything). You should then be able to run dpkg --configure -a to get the package properly installed before you can remove it.

You might need to edit more of the packages maintainer scripts in order to remove the package - they'll all be in /var/lib/dpkg/info/, and they'll be named something like brmfc7340lpr.X where X can be one of preinst, postinst, prerm, postrm.

This is an example of the sort of havoc a poorly written package can wreak.

Actually, I ran into the same problem. Turns out I followed some irrelevant information and created a /etc/init.d/lpd file as a softlink to /etc/init.d/cups
The .postrm script checks for lpd and if it exists, tries to start the service.
After I deleted the softlinked lpd file in the init.d directory, the package installation and removal went back to normal.