ICS/Lotus (mostly), Linux, Travel, Skiing, Mixology, and Random Musing of Interest

 
Bill Malchisky
 

Archives

    Find me here…

  • Skype
  • Bleedyellow via Sametime
  • Ubuntu - Fixing a Damaged Software Catalog and Package Database

    Bill Malchisky  September 16 2013 12:05:00 AM
    Well, when you download enough tools and new packages, at some point you are bound to break something. That happened to me recently and rendered my Ubuntu software catalog useless. Thus, any automatic system updates failed, I was unable to install or remove existing software from within the Ubuntu Software Center, and running any apt-get install commands also failed. This left my system in a static state until fixed. I tried several things from a few community posts, and this post represents the set of steps that worked for me. Now, I am back and yes, I have a few system updates to install too. Nice to be current with my software once again.


    Initial Errors
    1. Ubuntu Software Catalog -- inside a dialog box: “Items Cannot be installed or removed until package catalog is repaired”?
    2. Apt-get command output -- inside a terminal window: "Errors were encountered while processing..."


    Initial Fix Steps
    These three steps can go a long way to fixing a file
    $sudo apt-get clean
    $sudo apt-get autoclean
    $sudo apt-get -f install

    The first step removes any local package files laying around. The second step removes any obsolete package files that might be left on the system. The third step fixes broken dependencies within your package files. You may see this occasionally if you install a package and there is an unmet dependency. The OS will tell you to run it. In this case, we are using manual intervention.

    Next, let's attempt to configure any and all existing unpacked and unconfigured packages on the system. Note this step does backup any existing conffiles (Debian configuration files, usually stored in /etc; run $dpkg --status {package} to see them), which is a nice safety check and then runs a post-installation script (akin to setup in the Domino arena) for the respective package (if available)
    $sudo dpkg --configure -a

    If there is nothing to do, the prompt should be returned. If the dpkg is unable to read the package database, you will most likely get more errors.

    Example:
    Setting up nagios3-common (3.2.3-3ubuntu1) ...
    chown: invalid group: `nagios:adm'
    dpkg: error processing nagios3-common (--configure):
     subprocess installed post-installation script returned error exit status 1

    Now you can try and install your package again --- if you are error-free --- which as you can see below, I am not.

    $sudo apt-get install rar unrar
    {skipping about 75 lines of output}
    dpkg: error processing ntop (--configure):
     subprocess installed post-installation script returned error exit status 1
    No apport report written because MaxReports is reached already
    Errors were encountered while processing:
     apache2.2-common
     apache2-mpm-prefork
     libapache2-mod-php5
     nagios3-common
     nagios3-core
     ntop
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    If the dpkg --configure or apt-get install commands fail, then you may have to get a bit more drastic, as I did.


    Brute-force Clean-up
    Using the final few lines listing from the apt-get install output listing six errant packages, I deliberately forced a remove of each noted entry. When you fix the install again, any missing files would appear internally as a missing dependency and get fixed (if needed). In my case, I am removing applications with their dependent library file package (e.g. apache2.2-common and libapache2-mod-php5), thus in theory the fix command should return nothing but clean output.
    Syntax: $sudo dpkg --force-all --remove {package name}

    For completeness, I will show the commannds used for all six files.

    $sudo dpkg --force-all --remove apache2.2-common
    (Reading database ... 337370 files and directories currently installed.)
    Removing apache2.2-common ...
    Processing triggers for man-db ...
    Processing triggers for ureadahead ...
    ureadahead will be reprofiled on next reboot
    Processing triggers for ufw ...

    $ sudo dpkg --force-all --remove apache2-mpm-prefork
    (Reading database ... 337049 files and directories currently installed.)
    Removing apache2-mpm-prefork ...
    $ sudo dpkg --force-all --remove libapache2-mod-php5
    (Reading database ... 337044 files and directories currently installed.)
    Removing libapache2-mod-php5 ...
    $ sudo dpkg --force-all --remove nagios3-common
    (Reading database ... 337039 files and directories currently installed.)
    Removing nagios3-common ...
     * Stopping nagios3 monitoring daemon nagios3                                  
                                                     [ OK ]
    Processing triggers for ureadahead ...
    $ sudo dpkg --force-all --remove nagios3-core
    (Reading database ... 336986 files and directories currently installed.)
    Removing nagios3-core ...
    Processing triggers for man-db ...
    $ sudo dpkg --force-all --remove ntop
    (Reading database ... 336979 files and directories currently installed.)
    Removing ntop ...
    Processing triggers for man-db ...
    Processing triggers for ureadahead ...


    Lets try and fix things again to ensure we got every file.
    5. $sudo apt-get -f install
    Reading package lists... Done
    Building dependency tree      
    Reading state information... Done
    0 upgraded, 0 newly installed, 0 to remove and 47 not upgraded.


    Much better. No hundred lines of output errors this time. Removing the errant library file entries fixed things.

    Finally, re-install your package(s)
    $sudo apt-get install rar unrar

    Reading package lists... Done
    Building dependency tree      
    Reading state information... Done
    The following NEW packages will be installed:
      rar unrar
    0 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.
    Need to get 0 B/675 kB of archives.
    After this operation, 1,483 kB of additional disk space will be used.
    Selecting previously unselected package rar.
    (Reading database ... 622023 files and directories currently installed.)
    Unpacking rar (from .../rar_2%3a4.0.b3-1_i386.deb) ...
    Selecting previously unselected package unrar.
    Unpacking unrar (from .../unrar_1%3a4.0.3-1_i386.deb) ...
    Processing triggers for man-db ...
    Setting up rar (2:4.0.b3-1) ...
    Setting up unrar (1:4.0.3-1) ...
    update-alternatives: using /usr/bin/unrar-nonfree to provide /usr/bin/unrar (unrar) in auto mode.

    All nice and clean.

    Tip: If you want to learn more about Debian package management, view this page.

    Powered by IBM Lotus Domino 8 | Lotus User Group | Get Firefox! | This blog is listed on Planet Lotus   IBM Certified

    © 2010 William Malchisky.