---
 docs/yum.8      |    2 +
 output.py       |   24 +++++++++++++++++-
 yum/__init__.py |    4 ++-
 yum/history.py  |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 96 insertions(+), 4 deletions(-)

diff --git a/docs/yum.8 b/docs/yum.8
index b9ee5ec..f9eb7fd 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -320,6 +320,8 @@ if there was something not good with the transaction.
 .br
 .I \fBE\fR - The transaction completed fine, but had warning/error output 
during the transaction.
 .br
+.I \fBs\fR - The transaction completed fine, but --skip-broken was enabled and 
had to skip some packages.
+.br
 
 .IP
 .IP "\fBcheck\fP"
diff --git a/output.py b/output.py
index 95564e1..65d3f44 100755
--- a/output.py
+++ b/output.py
@@ -1333,6 +1333,8 @@ to exit.
                 # We don't check .errors, because return_code will be non-0
             elif old.output:
                 rmark = lmark = 'E'
+            elif old.trans_skip:
+                rmark = lmark = 's'
             if old.altered_lt_rpmdb:
                 rmark = '<'
             if old.altered_gt_rpmdb:
@@ -1485,11 +1487,29 @@ to exit.
                 state  = _('Updated')
             elif ipkgs[0] < hpkg:
                 state  = _('Downgraded')
-            else: # multiple versions installed, both older and newer
-                state  = _('Weird')
+            else:
+                assert False, "Impossible, installed not newer and not older"
             print "%s%s %s" % (prefix, utf8_width_fill(state, 12), hpkg)
         print _("Packages Altered:")
         self.historyInfoCmdPkgsAltered(old, pats)
+        if old.trans_skip:
+            print _("Packages Skipped:")
+        for hpkg in old.trans_skip:
+            prefix = " " * 4
+            state  = _('Installed')
+            ipkgs = self.rpmdb.searchNames([hpkg.name])
+            ipkgs.sort()
+            if not ipkgs:
+                state  = _('Not installed')
+            elif hpkg.pkgtup in (ipkg.pkgtup for ipkg in ipkgs):
+                pass
+            elif ipkgs[-1] > hpkg:
+                state  = _('Older')
+            elif ipkgs[0] < hpkg:
+                state  = _('Newer')
+            else:
+                assert False, "Impossible, installed not newer and not older"
+            print "%s%s %s" % (prefix, utf8_width_fill(state, 12), hpkg)
         if old.output:
             print _("Scriptlet output:")
             num = 0
diff --git a/yum/__init__.py b/yum/__init__.py
index 64663cc..57c92f3 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1269,7 +1269,9 @@ class YumBase(depsolve.Depsolve):
                 ignore_pkgs = [txmbr.po for txmbr in txmbrs]
                 self._rpmdb_warn_checks(warn=lastdbv is not None,
                                         ignore_pkgs=ignore_pkgs)
-            self.history.beg(rpmdbv, using_pkgs, list(self.tsInfo))
+            self.history.beg(rpmdbv, using_pkgs, list(self.tsInfo),
+            self.history.beg(rpmdbv, using_pkgs, list(self.tsInfo),
+                             self.skipped_packages)
 
         #  Just before we update the transaction, update what we think the
         # rpmdb will look like. This needs to be done before the run, so that 
if
diff --git a/yum/history.py b/yum/history.py
index cba6bf3..7305a62 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -128,6 +128,7 @@ class YumHistoryTransaction:
 
         self._loaded_TW = None
         self._loaded_TD = None
+        self._loaded_TS = None
 
         self._loaded_ER = None
         self._loaded_OT = None
@@ -153,9 +154,14 @@ class YumHistoryTransaction:
         if self._loaded_TD is None:
             self._loaded_TD = sorted(self._history._old_data_pkgs(self.tid))
         return self._loaded_TD
+    def _getTransSkip(self):
+        if self._loaded_TS is None:
+            self._loaded_TS = sorted(self._history._old_skip_pkgs(self.tid))
+        return self._loaded_TS
 
     trans_with = property(fget=lambda self: self._getTransWith())
     trans_data = property(fget=lambda self: self._getTransData())
+    trans_skip = property(fget=lambda self: self._getTransSkip())
 
     def _getErrors(self):
         if self._loaded_ER is None:
@@ -311,6 +317,17 @@ class YumHistory:
                          VALUES (?, ?)""", (self._tid, pid))
         return cur.lastrowid
 
+    def trans_skip_pid(self, pid):
+        cur = self._get_cursor()
+        if cur is None or not self._update_db_file_2():
+            return None
+        
+        res = executeSQL(cur,
+                         """INSERT INTO trans_skip_pkgs
+                         (tid, pkgtupid)
+                         VALUES (?, ?)""", (self._tid, pid))
+        return cur.lastrowid
+
     def trans_data_pid_beg(self, pid, state):
         assert state is not None
         if not hasattr(self, '_tid') or state is None:
@@ -338,7 +355,7 @@ class YumHistory:
         self._commit()
         return cur.lastrowid
 
-    def beg(self, rpmdb_version, using_pkgs, txmbrs):
+    def beg(self, rpmdb_version, using_pkgs, txmbrs, skip_packages=[]):
         cur = self._get_cursor()
         if cur is None:
             return
@@ -359,6 +376,10 @@ class YumHistory:
             state = self.txmbr2state(txmbr)
             self.trans_data_pid_beg(pid, state)
         
+        for pkg in skip_packages:
+            pid   = self.pkg2pid(pkg)
+            self.trans_skip_pid(pid)
+
         self._commit()
 
     def _log_errors(self, errors):
@@ -467,6 +488,20 @@ class YumHistory:
                 obj.state_installed = False
             ret.append(obj)
         return ret
+    def _old_skip_pkgs(self, tid):
+        cur = self._get_cursor()
+        if cur is None or not self._update_db_file_2():
+            return []
+        executeSQL(cur,
+                   """SELECT name, arch, epoch, version, release, checksum
+                      FROM trans_skip_pkgs JOIN pkgtups USING(pkgtupid)
+                      WHERE tid = ?
+                      ORDER BY name ASC, epoch ASC""", (tid,))
+        ret = []
+        for row in cur:
+            obj = YumHistoryPackage(row[0],row[1],row[2],row[3],row[4], row[5])
+            ret.append(obj)
+        return ret
 
     def old(self, tids=[], limit=None, complete_transactions_only=False):
         """ Return a list of the last transactions, note that this includes
@@ -610,6 +645,37 @@ class YumHistory:
             tids.add(row[0])
         return tids
 
+    _update_ops_2 = ['''\
+\
+ CREATE TABLE trans_skip_pkgs (
+     tid INTEGER NOT NULL REFERENCES trans_beg,
+     pkgtupid INTEGER NOT NULL REFERENCES pkgtups);
+''']
+
+    def _update_db_file_2(self):
+        """ Update to version 2 of history, includes trans_skip_pkgs. """
+        if not self.conf.writable:
+            return False
+
+        if hasattr(self, '_cached_updated_2'):
+            return self._cached_updated_2
+
+        cur = self._get_cursor()
+        if cur is None:
+            return False
+
+        executeSQL(cur, "PRAGMA table_info(trans_skip_pkgs)")
+        #  If we get anything, we're fine. There might be a better way of
+        # saying "anything" but this works.
+        for ob in cur:
+            break
+        else:
+            for op in self._update_ops_2:
+                cur.execute(op)
+            self._commit()
+        self._cached_updated_2 = True
+        return True
+
     def _create_db_file(self):
         """ Create a new history DB file, populating tables etc. """
 
@@ -671,6 +737,8 @@ class YumHistory:
 ''']
         for op in ops:
             cur.execute(op)
+        for op in self._update_ops_2:
+            cur.execute(op)
         self._commit()
 
 # Pasted from sqlitesack
-- 
1.7.0.1

_______________________________________________
Yum-devel mailing list
Yum-devel@lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to