LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Yum not able to to completely upgrade the system, how to fix ? (https://www.linuxquestions.org/questions/linux-software-2/yum-not-able-to-to-completely-upgrade-the-system-how-to-fix-676205/)

harry2006 10-14-2008 03:05 AM

Yum not able to to completely upgrade the system, how to fix ?
 
Hi all. I apologize for not able to put a proper subject line. A couple of days back I was doing system upgrade as usual using the following command
Code:

sudo yum update
.
I'd done the same thing around a month ago and it was upgrade of about 1GB and everything was working fine after that.
Now this time when I ran the above command, it downloaded the rpms and started upgrading and oops the screen went black, no response at all . it seemed to me that the keyboard, mouse etc stopped working, i don't know what happened. After waiting for some time I was forced to do a maual reboot. I remember that during installation just before that "black screen" problem the count was something [117/377] i mean the 117th upgrade was going on ,out of the total 377.
I'm using Fedora9[2.6.26 kernel] and also use apt-get alonwith yum. I tried to do an upgrade hoping to upgrade teh remaining pkgs, but it saind nothing to update. Then I tried to use apt-get to update. I got teh message from apt-get something like this
Code:

W: There are multiple versions of "kdeutils" in your system.

This package won't be cleanly updated, unless you leave
only one version. To leave multiple versions installed,
you may remove that warning by setting the following
option in your configuration file:

RPM::Allow-Duplicated { "^kdeutils$"; };

To disable these warnings completely set:

RPM::Allow-Duplicated-Warning "false";

W: You may want to run apt-get update to correct these problems
E: Unmet dependencies. Try 'apt-get --fix-broken install' with no packages (or specify a solution).

This is just a part, there are hell of messages like this. As mentioned in this i tried to run "apt-get --fix-broken install" but though it removed 1/2 packages but dint fix the overall problem. I manually removed some packages after finding that there are a lot of packages that indeed have multiple packages installed. I want to know how to fix this problem. How to make a complete upgrade. If I've to manually remove the packages then any quich method, as teh way I'm doing will obiviosly take ages to do . Please help me . Thank you.

osvaldomarques 10-14-2008 12:54 PM

Hi Harry2006,

I had this kind of problem a few years ago. The rpm database got corrupted and kills the update in the middle. In fact, it retarded me to adopt the fedora.

I found a python script on the internet, which I save with the jewels of the crown. Sorry that I don't remember the site nor the author, but the script is here:
Code:

#!/usr/bin/python -tt

import sys
sys.path.insert(0,'/usr/share/yum-cli')
import cli

def findDupes(my):
    """takes a yum base object prints out a list of package duplicates.
      These typically happen when an update transaction is left half-completed"""

    # iterate rpmdb.pkglist
    # put each package into name.arch dicts with lists as the po
    # look for any keys with a > 1 length list of pos where the name
    # of the package is not kernel and/or does not provide a kernel-module
    pkgdict = {}
    refined = {}
    dupes = []

    for (n,a,e,v,r) in my.rpmdb.simplePkgList():
        if not pkgdict.has_key((n,a)):
            pkgdict[(n,a)] = []
        pkgdict[(n,a)].append((e,v,r))

    for (n,a) in pkgdict.keys():
        if len(pkgdict[(n,a)]) > 1:
            refined[(n,a)] = pkgdict[(n,a)]

    del pkgdict

    return refined


def setupOldDupes(my):
    """remove all the older duplicates"""

    dupedict = findDupes(my)
    removedupes = []
    for (n,a) in dupedict.keys():
        if n.startswith('kernel'):
            continue
        if n.startswith('gpg-pubkey'):
            continue
        (e,v,r) = dupedict[(n,a)][0]
        lowpo = my.getInstalledPackageObject((n,a,e,v,r))

        for (e,v,r) in dupedict[(n,a)][1:]:
            po = my.getInstalledPackageObject((n,a,e,v,r))
            if po.EVR < lowpo.EVR:
                lowpo = po

        removedupes.append(lowpo)

    for po in removedupes:
        my.remove(po)

    return len(removedupes)

def main():
    my = cli.YumBaseCli()
    my.doGenericSetup()

    #something here to set -y or not
    num = setupOldDupes(my)
    if num < 1:
        print 'no dupes to remove'
        sys.exit(0)

    my.buildTransaction()
    my.doTransaction()

    sys.exit(0)


if __name__ == "__main__":
  main()

Save it as "dupes-cli.py" (I guess that was the suggestion for the name), make it executable (chmod +x dupes-cli.py) and run it as root.

It will remove the duplicates from the rpm database. After that, (I hope so!) you can enter "yum update" again and the process will go till the end.

Osvaldo.

harry2006 10-16-2008 12:11 AM

Quote:

Originally Posted by osvaldomarques (Post 3309928)
Hi Harry2006,

I had this kind of problem a few years ago. The rpm database got corrupted and kills the update in the middle. In fact, it retarded me to adopt the fedora.

I found a python script on the internet, which I save with the jewels of the crown. Sorry that I don't remember the site nor the author, but the script is here:
Code:

#!/usr/bin/python -tt

import sys
sys.path.insert(0,'/usr/share/yum-cli')
import cli

def findDupes(my):
    """takes a yum base object prints out a list of package duplicates.
      These typically happen when an update transaction is left half-completed"""

    # iterate rpmdb.pkglist
    # put each package into name.arch dicts with lists as the po
    # look for any keys with a > 1 length list of pos where the name
    # of the package is not kernel and/or does not provide a kernel-module
    pkgdict = {}
    refined = {}
    dupes = []

    for (n,a,e,v,r) in my.rpmdb.simplePkgList():
        if not pkgdict.has_key((n,a)):
            pkgdict[(n,a)] = []
        pkgdict[(n,a)].append((e,v,r))

    for (n,a) in pkgdict.keys():
        if len(pkgdict[(n,a)]) > 1:
            refined[(n,a)] = pkgdict[(n,a)]

    del pkgdict

    return refined


def setupOldDupes(my):
    """remove all the older duplicates"""

    dupedict = findDupes(my)
    removedupes = []
    for (n,a) in dupedict.keys():
        if n.startswith('kernel'):
            continue
        if n.startswith('gpg-pubkey'):
            continue
        (e,v,r) = dupedict[(n,a)][0]
        lowpo = my.getInstalledPackageObject((n,a,e,v,r))

        for (e,v,r) in dupedict[(n,a)][1:]:
            po = my.getInstalledPackageObject((n,a,e,v,r))
            if po.EVR < lowpo.EVR:
                lowpo = po

        removedupes.append(lowpo)

    for po in removedupes:
        my.remove(po)

    return len(removedupes)

def main():
    my = cli.YumBaseCli()
    my.doGenericSetup()

    #something here to set -y or not
    num = setupOldDupes(my)
    if num < 1:
        print 'no dupes to remove'
        sys.exit(0)

    my.buildTransaction()
    my.doTransaction()

    sys.exit(0)


if __name__ == "__main__":
  main()

Save it as "dupes-cli.py" (I guess that was the suggestion for the name), make it executable (chmod +x dupes-cli.py) and run it as root.

It will remove the duplicates from the rpm database. After that, (I hope so!) you can enter "yum update" again and the process will go till the end.

Osvaldo.

Thanks you very much, Osvaldo. This is exactly what I need. There is a problem, I copied the code from your reply and chmod +x then tried to run this but there seems to be some kind of syntax error or may be some thing else, it said
Code:

File "./clear-dups.py", line 15
    pkgdict = {}
    ^
IndentationError: unexpected indent

I dont know much of python, tried to look around but dont know whatz the problem. Can you please have a look and let me know the fix? Thank you.

osvaldomarques 10-16-2008 02:21 AM

Harry2006,

First I must declare: "I don't know a drop of python". This is for some expert looking this thread and dislike the stupidities I will talk now!

As far as I (don't) know, the python syntax is oriented to indentation. Instead of parenthesis, braces, tags and etc., the indentation defines the code blocks.

If your editor edited the text during the paste process, you get a wrong code; I did reproduce the behavior you reported using vim with "set autoindent"; with this option, vim (vi) indent each new line following the previous margin; this result in an stair case text and the error is reported on line 15.

So, try the following process:
1. open an xterm session;
2. enter the following command:
cat >clear-dups.py <enter>
3. Copy the text on the browser;
4. paste it on the xterm session;
5. press CTRL/D to finish input;

Now, chmod +x , blah, blah, blah ...

harry2006 10-17-2008 05:58 AM

@Thank you very much for giving a quick and detailed response. I was trying to do what you said and in the meantime googling out for the problem and luckily found one yum-plugin that takes care of all the duplicate installs and gets rid of them. I would like to share the same for the benifit of others. Just use the following command
Code:

yum install yum-utils
this will install the plugin and now you can issue the following commands
Code:

package-cleanup --dupes # list out duplicates
package-cleanup --cleandupes # clean up duplicates
package-cleanup --problems # list out packages with broken dependencies

Make sure you run this command prefixed with sudo as it requires root previleges to remove packages. If you want to know about this plugin in details and also some more really useful yum plugings then have a look here,
http://blog.kagesenshi.org/2008/04/1...nd-tricks.html

Thank you very much.


All times are GMT -5. The time now is 09:11 PM.