Use find and xargs instead of 'find -exec'

This takes up a fraction of the time, as it avoids spawning a bunch of
sed processes
This commit is contained in:
Maxwell G 2022-11-19 15:37:45 -06:00
commit a4066fae5c
No known key found for this signature in database
GPG key ID: F79E4E25E8C661F8

View file

@ -137,7 +137,12 @@ find ansible_collections/lowlydba/sqlserver/ -executable -type f -print -exec ch
# Remove shebangs instead of hardocding to %%__python3 to avoid unexpected issues
# from https://github.com/ansible/ansible/commit/9142be2f6cabbe6597c9254c5bb9186d17036d55.
# Upstream, ansible-core has also removed shebangs from its modules.
find -type f ! -executable -name '*.py' -print -exec sed -i -e '1{\@^#!.*@d}' '{}' \;
#
# XXX: Print out the files before they're replaced
find -type f ! -executable -name '*.py' | tee non_exec
# xargs is noticably faster than find -exec, because it spawns one sed process
# instead of ~13 thousand!
xargs -a non_exec -d'\n' sed -i -e '1{\@^#!.*@d}'
# This ensures that %%ansible_core_requires is set properly, when %%pyproject_buildrequires is defined.
# It also ensures that dependencies remain consistent.