[yum-commits] Branch 'yum-3_2_X' - 12 commits - cli.py rpmUtils/updates.py utils.py yum/Errors.py yum/__init__.py yum/packages.py yummain.py

James Antill james at osuosl.org
Mon Jan 19 22:10:30 UTC 2009


 cli.py              |   20 +++++++----
 rpmUtils/updates.py |   88 +++++++++++++++++++++++++++-------------------------
 utils.py            |   24 +++++++-------
 yum/Errors.py       |    3 +
 yum/__init__.py     |   83 +++++++++++++++++++++++++++++++------------------
 yum/packages.py     |   72 +++++++++++++++++++++++++++++-------------
 yummain.py          |   78 +++++++++++++++++++++++++++++++++++++++++++---
 7 files changed, 251 insertions(+), 117 deletions(-)

New commits:
commit c595bd9128abecb64675a9450f09761dedc3a581
Merge: 365d4a6... 800c9e4...
Author: James Antill <james at and.org>
Date:   Mon Jan 19 17:04:14 2009 -0500

    Merge branch 'show-locker-task-data' into yum-3_2_X
    
    * show-locker-task-data:
      Show task info. when we don't get the lock

commit 365d4a6d0e86f770e3b69ef5ed75964fc36b9649
Merge: 7c90a9e... d861088...
Author: James Antill <james at and.org>
Date:   Mon Jan 19 16:58:05 2009 -0500

    Merge branch 'changelog-fix' into yum-3_2_X
    
    * changelog-fix:
      Fix changelog for same day sorting

commit 7c90a9ecf9c7cf6ef7e1b38188e78320550a32e6
Merge: 2931679... 5c65fb4...
Author: James Antill <james at and.org>
Date:   Mon Jan 19 16:55:56 2009 -0500

    Merge preconf branch and enable/disable plugins change to utils.py

diff --cc utils.py
index cea9110,9348608..13a698c
--- a/utils.py
+++ b/utils.py
@@@ -61,20 -61,16 +61,20 @@@ class YumUtilBase(YumBaseCli)
          root = self._parser.getRoot(opts)
          # Read up configuration options and initialise plugins
          try:
-             disabled_plugins = None
+             pc = self.preconf
+             pc.fn = opts.conffile
+             pc.root = root
+             pc.init_plugins = not opts.noplugins
+             pc.plugin_types = pluginsTypes
+             pc.optparser = self._parser
+             pc.debuglevel = opts.debuglevel
+             pc.errorlevel = opts.errorlevel
 +            if hasattr(opts, "disableplugins"):
-                 disabled_plugins = self._parser._splitArg(opts.disableplugins)
-             enabled_plugins  = None
++                pc.disabled_plugins =self._parser._splitArg(opts.disableplugins)
 +            if hasattr(opts, "enableplugins"):
-                 enabled_plugins = self._parser._splitArg(opts.enableplugins)
-             self._getConfig(opts.conffile, root, 
-                     init_plugins=not opts.noplugins,
-                     plugin_types= pluginsTypes,
-                     optparser=self._parser,
-                     debuglevel=opts.debuglevel,
-                     errorlevel=opts.errorlevel,
-                     disabled_plugins=disabled_plugins,
-                     enabled_plugins=enabled_plugins)
++                pc.enabled_plugins = self._parser._splitArg(opts.enableplugins)
+             self.conf
+ 
          except yum.Errors.ConfigError, e:
              self.logger.critical(_('Config Error: %s'), e)
              sys.exit(1)
commit 2931679a397f77ec5f84d8f6e40062372f7e0d0d
Merge: 80ee241... bac5335...
Author: James Antill <james at and.org>
Date:   Mon Jan 19 16:52:54 2009 -0500

    Merge branch 'speed' into yum-3_2_X
    
    * speed:
      Don't limit obs to the newest pkgs, as we can minimally update (also speedup)
      Do some minor speedups for updates processing
      Add specific pkg == pkg functions, for speed (no need to call into librpm)

commit d8610889d92f8f229751b284548b58bda2a81ff2
Author: James Antill <james at and.org>
Date:   Mon Dec 22 13:51:03 2008 -0500

    Fix changelog for same day sorting

diff --git a/yum/packages.py b/yum/packages.py
index 31b6045..3659d23 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -927,11 +927,12 @@ class YumAvailablePackage(PackageObject, RpmBase):
         if not self.changelog:
             return ""
         msg = "\n"
-        clog_count = 0
-        for (ts, author, content) in reversed(sorted(self.changelog)):
-            if clog_limit and clog_count >= clog_limit:
-                break
-            clog_count += 1
+        # We need to output them "backwards", so the oldest is first
+        if not clog_limit:
+            clogs = self.changelog
+        else:
+            clogs = self.changelog[:clog_limit]
+        for (ts, author, content) in reversed(clogs):
             msg += """<changelog author="%s" date="%s">%s</changelog>\n""" % (
                         misc.to_xml(author, attrib=True), misc.to_xml(str(ts)), 
                         misc.to_xml(content))
commit bac5335f1555c5904795e27e08ec01886f038b2b
Author: James Antill <james at and.org>
Date:   Sun Nov 30 13:39:19 2008 -0500

    Don't limit obs to the newest pkgs, as we can minimally update (also speedup)

diff --git a/yum/__init__.py b/yum/__init__.py
index 1f03840..891b67a 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -493,7 +493,7 @@ class YumBase(depsolve.Depsolve):
         
         if self.conf.obsoletes:
             obs_init = time.time()    
-            self._up.rawobsoletes = self.pkgSack.returnObsoletes(newest=True)
+            self._up.rawobsoletes = self.pkgSack.returnObsoletes()
             self.verbose_logger.debug('up:Obs Init time: %0.3f' % (time.time() - obs_init))
             
         self._up.exactarch = self.conf.exactarch
commit a5923505d33a632fcbf6865a2f485f2b836365e1
Author: James Antill <james at and.org>
Date:   Sun Nov 30 13:37:58 2008 -0500

    Do some minor speedups for updates processing

diff --git a/rpmUtils/updates.py b/rpmUtils/updates.py
index f348ae9..2c63a2f 100644
--- a/rpmUtils/updates.py
+++ b/rpmUtils/updates.py
@@ -18,6 +18,8 @@ import rpmUtils
 import rpmUtils.miscutils
 import rpmUtils.arch
 
+def _vertup_cmp(tup1, tup2):
+    return rpmUtils.miscutils.compareEVR(tup1, tup2)
 class Updates:
     """
     This class computes and keeps track of updates and obsoletes.
@@ -38,8 +40,10 @@ class Updates:
         self.obsoleting_dict = {} # obsoleting pkgtup -> [ obsoleted pkgtups ]
 
         self.exactarch = 1 # don't change archs by default
-        self.exactarchlist = ['kernel', 'kernel-smp', 'glibc', 'kernel-hugemem',
-                              'kernel-enterprise', 'kernel-bigmem', 'kernel-BOOT']
+        self.exactarchlist = set(['kernel', 'kernel-smp', 'glibc',
+                                  'kernel-hugemem',
+                                  'kernel-enterprise', 'kernel-bigmem',
+                                  'kernel-BOOT'])
                               
         self.myarch = rpmUtils.arch.canonArch # set this if you want to
                                               # test on some other arch
@@ -96,7 +100,7 @@ class Updates:
     def debugprint(self, msg):
         if self.debug:
             print msg
-        
+
     def makeNADict(self, pkglist, Nonelists):
         """return lists of (e,v,r) tuples as value of a dict keyed on (n, a)
             optionally will return a (n, None) entry with all the a for that
@@ -139,28 +143,21 @@ class Updates:
         """returns a list of package tuples in a list (n, a, e, v, r)
            takes a package name, a list of archs, and a list of pkgs in
            (n, a, e, v, r) form."""
-        # go through list and throw out all pkgs not in archlist
-        matchlist = []
-        for (n, a, e, v, r) in pkglist:
-            if name == n:
-                if a in archlist:
-                    matchlist.append((n, a, e, v, r))
-
-        if len(matchlist) == 0:
-            return []
-            
-        # get all the evr's in a tuple list for returning the highest
-        verlist = []
-        for (n, a, e, v, r) in matchlist:
-            verlist.append((e,v,r))
-
-        (high_e, high_v, high_r) = self.returnNewest(verlist)
-            
         returnlist = []
-        for (n, a, e, v, r) in matchlist:
-            if (high_e, high_v, high_r) == (e, v, r):
-                returnlist.append((n,a,e,v,r))
-                
+        high_vertup = None
+        for pkgtup in pkglist:
+            (n, a, e, v, r) = pkgtup
+            # FIXME: returnlist used to _possibly_ contain things not in
+            #        archlist ... was that desired?
+            if name == n and a in archlist:
+                vertup = (e, v, r)
+                if (high_vertup is None or
+                    (_vertup_cmp(high_vertup, vertup) < 0)):
+                    high_vertup = vertup
+                    returnlist = []
+                if vertup == high_vertup:
+                    returnlist.append(pkgtup)
+
         return returnlist
            
     def condenseUpdates(self):
@@ -294,7 +291,6 @@ class Updates:
         newpkgs = self.availdict
         
         archlist = rpmUtils.arch.getArchList(self.myarch)
-                
         for (n, a) in newpkgs.keys():
             # remove stuff not in our archdict
             # high log here
@@ -420,9 +416,11 @@ class Updates:
             
             multicompat = rpmUtils.arch.getMultiArchInfo(self.myarch)[0]
             multiarchlist = rpmUtils.arch.getArchList(multicompat)
-            archlists = [ biarches, multiarchlist ]
+            archlists = [ set(biarches), set(multiarchlist) ]
+            # archlists = [ biarches, multiarchlist ]
         else:
-            archlists = [ archlist ]
+            archlists = [ set(archlist) ]
+            # archlists = [ archlist ]
             
         for n in complexupdate:
             for thisarchlist in archlists:
@@ -434,19 +432,18 @@ class Updates:
 
                 highestinstalledpkgs = self.returnHighestVerFromAllArchsByName(n,
                                          thisarchlist, tmplist)
+                hipdict = self.makeNADict(highestinstalledpkgs, 0)
                                          
                 
-                tmplist = []
-                for (a, e, v, r) in newpkgs[(n, None)]:
-                    tmplist.append((n, a, e, v, r))                        
-                highestavailablepkgs = self.returnHighestVerFromAllArchsByName(n,
-                                         thisarchlist, tmplist)
+                if n in self.exactarchlist:
+                    tmplist = []
+                    for (a, e, v, r) in newpkgs[(n, None)]:
+                        tmplist.append((n, a, e, v, r))
+                    highestavailablepkgs = self.returnHighestVerFromAllArchsByName(n,
+                                             thisarchlist, tmplist)
 
-                hapdict = self.makeNADict(highestavailablepkgs, 0)
-                hipdict = self.makeNADict(highestinstalledpkgs, 0)
+                    hapdict = self.makeNADict(highestavailablepkgs, 0)
 
-                # now we have the two sets of pkgs
-                if n in self.exactarchlist:
                     for (n, a) in hipdict:
                         if hapdict.has_key((n, a)):
                             self.debugprint('processing %s.%s' % (n, a))
@@ -464,16 +461,25 @@ class Updates:
                     # this is where we have to have an arch contest if there
                     # is more than one arch updating with the highest ver
                     instarchs = []
-                    availarchs = []
                     for (n,a) in hipdict:
                         instarchs.append(a)
-                    for (n,a) in hapdict:
-                        availarchs.append(a)
                     
                     rpm_a = rpmUtils.arch.getBestArchFromList(instarchs, myarch=self.myarch)
+                    if rpm_a is None:
+                        continue
+
+                    tmplist = []
+                    for (a, e, v, r) in newpkgs[(n, None)]:
+                        tmplist.append((n, a, e, v, r))
+                    highestavailablepkgs = self.returnHighestVerFromAllArchsByName(n,
+                                             thisarchlist, tmplist)
+
+                    hapdict = self.makeNADict(highestavailablepkgs, 0)
+                    availarchs = []
+                    for (n,a) in hapdict:
+                        availarchs.append(a)
                     a = rpmUtils.arch.getBestArchFromList(availarchs, myarch=self.myarch)
-                    
-                    if rpm_a is None or a is None:
+                    if a is None:
                         continue
                         
                     (rpm_e, rpm_v, rpm_r) = hipdict[(n, rpm_a)][0] # there can be just one
commit 900e6d636c664db1139c5a598234e64976333d0d
Author: James Antill <james at and.org>
Date:   Sun Nov 30 13:36:55 2008 -0500

    Add specific pkg == pkg functions, for speed (no need to call into librpm)

diff --git a/yum/packages.py b/yum/packages.py
index 48dfc8d..3acc6ac 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -41,14 +41,25 @@ urlparse.uses_fragment.append("media")
 # For verify
 import pwd
 import grp
+import sys
 
 def comparePoEVR(po1, po2):
     """
-    Compare two PackageEVR objects.
+    Compare two Package or PackageEVR objects.
     """
     (e1, v1, r1) = (po1.epoch, po1.version, po1.release)
     (e2, v2, r2) = (po2.epoch, po2.version, po2.release)
     return rpmUtils.miscutils.compareEVR((e1, v1, r1), (e2, v2, r2))
+def comparePoEVREQ(po1, po2):
+    """
+    Compare two Package or PackageEVR objects for equality.
+    """
+    (e1, v1, r1) = (po1.epoch, po1.version, po1.release)
+    (e2, v2, r2) = (po2.epoch, po2.version, po2.release)
+    if r1 != r2: return False
+    if v1 != v2: return False
+    if e1 != e2: return False
+    return True
 
 def buildPkgRefDict(pkgs, casematch=True):
     """take a list of pkg objects and return a dict the contains all the possible
@@ -207,10 +218,29 @@ class PackageObject(object):
         if ret == 0 and hasattr(self, 'repoid') and hasattr(other, 'repoid'):
             ret = cmp(self.repoid, other.repoid)
         return ret
+    def __eq__(self, other):
+        """ Compare packages for yes/no equality, includes everything in the
+            UI package comparison. """
+        if not other:
+            return False
+        if self.pkgtup != other.pkgtup:
+            return False
+        if self.repoid != other.repoid:
+            return False
+        return True
+    def __ne__(self, other):
+        if not (self == other):
+            return True
+        return False
 
     def verEQ(self, other):
-        """ Uses verCMP, tests if the _rpm-versions_ are the same. """
-        return self.verCMP(other) == 0
+        """ Compare package to another one, only rpm-version equality. """
+        if not other:
+            return False
+        ret = cmp(self.name, other.name)
+        if ret != 0:
+            return False
+        return comparePoEVREQ(self, other)
     def verLT(self, other):
         """ Uses verCMP, tests if the other _rpm-version_ is <  ours. """
         return self.verCMP(other) <  0
@@ -259,22 +289,21 @@ class RpmBase(object):
         self.licenses = []
         self._hash = None
 
-    #  Do we still need __eq__ and __ne__ given that
-    # PackageObject has a working __cmp__?
+    # FIXME: This is identical to PackageObject.__eq__ and __ne__, should be
+    #        remove (is .repoid fine here? ... we need it, maybe .repo.id).
     def __eq__(self, other):
         if not other: # check if other not is a package object. 
             return False
-        if comparePoEVR(self, other) == 0 and self.arch == other.arch and self.name == other.name:
-            return True
-        return False
-
+        if self.pkgtup != other.pkgtup:
+            return False
+        if self.repoid != other.repoid:
+            return False
+        return True
     def __ne__(self, other):
-        if not other:
-            return True
-        if comparePoEVR(self, other) != 0 or self.arch != other.arch or self.name != other.name:
+        if not (self == other):
             return True
         return False
-       
+
     def returnEVR(self):
         return PackageEVR(self.epoch, self.version, self.release)
     
@@ -459,12 +488,10 @@ class PackageEVR:
         return False
 
     def __eq__(self, other):
-        if self.compare(other) == 0:
-            return True
-        return False
+        return comparePoEVREQ(self, other)
 
     def __ne__(self, other):
-        if self.compare(other) != 0:
+        if not (self == other):
             return True
         return False
     
commit 800c9e47f40b9cbfb5bc853b6058e8b58f81558f
Author: James Antill <james at and.org>
Date:   Tue Nov 25 15:31:54 2008 -0500

    Show task info. when we don't get the lock

diff --git a/yum/Errors.py b/yum/Errors.py
index 4bccd86..c73b279 100644
--- a/yum/Errors.py
+++ b/yum/Errors.py
@@ -42,10 +42,11 @@ class YumRPMCheckError(YumBaseError):
     pass
         
 class LockError(YumBaseError):
-    def __init__(self, errno, msg):
+    def __init__(self, errno, msg, pid=0):
         YumBaseError.__init__(self)
         self.errno = errno
         self.msg = msg
+        self.pid = pid
         
 class DepError(YumBaseError):
     pass
diff --git a/yum/__init__.py b/yum/__init__.py
index 1f03840..0aea68d 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1065,11 +1065,11 @@ class YumBase(depsolve.Depsolve):
                     else:
                         # Whoa. What the heck happened?
                         msg = _('Unable to check if PID %s is active') % oldpid
-                        raise Errors.LockError(1, msg)
+                        raise Errors.LockError(1, msg, oldpid)
                 else:
                     # Another copy seems to be running.
                     msg = _('Existing lock %s: another copy is running as pid %s.') % (lockfile, oldpid)
-                    raise Errors.LockError(0, msg)
+                    raise Errors.LockError(0, msg, oldpid)
         # We've got the lock, store it so we can auto-unlock on __del__...
         self._lockfile = lockfile
     
diff --git a/yummain.py b/yummain.py
index fde590c..95ae69c 100755
--- a/yummain.py
+++ b/yummain.py
@@ -19,9 +19,10 @@ Entrance point for the yum command line interface.
 """
 
 import os
+import os.path
 import sys
 import logging
-import time # test purposes only
+import time
 
 from yum import Errors
 from yum import plugins
@@ -52,7 +53,7 @@ def main(args):
         '''Called when a plugin raises PluginYumExit.
 
         Log the plugin's exit message if one was supplied.
-        '''
+        ''' # ' xemacs hack
         exitmsg = str(e)
         if exitmsg:
             logger.warn('\n\n%s', exitmsg)
@@ -72,6 +73,74 @@ def main(args):
             return 200
         return 0
 
+    def jiffies_to_seconds(jiffies):
+        Hertz = 100 # FIXME: Hack, need to get this, AT_CLKTCK elf note *sigh*
+        return int(jiffies) / Hertz
+    def seconds_to_ui_time(seconds):
+        if seconds >= 60 * 60 * 24:
+            return "%d day(s) %d:%02d:%02d" % (seconds / (60 * 60 * 24),
+                                               (seconds / (60 * 60)) % 24,
+                                               (seconds / 60) % 60,
+                                               seconds % 60)
+        if seconds >= 60 * 60:
+            return "%d:%02d:%02d" % (seconds / (60 * 60), (seconds / 60) % 60,
+                                     (seconds % 60))
+        return "%02d:%02d" % ((seconds / 60), seconds % 60)
+    def show_lock_owner(pid):
+        if not pid:
+            return
+
+        if (not os.path.exists("/proc/%d/status" % pid) or
+            not os.path.exists("/proc/%d/stat" % pid)):
+            return
+
+        ps = {}
+        for line in open("/proc/%d/status" % pid):
+            if line[-1] != '\n':
+                continue
+            data = line[:-1].split(':\t', 1)
+            if data[1].endswith(' kB'):
+                data[1] = data[1][:-3]
+            ps[data[0].strip().lower()] = data[1].strip()
+        if 'vmrss' not in ps:
+            return
+        if 'vmsize' not in ps:
+            return
+        boot_time = None
+        for line in open("/proc/stat"):
+            if line.startswith("btime "):
+                boot_time = int(line[len("btime "):-1])
+                break
+        if boot_time is None:
+            return
+        ps_stat = open("/proc/%d/stat" % pid).read().split()
+        ps['utime'] = jiffies_to_seconds(ps_stat[13])
+        ps['stime'] = jiffies_to_seconds(ps_stat[14])
+        ps['cutime'] = jiffies_to_seconds(ps_stat[15])
+        ps['cstime'] = jiffies_to_seconds(ps_stat[16])
+        ps['start_time'] = boot_time + jiffies_to_seconds(ps_stat[21])
+        ps['state'] = {'R' : _('Running'),
+                       'S' : _('Sleeping'),
+                       'D' : _('Uninteruptable'),
+                       'Z' : _('Zombie'),
+                       'T' : _('Traced/Stopped')
+                       }.get(ps_stat[2], _('Unknown'))
+
+        # This yumBackend isn't very friendly, so...
+        if ps['name'] == 'yumBackend.py':
+            nmsg = _("  The other application is: PackageKit")
+        else:
+            nmsg = _("  The other application is: %s") % ps['name']
+
+        logger.critical("%s", nmsg)
+        logger.critical(_("    Memory : %5s RSS (%5sB VSZ)") %
+                        (base.format_number(int(ps['vmrss']) * 1024),
+                         base.format_number(int(ps['vmsize']) * 1024)))
+        ago = seconds_to_ui_time(int(time.time()) - ps['start_time'])
+        logger.critical(_("    Started: %s - %s ago") %
+                        (time.ctime(ps['start_time']), ago))
+        logger.critical(_("    State  : %s, pid: %d") % (ps['state'], pid))
+
     logger = logging.getLogger("yum.main")
     verbose_logger = logging.getLogger("yum.verbose.main")
 
@@ -96,6 +165,7 @@ def main(args):
                 lockerr = "%s" %(e.msg,)
                 logger.critical(lockerr)
             logger.critical(_("Another app is currently holding the yum lock; waiting for it to exit..."))
+            show_lock_owner(e.pid)
             time.sleep(2)
         else:
             break
@@ -193,7 +263,7 @@ def main(args):
     return return_code
 
 def hotshot(func, *args, **kwargs):
-    import hotshot.stats, os.path
+    import hotshot.stats
     fn = os.path.expanduser("~/yum.prof")
     prof = hotshot.Profile(fn)
     rc = prof.runcall(func, *args, **kwargs)
@@ -202,7 +272,7 @@ def hotshot(func, *args, **kwargs):
     return rc
 
 def cprof(func, *args, **kwargs):
-    import cProfile, pstats, os.path
+    import cProfile, pstats
     fn = os.path.expanduser("~/yum.prof")
     prof = cProfile.Profile()
     rc = prof.runcall(func, *args, **kwargs)
commit 5c65fb44ebde5733bdcd5be80649ab425baf2cc7
Author: James Antill <james at and.org>
Date:   Fri Oct 24 14:47:30 2008 -0400

    Add preconf, so we can remove doConfigSetup etc.

diff --git a/cli.py b/cli.py
index ff4c7d6..af97d0e 100644
--- a/cli.py
+++ b/cli.py
@@ -174,14 +174,18 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
        
         # Read up configuration options and initialise plugins
         try:
-            self._getConfig(opts.conffile, root, 
-                    init_plugins=not opts.noplugins,
-                    plugin_types=(yum.plugins.TYPE_CORE, yum.plugins.TYPE_INTERACTIVE),
-                    optparser=self.optparser,
-                    debuglevel=opts.debuglevel,
-                    errorlevel=opts.errorlevel,
-                    disabled_plugins=self.optparser._splitArg(opts.disableplugins),
-                    enabled_plugins=self.optparser._splitArg(opts.enableplugins))
+            pc = self.preconf
+            pc.fn = opts.conffile
+            pc.root = root
+            pc.init_plugins = not opts.noplugins
+            pc.plugin_types = (yum.plugins.TYPE_CORE,
+                               yum.plugins.TYPE_INTERACTIVE)
+            pc.optparser = self.optparser
+            pc.debuglevel = opts.debuglevel
+            pc.errorlevel = opts.errorlevel
+            pc.disabled_plugins = self.optparser._splitArg(opts.disableplugins)
+            pc.enabled_plugins  = self.optparser._splitArg(opts.enableplugins)
+            self.conf
                     
         except yum.Errors.ConfigError, e:
             self.logger.critical(_('Config Error: %s'), e)
diff --git a/utils.py b/utils.py
index d92f533..9348608 100644
--- a/utils.py
+++ b/utils.py
@@ -61,12 +61,16 @@ class YumUtilBase(YumBaseCli):
         root = self._parser.getRoot(opts)
         # Read up configuration options and initialise plugins
         try:
-            self._getConfig(opts.conffile, root, 
-                    init_plugins=not opts.noplugins,
-                    plugin_types= pluginsTypes,
-                    optparser=self._parser,
-                    debuglevel=opts.debuglevel,
-                    errorlevel=opts.errorlevel)
+            pc = self.preconf
+            pc.fn = opts.conffile
+            pc.root = root
+            pc.init_plugins = not opts.noplugins
+            pc.plugin_types = pluginsTypes
+            pc.optparser = self._parser
+            pc.debuglevel = opts.debuglevel
+            pc.errorlevel = opts.errorlevel
+            self.conf
+
         except yum.Errors.ConfigError, e:
             self.logger.critical(_('Config Error: %s'), e)
             sys.exit(1)
diff --git a/yum/__init__.py b/yum/__init__.py
index 7aafb84..e721d68 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -82,6 +82,23 @@ __version_info__ = tuple([ int(num) for num in __version__.split('.')])
 # multiple YumBase() objects.
 default_grabber.opts.user_agent += " yum/" + __version__
 
+class _YumPreBaseConf:
+    """This is the configuration interface for the YumBase configuration.
+       So if you want to change if plugins are on/off, or debuglevel/etc.
+       you tweak it here, and when yb.conf does it's thing ... it happens. """
+
+    def __init__(self):
+        self.fn = '/etc/yum/yum.conf'
+        self.root = '/'
+        self.init_plugins = True
+        self.plugin_types = (plugins.TYPE_CORE,)
+        self.optparser = None
+        self.debuglevel = None
+        self.errorlevel = None
+        self.disabled_plugins = None
+        self.enabled_plugins = None
+
+
 class YumBase(depsolve.Depsolve):
     """This is a primary structure and base class. It houses the objects and
        methods needed to perform most things in yum. It is almost an abstract
@@ -108,6 +125,8 @@ class YumBase(depsolve.Depsolve):
 
         self.mediagrabber = None
 
+        self.preconf = _YumPreBaseConf()
+
     def __del__(self):
         self.close()
         self.closeRpmDB()
@@ -124,8 +143,8 @@ class YumBase(depsolve.Depsolve):
     def doGenericSetup(self, cache=0):
         """do a default setup for all the normal/necessary yum components,
            really just a shorthand for testing"""
-        
-        self._getConfig(init_plugins=False)
+
+        self.preconf.init_plugins = False
         self.conf.cache = cache
 
     def doConfigSetup(self, fn='/etc/yum/yum.conf', root='/', init_plugins=True,
@@ -133,38 +152,44 @@ class YumBase(depsolve.Depsolve):
             errorlevel=None):
         warnings.warn(_('doConfigSetup() will go away in a future version of Yum.\n'),
                 Errors.YumFutureDeprecationWarning, stacklevel=2)
-                
-        return self._getConfig(fn=fn, root=root, init_plugins=init_plugins,
-             plugin_types=plugin_types, optparser=optparser, debuglevel=debuglevel,
-             errorlevel=errorlevel)
+
+        if hasattr(self, 'preconf'):
+            self.preconf.fn = fn
+            self.preconf.root = root
+            self.preconf.init_plugins = init_plugins
+            self.preconf.plugin_types = plugin_types
+            self.preconf.optparser = optparser
+            self.preconf.debuglevel = debuglevel
+            self.preconf.errorlevel = errorlevel
+
+        return self.conf
         
-    def _getConfig(self, fn='/etc/yum/yum.conf', root='/', init_plugins=True,
-            plugin_types=(plugins.TYPE_CORE,), optparser=None, debuglevel=None,
-            errorlevel=None,disabled_plugins=None,enabled_plugins=None):
+    def _getConfig(self):
         '''
         Parse and load Yum's configuration files and call hooks initialise
-        plugins and logging.
-
-        @param fn: Path to main configuration file to parse (yum.conf).
-        @param root: Filesystem root to use.
-        @param init_plugins: If False, plugins will not be loaded here. If
-            True, plugins will be loaded if the "plugins" option is enabled in
-            the configuration file.
-        @param plugin_types: As per doPluginSetup()
-        @param optparser: As per doPluginSetup()
-        @param debuglevel: Debug level to use for logging. If None, the debug
-            level will be read from the configuration file.
-        @param errorlevel: Error level to use for logging. If None, the debug
-            level will be read from the configuration file.
-        @param disabled_plugins: Plugins to be disabled    
-        @param enabled_plugins: Plugins to be enabled
-        '''
+        plugins and logging. Uses self.preconf for pre-configuration,
+        configuration. '''
 
         # ' xemacs syntax hack
 
         if self._conf:
             return self._conf
         conf_st = time.time()            
+
+        fn = self.preconf.fn
+        root = self.preconf.root
+        init_plugins = self.preconf.init_plugins
+        plugin_types = self.preconf.plugin_types
+        optparser = self.preconf.optparser
+        debuglevel = self.preconf.debuglevel
+        errorlevel = self.preconf.errorlevel
+        disabled_plugins = self.preconf.disabled_plugins
+        enabled_plugins = self.preconf.enabled_plugins
+
+        #  We don't want people accessing/altering preconf after it becomes
+        # worthless. So we delete it, and thus. it'll raise AttributeError
+        del self.preconf
+
         # TODO: Remove this block when we no longer support configs outside
         # of /etc/yum/
         if fn == '/etc/yum/yum.conf' and not os.path.exists(fn):
@@ -391,7 +416,7 @@ class YumBase(depsolve.Depsolve):
 
     def _getRepos(self, thisrepo=None, doSetup = False):
         """ For each enabled repository set up the basics of the repository. """
-        self._getConfig() # touch the config class first
+        self.conf # touch the config class first
 
         if doSetup:
             repo_st = time.time()        
commit 647cfa773f7cd763919eeb1e43bad1f99554f65d
Merge: aae6cb0... 2d6891b...
Author: James Antill <james at and.org>
Date:   Fri Oct 24 14:22:42 2008 -0400

    Merge branch 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum into yum-3_2_X
    
    * 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum:
      fix installed size being wrong for metadata/local pkgs

commit aae6cb02d4419f3259f88d4c9462250338ee1004
Author: James Antill <james at and.org>
Date:   Wed Oct 22 01:41:48 2008 -0400

    Add documentation on install @grp

diff --git a/docs/yum.8 b/docs/yum.8
index 4b82533..4ebd19d 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -75,7 +75,9 @@ Repository configuration is honored in all operations.
 Is used to install the latest version of a package or
 group of packages while ensuring that all dependencies are
 satisfied\&.  If no package matches the given package name(s), they are
-assumed to be a shell glob and any matches are then installed\&.
+assumed to be a shell glob and any matches are then installed\&. If the
+name starts with an @ character the rest of the name is used as though
+passed to the groupinstall command\&.
 .IP 
 .IP "\fBupdate\fP"
 If run without any packages, update will update every currently


More information about the Yum-commits mailing list