Fix for preupgrade-cli on Fedora 12

Background:
I had been running Fedora 12 on my home server with a 5-year old CPU and Nvidia video card. Last weekend, I decided to modernize with fancy new hardware, an Intel G6950 dual-core with integrated graphics. This is great, but Fedora 12 has graphics drivers that like to crash with Intel integrated graphics hardware, so once I changed the hardware, my desktop would freeze, about 30 seconds after logging in. So I decided to upgrade to Fedora 13.

The generally recommended way to upgrade on Fedora is to use the preupgrade tool, which would be nice, graphical, and great if my graphical desktop didn’t crash (and if it didn’t, I’d be sticking with F12 for now). So the alternative is supposed to be “preupgrade-cli”. This would work, because I could boot and do a console (non-graphical) login, so the video driver couldn’t muck things up (as easily?).

Problem: preupgrade-cli doesn’t work in Fedora 12.
(Okay, maybe it will for you, because you have executive platinum status with Fedora.) I got this error, which is pasted below:
# preupgrade-cli
Loaded plugins: blacklist, dellsysidplugin2, priorities, versionlock, whiteout
No plugin match for: rpm-warm-cache
No plugin match for: auto-update-debuginfo
No plugin match for: refresh-packagekit
No plugin match for: presto
Traceback (most recent call last):
File "/usr/share/preupgrade/preupgrade-cli.py", line 316, in
pu = PreUpgradeCli()
File "/usr/share/preupgrade/preupgrade-cli.py", line 52, in __init__
PreUpgrade.__init__(self)
File "/usr/lib/python2.6/site-packages/preupgrade/__init__.py", line 80, in __init__
self._getConfig()
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 282, in _getConfig
startupconf.pluginconfpath,disabled_plugins,enabled_plugins)
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 465, in doPluginSetup
plugin_types, confpath, disabled_plugins, enabled_plugins)
File "/usr/lib/python2.6/site-packages/yum/plugins.py", line 160, in __init__
self.run('config')
File "/usr/lib/python2.6/site-packages/yum/plugins.py", line 177, in run
func(conduitcls(self, self.base, conf, **kwargs))
File "/usr/lib/yum-plugins/versionlock.py", line 153, in config_hook
conduit.registerCommand(VersionLockCommand())
File "/usr/lib/python2.6/site-packages/yum/plugins.py", line 499, in registerCommand
self._base.registerCommand(command)
File "/usr/share/yum-cli/cli.py", line 106, in registerCommand
if name in self.yum_cli_commands:
AttributeError: 'PreUpgradeCli' object has no attribute 'yum_cli_commands'

Apparently the anonymous poster at the How to Upgrade page had the same problem. Perhaps we are the only two to bother with the “arcane” command-line preupgrade tool. I am curious as to whether anyone (at all) succeeded with preupgrade-cli for Fedora 12 to Fedora 13.

Solution: Patch preupgrade-cli.py. If you don’t have experience writing code on Linux, this is probably not for you. But it’s pretty straightforward. You need to change the definition of the PreUpgradeCli class so that it self.yum_cli_commands is valid. Do this by replacing the line:

class PreUpgradeCli(PreUpgrade, YumUtilBase):

with

class PreUpgradeCli(PreUpgrade, YumUtilBase, YumBaseCli):

so that it inherits from a class with such an attribute and insert this line:

        YumBaseCli.__init__(self)

as the first line of the initializer, below

    def __init__(self):

and before

        PreUpgrade.__init__(self)

so that the parent class's initializer gets called and self.yum_cli_commands gets populated. The file is found at /usr/share/preupgrade/preupgrade-cli.py

Remember, this is Python, so line indentation is important. There you go. preupgrade-cli should work as normal now.

Note: I don't know whether this is the Right Way To Fix It, but it seemed reasonable to me, and I got the result I wanted. I will probably point the developer of preupgrade-cli.py to this page so he/she can compose a better fix.

Update (6/13/2011): This fix has been accepted officially (see comments), thanks to the efforts of Andrew Meredith, who opened the bug on Red Hat's bugzilla, and Martin Dengler who opened a ticket in preupgrade's own Trac site.

Leave a comment ?

13 Comments.

  1. Prabhat Kumar

    Thanks buddy its working.

  2. Andrew Meredith

    Nice catch m8. Thanks for publishing.

  3. Thanks ! That worked.

  4. Anyone tried preupgrade from f13 to f14? - pingback on November 16, 2010 at 4:53 pm
  5. Wumple.com » Fedora 12 to 14 Upgrade - pingback on December 26, 2010 at 9:17 am
  6. I submitted a ticket upstream at https://fedorahosted.org/preupgrade/ticket/66 and tried to get the downstream ticket reopened at https://bugzilla.redhat.com/show_bug.cgi?id=615640 .

    More bumps would be appreciated as this bug has been out there for a while.

  7. Looks like your patch was accepted and the problem will be fixed next release.

    Thanks again.

  8. Thanks, it worked in F14, too.

  9. Fedora 15 used the patch but they put
    YumBaseCli.__init__(self)
    before
    YumBaseCli.__init__(self)
    !!!!!

  10. I have submitted a new patch at https://fedorahosted.org/preupgrade/ticket/66#comment:3 …feel free to bump it, or something.

  11. Helps with upgrade from Fedora 16 to Fedora 17 also. First part was already in place, and second part was there but in wrong sequence. Resequenced YumBaseCli.__init__(self), and my upgrade restarted after having been hanging for two days.

    Thank you very much! Hopefully I’ll have 17 soon!

  12. magnificent points altogether, you simply received a brand new reader. What may you recommend in regards to your put up that you just made some days ago? Any sure?

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks and Pingbacks: