The perl snippat that looks like this can cope with multiple files at
once, so save a few execs:
MODPY_BIN_ADJ = perl -pi \
-e '$$. == 1 && s|^.*env +python.*$$|\#!${MODPY_BIN}|;' \
-e '$$. == 1 && s|^.*bin/python.*$$|\#!${MODPY_BIN}|;' \
-e 'close ARGV if eof;'
To make it more robust, also append `--' to it such that ports cannot
(accidentially) pass options; I've checked the tree that no port does
this on purpose.
The only this where this could fail is with huge MODPY_ADJ_FILES but
that is not the case in our tree; ports where lots of shebangs are
fixed have their own construct around it, e.g. textproc/calibre which
uses the `find -exec ${MODPY_ADJ_FILES} {} +' idiom.
Feedback? Objections? OK?
Index: python.port.mk
===================================================================
RCS file: /cvs/ports/lang/python/python.port.mk,v
retrieving revision 1.124
diff -u -p -r1.124 python.port.mk
--- python.port.mk 29 Dec 2020 23:59:06 -0000 1.124
+++ python.port.mk 1 Feb 2021 04:18:48 -0000
@@ -214,12 +214,11 @@ UPDATE_PLIST_ARGS += -S MODPY_BIN_SUFFIX
MODPY_BIN_ADJ = perl -pi \
-e '$$. == 1 && s|^.*env +python.*$$|\#!${MODPY_BIN}|;' \
-e '$$. == 1 && s|^.*bin/python.*$$|\#!${MODPY_BIN}|;' \
- -e 'close ARGV if eof;'
+ -e 'close ARGV if eof;' --
MODPY_ADJ_FILES ?=
.if !empty(MODPY_ADJ_FILES)
-MODPYTHON_pre-configure += for f in ${MODPY_ADJ_FILES}; do \
- ${MODPY_BIN_ADJ} ${WRKSRC}/$${f}; done
+MODPYTHON_pre-configure += cd ${WRKSRC} && ${MODPY_BIN_ADJ} ${MODPY_ADJ_FILES}
.endif
MODPY_BUILD_TARGET = ${_MODPY_PRE_BUILD_STEPS}; \
No comments:
Post a Comment