[yum-commits] 2 commits - docs/yum.8 yumcommands.py yum/comps.py

James Antill james at osuosl.org
Wed May 1 04:02:21 UTC 2013


 docs/yum.8     |    2 +-
 yum/comps.py   |   18 +++++++++++++++++-
 yumcommands.py |   40 ++++++++++++++++++++++++++++++++--------
 3 files changed, 50 insertions(+), 10 deletions(-)

New commits:
commit a31a529e71f261b474089ffee31c71a3e5038909
Author: Bill Nottingham <notting at redhat.com>
Date:   Tue Apr 30 17:20:44 2013 -0400

    Allow environment options to default to on.

diff --git a/yum/comps.py b/yum/comps.py
index fe5649d..d2deb4a 100755
--- a/yum/comps.py
+++ b/yum/comps.py
@@ -295,6 +295,7 @@ class Environment(CompsObj):
         self.installed = False
         self._groups = {}
         self._options = {}
+        self._defaultoptions = {}
 
         if elem:
             self.parse(elem)
@@ -316,6 +317,11 @@ class Environment(CompsObj):
 
     options = property(_optioniter)
 
+    def _defaultoptioniter(self):
+        return self._defaultoptions.keys()
+
+    defaultoptions = property(_defaultoptioniter)
+
     def parse(self, elem):
         for child in elem:
             if child.tag == 'id':
@@ -366,6 +372,10 @@ class Environment(CompsObj):
             if child.tag == 'groupid':
                 optionid = child.text
                 self._options[optionid] = 1
+                defopt = child.attrib.get('default')
+                default = parse_boolean(defopt)
+                if default:
+                    self._defaultoptions[optionid] = 1
 
     def add(self, obj):
         """Add another category object to this object"""
@@ -373,6 +383,9 @@ class Environment(CompsObj):
         for grp in obj.groups:
             self._groups[grp] = 1
 
+        for grp in obj.defaultoptions:
+            self._defaultoptions[grp] = 1
+
         for grp in obj.options:
             self._options[grp] = 1
 
@@ -406,7 +419,10 @@ class Environment(CompsObj):
         msg += """    </grouplist>\n"""
         msg += """    <optionlist>\n"""
         for grp in self.options:
-            msg += """     <groupid>%s</groupid>\n""" % grp
+            if grp in self.defaultoptions:
+                msg += """     <groupid default="true">%s</groupid>\n""" % grp
+            else:
+                msg += """     <groupid>%s</groupid>\n""" % grp
         msg += """    </optionlist>\n"""
         msg += """  </environment>\n"""
 
commit 38a8b255f177a0d1c6572737a18308f76aca3ef2
Author: James Antill <james at and.org>
Date:   Tue Apr 30 13:02:54 2013 -0400

    Split out install/remove members in load-ts list.

diff --git a/docs/yum.8 b/docs/yum.8
index 2980c07..8c156f0 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -543,7 +543,7 @@ $TMPDIR/yum_save_tx.* when a transaction is solved but not run.
 Running the command without an argument, or a directory as an argument will
 try and list the possible files available to load. Showing if the packages are
 still available, if the rpmdb matches the current rpmdb, how many transaction
-members are in the saved transaction and what the filename is.
+install/removes members are in the saved transaction and what the filename is.
 
 .IP
 .IP "\fBupdateinfo\fP"
diff --git a/yumcommands.py b/yumcommands.py
index e5f2363..0407c92 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -3218,6 +3218,14 @@ class LoadTransactionCommand(YumCommand):
                 return False # Bad...
 
             return True
+        def _pkg_counts(l, counts):
+            if not l.startswith('  ts_state: '):
+                return
+            state = l[len('  ts_state: '):]
+            if state in ('e', 'od', 'ud'):
+                counts['remove'] += 1
+            elif state in ('i', 'u'):
+                counts['install'] += 1
 
         if not extcmds:
             extcmds = [tempfile.gettempdir()]
@@ -3253,6 +3261,11 @@ class LoadTransactionCommand(YumCommand):
                 except:
                     continue
 
+                counts = {'install' : 0, 'remove' : 0}
+                for l in data[pkgstart:]:
+                    l = l.rstrip()
+                    _pkg_counts(l, counts)
+
                 # Check to see if all the packages are available..
                 bad = ' '
                 for l in data[pkgstart:]:
@@ -3263,19 +3276,30 @@ class LoadTransactionCommand(YumCommand):
                     bad = '*'
                     break
 
+                # assert (counts['install'] + counts['remove']) == numpkgs
                 current = '%s%s' % (bad, current)
                 if not done:
-                    pkgtitle = _("Members")
-                    pkglen = utf8_width(pkgtitle)
-                    if pkglen < 6:
-                        pkglen = 6
-                    pkgtitle = utf8_width_fill(pkgtitle, pkglen)
-                    print "?? |", pkgtitle, "|", _("Filename")
+                    pkgititle = _("Install")
+                    pkgilen = utf8_width(pkgititle)
+                    if pkgilen < 6:
+                        pkgilen = 6
+                    pkgititle = utf8_width_fill(pkgititle, pkgilen)
+
+                    pkgetitle = _("Remove")
+                    pkgelen = utf8_width(pkgetitle)
+                    if pkgelen < 6:
+                        pkgelen = 6
+                    pkgetitle = utf8_width_fill(pkgetitle, pkgelen)
+                    print "?? |", pkgititle, "|", pkgetitle, "|", _("Filename")
                     
                     done = True
 
-                numpkgs = "%*s" % (pkglen, locale.format("%d", numpkgs, True))
-                print current, '|', numpkgs, '|', os.path.basename(yumtx)
+                numipkgs = locale.format("%d", counts['install'], True)
+                numipkgs = "%*s" % (pkgilen, numipkgs)
+                numepkgs = locale.format("%d", counts['remove'], True)
+                numepkgs = "%*s" % (pkgelen, numepkgs)
+                print "%s | %s | %s | %s" % (current, numipkgs, numepkgs,
+                                             os.path.basename(yumtx))
             return 0, [_('Saved transactions from %s; looked at %u files') %
                        (load_file, len(yumtxs))]
 


More information about the Yum-commits mailing list