From 81f75c0da2789e3c8777036bf970539fedd8e781 Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Mar 13 2019 04:36:44 +0000 Subject: Run dnf repoquery from within the mock chroot --- diff --git a/plugins/generic.py b/plugins/generic.py index a2f0dc3..9f6c114 100644 --- a/plugins/generic.py +++ b/plugins/generic.py @@ -1032,11 +1032,8 @@ class CheckOwnDirs(GenericCheckBase): 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 @@ class CheckIfDepsDeprecated(GenericCheckBase): # 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 @@ class CheckIfDepsDeprecated(GenericCheckBase): 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) diff --git a/src/FedoraReview/deps.py b/src/FedoraReview/deps.py index 20df700..59a0922 100644 --- a/src/FedoraReview/deps.py +++ b/src/FedoraReview/deps.py @@ -32,7 +32,14 @@ def init(): # 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 @@ def list_deps(pkgs): 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 @@ def list_provides(pkgs): 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(reqs): 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 @@ def list_owners(paths): 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 @@ def list_owners(paths): 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 @@ def list_paths(pkgs): 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: