Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/shebangfix.mk
| Context not available. | |||||
| # Usage: USES=shebangfix | # Usage: USES=shebangfix | ||||
| # | # | ||||
| # SHEBANG_REGEX a regular expression to match files that needs to be converted | # SHEBANG_REGEX a regular expression to match files that needs to be converted | ||||
| # SHEBANG_FILES list of files or glob pattern relative to ${WRKSRC} | # SHEBANG_FILES_* list of files or glob pattern: | ||||
| # SHEBANG_FILES_PATCH files relative to ${WRKSRC} to fix during | |||||
| # the patch phase | |||||
| # SHEBANG_FILES_INSTALL files relative to ${STAGEDIR}${PREFIX} to | |||||
| # fix during the stage phase | |||||
| # SHEBANG_GLOB list of glob pattern find(1) will match with | # SHEBANG_GLOB list of glob pattern find(1) will match with | ||||
| # | # | ||||
| # To specify that ${WRKSRC}/path1/file and all .pl files in ${WRKSRC}/path2 | # To specify that ${WRKSRC}/path1/file and all .pl files in ${WRKSRC}/path2 | ||||
| # should be processed: | # should be processed: | ||||
| # | # | ||||
| # SHEBANG_FILES= path1/file path2/*.pl | # SHEBANG_FILES_PATCH= path1/file path2/*.pl | ||||
| # | # | ||||
| # To define custom shebangs to replace, use the following (note that | # To define custom shebangs to replace, use the following (note that | ||||
| # shebangs with spaces should be quoted): | # shebangs with spaces should be quoted): | ||||
| Context not available. | |||||
| . endfor | . endfor | ||||
| .endfor | .endfor | ||||
| _USES_patch+= 210:fix-shebang | .if defined(SHEBANG_FILES) | ||||
| fix-shebang: | # Allow original SHEBANG_FILES as a synonym for SHEBANG_FILES_PATCH. | ||||
| SHEBANG_FILES_PATCH= ${SHEBANG_FILES} | |||||
| .endif | |||||
| .if defined(SHEBANG_FILES_PATCH) | |||||
| _USES_patch+= 210:fix-shebang-patch | |||||
| _SHEBANG_PATCH_DIR= ${WRKSRC} | |||||
| .endif | |||||
| .if defined(SHEBANG_FILES_INSTALL) | |||||
| _USES_install+= 899:fix-shebang-install | |||||
| _SHEBANG_INSTALL_DIR= ${STAGEDIR}${PREFIX} | |||||
| .endif | |||||
| _fix-shebang: .USE | |||||
| echo TARGET: ${.TARGET} | |||||
| .if defined(SHEBANG_REGEX) | .if defined(SHEBANG_REGEX) | ||||
| @cd ${WRKSRC}; \ | @cd ${_SHEBANG_${.TARGET:C/fix-shebang-//:tu}_DIR}; \ | ||||
| ${FIND} -E . -type f -iregex '${SHEBANG_REGEX}' \ | ${FIND} -E . -type f -iregex '${SHEBANG_REGEX}' \ | ||||
| -exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} + | -exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} + | ||||
| .elif defined(SHEBANG_GLOB) | .elif defined(SHEBANG_GLOB) | ||||
| .for f in ${SHEBANG_GLOB} | .for f in ${SHEBANG_GLOB} | ||||
| @cd ${WRKSRC}; \ | @cd ${_SHEBANG_${.TARGET:C/fix-shebang-//:tu}_DIR}; \ | ||||
| ${FIND} . -type f -name '${f}' \ | ${FIND} . -type f -name '${f}' \ | ||||
| -exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} + | -exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} + | ||||
| .endfor | .endfor | ||||
| .else | .else | ||||
| @cd ${WRKSRC}; \ | @cd ${_SHEBANG_${.TARGET:C/fix-shebang-//:tu}_DIR}; \ | ||||
| ${ECHO_CMD} ${SHEBANG_FILES} | ${XARGS} ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} | ${ECHO_CMD} ${SHEBANG_FILES_${.TARGET:C/fix-shebang-//:tu}} | ${XARGS} ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} | ||||
| .endif | .endif | ||||
| fix-shebang-install: _fix-shebang | |||||
| fix-shebang-patch: _fix-shebang | |||||
| .endif | .endif | ||||
| Context not available. | |||||