I'm getting an apt-get error that says
E: The package brmfc7340lpr needs to be reinstalled, but I can't find an archive for it.
The brmfc7340lpr is a printer driver -- it's a local deb file. Doing a dpkg or apt-get purge doesn't work, neither does apt-get install -f .
How do I reinstall a package from a local deb file?
Output:
box-name% sudo apt-get upgrade
[sudo] password for username:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package brmfc7340lpr needs to be reinstalled, but I can't find an archive for it.
box-name% sudo apt-get purge brmfc7340lpr
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package brmfc7340lpr needs to be reinstalled, but I can't find an archive for it.
box-name% sudo dpkg --purge brmfc7340lpr
dpkg: error processing brmfc7340lpr (--purge): Package is in a very bad inconsistent state - you should reinstall it before attempting a removal.
Errors were encountered while processing: brmfc7340lpr
box-name% sudo dpkg --install brmfc7340lpr-2.0.2-1.i386.deb
Selecting previously deselected package brmfc7340lpr.
(Reading database ... 725204 files and directories currently installed.)
Preparing to replace brmfc7340lpr 2.0.2-1 (using .../brmfc7340lpr-2.0.2-1.i386.deb) ...
Unpacking replacement brmfc7340lpr ...
start: Unknown job: lpd
dpkg: warning: subprocess old post-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
start: Unknown job: lpd
dpkg: error processing brmfc7340lpr-2.0.2-1.i386.deb (--install): subprocess new post-removal script returned error exit status 1
start: Unknown job: lpd
dpkg: error while cleaning up: subprocess new post-removal script returned error exit status 1
Errors were encountered while processing:
brmfc7340lpr-2.0.2-1.i386.deb
box-name% sudo apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package brmfc7340lpr needs to be reinstalled, but I can't find an archive for it.
box-name% 1 4 Answers
You can always (re)install a package using dpkg:
dpkg --install local-file.debIn order to make a "clean room" installation, you can first purge the package and then install it again:
dpkg --purge brmfc7340lpr
dpkg --install brmfc7340lpr*.debYou 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.postinstrun after the package has been installed, e.g., to start services provided by the package.X.prermrun before removing/purging the package, e.g., to ensure that daemons provided by the package are stopped.X.postrmrun 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 lpdprinter 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.)
The best option to go forward comes from this launchpad answer:
ln -s /etc/init.d/cpus /etc/init.d/lpdThis 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.postrmscript, and comment out the line that is invoking/etc/init.d/lpd start(orrestartorstop), (e.g., just replace it with/bin/true). Another option is to just placeexit 0as 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 thebrmfc6340lprpackage, purgelpr: this requires a bit of attention aslprconflicts with the default Ubuntu printer spooling system CUPS:a.
sudo aptitude install lpr(this will removecups-bsdandubuntu-desktopas 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)
Riccardo's solution should work, I am guessing the problem lies here:
start: Unknown job: lpd
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.
1Actually, 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/cupsThe .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.
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.