Skip to content

Commit

Permalink
Add a mechanism to automatically exclude Windows executables
Browse files Browse the repository at this point in the history
Some packages, especially PIP wheels, install Windows executables.
Introduce an option, allow_exe, with which to permit installing those
executables. Otherwise, explicitly delete them so they're not
inadvertently installed via wildcards later.
  • Loading branch information
bwarden authored and bryteise committed Jan 16, 2024
1 parent ab27b0e commit e664610
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion autospec/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def __init__(self, download_path):
"nodebug": "do not generate debuginfo for this package",
"openmpi": "configure build also for openmpi",
"server": "Package is only used by servers",
"no_glob": "Do not use the replacement pattern for file matching"
"no_glob": "Do not use the replacement pattern for file matching",
"allow_exe": "Allow Windows executables (*.exe, *.dll) to be packaged",
}
# simple_pattern_pkgconfig patterns
# contains patterns for parsing build.log for missing dependencies
Expand Down
10 changes: 10 additions & 0 deletions autospec/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ def push_file(self, filename, pkg_name):
if self.want_dev_split and self.file_pat_match(filename, r"^/usr/.*/include/.*\.h$", "dev"):
return

# Exclude Windows executables and DLLs unless otherwise configured
# Can't just skip them because they could be swept up in a python lib wildcard, for example
if re.search(r"[^/]+\.(exe|dll)$", filename):
if self.config.config_opts.get('allow_exe'):
util.print_warning("Allowing {} because allow_exe is true".format(filename))
else:
util.print_warning("Blocking {} because allow_exe is false".format(filename))
self.excludes.append(filename)
return

# if configured to do so, add .so files to the lib package instead of
# the dev package. THis is useful for packages with a plugin
# architecture like elfutils and mesa.
Expand Down

0 comments on commit e664610

Please sign in to comment.