Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 439356 | Differences between
and this patch

Collapse All | Expand All

(-)a/bin/helper-functions.sh (-1 / +1 lines)
Lines 82-88 __redirect_alloc_fd() { Link Here
82
					if [[ ! -e /dev/fd/${fd} ]] && [[ ! -L /dev/fd/${fd} ]] ; then
82
					if [[ ! -e /dev/fd/${fd} ]] && [[ ! -L /dev/fd/${fd} ]] ; then
83
							eval "exec ${fd}${redir}'${file}'" && break
83
							eval "exec ${fd}${redir}'${file}'" && break
84
					fi
84
					fi
85
					[[ ${fd} -gt 1024 ]] && die "__redirect_alloc_fd failed"
85
					[[ ${fd} -gt 1024 ]] && __helpers_die "__redirect_alloc_fd failed"
86
					: $(( ++fd ))
86
					: $(( ++fd ))
87
			done
87
			done
88
			: $(( ${var} = fd ))
88
			: $(( ${var} = fd ))
(-)a/bin/isolated-functions.sh (-11 / +18 lines)
Lines 17-23 assert() { Link Here
17
	done
17
	done
18
}
18
}
19
19
20
__assert_sigpipe_ok() {
20
__helpers_assert_sigpipe_ok() {
21
	# When extracting a tar file like this:
21
	# When extracting a tar file like this:
22
	#
22
	#
23
	#     bzip2 -dc foo.tar.bz2 | tar xof -
23
	#     bzip2 -dc foo.tar.bz2 | tar xof -
Lines 36-46 __assert_sigpipe_ok() { Link Here
36
	local x pipestatus=${PIPESTATUS[*]}
36
	local x pipestatus=${PIPESTATUS[*]}
37
	for x in $pipestatus ; do
37
	for x in $pipestatus ; do
38
		# Allow SIGPIPE through (128 + 13)
38
		# Allow SIGPIPE through (128 + 13)
39
		[[ $x -ne 0 && $x -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && die "$@"
39
		[[ $x -ne 0 && $x -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && __helpers_die "$@"
40
	done
40
	done
41
41
42
	# Require normal success for the last process (tar).
42
	# Require normal success for the last process (tar).
43
	[[ $x -eq 0 ]] || die "$@"
43
	[[ $x -eq 0 ]] || __helpers_die "$@"
44
}
44
}
45
45
46
shopt -s extdebug
46
shopt -s extdebug
Lines 92-117 nonfatal() { Link Here
92
		die "$FUNCNAME() not supported in this EAPI"
92
		die "$FUNCNAME() not supported in this EAPI"
93
	fi
93
	fi
94
	if [[ $# -lt 1 ]]; then
94
	if [[ $# -lt 1 ]]; then
95
		die "$FUNCNAME(): Missing argument"
95
		# Well they said nonfatal and forgot to finish their sentence.
96
		# Something ain't right, to be sure, but die()ing here seems a bit
97
		# pendantic and mean-spirited :)
98
		local phase_str=
99
		[[ -n ${EBUILD_PHASE} ]] && phase_str=" (${EBUILD_PHASE} phase)"
100
		eerror "ERROR: ${CATEGORY}/${PF}${phase_str}:"
101
		eerror "  ${FUNCNAME}: Missing argument"
102
		eerror
103
		return 1
96
	fi
104
	fi
97
105
98
	PORTAGE_NONFATAL=1 "$@"
106
	PORTAGE_NONFATAL=1 "$@"
99
}
107
}
100
108
101
__helpers_die() {
109
__helpers_die() {
102
	if ___eapi_helpers_can_die; then
110
	if ___eapi_helpers_can_die && [[ "${PORTAGE_NONFATAL:-0}" != 1 ]]; then
103
		die "$@"
111
		die "$@"
104
	else
112
	else
105
		echo -e "$@" >&2
113
		local phase_str=
114
		[[ -n ${EBUILD_PHASE} ]] && phase_str=" (${EBUILD_PHASE} phase)"
115
		ewarn "WARNING: ${CATEGORY}/${PF}${phase_str}:"
116
		ewarn "  ${FUNCNAME}: ${*:-(no error message)}"
117
		ewarn
106
	fi
118
	fi
107
}
119
}
108
120
109
die() {
121
die() {
110
	if [[ $PORTAGE_NONFATAL -eq 1 ]]; then
111
		echo -e " $WARN*$NORMAL ${FUNCNAME[1]}: WARNING: $@" >&2
112
		return 1
113
	fi
114
115
	set +e
122
	set +e
116
	if [ -n "${QA_INTERCEPTORS}" ] ; then
123
	if [ -n "${QA_INTERCEPTORS}" ] ; then
117
		# die was called from inside inherit. We need to clean up
124
		# die was called from inside inherit. We need to clean up
(-)a/bin/phase-helpers.sh (-2 / +2 lines)
Lines 299-305 unpack() { Link Here
299
		__unpack_tar() {
299
		__unpack_tar() {
300
			if [ "${y}" == "tar" ]; then
300
			if [ "${y}" == "tar" ]; then
301
				$1 -c -- "$srcdir$x" | tar xof -
301
				$1 -c -- "$srcdir$x" | tar xof -
302
				__assert_sigpipe_ok "$myfail"
302
				__helpers_assert_sigpipe_ok "$myfail"
303
			else
303
			else
304
				local cwd_dest=${x##*/}
304
				local cwd_dest=${x##*/}
305
				cwd_dest=${cwd_dest%.*}
305
				cwd_dest=${cwd_dest%.*}
Lines 317-323 unpack() { Link Here
317
				;;
317
				;;
318
			tbz|tbz2)
318
			tbz|tbz2)
319
				${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "$srcdir$x" | tar xof -
319
				${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "$srcdir$x" | tar xof -
320
				__assert_sigpipe_ok "$myfail"
320
				__helpers_assert_sigpipe_ok "$myfail"
321
				;;
321
				;;
322
			ZIP|zip|jar)
322
			ZIP|zip|jar)
323
				# unzip will interactively prompt under some error conditions,
323
				# unzip will interactively prompt under some error conditions,
(-)a/bin/save-ebuild-env.sh (-1 / +1 lines)
Lines 46-52 __save_ebuild_env() { Link Here
46
	done
46
	done
47
	unset x
47
	unset x
48
48
49
	unset -f assert __assert_sigpipe_ok \
49
	unset -f assert __helpers_assert_sigpipe_ok \
50
		__dump_trace die \
50
		__dump_trace die \
51
		__quiet_mode __vecho __elog_base eqawarn elog \
51
		__quiet_mode __vecho __elog_base eqawarn elog \
52
		einfo einfon ewarn eerror ebegin __eend eend KV_major \
52
		einfo einfon ewarn eerror ebegin __eend eend KV_major \
(-)a/doc/package/ebuild/eapi/4.docbook (-3 / +8 lines)
Lines 11-19 The dohard and dosed helpers from previous EAPIs are no longer available. Link Here
11
<section id='package-ebuild-eapi-4-helpers-die-nonfatal'>
11
<section id='package-ebuild-eapi-4-helpers-die-nonfatal'>
12
<title>All helpers die on failure</title>
12
<title>All helpers die on failure</title>
13
<para>
13
<para>
14
All helpers now die automatically whenever some sort of error occurs.
14
All helpers now die automatically whenever any meaningful error occurs.
15
Helper calls may be prefixed with the 'nonfatal' helper in order
15
The 'nonfatal' helper may be used to effect the error-handling behavior
16
to prevent errors from being fatal.
16
of EAPIs 0-3, in which recoverable errors emit a warning and return
17
nonzero exit-codes to invokees.  It is used by prepending 'nonfatal' to any helper
18
invocation; for example, by replacing 'dodoc /foo.txt' with 'nonfatal dodoc /foo.txt'.
19
The 'nonfatal' helper should not be applied to
20
statements other than helper invocations, and has no effect on the 'die'
21
and 'assert' helpers.
17
</para>
22
</para>
18
</section>
23
</section>
19
<section id='package-ebuild-eapi-4-helpers-docompress'>
24
<section id='package-ebuild-eapi-4-helpers-docompress'>

Return to bug 439356