#334 Run dnf repoquery from within the mock chroot
Merged 5 years ago by ngompa. Opened 5 years ago by eclipseo.
Unknown source run_repoquery_in_mock  into  devel

file modified
+9 -14
@@ -1032,11 +1032,8 @@

              skipping any version requirements.

              '''

              pkgs = []

-             requires = [re.split('[<=>]+', r)[0] for r in requires_arg]

-             requires = [r.strip('(') for r in requires]

-             requires = [re.sub('/.*$', ')', r) for r in requires]

-             requires_to_process = list(requires)

-             for r in requires:

+             requires_to_process = list(requires_arg)

+             for r in requires_arg:

                  if r.startswith('rpmlib'):

                      requires_to_process.remove(r)

                      continue
@@ -1942,15 +1939,11 @@

          # pylint: disable=R0912

          def resolve(requires_arg):

              '''

-             Resolve list of symbols to packages in srpm or by repoquery,

-             skipping any version requirements.

+             Resolve list of symbols to packages in srpm or by repoquery

              '''

              pkgs = []

-             requires = [re.split('[<=>]+', r)[0] for r in requires_arg]

-             requires = [r.strip('(') for r in requires]

-             requires = [re.sub('/.*$', ')', r) for r in requires]

-             requires_to_process = list(requires)

-             for r in requires:

+             requires_to_process = list(requires_arg)

+             for r in requires_arg:

                  if r.startswith('rpmlib'):

                      requires_to_process.remove(r)

                      continue
@@ -1963,10 +1956,12 @@

              return set(pkgs)

  

          pkg_deps = set()

+         pkg_list = set()

          for pkg in self.spec.packages:

-             pkg_deps |= resolve(self.rpms.get(pkg).requires)

+             pkg_list |= set(self.rpms.get(pkg).requires)

+         pkg_list |= set(self.spec.build_requires)

  

-         pkg_deps |= set(self.spec.build_requires)

+         pkg_deps |= resolve(pkg_list)

  

          for pkg in pkg_deps:

              provides = deps.list_provides(pkg)

file modified
+23 -10
@@ -32,7 +32,14 @@

      # Might be solvable, see

      # https://bugs.launchpad.net/ubuntu/+source/packagekit/+bug/1008106

      try:

-         check_output(['dnf', 'makecache'])

+         check_output(['mock', '-r', Settings.mock_config, '-qn', 'install',

+                       'dnf'])

+     except subprocess.CalledProcessError:

+         Settings.get_logger().warning(

+             "Cannot install dnf, trouble ahead")

+     try:

+         check_output(['mock', '-r', Settings.mock_config, '-qn',

+                       '--enable-network', 'shell', 'dnf makecache'])

      except subprocess.CalledProcessError:

          Settings.get_logger().warning(

              "Cannot run dnf makecache, trouble ahead")
@@ -46,8 +53,9 @@

      if not pkgs:

          return []

  

-     cmd = ['dnf', 'repoquery', '-q', '-C', '--requires', '--resolve']

-     cmd.extend(list(set(pkgs)))

+     cmd = ['mock', '-r', Settings.mock_config, '-qn', '--enable-network',

+            'shell', 'dnf repoquery -q -C --requires --resolve ' +

+            ' '.join(list(set(pkgs)))]

      Settings.get_logger().debug("Running: %s", ' '.join(cmd))

      try:

          dnf = subprocess.Popen(cmd, stdout=subprocess.PIPE)
@@ -72,8 +80,9 @@

      if not pkgs:

          return []

  

-     cmd = ['dnf', 'repoquery', '-q', '-C', '--provides']

-     cmd.extend(list(set(pkgs)))

+     cmd = ['mock', '-r', Settings.mock_config, '-qn', '--enable-network',

+            'shell', 'dnf repoquery -q -C --provides '

+            + ' '.join(list(set(pkgs)))]

      Settings.get_logger().debug("Running: %s", ' '.join(cmd))

      try:

          dnf = subprocess.Popen(cmd, stdout=subprocess.PIPE)
@@ -107,7 +116,8 @@

  

  def resolve_one(req):

      ''' Return the packages providing the req symbol. '''

-     cmd = ['dnf', 'repoquery', '-C', '--whatprovides', req]

+     cmd = ['mock', '-r', Settings.mock_config, '-qn', '--enable-network',

+            'shell', 'dnf repoquery -C --whatprovides "' + req + '"']

      Settings.get_logger().debug("Running: %s", ' '.join(cmd))

  

      try:
@@ -166,7 +176,9 @@

      owners = []

      paths_to_exam = list(paths)

      for path in paths:

-         p = subprocess.Popen(['rpm', '--qf', '%{NAME}\n', '-qf', path],

+         p = subprocess.Popen(['mock', '-r', Settings.mock_config, '-qn',

+                               '--enable-network', 'shell',

+                               'rpm --qf %{NAME}\n -qf ' + path],

                               stdout=subprocess.PIPE,

                               stderr=subprocess.PIPE)

          path_owners = p.communicate()[0].split()
@@ -181,7 +193,8 @@

          paths_to_exam.remove(path)

          owners.extend(path_owners)

      for path in paths_to_exam:

-         cmd = ['dnf', 'repoquery', '-C', '--quiet', '--file', path]

+         cmd = ['mock', '-r', Settings.mock_config, '-qn', '--enable-network',

+                'shell', 'dnf repoquery -C --quiet --file ' + path]

          Settings.get_logger().debug("Running: %s", ' '.join(cmd))

          try:

              lines = check_output(cmd).split()
@@ -204,8 +217,8 @@

      if not isinstance(pkgs, list):

          pkgs = [pkgs]

  

-     cmd = ['dnf', 'repoquery', '-C', '-l']

-     cmd.extend(list(set(pkgs)))

+     cmd = ['mock', '-r', Settings.mock_config, '-qn', '--enable-network',

+            'shell', 'dnf repoquery -C -l ' + ' '.join(list(set(pkgs)))]

  

      Settings.get_logger().debug("Running: %s", ' '.join(cmd))

      try:

Pull-Request has been merged by ngompa

5 years ago