aboutsummaryrefslogtreecommitdiff
blob: 8e5b45f2c125af6ed58856f760c9f58715a0b88f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1

helper=${__PORTAGE_HELPER:-${0##*/}}

if [[ ${helper} == dodoc ]] ; then
	if [ $# -eq 0 ] ; then
		# default_src_install may call dodoc with no arguments
		# when DOC is defined but empty, so simply return
		# sucessfully in this case.
		eqawarn "QA Notice: dodoc called with no arguments"
		exit 0
	fi
	export INSOPTIONS=-m0644
	export DIROPTIONS=""
	export __E_INSDESTTREE=usr/share/doc/${PF}/${__E_DOCDESTTREE}
else
	if ! ___eapi_has_DESTTREE_INSDESTTREE; then
		[[ -n ${INSDESTTREE} ]] &&
			die "${0##*/}: \${INSDESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
	else
		# backwards compatibility
		__E_INSDESTTREE=${INSDESTTREE}
	fi
fi

if [ $# -lt 1 ] ; then
	__helpers_die "${helper}: at least one argument needed"
	exit 1
fi

DOINS_ARGS=()
if [[ "${1}" == "-r" ]] ; then
	DOINS_ARGS+=( --recursive )
	shift
fi

if ! ___eapi_has_prefix_variables; then
	export ED="${D}"
fi

if [[ ${__E_INSDESTTREE#${D}} != "${__E_INSDESTTREE}" ]]; then
	__vecho "-------------------------------------------------------" 1>&2
	__vecho "You should not use \${D} or \${ED} with helpers." 1>&2
	__vecho "  --> ${__E_INSDESTTREE}" 1>&2
	__vecho "-------------------------------------------------------" 1>&2
	__helpers_die "${helper} used with \${D} or \${ED}"
	exit 1
fi
if [[ -n ${EPREFIX} && \
		${__E_INSDESTTREE#${EPREFIX}} != "${__E_INSDESTTREE}" ]]
then
	__vecho "-------------------------------------------------------" 1>&2
	__vecho "You should not use \${EPREFIX} with helpers." 1>&2
	__vecho "  --> ${__E_INSDESTTREE}" 1>&2
	__vecho "-------------------------------------------------------" 1>&2
	__helpers_die "${helper} used with \${EPREFIX}"
	exit 1
fi

if ___eapi_doins_and_newins_preserve_symlinks; then
	DOINS_ARGS+=( --preserve_symlinks )
fi

if ___eapi_helpers_can_die; then
	DOINS_ARGS+=( --helpers_can_die )
fi

if [[ -n "${INSOPTIONS}" ]]; then
	DOINS_ARGS+=( "--insoptions=${INSOPTIONS}" )
fi

if [[ -n "${DIROPTIONS}" ]]; then
	DOINS_ARGS+=( "--diroptions=${DIROPTIONS}" )
fi

if [[ -n "${PORTAGE_ACTUAL_DISTDIR}" ]]; then
	DOINS_ARGS+=( "--distdir=${PORTAGE_ACTUAL_DISTDIR}" )
fi

if [[ "${DOINSSTRICTOPTION}" == 1 ]]; then
	DOINS_ARGS+=( --strict_option )
fi

if has xattr ${FEATURES}; then
	DOINS_ARGS+=(
		--enable_copy_xattr
		"--xattr_exclude=${PORTAGE_XATTR_EXCLUDE}"
	)
fi

DOINS_ARGS+=(
	"--helper=${helper}"
	"--dest=${ED%/}/${__E_INSDESTTREE#/}"
)

# Explicitly set PYTHONPATH to non empty.
# If PYTHONPATH is empty (not unset), it means "add current working directory
# to the import path" if the Python is prior to 3.4, which would cause
# unexpected import. See also #469338.
PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
	"${PORTAGE_PYTHON:-/usr/bin/python}" \
	"${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/doins.py \
	"${DOINS_ARGS[@]}" -- "$@" || \
{ __helpers_die "${helper} failed"; exit 1; }