From 0e563b752a9238cbc0006a6eda5dce59eb633712 Mon Sep 17 00:00:00 2001 From: Andrew Toskin Date: Jul 15 2020 17:31:03 +0000 Subject: Completely strip shebangs from Python files that will be installed to /usr/share/ In the source directory, currently, all Python files under ./bleachbit/ get installed to /usr/share/ as non-executable files, so they don't require a shebang at all. I don't know if this is guaranteed, though, so this may or may not need a better heuristic later. In the source, for some reason, most Python files have the executability bit, which is then removed where unneeded during `make`. So, what seems more foolproof would be to wait till after %build and %install, test files installed under /usr/share/bleachbit/ for executability, and *then* remove the unneeded shebangs... But this causes a timestamp mismatch between the source files and compiled byte code, which will force the Python interpreter to recompile every time. --- diff --git a/bleachbit.spec b/bleachbit.spec index 62170f2..ae6d653 100644 --- a/bleachbit.spec +++ b/bleachbit.spec @@ -52,9 +52,12 @@ to make them run faster. # Disable update notifications, since package will be updated by DNF or Packagekit. sed 's/online_update_notification_enabled = True/online_update_notification_enabled = False/g' --in-place ./bleachbit/__init__.py -# Replace env shebangs, and calls to unversioned or unnecessarily specifically versioned python. -find ./ -type f -name '*.py' -exec sed --regexp-extended '1s|^#! ?/usr/bin/env python3?$|#!%{_bindir}/python3|g' --in-place '{}' + -find ./ -type f -name '*.py' -exec sed --regexp-extended '1s|^#! ?/usr/bin/python[[:digit:][:punct:]]*$|#!%{_bindir}/python3|g' --in-place '{}' + +# These get installed to %%{_datadir} as non-executable files, and so shouldn't need a shebang at all. +find ./bleachbit/ -type f -iname '*.py' -exec sed --regexp-extended '1s|^#! ?/.+$||g' --in-place '{}' + + +# Replace any remaining env shebangs, or shebangs calling unversioned or unnecessarily specifically versioned Python, with plain python3. +find ./ -type f -iname '*.py' -exec sed --regexp-extended '1s|^#! ?/usr/bin/env python3?$|#!%{_bindir}/python3|g' --in-place '{}' + +find ./ -type f -iname '*.py' -exec sed --regexp-extended '1s|^#! ?/usr/bin/python[[:digit:][:punct:]]*$|#!%{_bindir}/python3|g' --in-place '{}' +