Skip to content

Commit

Permalink
Split packages from cmake_modules when adding them as buildreqs
Browse files Browse the repository at this point in the history
When parsing cmake files for find_package dependencies, we match against
entries in cmake_modules. Many of the entries of this file list
multiple packages, separated by space. Split on whitespace so we
actually feed only individual package names to each add_buildreq call.

Otherwise, if cmake_modules provides "extra-cmake-modules png2ico", for
example, and you have "png2ico" in buildreq_ban, the specfile would still
list both extra-cmake-modules and png2ico as build dependencies, because
add_buildreq only compared exact matches.
  • Loading branch information
bwarden committed Oct 1, 2024
1 parent a19cdc7 commit 965ebf1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions autospec/buildreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,13 @@ def parse_cmake(self, filename, cmake_modules, conf32):
for line in lines:
if match := findpackage.search(line):
module = match.group(1)
if pkg := cmake_modules.get(module):
self.add_buildreq(pkg)
if pkgs := cmake_modules.get(module):
# Some of the entries in cmake_modules list multiple packages, space-separated, so we need to split.
# Otherwise, anything in buildreq_ban would have to match the entire string, not just a single package name.
# For example: Png2Ico, extra-cmake-modules png2ico
# buildreq_ban would have to contain "extra-cmake-modules png2ico" to match, instead of just "png2ico"
for pkg in pkgs.split():
self.add_buildreq(pkg)
elif findpackage_multiline.search(line):
self.findpackage_parse_lines(line, lines, cmake_modules)

Expand Down

0 comments on commit 965ebf1

Please sign in to comment.