Skip to content

Commit

Permalink
improved conflict detection which are resolved via Requires
Browse files Browse the repository at this point in the history
This improves the conflict detection to not report
a conflict when the conflict is resolved via requires
of dependencies.

Bug: 1412910
Change-Id: I41a7c1e3d5f717eda19b052311dbbcb0b6be10b2
  • Loading branch information
Tyrone Abdy committed Jan 18, 2017
1 parent 6767784 commit 1a6b1bf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
35 changes: 35 additions & 0 deletions acceptance_tests/test_check_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,38 @@ def cleanUp():
assert exitcode == 3
assert err == ('Undeclared file conflicts:\n'
'b-0.1-1.i386 provides /usr/share/thing which is also provided by a-0.1-1.x86_64\n')

# https://bugzilla.redhat.com/show_bug.cgi?id=1412910
def test_conflict_is_ignored_if_not_installable_concurrently(request, dir_server):
glib_26 = rpmfluff.SimpleRpmBuild('glib', '2.26', '1.el6', ['i686'])
glib_26.add_devel_subpackage()
glib_26.add_installed_file(
installPath="usr/share/gtk-doc/html/gio/annotation-glossary.html",
sourceFile=rpmfluff.SourceFile('annotation-glossary.html', 'something\n'),
subpackageSuffix='devel')
glib_28 = rpmfluff.SimpleRpmBuild('glib', '2.28', '8.el6', ['i686'])
glib_doc = glib_28.add_subpackage('doc')
glib_doc.add_requires('glib = 2.28-8.el6')
glib_28.add_installed_file(
installPath="usr/share/gtk-doc/html/gio/annotation-glossary.html",
sourceFile=rpmfluff.SourceFile('annotation-glossary.html', 'some other content\n'),
subpackageSuffix='doc')
glib_28.make()

repo = rpmfluff.YumRepoBuild((glib_26,))
repo.make('i686')
dir_server.basepath = repo.repoDir

def cleanUp():
shutil.rmtree(repo.repoDir)
shutil.rmtree(glib_28.get_base_dir())
shutil.rmtree(glib_26.get_base_dir())
request.addfinalizer(cleanUp)

exitcode, out, err = run_rpmdeplint(['rpmdeplint', 'check-conflicts',
'--repo=base,{}'.format(dir_server.url),
glib_28.get_built_rpm('i686'),
glib_28.get_built_rpm('i686', 'glib-doc')])
assert exitcode == 0
assert err == ''
assert out == ''
17 changes: 11 additions & 6 deletions rpmdeplint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ def find_repoclosure_problems(self):
problems.append(problem_msg)
return sorted(problems)

def _packages_have_explicit_conflict(self, left, right):
def _packages_can_be_installed_together(self, left, right):
"""
Returns True if the given packages have an explicit RPM-level Conflicts
declared between each other.
Returns True if the given packages can be installed together and False
if it runs into a conflict or indirect Requires relationship method.
"""
# XXX there must be a better way of testing for explicit Conflicts but
# the best I could find was to try solving the installation of both and
Expand All @@ -264,8 +264,13 @@ def _packages_have_explicit_conflict(self, left, right):
g.run()
if g.problems and 'conflicts' in g.problems[0]:
logger.debug('Found explicit Conflicts between %s and %s', left, right)
return True
return False
return False
if g.problems and \
six.text_type(right) in g.problems[0] and \
'none of the providers can be installed' in g.problems[0]:
logger.debug("Packages can't be installed together and won't conflict %s and %s", left, right)
return False
return True

def _file_conflict_is_permitted(self, left, right, filename):
"""
Expand Down Expand Up @@ -345,7 +350,7 @@ def find_conflicts(self):
for i, conflicting in enumerate(conflicting_packages, 1):
if conflicting == package:
continue
if self._packages_have_explicit_conflict(package, conflicting):
if not self._packages_can_be_installed_together(package, conflicting):
continue
logger.debug('Considering conflict on %s with %s', filename, conflicting)
conflicting_amount = len(conflicting_packages) - i
Expand Down

0 comments on commit 1a6b1bf

Please sign in to comment.