lib/chef/provider/package/yum-dump.py in chef-0.7.16 vs lib/chef/provider/package/yum-dump.py in chef-0.8.2

- old
+ new

@@ -43,12 +43,21 @@ # Can't do try: except: finally: in python 2.4 it seems, hence this fun. try: try: y = yum.YumBase() - # Only want our output - y.doConfigSetup(debuglevel=0, errorlevel=0) + try: + # Only want our output + y.doConfigSetup(errorlevel=0,debuglevel=0) + except: + # but of course, yum on even moderately old + # redhat/centosen doesn't know how to do logging properly + # so we duck punch our way to victory + def __log(a,b): pass + y.doConfigSetup() + y.log = __log + y.errorlog = __log # Yum assumes it can update the cache directory. Disable this for non root # users. y.conf.cache = os.geteuid() != 0 @@ -68,10 +77,20 @@ break y.doTsSetup() y.doRpmDBSetup() - db = y.doPackageLists('all') + try: + db = y.doPackageLists('all') + except AttributeError: + # some people claim that testing for yum.__version__ should be + # enough to see if this is required, but I say they're liars. + # the yum on 4.8 at least understands yum.__version__ but still + # needs to get its repos and sacks set up manually. + # Thus, we just try it, fail, and then try again. WCPGW? + y.doRepoSetup() + y.doSackSetup() + db = y.doPackageLists('all') y.closeRpmDB() except Errors.YumBaseError, e: print >> sys.stderr, "Error! %s" % e