From ddaea63ffea4ca63c1b7c96207009aed6e1cc369 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sun, 30 Jun 2013 12:17:02 -0700 Subject: [PATCH] Handle rpm name versions correctly. Ensure that we cut off the python -> rpm name versions correctly and don't put duplicate names into the returned array. Change-Id: I4767ed815ecbfcfb4756c751be2b2e5ccd0deb40 --- anvil/packaging/yum.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/anvil/packaging/yum.py b/anvil/packaging/yum.py index bc379ca6..9205a38f 100644 --- a/anvil/packaging/yum.py +++ b/anvil/packaging/yum.py @@ -547,12 +547,17 @@ class YumDependencyHandler(base.DependencyHandler): return [] cmdline = self.py2rpm_start_cmdline() + ["--convert"] + python_names rpm_names = [] - for name in sh.execute(cmdline)[0].splitlines(): - # name is "Requires: rpm-name" - try: - rpm_names.append(name.split(":", 1)[1].strip()) - except IndexError: - pass + for line in sh.execute(cmdline)[0].splitlines(): + # format is "Requires: rpm-name <=> X" + if not line.startswith("Requires:"): + continue + line = line[len("Requires:"):].strip() + positions = [line.find(">"), line.find("<"), line.find("=")] + positions = sorted([p for p in positions if p != -1]) + if positions: + line = line[0:positions[0]].strip() + if line and line not in rpm_names: + rpm_names.append(line) return rpm_names def _all_rpm_names(self):