Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 2/4] distutils-r1.eclass: Eliminate path arg to ..._wrap_scripts
Date: Fri, 25 Jun 2021 19:51:53
Message-Id: 20210625195101.351937-3-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/4] distutils-r1.eclass: dosym -r, attempt two by "Michał Górny"
1 Eliminate the path argument to _distutils-r1_wrap_scripts, and inline
2 the use of ${D} instead. This should make the code less confusing.
3
4 Signed-off-by: Michał Górny <mgorny@g.o>
5 ---
6 eclass/distutils-r1.eclass | 25 ++++++++++++-------------
7 1 file changed, 12 insertions(+), 13 deletions(-)
8
9 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
10 index e194731ba6bb..87091951fafa 100644
11 --- a/eclass/distutils-r1.eclass
12 +++ b/eclass/distutils-r1.eclass
13 @@ -740,24 +740,23 @@ distutils-r1_python_compile() {
14 }
15
16 # @FUNCTION: _distutils-r1_wrap_scripts
17 -# @USAGE: <path> <bindir>
18 +# @USAGE: <bindir>
19 # @INTERNAL
20 # @DESCRIPTION:
21 # Moves and wraps all installed scripts/executables as necessary.
22 _distutils-r1_wrap_scripts() {
23 debug-print-function ${FUNCNAME} "${@}"
24
25 - [[ ${#} -eq 2 ]] || die "usage: ${FUNCNAME} <path> <bindir>"
26 - local path=${1}
27 - local bindir=${2}
28 + [[ ${#} -eq 1 ]] || die "usage: ${FUNCNAME} <bindir>"
29 + local bindir=${1}
30
31 local scriptdir=$(python_get_scriptdir)
32 local f python_files=() non_python_files=()
33
34 - if [[ -d ${path}${scriptdir} ]]; then
35 - for f in "${path}${scriptdir}"/*; do
36 + if [[ -d ${D%/}${scriptdir} ]]; then
37 + for f in "${D%/}${scriptdir}"/*; do
38 [[ -d ${f} ]] && die "Unexpected directory: ${f}"
39 - debug-print "${FUNCNAME}: found executable at ${f#${path}/}"
40 + debug-print "${FUNCNAME}: found executable at ${f#${D%/}/}"
41
42 local shebang
43 read -r shebang < "${f}"
44 @@ -769,22 +768,22 @@ _distutils-r1_wrap_scripts() {
45 non_python_files+=( "${f}" )
46 fi
47
48 - mkdir -p "${path}${bindir}" || die
49 + mkdir -p "${D%/}${bindir}" || die
50 done
51
52 for f in "${python_files[@]}"; do
53 local basename=${f##*/}
54
55 debug-print "${FUNCNAME}: installing wrapper at ${bindir}/${basename}"
56 - _python_ln_rel "${path}${EPREFIX}"/usr/lib/python-exec/python-exec2 \
57 - "${path}${bindir}/${basename}" || die
58 + _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 \
59 + "${D%/}${bindir}/${basename}" || die
60 done
61
62 for f in "${non_python_files[@]}"; do
63 local basename=${f##*/}
64
65 - debug-print "${FUNCNAME}: moving ${f#${path}/} to ${bindir}/${basename}"
66 - mv "${f}" "${path}${bindir}/${basename}" || die
67 + debug-print "${FUNCNAME}: moving ${f#${D%/}/} to ${bindir}/${basename}"
68 + mv "${f}" "${D%/}${bindir}/${basename}" || die
69 done
70 fi
71 }
72 @@ -922,7 +921,7 @@ distutils-r1_python_install() {
73
74 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
75 multibuild_merge_root "${root}" "${D%/}"
76 - _distutils-r1_wrap_scripts "${D%/}" "${scriptdir}"
77 + _distutils-r1_wrap_scripts "${scriptdir}"
78 fi
79 }
80
81 --
82 2.32.0