Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 927248
Collapse All | Expand All

(-)a/bin/install-qa-check.d/05prefix (-24 / +16 lines)
Lines 33-39 install_qa_check_prefix() { Link Here
33
33
34
	# check shebangs, bug #282539
34
	# check shebangs, bug #282539
35
	rm -f "${T}"/non-prefix-shebangs-errs
35
	rm -f "${T}"/non-prefix-shebangs-errs
36
	local WHITELIST=" /usr/bin/env "
36
	local WHITELIST=""
37
	# this is hell expensive, but how else?
37
	# this is hell expensive, but how else?
38
	find "${ED}" -executable \! -type d -print0 \
38
	find "${ED}" -executable \! -type d -print0 \
39
			| xargs -0 grep -H -n -m1 "^#!" \
39
			| xargs -0 grep -H -n -m1 "^#!" \
Lines 76-104 install_qa_check_prefix() { Link Here
76
			fi
76
			fi
77
			continue
77
			continue
78
		fi
78
		fi
79
		# unprefixed shebang, is the script directly in ${PATH} or an init script?
79
		# unprefixed shebang, prefixify it!
80
		if [[ ":${PATH}:${EPREFIX}/etc/init.d:" == *":${fp}:"* ]] ; then
80
		if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; then
81
			if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; then
81
			# is it unprefixed, but we can just fix it because a
82
				# is it unprefixed, but we can just fix it because a
82
			# prefixed variant exists
83
				# prefixed variant exists
83
			eqawarn "QA Notice:  prefixing shebang of ${fn#${D}}"
84
				eqawarn "QA Notice:  prefixing shebang of ${fn#${D}}"
84
			# statement is made idempotent on purpose, because
85
				# statement is made idempotent on purpose, because
85
			# symlinks may point to the same target, and hence the
86
				# symlinks may point to the same target, and hence the
86
			# same real file may be sedded multiple times since we
87
				# same real file may be sedded multiple times since we
87
			# read the shebangs in one go upfront for performance
88
				# read the shebangs in one go upfront for performance
88
			# reasons
89
				# reasons
89
			sed -i -e '1s:^#! \?'"${line[0]}"':#!'"${EPREFIX}"${line[0]}':' "${rf}"
90
				sed -i -e '1s:^#! \?'"${line[0]}"':#!'"${EPREFIX}"${line[0]}':' "${rf}"
90
			continue
91
				continue
92
			else
93
				# this is definitely wrong: script in ${PATH} and invalid shebang
94
				echo "${fn#${D}}:${line[0]} (script ${fn##*/} installed in PATH but interpreter ${line[0]} not found)" \
95
					>> "${T}"/non-prefix-shebangs-errs
96
			fi
97
		else
91
		else
98
			# unprefixed/invalid shebang, but outside ${PATH}, this may be
92
			# this is definitely wrong: script in ${PATH} and invalid shebang
99
			# intended (e.g. config.guess) so remain silent by default
93
			echo "${fn#${D}}:${line[0]} (script ${fn##*/} installed in PATH but interpreter ${line[0]} not found)" \
100
			has stricter ${FEATURES} && \
94
				>> "${T}"/non-prefix-shebangs-errs
101
				eqawarn "QA Notice: invalid shebang in ${fn#${D}}: ${line[0]}"
102
		fi
95
		fi
103
	done
96
	done
104
	if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then
97
	if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then
105
- 

Return to bug 927248