[yum-commits] Branch 'yum-3_2_X' - 10 commits - docs/yum.8 output.py yum/history.py yum/__init__.py
James Antill
james at osuosl.org
Fri May 7 18:59:34 UTC 2010
docs/yum.8 | 4
output.py | 48 +++++++++
yum/__init__.py | 18 ++-
yum/history.py | 271 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 332 insertions(+), 9 deletions(-)
New commits:
commit eb256430ee0cad7a537960ba1cf9381da95258ce
Author: James Antill <james at and.org>
Date: Thu May 6 17:12:44 2010 -0400
Fix the VIEW vtrans_prob_pkgs, for newer sqlite which gets confused.
diff --git a/yum/history.py b/yum/history.py
index 50dee0b..b37089d 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -844,7 +844,7 @@ class YumHistory:
''', '''\
\
CREATE VIEW vtrans_prob_pkgs AS
- SELECT tid,rpid,name,epoch,version,release,arch,pkgtupid,
+ SELECT tid,rpid,name,epoch,version,release,arch,pkgtups.pkgtupid,
main,
name || '-' || epoch || ':' ||
version || '-' || release || '.' || arch AS nevra
commit 7de7e2d20f176cd964ca09999238be78d02b4ed3
Author: James Antill <james at and.org>
Date: Thu May 6 14:58:26 2010 -0400
Save, and then Highlight, the "main" package which has a problem
diff --git a/output.py b/output.py
index 484fd5e..7a3cfb0 100755
--- a/output.py
+++ b/output.py
@@ -1440,7 +1440,7 @@ to exit.
def _historyInfoCmd(self, old, pats=[]):
name = self._pwd_ui_username(old.loginuid)
- def _simple_pkg(pkg, prefix_len):
+ def _simple_pkg(pkg, prefix_len, highlight=False):
prefix = " " * prefix_len
state = _('Installed')
ipkgs = self.rpmdb.searchNames([hpkg.name])
@@ -1455,7 +1455,13 @@ to exit.
state = _('Newer')
else:
assert False, "Impossible, installed not newer and not older"
- print "%s%s %s" % (prefix, utf8_width_fill(state, 12), hpkg)
+ if highlight:
+ (hibeg, hiend) = self._highlight('bold')
+ else:
+ (hibeg, hiend) = self._highlight('normal')
+ print "%s%s %s%s%s" % (prefix,
+ hibeg, utf8_width_fill(state, 12), hiend,
+ hpkg)
print _("Transaction ID :"), old.tid
begtm = time.ctime(old.beg_timestamp)
@@ -1526,7 +1532,7 @@ to exit.
key = "%s%s: " % (" " * 4, prob.problem)
print self.fmtKeyValFill(key, prob.text)
for hpkg in prob.packages:
- _simple_pkg(hpkg, 8)
+ _simple_pkg(hpkg, 8, highlight=hpkg.main)
if old.output:
print _("Scriptlet output:")
diff --git a/yum/history.py b/yum/history.py
index 8983261..50dee0b 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -431,10 +431,14 @@ class YumHistory:
for pkg in pkgs.values():
pid = self.pkg2pid(pkg)
+ if pkg.pkgtup == problem.pkg.pkgtup:
+ main = 'TRUE'
+ else:
+ main = 'FALSE'
res = executeSQL(cur,
"""INSERT INTO trans_prob_pkgs
- (rpid, pkgtupid)
- VALUES (?, ?)""", (rpid, pid))
+ (rpid, pkgtupid, main)
+ VALUES (?, ?, ?)""", (rpid, pid, main))
return rpid
@@ -609,13 +613,14 @@ class YumHistory:
if cur is None or not self._update_db_file_2():
return []
executeSQL(cur,
- """SELECT name, arch, epoch, version, release, checksum
+ """SELECT name, arch, epoch, version, release, checksum, main
FROM trans_prob_pkgs JOIN pkgtups USING(pkgtupid)
WHERE rpid = ?
ORDER BY name ASC, epoch ASC""", (rpid,))
ret = []
for row in cur:
obj = YumHistoryPackage(row[0],row[1],row[2],row[3],row[4], row[5])
+ obj.main = row[6] == 'TRUE'
ret.append(obj)
return ret
@@ -809,7 +814,8 @@ class YumHistory:
\
CREATE TABLE trans_prob_pkgs (
rpid INTEGER NOT NULL REFERENCES trans_rpmdb_problems,
- pkgtupid INTEGER NOT NULL REFERENCES pkgtups);
+ pkgtupid INTEGER NOT NULL REFERENCES pkgtups,
+ main BOOL NOT NULL DEFAULT FALSE);
''', '''\
\
CREATE VIEW vtrans_data_pkgs AS
@@ -839,6 +845,7 @@ class YumHistory:
\
CREATE VIEW vtrans_prob_pkgs AS
SELECT tid,rpid,name,epoch,version,release,arch,pkgtupid,
+ main,
name || '-' || epoch || ':' ||
version || '-' || release || '.' || arch AS nevra
FROM (trans_prob_pkgs JOIN trans_rpmdb_problems USING(rpid))
commit 6597171c73322f2c23c2985aac9d62ffad3b740a
Author: James Antill <james at and.org>
Date: Thu May 6 14:39:34 2010 -0400
Fix sorting of historic rpmdb problems
diff --git a/yum/history.py b/yum/history.py
index bd10e51..8983261 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -131,7 +131,7 @@ class YumHistoryRpmdbProblem(PackageObject):
ret = cmp(self.problem, other.problem)
if ret: return -ret
ret = cmp(self.rpid, other.rpid)
- return -ret
+ return ret
def _getProbPkgs(self):
if self._loaded_P is None:
commit 97888d14662cdfe1e85bd5b124cdc7b7475030e0
Author: James Antill <james at and.org>
Date: Thu May 6 14:25:42 2010 -0400
Mark pre-exsting rpmdb problems in history list, with 'P'.
diff --git a/docs/yum.8 b/docs/yum.8
index f9eb7fd..053173d 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 \fBP\fR - The transaction completed fine, but problems already existed in the rpmdb.
+.br
.I \fBs\fR - The transaction completed fine, but --skip-broken was enabled and had to skip some packages.
.br
diff --git a/output.py b/output.py
index 188c52a..484fd5e 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.rpmdb_problems:
+ rmark = lmark = 'P'
elif old.trans_skip:
rmark = lmark = 's'
if old.altered_lt_rpmdb:
commit 812aa32b53ccfb8a5d84ef887e040961253ad837
Author: James Antill <james at and.org>
Date: Thu May 6 14:26:14 2010 -0400
Move obsoleted.obsoleter check into the correct problem loop
diff --git a/yum/__init__.py b/yum/__init__.py
index b27d6e1..b7f7702 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1229,14 +1229,14 @@ class YumBase(depsolve.Depsolve):
for prob in self.rpmdb.check_obsoleted():
if prob.pkg.pkgtup in ignore_pkgtups:
continue
+ if prob.obsoleter.pkgtup in ignore_pkgtups:
+ continue
probs.append(prob)
if chkcmd.intersection(set(('all', 'provides'))):
for prob in self.rpmdb.check_provides():
if prob.pkg.pkgtup in ignore_pkgtups:
continue
- if prob.obsoleter.pkgtup in ignore_pkgtups:
- continue
probs.append(prob)
header(len(probs))
commit 4774b88d82a01812c0b67e817648dadba7dc0301
Author: James Antill <james at and.org>
Date: Thu May 6 14:24:05 2010 -0400
Output cmdline and rpmdb problems in history info
diff --git a/output.py b/output.py
index 65d3f44..188c52a 100755
--- a/output.py
+++ b/output.py
@@ -1438,6 +1438,23 @@ to exit.
def _historyInfoCmd(self, old, pats=[]):
name = self._pwd_ui_username(old.loginuid)
+ def _simple_pkg(pkg, prefix_len):
+ prefix = " " * prefix_len
+ 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)
+
print _("Transaction ID :"), old.tid
begtm = time.ctime(old.beg_timestamp)
print _("Begin time :"), begtm
@@ -1473,6 +1490,9 @@ to exit.
print _("Return-Code :"), _("Failure:"), old.return_code
else:
print _("Return-Code :"), _("Success")
+ if old.cmdline is not None:
+ print _("Command Line :"), old.cmdline
+
print _("Transaction performed with:")
for hpkg in old.trans_with:
prefix = " " * 4
@@ -1492,24 +1512,20 @@ to exit.
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)
+ _simple_pkg(hpkg, 4)
+
+ if old.rpmdb_problems:
+ print _("Rpmdb Problems:")
+ for prob in old.rpmdb_problems:
+ key = "%s%s: " % (" " * 4, prob.problem)
+ print self.fmtKeyValFill(key, prob.text)
+ for hpkg in prob.packages:
+ _simple_pkg(hpkg, 8)
+
if old.output:
print _("Scriptlet output:")
num = 0
commit aa8b33bfa535680ba20df01a8808e9d1aacb89d5
Author: James Antill <james at and.org>
Date: Thu May 6 14:23:52 2010 -0400
Save rpmdb problems, and cmdline, into yum history
diff --git a/yum/__init__.py b/yum/__init__.py
index d5fabf5..b27d6e1 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1243,7 +1243,7 @@ class YumBase(depsolve.Depsolve):
for prob in sorted(probs):
out(prob)
- return len(probs)
+ return probs
def runTransaction(self, cb):
"""takes an rpm callback object, performs the transaction"""
@@ -1264,14 +1264,18 @@ class YumBase(depsolve.Depsolve):
lastdbv = self.history.last()
if lastdbv is not None:
lastdbv = lastdbv.end_rpmdbversion
+ rpmdb_problems = []
if lastdbv is None or rpmdbv != lastdbv:
txmbrs = self.tsInfo.getMembersWithState(None, TS_REMOVE_STATES)
ignore_pkgs = [txmbr.po for txmbr in txmbrs]
- self._rpmdb_warn_checks(warn=lastdbv is not None,
- ignore_pkgs=ignore_pkgs)
+ output_warn = lastdbv is not None
+ rpmdb_problems = self._rpmdb_warn_checks(warn=output_warn,
+ ignore_pkgs=ignore_pkgs)
+ cmdline = None
+ if hasattr(self, 'cmds') and self.cmds:
+ cmdline = ' '.join(self.cmds)
self.history.beg(rpmdbv, using_pkgs, list(self.tsInfo),
- self.history.beg(rpmdbv, using_pkgs, list(self.tsInfo),
- self.skipped_packages)
+ self.skipped_packages, rpmdb_problems, cmdline)
# 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
commit dfa0483c90a736d878599c5c9de0d7072a48ae71
Author: James Antill <james at and.org>
Date: Thu May 6 14:22:55 2010 -0400
Add rpmdb problems, and cmdline to the history DBv2 update
diff --git a/yum/history.py b/yum/history.py
index 358edf1..bd10e51 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -112,6 +112,35 @@ class YumHistoryPackage(PackageObject):
chk = checksum.split(':')
self._checksums = [(chk[0], chk[1], 0)] # (type, checksum, id(0,1))
+class YumHistoryRpmdbProblem(PackageObject):
+ """ Class representing an rpmdb problem that existed at the time of the
+ transaction. """
+
+ def __init__(self, history, rpid, problem, text):
+ self._history = weakref(history)
+
+ self.rpid = rpid
+ self.problem = problem
+ self.text = text
+
+ self._loaded_P = None
+
+ def __cmp__(self, other):
+ if other is None:
+ return 1
+ ret = cmp(self.problem, other.problem)
+ if ret: return -ret
+ ret = cmp(self.rpid, other.rpid)
+ return -ret
+
+ def _getProbPkgs(self):
+ if self._loaded_P is None:
+ self._loaded_P = sorted(self._history._old_prob_pkgs(self.rpid))
+ return self._loaded_P
+
+ packages = property(fget=lambda self: self._getProbPkgs())
+
+
class YumHistoryTransaction:
""" Holder for a history transaction. """
@@ -130,6 +159,11 @@ class YumHistoryTransaction:
self._loaded_TD = None
self._loaded_TS = None
+ self._loaded_PROB = None
+
+ self._have_loaded_CMD = False # cmdline can validly be None
+ self._loaded_CMD = None
+
self._loaded_ER = None
self._loaded_OT = None
@@ -163,6 +197,21 @@ class YumHistoryTransaction:
trans_data = property(fget=lambda self: self._getTransData())
trans_skip = property(fget=lambda self: self._getTransSkip())
+ def _getProblems(self):
+ if self._loaded_PROB is None:
+ self._loaded_PROB = sorted(self._history._old_problems(self.tid))
+ return self._loaded_PROB
+
+ rpmdb_problems = property(fget=lambda self: self._getProblems())
+
+ def _getCmdline(self):
+ if not self._have_loaded_CMD:
+ self._have_loaded_CMD = True
+ self._loaded_CMD = self._history._old_cmdline(self.tid)
+ return self._loaded_CMD
+
+ cmdline = property(fget=lambda self: self._getCmdline())
+
def _getErrors(self):
if self._loaded_ER is None:
self._loaded_ER = self._history._load_errors(self.tid)
@@ -355,7 +404,54 @@ class YumHistory:
self._commit()
return cur.lastrowid
- def beg(self, rpmdb_version, using_pkgs, txmbrs, skip_packages=[]):
+ def _trans_rpmdb_problem(self, problem):
+ if not hasattr(self, '_tid'):
+ return # Not configured to run
+ cur = self._get_cursor()
+ if cur is None or not self._update_db_file_2():
+ return None
+ res = executeSQL(cur,
+ """INSERT INTO trans_rpmdb_problems
+ (tid, problem, msg)
+ VALUES (?, ?, ?)""", (self._tid,
+ problem.problem, str(problem)))
+ rpid = cur.lastrowid
+
+ if not rpid:
+ return rpid
+
+ pkgs = {}
+ pkg = problem.pkg
+ pkgs[pkg.pkgtup] = pkg
+ if problem.problem == 'conflicts':
+ for pkg in problem.conflicts:
+ pkgs[pkg.pkgtup] = pkg
+ if problem.problem == 'duplicates':
+ pkgs[problem.duplicate.pkgtup] = problem.duplicate
+
+ for pkg in pkgs.values():
+ pid = self.pkg2pid(pkg)
+ res = executeSQL(cur,
+ """INSERT INTO trans_prob_pkgs
+ (rpid, pkgtupid)
+ VALUES (?, ?)""", (rpid, pid))
+
+ return rpid
+
+ def _trans_cmdline(self, cmdline):
+ if not hasattr(self, '_tid'):
+ return # Not configured to run
+ cur = self._get_cursor()
+ if cur is None or not self._update_db_file_2():
+ return None
+ res = executeSQL(cur,
+ """INSERT INTO trans_cmdline
+ (tid, cmdline)
+ VALUES (?, ?)""", (self._tid, cmdline))
+ return cur.lastrowid
+
+ def beg(self, rpmdb_version, using_pkgs, txmbrs, skip_packages=[],
+ rpmdb_problems=[], cmdline=None):
cur = self._get_cursor()
if cur is None:
return
@@ -380,6 +476,12 @@ class YumHistory:
pid = self.pkg2pid(pkg)
self.trans_skip_pid(pid)
+ for problem in rpmdb_problems:
+ self._trans_rpmdb_problem(problem)
+
+ if cmdline:
+ self._trans_cmdline(cmdline)
+
self._commit()
def _log_errors(self, errors):
@@ -502,6 +604,48 @@ class YumHistory:
obj = YumHistoryPackage(row[0],row[1],row[2],row[3],row[4], row[5])
ret.append(obj)
return ret
+ def _old_prob_pkgs(self, rpid):
+ 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_prob_pkgs JOIN pkgtups USING(pkgtupid)
+ WHERE rpid = ?
+ ORDER BY name ASC, epoch ASC""", (rpid,))
+ 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_problems(self, tid):
+ cur = self._get_cursor()
+ if cur is None or not self._update_db_file_2():
+ return []
+ executeSQL(cur,
+ """SELECT rpid, problem, msg
+ FROM trans_rpmdb_problems
+ WHERE tid = ?
+ ORDER BY problem ASC, rpid ASC""", (tid,))
+ ret = []
+ for row in cur:
+ obj = YumHistoryRpmdbProblem(self, row[0], row[1], row[2])
+ ret.append(obj)
+ return ret
+
+ def _old_cmdline(self, tid):
+ cur = self._get_cursor()
+ if cur is None or not self._update_db_file_2():
+ return None
+ executeSQL(cur,
+ """SELECT cmdline
+ FROM trans_cmdline
+ WHERE tid = ?""", (tid,))
+ ret = []
+ for row in cur:
+ return row[0]
+ return None
def old(self, tids=[], limit=None, complete_transactions_only=False):
""" Return a list of the last transactions, note that this includes
@@ -652,6 +796,22 @@ class YumHistory:
pkgtupid INTEGER NOT NULL REFERENCES pkgtups);
''', '''\
\
+ CREATE TABLE trans_cmdline (
+ tid INTEGER NOT NULL REFERENCES trans_beg,
+ cmdline TEXT NOT NULL);
+''', '''\
+\
+ CREATE TABLE trans_rpmdb_problems (
+ rpid INTEGER PRIMARY KEY,
+ tid INTEGER NOT NULL REFERENCES trans_beg,
+ problem TEXT NOT NULL, msg TEXT NOT NULL);
+''', '''\
+\
+ CREATE TABLE trans_prob_pkgs (
+ rpid INTEGER NOT NULL REFERENCES trans_rpmdb_problems,
+ pkgtupid INTEGER NOT NULL REFERENCES pkgtups);
+''', '''\
+\
CREATE VIEW vtrans_data_pkgs AS
SELECT tid,name,epoch,version,release,arch,pkgtupid,
state,done,
@@ -675,6 +835,15 @@ class YumHistory:
version || '-' || release || '.' || arch AS nevra
FROM trans_skip_pkgs JOIN pkgtups USING(pkgtupid)
ORDER BY name;
+''', '''\
+\
+ CREATE VIEW vtrans_prob_pkgs AS
+ SELECT tid,rpid,name,epoch,version,release,arch,pkgtupid,
+ name || '-' || epoch || ':' ||
+ version || '-' || release || '.' || arch AS nevra
+ FROM (trans_prob_pkgs JOIN trans_rpmdb_problems USING(rpid))
+ JOIN pkgtups USING(pkgtupid)
+ ORDER BY name;
''']
def _update_db_file_2(self):
commit 4bd360023d0a3e0996cc5095040cb615156f67c9
Author: James Antill <james at and.org>
Date: Wed Apr 28 02:17:35 2010 -0400
Add three views to make look at history by hand easier
diff --git a/yum/history.py b/yum/history.py
index 7305a62..358edf1 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -650,6 +650,31 @@ class YumHistory:
CREATE TABLE trans_skip_pkgs (
tid INTEGER NOT NULL REFERENCES trans_beg,
pkgtupid INTEGER NOT NULL REFERENCES pkgtups);
+''', '''\
+\
+ CREATE VIEW vtrans_data_pkgs AS
+ SELECT tid,name,epoch,version,release,arch,pkgtupid,
+ state,done,
+ name || '-' || epoch || ':' ||
+ version || '-' || release || '.' || arch AS nevra
+ FROM trans_data_pkgs JOIN pkgtups USING(pkgtupid)
+ ORDER BY name;
+''', '''\
+\
+ CREATE VIEW vtrans_with_pkgs AS
+ SELECT tid,name,epoch,version,release,arch,pkgtupid,
+ name || '-' || epoch || ':' ||
+ version || '-' || release || '.' || arch AS nevra
+ FROM trans_with_pkgs JOIN pkgtups USING(pkgtupid)
+ ORDER BY name;
+''', '''\
+\
+ CREATE VIEW vtrans_skip_pkgs AS
+ SELECT tid,name,epoch,version,release,arch,pkgtupid,
+ name || '-' || epoch || ':' ||
+ version || '-' || release || '.' || arch AS nevra
+ FROM trans_skip_pkgs JOIN pkgtups USING(pkgtupid)
+ ORDER BY name;
''']
def _update_db_file_2(self):
commit 86a1ef458057cf5513c2ac5f81fa5b7603392217
Author: James Antill <james at and.org>
Date: Thu Apr 22 18:40:31 2010 -0400
Add skip broken packages to history transaction.
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 d2a3a76..d5fabf5 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
More information about the Yum-commits
mailing list