View | Details | Raw Unified | Return to bug 218979 | Differences between
and this patch

Collapse All | Expand All

(-)../../Mk/Uses/shebangfix.mk (-8 / +26 lines)
Lines 9-21 Link Here
9
# Usage:	USES=shebangfix
9
# Usage:	USES=shebangfix
10
#
10
#
11
#   SHEBANG_REGEX	a regular expression to match files that needs to be converted
11
#   SHEBANG_REGEX	a regular expression to match files that needs to be converted
12
#   SHEBANG_FILES	list of files or glob pattern relative to ${WRKSRC}
12
#   SHEBANG_FILES_*	list of files or glob pattern:
13
#     SHEBANG_FILES_PATCH	files relative to ${WRKSRC} to fix during
14
#                        	the patch phase
15
#     SHEBANG_FILES_INSTALL	files relative to ${STAGEDIR}${PREFIX} to
16
#                          	fix during the stage phase
13
#   SHEBANG_GLOB	list of glob pattern find(1) will match with
17
#   SHEBANG_GLOB	list of glob pattern find(1) will match with
14
#
18
#
15
# To specify that ${WRKSRC}/path1/file and all .pl files in ${WRKSRC}/path2
19
# To specify that ${WRKSRC}/path1/file and all .pl files in ${WRKSRC}/path2
16
# should be processed:
20
# should be processed:
17
#
21
#
18
#   SHEBANG_FILES=	path1/file path2/*.pl
22
#   SHEBANG_FILES_PATCH=	path1/file path2/*.pl
19
#
23
#
20
# To define custom shebangs to replace, use the following (note that
24
# To define custom shebangs to replace, use the following (note that
21
# shebangs with spaces should be quoted):
25
# shebangs with spaces should be quoted):
Lines 78-98 Link Here
78
.  endfor
82
.  endfor
79
.endfor
83
.endfor
80
84
81
_USES_patch+=	210:fix-shebang
85
.if defined(SHEBANG_FILES)
82
fix-shebang:
86
# Allow original SHEBANG_FILES as a synonym for SHEBANG_FILES_PATCH.
87
SHEBANG_FILES_PATCH=	${SHEBANG_FILES}
88
.endif
89
.if defined(SHEBANG_FILES_PATCH)
90
_USES_patch+=	210:fix-shebang-patch
91
_SHEBANG_PATCH_DIR=	${WRKSRC}
92
.endif
93
.if defined(SHEBANG_FILES_INSTALL)
94
_USES_install+=	899:fix-shebang-install
95
_SHEBANG_INSTALL_DIR=	${STAGEDIR}${PREFIX}
96
.endif
97
_fix-shebang: .USE
98
	echo TARGET: ${.TARGET}
83
.if defined(SHEBANG_REGEX)
99
.if defined(SHEBANG_REGEX)
84
	@cd ${WRKSRC}; \
100
	@cd ${_SHEBANG_${.TARGET:C/fix-shebang-//:tu}_DIR}; \
85
		${FIND} -E . -type f -iregex '${SHEBANG_REGEX}' \
101
		${FIND} -E . -type f -iregex '${SHEBANG_REGEX}' \
86
		-exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} +
102
		-exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} +
87
.elif defined(SHEBANG_GLOB)
103
.elif defined(SHEBANG_GLOB)
88
.for f in ${SHEBANG_GLOB}
104
.for f in ${SHEBANG_GLOB}
89
	@cd ${WRKSRC}; \
105
	@cd ${_SHEBANG_${.TARGET:C/fix-shebang-//:tu}_DIR}; \
90
		${FIND} . -type f -name '${f}' \
106
		${FIND} . -type f -name '${f}' \
91
		-exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} +
107
		-exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} +
92
.endfor
108
.endfor
93
.else
109
.else
94
	@cd ${WRKSRC}; \
110
	@cd ${_SHEBANG_${.TARGET:C/fix-shebang-//:tu}_DIR}; \
95
		${ECHO_CMD} ${SHEBANG_FILES} | ${XARGS} ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS}
111
		${ECHO_CMD} ${SHEBANG_FILES_${.TARGET:C/fix-shebang-//:tu}} | ${XARGS} ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS}
96
.endif
112
.endif
113
fix-shebang-install: _fix-shebang
114
fix-shebang-patch: _fix-shebang
97
115
98
.endif
116
.endif

Return to bug 218979