|
|
07a10e |
diff -up yum-3.4.3/yum/update_md.py.org yum-3.4.3/yum/update_md.py
|
|
|
07a10e |
--- yum-3.4.3/yum/update_md.py.org 2017-01-24 18:55:03.529842775 +0100
|
|
|
07a10e |
+++ yum-3.4.3/yum/update_md.py 2017-01-24 18:55:57.213511475 +0100
|
|
|
07a10e |
@@ -58,7 +58,7 @@ class UpdateNotice(object):
|
|
|
07a10e |
A single update notice (for instance, a security fix).
|
|
|
07a10e |
"""
|
|
|
07a10e |
|
|
|
07a10e |
- def __init__(self, elem=None):
|
|
|
07a10e |
+ def __init__(self, elem=None, repoid=None, vlogger=None):
|
|
|
07a10e |
self._md = {
|
|
|
07a10e |
'from' : '',
|
|
|
07a10e |
'type' : '',
|
|
|
07a10e |
@@ -83,6 +83,9 @@ class UpdateNotice(object):
|
|
|
07a10e |
if elem:
|
|
|
07a10e |
self._parse(elem)
|
|
|
07a10e |
|
|
|
07a10e |
+ self._repoid = repoid
|
|
|
07a10e |
+ self._vlogger = vlogger
|
|
|
07a10e |
+
|
|
|
07a10e |
def __getitem__(self, item):
|
|
|
07a10e |
""" Allows scriptable metadata access (ie: un['update_id']). """
|
|
|
07a10e |
if type(item) is int:
|
|
|
07a10e |
@@ -103,6 +106,24 @@ class UpdateNotice(object):
|
|
|
07a10e |
# Tests to see if it's "the same data", which means that the
|
|
|
07a10e |
# packages can be different (see add_notice).
|
|
|
07a10e |
|
|
|
07a10e |
+ def _rid(un):
|
|
|
07a10e |
+ if hasattr(un, '_repoid') and un._repoid is not None:
|
|
|
07a10e |
+ return un._repoid
|
|
|
07a10e |
+ else:
|
|
|
07a10e |
+ return '<unknown>'
|
|
|
07a10e |
+
|
|
|
07a10e |
+ def _log_failure(data):
|
|
|
07a10e |
+ """Log the mismatched data similarly to conflict markers in git."""
|
|
|
07a10e |
+ if self._vlogger is None:
|
|
|
07a10e |
+ return
|
|
|
07a10e |
+ msg = _('Duplicate of %s differs in some fields:\n')
|
|
|
07a10e |
+ msg %= other._md['update_id']
|
|
|
07a10e |
+ msg += '<<<<<<< %s:%s\n' % (_rid(other), data)
|
|
|
07a10e |
+ msg += '%r\n=======\n%r\n' % (other._md[data], self._md[data])
|
|
|
07a10e |
+ msg += '>>>>>>> %s:%s' % (_rid(self), data)
|
|
|
07a10e |
+ # --verbose mode enables this
|
|
|
07a10e |
+ self._vlogger.log(logginglevels.DEBUG_3, msg)
|
|
|
07a10e |
+
|
|
|
07a10e |
if not other or not hasattr(other, '_md'):
|
|
|
07a10e |
return False
|
|
|
07a10e |
|
|
|
07a10e |
@@ -113,6 +134,7 @@ class UpdateNotice(object):
|
|
|
07a10e |
if data == 'status': # FIXME: See below...
|
|
|
07a10e |
continue
|
|
|
07a10e |
if self._md[data] != other._md[data]:
|
|
|
07a10e |
+ _log_failure(data)
|
|
|
07a10e |
return False
|
|
|
07a10e |
# FIXME: Massive hack, Fedora is really broken and gives status=stable
|
|
|
07a10e |
# and status=testing for updateinfo notices, just depending on which
|
|
|
07a10e |
@@ -120,8 +142,10 @@ class UpdateNotice(object):
|
|
|
07a10e |
data = 'status'
|
|
|
07a10e |
if self._md[data] != other._md[data]:
|
|
|
07a10e |
if self._md[data] not in ('stable', 'testing'):
|
|
|
07a10e |
+ _log_failure(data)
|
|
|
07a10e |
return False
|
|
|
07a10e |
if other._md[data] not in ('stable', 'testing'):
|
|
|
07a10e |
+ _log_failure(data)
|
|
|
07a10e |
return False
|
|
|
07a10e |
# They are both really "stable" ...
|
|
|
07a10e |
self._md[data] = 'stable'
|
|
|
07a10e |
@@ -574,7 +598,7 @@ class UpdateMetadata(object):
|
|
|
07a10e |
for event, elem in safe_iterparse(infile, logger=self._logger):
|
|
|
07a10e |
if elem.tag == 'update':
|
|
|
07a10e |
try:
|
|
|
07a10e |
- un = UpdateNotice(elem)
|
|
|
07a10e |
+ un = UpdateNotice(elem, repoid, self._vlogger)
|
|
|
07a10e |
except UpdateNoticeException, e:
|
|
|
07a10e |
msg = _("An update notice%s is broken, skipping.") % _rid(repoid)
|
|
|
07a10e |
if self._vlogger:
|
|
|
07a10e |
@@ -587,6 +611,8 @@ class UpdateMetadata(object):
|
|
|
07a10e |
msg = _("Update notice %s%s is broken, or a bad duplicate, skipping.") % (un['update_id'], _rid(repoid))
|
|
|
07a10e |
if not have_dup:
|
|
|
07a10e |
msg += _('\nYou should report this problem to the owner of the %srepository.') % _rid(repoid, "%s ")
|
|
|
07a10e |
+ msg += _('\nIf you are the owner, consider re-running the same command with --verbose to see the '
|
|
|
07a10e |
+ 'exact data that caused the conflict.')
|
|
|
07a10e |
have_dup = True
|
|
|
07a10e |
if self._vlogger:
|
|
|
07a10e |
self._vlogger.warn("%s", msg)
|