Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: bin/
Date: Tue, 01 May 2018 16:26:03
Message-Id: 1525163324.43b6be7423aaebee26e4659d580a9a17b4fde01e.zmedico@gentoo
1 commit: 43b6be7423aaebee26e4659d580a9a17b4fde01e
2 Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
3 AuthorDate: Tue Nov 7 23:14:40 2017 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Tue May 1 08:28:44 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=43b6be74
7
8 phase-helpers.sh: Implement -r|-d|-b options for best/has_version
9
10 The code for these functions is practically identical so refactor them
11 around a common function.
12
13 bin/eapi.sh | 6 ++-
14 bin/phase-helpers.sh | 146 ++++++++++++++++++++-------------------------------
15 2 files changed, 63 insertions(+), 89 deletions(-)
16
17 diff --git a/bin/eapi.sh b/bin/eapi.sh
18 index 3b6a5c1a9..455bc9b0d 100644
19 --- a/bin/eapi.sh
20 +++ b/bin/eapi.sh
21 @@ -155,7 +155,11 @@ ___eapi_has_package_manager_build_group() {
22 # HELPERS BEHAVIOR
23
24 ___eapi_best_version_and_has_version_support_--host-root() {
25 - [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
26 + [[ ${1-${EAPI-0}} =~ ^(5|5-progress|6)$ ]]
27 +}
28 +
29 +___eapi_best_version_and_has_version_support_-b_-d_-r() {
30 + [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-progress|6)$ ]]
31 }
32
33 ___eapi_unpack_supports_xz() {
34
35 diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
36 index f6c9ef6fc..59c19cf67 100644
37 --- a/bin/phase-helpers.sh
38 +++ b/bin/phase-helpers.sh
39 @@ -878,46 +878,55 @@ __eapi6_src_install() {
40 einstalldocs
41 }
42
43 -# @FUNCTION: has_version
44 -# @USAGE: [--host-root] <DEPEND ATOM>
45 -# @DESCRIPTION:
46 -# Return true if given package is installed. Otherwise return false.
47 -# Callers may override the ROOT variable in order to match packages from an
48 -# alternative ROOT.
49 -has_version() {
50 -
51 - local atom eroot host_root=false root=${ROOT}
52 - if [[ $1 == --host-root ]] ; then
53 - host_root=true
54 - shift
55 - fi
56 +___best_version_and_has_version_common() {
57 + local atom root root_arg
58 + case $1 in
59 + --host-root|-r|-d|-b)
60 + root_arg=$1
61 + shift ;;
62 + esac
63 atom=$1
64 shift
65 - [ $# -gt 0 ] && die "${FUNCNAME[0]}: unused argument(s): $*"
66 + [ $# -gt 0 ] && die "${FUNCNAME[1]}: unused argument(s): $*"
67
68 - if ${host_root} ; then
69 - if ! ___eapi_best_version_and_has_version_support_--host-root; then
70 - die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
71 - fi
72 - root=/
73 - fi
74 + case ${root_arg} in
75 + "") if ___eapi_has_prefix_variables; then
76 + root=${EROOT}
77 + else
78 + root=${ROOT}
79 + fi ;;
80 + --host-root)
81 + if ! ___eapi_best_version_and_has_version_support_--host-root; then
82 + die "${FUNCNAME[1]}: option ${root_arg} is not supported with EAPI ${EAPI}"
83 + fi
84 + if ___eapi_has_prefix_variables; then
85 + root=/${PORTAGE_OVERRIDE_EPREFIX#/}
86 + else
87 + root=/
88 + fi ;;
89 + -r|-d|-b)
90 + if ! ___eapi_best_version_and_has_version_support_-b_-d_-r; then
91 + die "${FUNCNAME[1]}: option ${root_arg} is not supported with EAPI ${EAPI}"
92 + fi
93 + if ___eapi_has_prefix_variables; then
94 + case ${root_arg} in
95 + -r) root=${EROOT} ;;
96 + -d) root=${ESYSROOT} ;;
97 + -b) root=${BROOT:-/} ;;
98 + esac
99 + else
100 + case ${root_arg} in
101 + -r) root=${ROOT} ;;
102 + -d) root=${SYSROOT} ;;
103 + -b) root=/ ;;
104 + esac
105 + fi ;;
106 + esac
107
108 - if ___eapi_has_prefix_variables; then
109 - # [[ ${root} == / ]] would be ambiguous here,
110 - # since both prefixes can share root=/ while
111 - # having different EPREFIX offsets.
112 - if ${host_root} ; then
113 - eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/
114 - else
115 - eroot=${root%/}${EPREFIX}/
116 - fi
117 - else
118 - eroot=${root}
119 - fi
120 if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
121 - "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "${eroot}" "${atom}"
122 + "${PORTAGE_BIN_PATH}"/ebuild-ipc "${FUNCNAME[1]}" "${root}" "${atom}"
123 else
124 - "${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" has_version "${eroot}" "${atom}"
125 + "${PORTAGE_BIN_PATH}"/ebuild-helpers/portageq "${FUNCNAME[1]}" "${root}" "${atom}"
126 fi
127 local retval=$?
128 case "${retval}" in
129 @@ -925,75 +934,36 @@ has_version() {
130 return ${retval}
131 ;;
132 2)
133 - die "${FUNCNAME[0]}: invalid atom: ${atom}"
134 + die "${FUNCNAME[1]}: invalid atom: ${atom}"
135 ;;
136 *)
137 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
138 - die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}"
139 + die "${FUNCNAME[1]}: unexpected ebuild-ipc exit code: ${retval}"
140 else
141 - die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}"
142 + die "${FUNCNAME[1]}: unexpected portageq exit code: ${retval}"
143 fi
144 ;;
145 esac
146 }
147
148 +# @FUNCTION: has_version
149 +# @USAGE: [--host-root|-r|-d|-b] <DEPEND ATOM>
150 +# @DESCRIPTION:
151 +# Return true if given package is installed. Otherwise return false.
152 +# Callers may override the ROOT variable in order to match packages from an
153 +# alternative ROOT.
154 +has_version() {
155 + ___best_version_and_has_version_common "$@"
156 +}
157 +
158 # @FUNCTION: best_version
159 -# @USAGE: [--host-root] <DEPEND ATOM>
160 +# @USAGE: [--host-root|-r|-d|-b] <DEPEND ATOM>
161 # @DESCRIPTION:
162 # Returns highest installed matching category/package-version (without .ebuild).
163 # Callers may override the ROOT variable in order to match packages from an
164 # alternative ROOT.
165 best_version() {
166 -
167 - local atom eroot host_root=false root=${ROOT}
168 - if [[ $1 == --host-root ]] ; then
169 - host_root=true
170 - shift
171 - fi
172 - atom=$1
173 - shift
174 - [ $# -gt 0 ] && die "${FUNCNAME[0]}: unused argument(s): $*"
175 -
176 - if ${host_root} ; then
177 - if ! ___eapi_best_version_and_has_version_support_--host-root; then
178 - die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
179 - fi
180 - root=/
181 - fi
182 -
183 - if ___eapi_has_prefix_variables; then
184 - # [[ ${root} == / ]] would be ambiguous here,
185 - # since both prefixes can share root=/ while
186 - # having different EPREFIX offsets.
187 - if ${host_root} ; then
188 - eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/
189 - else
190 - eroot=${root%/}${EPREFIX}/
191 - fi
192 - else
193 - eroot=${root}
194 - fi
195 - if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
196 - "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "${eroot}" "${atom}"
197 - else
198 - "${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" best_version "${eroot}" "${atom}"
199 - fi
200 - local retval=$?
201 - case "${retval}" in
202 - 0|1)
203 - return ${retval}
204 - ;;
205 - 2)
206 - die "${FUNCNAME[0]}: invalid atom: ${atom}"
207 - ;;
208 - *)
209 - if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
210 - die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}"
211 - else
212 - die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}"
213 - fi
214 - ;;
215 - esac
216 + ___best_version_and_has_version_common "$@"
217 }
218
219 if ___eapi_has_get_libdir; then