#29 make --resolve work on dnf api <2
Merged 6 years ago by phracek. Opened 6 years ago by ttomecek.
modularity/ ttomecek/modularity-tools fix25  into  master

@@ -21,6 +21,20 @@ 

  p = None

  

  

+ def get_pkgs_source_rpm_name(pkg):

+     """

+     pkg: dnf.Package

+ 

+     returns name of source RPM used to build the provided rpm

+     """

+     if LooseVersion(dnf.__version__) < LooseVersion("2.0.0"):

+         source_rpm = pkg.sourcerpm

+         source_rpm_name = source_rpm.rsplit('-', 2)[0]

+     else:

+         source_rpm_name = pkg.source_name

+     return source_rpm_name

+ 

+ 

  def get_pdc_client():

      """ cache PDCClient instance """

      global p
@@ -115,11 +129,7 @@ 

          source_pkgs = []

          base = ModuleDepsDiffer.get_base_from_repo('f26-source', REPO_F26_SOURCE)

          for pkg in pkgs:

-             if LooseVersion(dnf.__version__) < LooseVersion("2.0.0"):

-                 source_rpm = pkgs[0].sourcerpm

-                 source_rpm_name = source_rpm.rsplit('-', 2)[0]

-             else:

-                 source_rpm_name = pkgs[0].source_name

+             source_rpm_name = get_pkgs_source_rpm_name(pkgs[0])

              filter_result = base.sack.query().filter(name=source_rpm_name)

              ModuleDepsDiffer.package_unique(filter_result)

              source_pkgs.append(filter_result[0])
@@ -161,13 +171,12 @@ 

          q = base.sack.query()

          for cap in caps:

              pkg = q.filter(provides__glob=[cap], arch=['noarch', ARCH], latest=True)

-             if pkg:

-                 result.add(str(pkg.result[0].source_name))

-             else:

+             if not pkg:

                  pkg = q.filter(file__glob=cap)

                  if len(pkg) == 0:

                      raise ValueError('No package provides capability \'' + cap + '\'')

-                 result.add(str(pkg.result[0].source_name))

+             source_rpm_name = get_pkgs_source_rpm_name(pkg.result[0])

+             result.add(source_rpm_name)

          return result

  

      def _dump_caps_result(self, items):

this fix preserves functionality and should be a better fix than pr#28

Pull-Request has been merged by phracek

6 years ago
Metadata