1

At some point, one of my servers stopped writing to its network attached storage device (I presume), and it resulted in a week or more's worth of packages ending up in the "half-installed" state.

What is odd is that apt-get does not report any issues and I was able to get the most recent updates to install as intended.

It was only when I took a look through the logs (dpkg.log*) and found that there was many more packages in this state.

I need a way to go through all of the packages in apt-get or dpkg, and perform an apt-get install <packagename> --reinstall operation.

Unless there is another way to clean up this mess.

Does anybody have any idea on how I can do this? or have any other ideas on how to resolve this issue?

3

Try sudo dpkg --configure -a. That should automatically repair those packages.

If that doesn't work, try running sudo apt-get install -f and then running sudo dpkg --configure -a again

If you really want to go through each package and reinstall,

And keep in mind, this is definitely not the ideal solution.

Only do this if the sudo dpkg --configure -a command does not work.

This will take a really, really long time since it has to download all the packages again and install them:

for pkg in `dpkg --get-selections | awk '{print $1}' | egrep -v '(dpkg|apt|mysql|mythtv)'` ; do apt-get -y --force-yes install --reinstall $pkg ; done

Source

  • Unfortunately, the dpkg and apt-get builtins for restoring order to the package manager were not working. this is exactly what I was looking for. I couldn’t find a suitable one-liner anywhere to do this, and I simply did not have the time to write one. I just moved on to work on something else. thank you very much. hopefully this helps anybody who has the same issue i did – RapidWebs Aug 15 '14 at 16:03
  • just noticed that this might reinstall all packages. maybe I can modify this at a later time to specifically reinstall packages in the "half-installed" state. if I do so, I will reply to this thread with another answer. either way, this is a suitable starting point. thanks again – RapidWebs Aug 15 '14 at 16:16
  • Yes, it will reinstall all packages. It's really more of a last resort than a solution. – Pranav Marathe Aug 15 '14 at 18:51
0

to Pranav Marathe answer:

   --force-yes
       Force yes; this is a dangerous option that will cause apt to
       continue without prompting if it is doing something potentially
       harmful. It should not be used except in very special situations.
       Using force-yes can potentially destroy your system! Configuration
       Item: APT::Get::force-yes. This is deprecated and replaced by
       --allow-downgrades, --allow-remove-essential,
       --allow-change-held-packages in 1.1.

   -y, --yes, --assume-yes
         Automatic yes to prompts; assume "yes" as answer 
         to all prompts  and run non-interactively. 
         If an undesirable situation, such as changing a held package, 
         trying to install a unauthenticated package 
         or removing an essential package occurs then apt-get will abort.  
         Configuration Item: APT::Get::Assume-Yes.
0

I ran into this problem after installing the Opera web browser on Linux Mint. Srsly, just don't go there. I'm not sure what the guise who let the present Opera package into the repos were smoking, but apparently they did not test it against older but still living LTS (Long Term Support) versions of "supported" Debian-based operating systems before doing so.

If this ever happens to a system you're in charge of - update attempts returning "error code 1" and no changes made because of broken junk - here's a simple fix that works. Pop open a terminal and do:

cd /var/lib/dpkg/info/

This gets you to the directory where dpkg stores its configuration files related to installed software. Then do:

ls | grep -i opera

(replace "opera" with whatever package broke your package manager)

This command lists every file with "Opera" or etc. in its name. Look them over: Is anything /not/ related to Opera (or whatever) listed? If so, take note and delete only the "offending" package's files one at a time, using their full names, to avoid breaking other things with similar names. But if all the returns from your search obviously belong to the borken package, do:

sudo rm opera

... replacing "opera" with whatever junk has disabled your package manager.

Result: The half-installed broken package will sit on your hard drive "forever", an Mortal Insult to All That Is Good And Holy - but doing no actual harm of any kind other than wasting a few MB of drive space. Unless you go into you /bin directory and remove them by hand. Either way, you can now update your installed software, install new packages, etc. normally, because your package manager no longer knows that the failed package and its borken parts ever existed.

  • 1
    Where I wrote "sudo rm [asterisk]opera[asterisk]", Google's professional web designers in their infinite ingorance present the word "opera" in italics. Let's see what, if anything, they replace the quote marks above with... – user937208 Mar 23 '19 at 6:58

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.