From 5c736fb80c64dd5bd001cb6b48903aada4698d8d Mon Sep 17 00:00:00 2001 From: Otto Urpelainen Date: Jul 01 2021 10:48:20 +0000 Subject: Fix CheckOwnDirs recursion through subpackages CheckOwnDirs in the generic plugin is supposed to recurse one level of Requires to find owners of used directories. The recursion did not work properly through subpackages. Fixed here. Also recursion now goes through all subpackages and one additional level, mainly for ease of implementation. --- diff --git a/plugins/generic.py b/plugins/generic.py index 4892baf..8bcee96 100644 --- a/plugins/generic.py +++ b/plugins/generic.py @@ -1092,12 +1092,24 @@ class CheckOwnDirs(GenericCheckBase): def run_on_applicable(self): """ Test if all directories created by us are owned by us or - of a dependency. Dependency resolution recurses one level, but + of a dependency. Dependency resolution recurses through all + packages in the srpm and one additional level, but no more. This is partly to limit the result set, partly a a best practise not to trust deep dependency chains for package directory ownership. """ + def remove_rpmlib(requires_arg): + """ + Return copy of given list of strings with all entries starting with + 'rpmlib' removed. + """ + result = list(requires_arg) + for r in requires_arg: + if r.startswith("rpmlib"): + result.remove(r) + return result + # pylint: disable=R0912 def resolve(requires_arg): """ @@ -1105,14 +1117,13 @@ class CheckOwnDirs(GenericCheckBase): skipping any version requirements. """ pkgs = [] - requires_to_process = list(requires_arg) - for r in requires_arg: - if r.startswith("rpmlib"): - requires_to_process.remove(r) - continue + requires_to_process = remove_rpmlib(requires_arg) + for r in list(requires_to_process): for pkg in self.spec.packages: if r in self.rpms.get(pkg).provides: pkgs.append(pkg) + transitive = remove_rpmlib(self.rpms.get(pkg).requires) + requires_to_process.extend(transitive) requires_to_process.remove(r) break if requires_to_process: