Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: bin/ebuild-helpers/xattr/, bin/ebuild-helpers/, bin/postinst-qa-check.d/, bin/, ...
Date: Mon, 01 Aug 2022 22:39:18
Message-Id: 1659393491.cb8eda531dad92bec9293c89f93db9b581245fd3.sam@gentoo
1 commit: cb8eda531dad92bec9293c89f93db9b581245fd3
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jul 28 01:25:22 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Mon Aug 1 22:38:11 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=cb8eda53
7
8 bin: style tweaks
9
10 Signed-off-by: Sam James <sam <AT> gentoo.org>
11
12 bin/bashrc-functions.sh | 18 +-
13 bin/binhost-snapshot | 2 +-
14 bin/chpathtool.py | 8 +-
15 bin/doins.py | 8 +-
16 bin/ebuild | 2 +-
17 bin/ebuild-helpers/bsd/sed | 3 +-
18 bin/ebuild-helpers/dobin | 6 +-
19 bin/ebuild-helpers/dodir | 4 +-
20 bin/ebuild-helpers/dodoc | 4 +-
21 bin/ebuild-helpers/doexe | 17 +-
22 bin/ebuild-helpers/dohard | 4 +-
23 bin/ebuild-helpers/dohtml | 10 +-
24 bin/ebuild-helpers/doinfo | 6 +-
25 bin/ebuild-helpers/doins | 4 +-
26 bin/ebuild-helpers/dolib | 10 +-
27 bin/ebuild-helpers/doman | 10 +-
28 bin/ebuild-helpers/domo | 8 +-
29 bin/ebuild-helpers/dosbin | 4 +-
30 bin/ebuild-helpers/dosed | 8 +-
31 bin/ebuild-helpers/dosym | 14 +-
32 bin/ebuild-helpers/fowners | 6 +-
33 bin/ebuild-helpers/fperms | 6 +-
34 bin/ebuild-helpers/newins | 14 +-
35 bin/ebuild-helpers/portageq | 1 +
36 bin/ebuild-helpers/prepallstrip | 2 +-
37 bin/ebuild-helpers/prepinfo | 3 +-
38 bin/ebuild-helpers/prepstrip | 2 +-
39 bin/ebuild-helpers/unprivileged/chown | 3 +-
40 bin/ebuild-helpers/xattr/install | 2 +-
41 bin/ebuild.sh | 178 ++++++++--------
42 bin/ecompress | 13 +-
43 bin/ecompress-file | 15 +-
44 bin/egencache | 8 +-
45 bin/emerge-webrsync | 31 ++-
46 bin/estrip | 41 ++--
47 bin/etc-update | 27 ++-
48 bin/install-qa-check.d/05prefix | 8 +-
49 bin/install-qa-check.d/10executable-issues | 2 +-
50 bin/install-qa-check.d/20deprecated-directories | 6 +-
51 bin/install-qa-check.d/60udev | 5 +-
52 bin/install-qa-check.d/80libraries | 2 +-
53 bin/install-qa-check.d/90bad-bin-owner | 2 +-
54 bin/install-qa-check.d/90gcc-warnings | 10 +-
55 bin/install-qa-check.d/90world-writable | 10 +-
56 bin/isolated-functions.sh | 51 ++---
57 bin/misc-functions.sh | 99 +++++----
58 bin/phase-functions.sh | 267 +++++++++++++-----------
59 bin/phase-helpers.sh | 160 ++++++++------
60 bin/portageq | 4 +-
61 bin/postinst-qa-check.d/50xdg-utils | 21 +-
62 bin/save-ebuild-env.sh | 8 +-
63 51 files changed, 635 insertions(+), 522 deletions(-)
64
65 diff --git a/bin/bashrc-functions.sh b/bin/bashrc-functions.sh
66 index a45587b28..7d6aab544 100644
67 --- a/bin/bashrc-functions.sh
68 +++ b/bin/bashrc-functions.sh
69 @@ -5,22 +5,22 @@
70 register_die_hook() {
71 local x
72 for x in $* ; do
73 - has $x $EBUILD_DEATH_HOOKS || \
74 - export EBUILD_DEATH_HOOKS="$EBUILD_DEATH_HOOKS $x"
75 + has ${x} ${EBUILD_DEATH_HOOKS} || \
76 + export EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} ${x}"
77 done
78 }
79
80 register_success_hook() {
81 local x
82 for x in $* ; do
83 - has $x $EBUILD_SUCCESS_HOOKS || \
84 - export EBUILD_SUCCESS_HOOKS="$EBUILD_SUCCESS_HOOKS $x"
85 + has ${x} ${EBUILD_SUCCESS_HOOKS} || \
86 + export EBUILD_SUCCESS_HOOKS="${EBUILD_SUCCESS_HOOKS} ${x}"
87 done
88 }
89
90 __strip_duplicate_slashes() {
91 - if [[ -n $1 ]] ; then
92 - local removed=$1
93 + if [[ -n ${1} ]] ; then
94 + local removed=${1}
95 while [[ ${removed} == *//* ]] ; do
96 removed=${removed//\/\///}
97 done
98 @@ -29,14 +29,14 @@ __strip_duplicate_slashes() {
99 }
100
101 KV_major() {
102 - [[ -z $1 ]] && return 1
103 + [[ -z ${1} ]] && return 1
104
105 local KV=$@
106 echo "${KV%%.*}"
107 }
108
109 KV_minor() {
110 - [[ -z $1 ]] && return 1
111 + [[ -z ${1} ]] && return 1
112
113 local KV=$@
114 KV=${KV#*.}
115 @@ -44,7 +44,7 @@ KV_minor() {
116 }
117
118 KV_micro() {
119 - [[ -z $1 ]] && return 1
120 + [[ -z ${1} ]] && return 1
121
122 local KV=$@
123 KV=${KV#*.*.}
124
125 diff --git a/bin/binhost-snapshot b/bin/binhost-snapshot
126 index 4022cb32c..2076f2e53 100755
127 --- a/bin/binhost-snapshot
128 +++ b/bin/binhost-snapshot
129 @@ -44,7 +44,7 @@ def parse_args(argv):
130
131 usage += "\n"
132 usage += "Required Arguments:\n\n"
133 - usage += " src_pkg_dir - the source $PKGDIR\n"
134 + usage += " src_pkg_dir - the source ${PKGDIR}\n"
135 usage += " snapshot_dir - destination snapshot " + "directory (must not exist)\n"
136 usage += (
137 " snapshot_uri - URI which refers to "
138
139 diff --git a/bin/chpathtool.py b/bin/chpathtool.py
140 index d658e5012..de47b097f 100755
141 --- a/bin/chpathtool.py
142 +++ b/bin/chpathtool.py
143 @@ -4,7 +4,7 @@
144
145 doc = """Helper tool for converting installed files to custom prefixes.
146
147 -In other words, eprefixy $D for Gentoo/Prefix."""
148 +In other words, eprefixy ${D} for Gentoo/Prefix."""
149 __doc__ = doc
150
151 import argparse
152 @@ -146,9 +146,11 @@ def chpath_inplace_symlink(filename, st, old, new):
153 def main(argv):
154
155 parser = argparse.ArgumentParser(description=doc)
156 - parser.add_argument("location", default=None, help="root directory (e.g. $D)")
157 + parser.add_argument("location", default=None, help="root directory (e.g. ${D})")
158 parser.add_argument("old", default=None, help="original build prefix (e.g. /)")
159 - parser.add_argument("new", default=None, help="new install prefix (e.g. $EPREFIX)")
160 + parser.add_argument(
161 + "new", default=None, help="new install prefix (e.g. ${EPREFIX})"
162 + )
163 opts = parser.parse_args(argv)
164
165 location, old, new = opts.location, opts.old, opts.new
166
167 diff --git a/bin/doins.py b/bin/doins.py
168 index 7905c5c0d..77f9fe021 100644
169 --- a/bin/doins.py
170 +++ b/bin/doins.py
171 @@ -412,11 +412,11 @@ def _doins(opts, install_runner, relpath, source_root):
172 source = os.path.join(source_root, relpath)
173 dest = os.path.join(opts.dest, relpath)
174 if os.path.islink(source):
175 - # Our fake $DISTDIR contains symlinks that should not be
176 - # reproduced inside $D. In order to ensure that things like
177 - # dodoc "$DISTDIR"/foo.pdf work as expected, we dereference
178 + # Our fake ${DISTDIR} contains symlinks that should not be
179 + # reproduced inside ${D}. In order to ensure that things like
180 + # dodoc "${DISTDIR}"/foo.pdf work as expected, we dereference
181 # symlinked files that refer to absolute paths inside
182 - # $PORTAGE_ACTUAL_DISTDIR/.
183 + # ${PORTAGE_ACTUAL_DISTDIR}/.
184 try:
185 if opts.preserve_symlinks and not os.readlink(source).startswith(
186 opts.distdir
187
188 diff --git a/bin/ebuild b/bin/ebuild
189 index 546ab9d1c..ff2b4fe92 100755
190 --- a/bin/ebuild
191 +++ b/bin/ebuild
192 @@ -278,7 +278,7 @@ build_dir_phases = set(
193 )
194
195 # If the current metadata is invalid then force the ebuild to be
196 -# sourced again even if $T/environment already exists.
197 +# sourced again even if ${T}/environment already exists.
198 ebuild_changed = False
199 if mytree == "porttree" and build_dir_phases.intersection(pargs):
200 ebuild_changed = (
201
202 diff --git a/bin/ebuild-helpers/bsd/sed b/bin/ebuild-helpers/bsd/sed
203 index 2d7b844da..f19460b90 100755
204 --- a/bin/ebuild-helpers/bsd/sed
205 +++ b/bin/ebuild-helpers/bsd/sed
206 @@ -13,10 +13,11 @@ else
207 old_IFS="${IFS}"
208 IFS=":"
209
210 - for path in $PATH; do
211 + for path in ${PATH}; do
212 if [[ -x ${path}/${scriptname} ]]; then
213 [[ ${path} == */portage/*/ebuild-helpers* ]] && continue
214 [[ ${path}/${scriptname} -ef ${scriptpath} ]] && continue
215 +
216 exec "${path}/${scriptname}" "$@"
217 exit 0
218 fi
219
220 diff --git a/bin/ebuild-helpers/dobin b/bin/ebuild-helpers/dobin
221 index 8abcc713c..14faab9bf 100755
222 --- a/bin/ebuild-helpers/dobin
223 +++ b/bin/ebuild-helpers/dobin
224 @@ -15,7 +15,7 @@ fi
225
226 if ! ___eapi_has_DESTTREE_INSDESTTREE; then
227 [[ -n ${DESTTREE} ]] &&
228 - die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
229 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
230 else
231 # backwards compatibility
232 _E_DESTTREE_=${DESTTREE}
233 @@ -31,11 +31,11 @@ for x in "$@" ; do
234 if [[ -e ${x} ]] ; then
235 install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${ED%/}/${_E_DESTTREE_#/}/bin"
236 else
237 - echo "!!! ${0##*/}: $x does not exist" 1>&2
238 + echo "!!! ${0##*/}: ${x} does not exist" 1>&2
239 false
240 fi
241 ((ret|=$?))
242 done
243
244 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
245 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
246 exit ${ret}
247
248 diff --git a/bin/ebuild-helpers/dodir b/bin/ebuild-helpers/dodir
249 index 4fb113819..727f62a99 100755
250 --- a/bin/ebuild-helpers/dodir
251 +++ b/bin/ebuild-helpers/dodir
252 @@ -10,5 +10,5 @@ fi
253
254 install -d ${DIROPTIONS} "${@/#/${ED%/}/}"
255 ret=$?
256 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
257 -exit $ret
258 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
259 +exit ${ret}
260
261 diff --git a/bin/ebuild-helpers/dodoc b/bin/ebuild-helpers/dodoc
262 index af3764b7e..28e58ae0c 100755
263 --- a/bin/ebuild-helpers/dodoc
264 +++ b/bin/ebuild-helpers/dodoc
265 @@ -29,10 +29,10 @@ for x in "$@" ; do
266 elif [ -s "${x}" ] ; then
267 install -m0644 "${x}" "${dir}" || { ((ret|=1)); continue; }
268 elif [ ! -e "${x}" ] ; then
269 - echo "!!! ${0##*/}: $x does not exist" 1>&2
270 + echo "!!! ${0##*/}: ${x} does not exist" 1>&2
271 ((ret|=1))
272 fi
273 done
274
275 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
276 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
277 exit ${ret}
278
279 diff --git a/bin/ebuild-helpers/doexe b/bin/ebuild-helpers/doexe
280 index 154f5daca..9132fb592 100755
281 --- a/bin/ebuild-helpers/doexe
282 +++ b/bin/ebuild-helpers/doexe
283 @@ -23,24 +23,25 @@ ret=0
284
285 for x in "$@" ; do
286 if [ -L "${x}" ] ; then
287 - cp "$x" "$TMP"
288 - mysrc=$TMP/${x##*/}
289 + cp "${x}" "${TMP}"
290 + mysrc=${TMP}/${x##*/}
291 elif [ -d "${x}" ] ; then
292 __vecho "doexe: warning, skipping directory ${x}"
293 continue
294 else
295 mysrc="${x}"
296 fi
297 - if [ -e "$mysrc" ] ; then
298 - install ${EXEOPTIONS} "$mysrc" "${ED%/}/${_E_EXEDESTTREE_#/}"
299 +
300 + if [ -e "${mysrc}" ] ; then
301 + install ${EXEOPTIONS} "${mysrc}" "${ED%/}/${_E_EXEDESTTREE_#/}"
302 else
303 - echo "!!! ${0##*/}: $mysrc does not exist" 1>&2
304 + echo "!!! ${0##*/}: ${mysrc} does not exist" 1>&2
305 false
306 fi
307 ((ret|=$?))
308 done
309
310 -rm -rf "$TMP"
311 +rm -rf "${TMP}"
312
313 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
314 -exit $ret
315 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
316 +exit ${ret}
317
318 diff --git a/bin/ebuild-helpers/dohard b/bin/ebuild-helpers/dohard
319 index 4ee1ba258..326752b4f 100755
320 --- a/bin/ebuild-helpers/dohard
321 +++ b/bin/ebuild-helpers/dohard
322 @@ -5,12 +5,12 @@
323 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
324
325 if ! ___eapi_has_dohard; then
326 - die "'${0##*/}' has been banned for EAPI '$EAPI'"
327 + die "'${0##*/}' has been banned for EAPI '${EAPI}'"
328 exit 1
329 fi
330
331 if [[ $# -ne 2 ]] ; then
332 - echo "$0: two arguments needed" 1>&2
333 + echo "${0}: two arguments needed" 1>&2
334 exit 1
335 fi
336
337
338 diff --git a/bin/ebuild-helpers/dohtml b/bin/ebuild-helpers/dohtml
339 index b6373a36c..55339238e 100755
340 --- a/bin/ebuild-helpers/dohtml
341 +++ b/bin/ebuild-helpers/dohtml
342 @@ -5,22 +5,22 @@
343 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
344
345 if ! ___eapi_has_dohtml; then
346 - die "'${0##*/}' has been banned for EAPI '$EAPI'"
347 + die "'${0##*/}' has been banned for EAPI '${EAPI}'"
348 exit 1
349 fi
350
351 if ___eapi_has_dohtml_deprecated; then
352 - eqawarn "'${0##*/}' is deprecated in EAPI '$EAPI'"
353 + eqawarn "'${0##*/}' is deprecated in EAPI '${EAPI}'"
354 fi
355
356 # Use safe cwd, avoiding unsafe import for bug #469338.
357 export __PORTAGE_HELPER_CWD=${PWD}
358 cd "${PORTAGE_PYM_PATH}" || die
359 PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
360 - "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/dohtml.py" "$@"
361 + "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/dohtml.py" "$@"
362
363 ret=$?
364 # Restore cwd for display by __helpers_die
365 cd "${__PORTAGE_HELPER_CWD}"
366 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
367 -exit $ret
368 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
369 +exit ${ret}
370
371 diff --git a/bin/ebuild-helpers/doinfo b/bin/ebuild-helpers/doinfo
372 index cf4d42b1a..69de67026 100755
373 --- a/bin/ebuild-helpers/doinfo
374 +++ b/bin/ebuild-helpers/doinfo
375 @@ -19,10 +19,10 @@ fi
376
377 install -m0644 "$@" "${ED%/}/usr/share/info"
378 rval=$?
379 -if [ $rval -ne 0 ] ; then
380 +if [ ${rval} -ne 0 ] ; then
381 for x in "$@" ; do
382 - [ -e "$x" ] || echo "!!! ${0##*/}: $x does not exist" 1>&2
383 + [ -e "${x}" ] || echo "!!! ${0##*/}: ${x} does not exist" 1>&2
384 done
385 __helpers_die "${0##*/} failed"
386 fi
387 -exit $rval
388 +exit ${rval}
389
390 diff --git a/bin/ebuild-helpers/doins b/bin/ebuild-helpers/doins
391 index a5fc224a9..c90eccc90 100755
392 --- a/bin/ebuild-helpers/doins
393 +++ b/bin/ebuild-helpers/doins
394 @@ -20,7 +20,7 @@ if [[ ${helper} == dodoc ]] ; then
395 else
396 if ! ___eapi_has_DESTTREE_INSDESTTREE; then
397 [[ -n ${INSDESTTREE} ]] &&
398 - die "${0##*/}: \${INSDESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
399 + die "${0##*/}: \${INSDESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
400 else
401 # backwards compatibility
402 _E_INSDESTTREE_=${INSDESTTREE}
403 @@ -33,7 +33,7 @@ if [ $# -lt 1 ] ; then
404 fi
405
406 DOINS_ARGS=()
407 -if [[ "$1" == "-r" ]] ; then
408 +if [[ "${1}" == "-r" ]] ; then
409 DOINS_ARGS+=( --recursive )
410 shift
411 fi
412
413 diff --git a/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib
414 index c31442a8e..ca57199be 100755
415 --- a/bin/ebuild-helpers/dolib
416 +++ b/bin/ebuild-helpers/dolib
417 @@ -5,7 +5,7 @@
418 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
419
420 if [[ -z ${PORTAGE_INTERNAL_DOLIB} ]] && ! ___eapi_has_dolib_libopts; then
421 - die "'${0##*/}' has been banned for EAPI '$EAPI'"
422 + die "'${0##*/}' has been banned for EAPI '${EAPI}'"
423 exit 1
424 fi
425
426 @@ -15,7 +15,7 @@ fi
427
428 if ! ___eapi_has_DESTTREE_INSDESTTREE; then
429 [[ -n ${DESTTREE} ]] &&
430 - die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
431 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
432 else
433 # backwards compatibility
434 _E_DESTTREE_=${DESTTREE}
435 @@ -27,11 +27,11 @@ if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
436 CONF_LIBDIR=${!LIBDIR_VAR}
437 fi
438 unset LIBDIR_VAR
439 -# we need this to default to lib so that things dont break
440 +
441 +# We need this to default to lib so that things dont break
442 CONF_LIBDIR=${CONF_LIBDIR:-lib}
443 libdir="${ED%/}/${_E_DESTTREE_#/}/${CONF_LIBDIR}"
444
445 -
446 if [[ $# -lt 1 ]] ; then
447 __helpers_die "${0##*/}: at least one argument needed"
448 exit 1
449 @@ -56,5 +56,5 @@ for x in "$@" ; do
450 ((ret|=$?))
451 done
452
453 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
454 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
455 exit ${ret}
456
457 diff --git a/bin/ebuild-helpers/doman b/bin/ebuild-helpers/doman
458 index c2418ce40..67945f48b 100755
459 --- a/bin/ebuild-helpers/doman
460 +++ b/bin/ebuild-helpers/doman
461 @@ -22,6 +22,7 @@ for x in "$@" ; do
462 i18n=${x:6}/
463 continue
464 fi
465 +
466 if [[ ${x:0:6} == ".keep_" ]] ; then
467 continue
468 fi
469 @@ -35,9 +36,8 @@ for x in "$@" ; do
470 suffix=${realname##*.}
471 fi
472
473 - if has "${EAPI:-0}" 2 3 || [[ -z ${i18n} ]] \
474 - && ! has "${EAPI:-0}" 0 1 \
475 - && [[ $x =~ (.*)\.([a-z][a-z](_[A-Z][A-Z])?)\.(.*) ]]
476 + if has "${EAPI:-0}" 2 3 || [[ -z ${i18n} ]] && ! has "${EAPI:-0}" 0 1 \
477 + && [[ ${x} =~ (.*)\.([a-z][a-z](_[A-Z][A-Z])?)\.(.*) ]]
478 then
479 name=${BASH_REMATCH[1]##*/}.${BASH_REMATCH[4]}
480 mandir=${BASH_REMATCH[2]}/man${suffix:0:1}
481 @@ -56,7 +56,7 @@ for x in "$@" ; do
482 install -m0644 "${x}" "${ED%/}/usr/share/man/${mandir}/${name}"
483 ((ret|=$?))
484 elif [[ ! -e ${x} ]] ; then
485 - echo "!!! ${0##*/}: $x does not exist" 1>&2
486 + echo "!!! ${0##*/}: ${x} does not exist" 1>&2
487 ((ret|=1))
488 fi
489 else
490 @@ -65,5 +65,5 @@ for x in "$@" ; do
491 fi
492 done
493
494 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
495 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
496 exit ${ret}
497
498 diff --git a/bin/ebuild-helpers/domo b/bin/ebuild-helpers/domo
499 index 474bb7e1d..d864bed29 100755
500 --- a/bin/ebuild-helpers/domo
501 +++ b/bin/ebuild-helpers/domo
502 @@ -16,7 +16,7 @@ fi
503
504 if ! ___eapi_has_DESTTREE_INSDESTTREE; then
505 [[ -n ${DESTTREE} ]] &&
506 - die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
507 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
508 else
509 # backwards compatibility
510 _E_DESTTREE_=${DESTTREE}
511 @@ -42,11 +42,11 @@ for x in "$@" ; do
512 fi
513 install -m0644 "${x}" "${mydir}/${MOPREFIX}.mo"
514 else
515 - echo "!!! ${0##*/}: $x does not exist" 1>&2
516 + echo "!!! ${0##*/}: ${x} does not exist" 1>&2
517 false
518 fi
519 ((ret|=$?))
520 done
521
522 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
523 -exit $ret
524 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
525 +exit ${ret}
526
527 diff --git a/bin/ebuild-helpers/dosbin b/bin/ebuild-helpers/dosbin
528 index 1ff253bb1..4d2c8540b 100755
529 --- a/bin/ebuild-helpers/dosbin
530 +++ b/bin/ebuild-helpers/dosbin
531 @@ -15,7 +15,7 @@ fi
532
533 if ! ___eapi_has_DESTTREE_INSDESTTREE; then
534 [[ -n ${DESTTREE} ]] &&
535 - die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
536 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
537 else
538 # backwards compatibility
539 _E_DESTTREE_=${DESTTREE}
540 @@ -37,5 +37,5 @@ for x in "$@" ; do
541 ((ret|=$?))
542 done
543
544 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
545 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
546 exit ${ret}
547
548 diff --git a/bin/ebuild-helpers/dosed b/bin/ebuild-helpers/dosed
549 index d3c249352..748ab414a 100755
550 --- a/bin/ebuild-helpers/dosed
551 +++ b/bin/ebuild-helpers/dosed
552 @@ -5,7 +5,7 @@
553 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
554
555 if ! ___eapi_has_dosed; then
556 - die "'${0##*/}' has been banned for EAPI '$EAPI'"
557 + die "'${0##*/}' has been banned for EAPI '${EAPI}'"
558 exit 1
559 fi
560
561 @@ -38,9 +38,9 @@ for x in "$@" ; do
562 fi
563 done
564
565 -if [ $file_found = 0 ] ; then
566 - echo "!!! ${0##*/}: $y does not exist" 1>&2
567 +if [ ${file_found} = 0 ] ; then
568 + echo "!!! ${0##*/}: ${y} does not exist" 1>&2
569 ((ret|=1))
570 fi
571
572 -exit $ret
573 +exit ${ret}
574
575 diff --git a/bin/ebuild-helpers/dosym b/bin/ebuild-helpers/dosym
576 index 69a4a1ebe..e41558a15 100755
577 --- a/bin/ebuild-helpers/dosym
578 +++ b/bin/ebuild-helpers/dosym
579 @@ -5,7 +5,7 @@
580 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
581
582 option_r=
583 -if ___eapi_has_dosym_r && [[ $1 == -r ]]; then
584 +if ___eapi_has_dosym_r && [[ ${1} == -r ]]; then
585 option_r=t
586 shift
587 fi
588 @@ -24,7 +24,7 @@ if [[ ${2} == */ ]] || [[ -d ${ED%/}/${2#/} && ! -L ${ED%/}/${2#/} ]] ; then
589 __helpers_die "${0##*/}: dosym target omits basename: '${2}'"
590 fi
591
592 -target=$1
593 +target=${1}
594
595 if [[ ${option_r} ]]; then
596 # Transparent bash-only replacement for GNU "realpath -m -s".
597 @@ -33,8 +33,8 @@ if [[ ${option_r} ]]; then
598 dosym_canonicalize() {
599 local path slash i prev out IFS=/
600
601 - path=( $1 )
602 - [[ $1 == /* ]] && slash=/
603 + path=( ${1} )
604 + [[ ${1} == /* ]] && slash=/
605
606 while true; do
607 # Find first instance of non-".." path component followed by "..",
608 @@ -87,6 +87,6 @@ destdir=${2%/*}
609 [[ ! -d ${ED%/}/${destdir#/} ]] && dodir "${destdir}"
610 ln -snf "${target}" "${ED%/}/${2#/}"
611
612 -ret=$?
613 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
614 -exit $ret
615 +ret=${?}
616 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
617 +exit ${ret}
618
619 diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners
620 index c6ed36ed3..d245062e7 100755
621 --- a/bin/ebuild-helpers/fowners
622 +++ b/bin/ebuild-helpers/fowners
623 @@ -11,10 +11,12 @@ fi
624 got_owner=
625 for arg; do
626 [[ ${arg} == -* ]] && continue
627 +
628 if [[ ! ${got_owner} ]]; then
629 got_owner=1
630 continue
631 fi
632 +
633 if [[ ${arg} != /* ]]; then
634 eqawarn "Relative path passed to '${0##*/}': ${arg}"
635 eqawarn "This is unsupported. Please use 'chown' when you need to work on files"
636 @@ -29,5 +31,5 @@ slash="/"
637 chown "${@/#${slash}/${ED%/}${slash}}"
638 ret=$?
639
640 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
641 -exit $ret
642 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
643 +exit ${ret}
644
645 diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms
646 index 9620cc06a..9e5da5d16 100755
647 --- a/bin/ebuild-helpers/fperms
648 +++ b/bin/ebuild-helpers/fperms
649 @@ -12,10 +12,12 @@ got_mode=
650 for arg; do
651 # - can either be an option or a mode string
652 [[ ${arg} == -* && ${arg} != -[ugorwxXst] ]] && continue
653 +
654 if [[ ! ${got_mode} ]]; then
655 got_mode=1
656 continue
657 fi
658 +
659 if [[ ${arg} != /* ]]; then
660 eqawarn "Relative path passed to '${0##*/}': ${arg}"
661 eqawarn "This is unsupported. Please use 'chmod' when you need to work on files"
662 @@ -28,5 +30,5 @@ done
663 slash="/"
664 chmod "${@/#${slash}/${ED%/}${slash}}"
665 ret=$?
666 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
667 -exit $ret
668 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
669 +exit ${ret}
670
671 diff --git a/bin/ebuild-helpers/newins b/bin/ebuild-helpers/newins
672 index d05d688ac..02186a6b3 100755
673 --- a/bin/ebuild-helpers/newins
674 +++ b/bin/ebuild-helpers/newins
675 @@ -15,7 +15,7 @@ fi
676 eqawarn "QA Notice: ${helper} called with more than 2 arguments: ${*:3}"
677
678 stdin=
679 -if ___eapi_newins_supports_reading_from_standard_input && [[ $1 == "-" ]]; then
680 +if ___eapi_newins_supports_reading_from_standard_input && [[ ${1} == "-" ]]; then
681 stdin=yes
682 fi
683
684 @@ -27,11 +27,11 @@ if [[ ${stdin} ]] ; then
685 __helpers_die "!!! ${helper}: Input is from a terminal"
686 exit 1
687 fi
688 - cat > "${TMP}/$2"
689 + cat > "${TMP}/${2}"
690 ret=$?
691 else
692 if [[ ! -e $1 ]] ; then
693 - __helpers_die "!!! ${helper}: $1 does not exist"
694 + __helpers_die "!!! ${helper}: ${1} does not exist"
695 exit 1
696 fi
697
698 @@ -42,7 +42,7 @@ else
699 fi
700 fi
701
702 - cp ${cp_args} "$1" "${TMP}/$2"
703 + cp ${cp_args} "${1}" "${TMP}/$2"
704 ret=$?
705 fi
706
707 @@ -51,7 +51,7 @@ if [[ ${ret} -ne 0 ]] ; then
708 exit ${ret}
709 fi
710
711 -do${helper#new} "${TMP}/$2"
712 +do${helper#new} "${TMP}/${2}"
713 ret=$?
714 -[[ $ret -ne 0 ]] && __helpers_die "${helper} failed"
715 -exit $ret
716 +[[ ${ret} -ne 0 ]] && __helpers_die "${helper} failed"
717 +exit ${ret}
718
719 diff --git a/bin/ebuild-helpers/portageq b/bin/ebuild-helpers/portageq
720 index 199804f7b..7d14f54c2 100755
721 --- a/bin/ebuild-helpers/portageq
722 +++ b/bin/ebuild-helpers/portageq
723 @@ -15,6 +15,7 @@ for path in ${PATH}; do
724 [[ -x ${path}/${scriptname} ]] || continue
725 [[ ${path} == */portage/*/ebuild-helpers* ]] && continue
726 [[ ${path}/${scriptname} -ef ${scriptpath} ]] && continue
727 +
728 PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
729 exec "${PORTAGE_PYTHON:-/usr/bin/python}" \
730 "${path}/${scriptname}" "$@"
731
732 diff --git a/bin/ebuild-helpers/prepallstrip b/bin/ebuild-helpers/prepallstrip
733 index 2bf567634..2f9c0f70e 100755
734 --- a/bin/ebuild-helpers/prepallstrip
735 +++ b/bin/ebuild-helpers/prepallstrip
736 @@ -5,7 +5,7 @@
737 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
738
739 if ___eapi_has_dostrip; then
740 - die "${0##*/}: ${0##*/} has been banned for EAPI '$EAPI'; use 'dostrip' instead"
741 + die "${0##*/}: ${0##*/} has been banned for EAPI '${EAPI}'; use 'dostrip' instead"
742 fi
743
744 if ! ___eapi_has_prefix_variables; then
745
746 diff --git a/bin/ebuild-helpers/prepinfo b/bin/ebuild-helpers/prepinfo
747 index e771c97aa..9e509e8ca 100755
748 --- a/bin/ebuild-helpers/prepinfo
749 +++ b/bin/ebuild-helpers/prepinfo
750 @@ -8,7 +8,7 @@ if ! ___eapi_has_prefix_variables; then
751 ED=${D}
752 fi
753
754 -if [[ -z $1 ]] ; then
755 +if [[ -z ${1} ]] ; then
756 infodir="/usr/share/info"
757 else
758 if [[ -d ${ED%/}/${1#/}/share/info ]] ; then
759 @@ -31,6 +31,7 @@ find "${ED%/}/${infodir#/}" -type d -print0 | while read -r -d $'\0' x ; do
760 for f in "${x}"/.keepinfodir*; do
761 [[ -e ${f} ]] && continue 2
762 done
763 +
764 rm -f "${x}"/dir{,.info}{,.gz,.bz2}
765 done
766
767
768 diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip
769 index 9b523517c..789296050 100755
770 --- a/bin/ebuild-helpers/prepstrip
771 +++ b/bin/ebuild-helpers/prepstrip
772 @@ -5,7 +5,7 @@
773 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
774
775 if ___eapi_has_dostrip; then
776 - die "${0##*/}: ${0##*/} has been banned for EAPI '$EAPI'; use 'dostrip' instead"
777 + die "${0##*/}: ${0##*/} has been banned for EAPI '${EAPI}'; use 'dostrip' instead"
778 fi
779
780 __PORTAGE_HELPER=prepstrip exec "${PORTAGE_BIN_PATH}"/estrip "${@}"
781
782 diff --git a/bin/ebuild-helpers/unprivileged/chown b/bin/ebuild-helpers/unprivileged/chown
783 index 572664324..0788a8b15 100755
784 --- a/bin/ebuild-helpers/unprivileged/chown
785 +++ b/bin/ebuild-helpers/unprivileged/chown
786 @@ -13,10 +13,10 @@ for path in ${PATH}; do
787 [[ -x ${path}/${scriptname} ]] || continue
788 [[ ${path} == */portage/*/ebuild-helpers* ]] && continue
789 [[ ${path}/${scriptname} -ef ${scriptpath} ]] && continue
790 +
791 IFS=$' \t\n'
792 output=$("${path}/${scriptname}" "$@" 2>&1)
793 if [[ $? -ne 0 ]] ; then
794 -
795 # Avoid an extreme performance problem when the
796 # output is very long (bug #470992).
797 if [[ $(wc -l <<< "${output}") -gt 100 ]]; then
798 @@ -27,6 +27,7 @@ for path in ${PATH}; do
799 if ! ___eapi_has_prefix_variables; then
800 EPREFIX=
801 fi
802 +
803 msg="${scriptname} failure ignored with unprivileged user:\n ${scriptname} $*\n ${output}"
804 # Reverse expansion of ${D} and ${EPREFIX}, for readability.
805 msg=${msg//${D}/'${D}'}
806
807 diff --git a/bin/ebuild-helpers/xattr/install b/bin/ebuild-helpers/xattr/install
808 index ebc68645e..52ecf5a53 100755
809 --- a/bin/ebuild-helpers/xattr/install
810 +++ b/bin/ebuild-helpers/xattr/install
811 @@ -23,7 +23,7 @@ else
812 fi
813
814 # Filter internal portage paths from PATH, in order to avoid
815 -# a possible exec loop or fork bomb (see bug 547086).
816 +# a possible exec loop or fork bomb (see bug #547086).
817 IFS=':'
818 set -f
819 path=
820
821 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
822 index 6bb5d45b7..417bca78a 100755
823 --- a/bin/ebuild.sh
824 +++ b/bin/ebuild.sh
825 @@ -53,7 +53,7 @@ __check_bash_version() {
826 }
827 __check_bash_version
828
829 -if [[ $EBUILD_PHASE != depend ]] ; then
830 +if [[ ${EBUILD_PHASE} != depend ]] ; then
831 source "${PORTAGE_BIN_PATH}/phase-functions.sh" || die
832 source "${PORTAGE_BIN_PATH}/save-ebuild-env.sh" || die
833 source "${PORTAGE_BIN_PATH}/phase-helpers.sh" || die
834 @@ -104,29 +104,29 @@ export PORTAGE_BZIP2_COMMAND=${PORTAGE_BZIP2_COMMAND:-bzip2}
835 # when they are done.
836
837 __qa_source() {
838 - local shopts=$(shopt) OLDIFS="$IFS"
839 + local shopts=$(shopt) OLDIFS="${IFS}"
840 local retval
841 source "$@"
842 retval=$?
843 set +e
844 - [[ $shopts != $(shopt) ]] &&
845 + [[ ${shopts} != $(shopt) ]] &&
846 eqawarn "QA Notice: Global shell options changed and were not restored while sourcing '$*'"
847 - [[ "$IFS" != "$OLDIFS" ]] &&
848 + [[ "${IFS}" != "${OLDIFS}" ]] &&
849 eqawarn "QA Notice: Global IFS changed and was not restored while sourcing '$*'"
850 - return $retval
851 + return ${retval}
852 }
853
854 __qa_call() {
855 - local shopts=$(shopt) OLDIFS="$IFS"
856 + local shopts=$(shopt) OLDIFS="${IFS}"
857 local retval
858 "$@"
859 retval=$?
860 set +e
861 - [[ $shopts != $(shopt) ]] &&
862 + [[ ${shopts} != $(shopt) ]] &&
863 eqawarn "QA Notice: Global shell options changed and were not restored while calling '$*'"
864 - [[ "$IFS" != "$OLDIFS" ]] &&
865 + [[ "${IFS}" != "${OLDIFS}" ]] &&
866 eqawarn "QA Notice: Global IFS changed and was not restored while calling '$*'"
867 - return $retval
868 + return ${retval}
869 }
870
871 EBUILD_SH_ARGS="$*"
872 @@ -142,7 +142,7 @@ if ___eapi_has_ENV_UNSET; then
873 unset x
874 fi
875
876 -[[ $PORTAGE_QUIET != "" ]] && export PORTAGE_QUIET
877 +[[ ${PORTAGE_QUIET} != "" ]] && export PORTAGE_QUIET
878
879 # sandbox support functions; defined prior to profile.bashrc srcing, since the profile might need to add a default exception (e.g. /usr/lib64/conftest)
880 __sb_append_var() {
881 @@ -164,11 +164,11 @@ addread "/:${PORTAGE_TMPDIR}/portage"
882 [[ -n ${PORTAGE_GPG_DIR} ]] && addpredict "${PORTAGE_GPG_DIR}"
883
884 # Avoid sandbox violations in temporary directories.
885 -if [[ -w $T ]] ; then
886 - export TEMP=$T
887 - export TMP=$T
888 - export TMPDIR=$T
889 -elif [[ $SANDBOX_ON = 1 ]] ; then
890 +if [[ -w ${T} ]] ; then
891 + export TEMP=${T}
892 + export TMP=${T}
893 + export TMPDIR=${T}
894 +elif [[ ${SANDBOX_ON} = 1 ]] ; then
895 for x in TEMP TMP TMPDIR ; do
896 [[ -n ${!x} ]] && addwrite "${!x}"
897 done
898 @@ -178,7 +178,7 @@ fi
899 # The sandbox is disabled by default except when overridden in the relevant stages
900 export SANDBOX_ON=0
901
902 -# Ensure that $PWD is sane whenever possible, to protect against
903 +# Ensure that ${PWD} is sane whenever possible, to protect against
904 # exploitation of insecure search path for python -c in ebuilds.
905 # See bug #239560, bug #469338, and bug #595028.
906 # EAPI 8 requires us to use an empty directory here.
907 @@ -196,9 +196,9 @@ umask 022
908 # Sources all eclasses in parameters
909 declare -ix ECLASS_DEPTH=0
910 inherit() {
911 - ECLASS_DEPTH=$(($ECLASS_DEPTH + 1))
912 + ECLASS_DEPTH=$((${ECLASS_DEPTH} + 1))
913 if [[ ${ECLASS_DEPTH} -gt 1 ]]; then
914 - debug-print "*** Multiple Inheritence (Level: ${ECLASS_DEPTH})"
915 + debug-print "*** Multiple Inheritance (Level: ${ECLASS_DEPTH})"
916
917 # Since ECLASS_DEPTH > 1, the following variables are locals from the
918 # previous inherit call in the call stack.
919 @@ -224,13 +224,13 @@ inherit() {
920 local B_IDEPEND
921 local B_PROPERTIES
922 local B_RESTRICT
923 - while [[ "$1" ]]; do
924 + while [[ "${1}" ]]; do
925 location=""
926 potential_location=""
927
928 - ECLASS="$1"
929 - __export_funcs_var=__export_functions_$ECLASS_DEPTH
930 - unset $__export_funcs_var
931 + ECLASS="${1}"
932 + __export_funcs_var=__export_functions_${ECLASS_DEPTH}
933 + unset ${__export_funcs_var}
934
935 if [[ ${EBUILD_PHASE} != depend && ${EBUILD_PHASE} != nofetch && \
936 ${EBUILD_PHASE} != *rm && ${EMERGE_FROM} != "binary" && \
937 @@ -242,8 +242,8 @@ inherit() {
938 # disabled for nofetch, since that can be called by repoman and
939 # that triggers bug #407449 due to repoman not exporting
940 # non-essential variables such as INHERITED.
941 - if ! has $ECLASS $INHERITED $__INHERITED_QA_CACHE ; then
942 - eqawarn "QA Notice: ECLASS '$ECLASS' inherited illegally in $CATEGORY/$PF $EBUILD_PHASE"
943 + if ! has ${ECLASS} ${INHERITED} ${__INHERITED_QA_CACHE} ; then
944 + eqawarn "QA Notice: Eclass '${ECLASS}' inherited illegally in ${CATEGORY}/${PF} ${EBUILD_PHASE}"
945 fi
946 fi
947
948 @@ -255,7 +255,7 @@ inherit() {
949 break
950 fi
951 done
952 - debug-print "inherit: $1 -> $location"
953 + debug-print "inherit: ${1} -> ${location}"
954 [[ -z ${location} ]] && die "${1}.eclass could not be found by inherit()"
955
956 # Inherits in QA checks can't handle metadata assignments
957 @@ -287,11 +287,11 @@ inherit() {
958 unset RESTRICT
959 fi
960
961 - #turn on glob expansion
962 + # Turn on glob expansion
963 set +f
964 fi
965
966 - __qa_source "$location" || die "died sourcing $location in inherit()"
967 + __qa_source "${location}" || die "died sourcing ${location} in inherit()"
968
969 if [[ -z ${_IN_INSTALL_QA_CHECK} ]]; then
970 # Turn off glob expansion
971 @@ -350,15 +350,15 @@ inherit() {
972
973 if [[ -n ${!__export_funcs_var} ]] ; then
974 for x in ${!__export_funcs_var} ; do
975 - debug-print "EXPORT_FUNCTIONS: $x -> ${ECLASS}_$x"
976 - declare -F "${ECLASS}_$x" >/dev/null || \
977 - die "EXPORT_FUNCTIONS: ${ECLASS}_$x is not defined"
978 - eval "$x() { ${ECLASS}_$x \"\$@\" ; }" > /dev/null
979 + debug-print "EXPORT_FUNCTIONS: ${x} -> ${ECLASS}_${x}"
980 + declare -F "${ECLASS}_${x}" >/dev/null || \
981 + die "EXPORT_FUNCTIONS: ${ECLASS}_${x} is not defined"
982 + eval "$x() { ${ECLASS}_${x} \"\$@\" ; }" > /dev/null
983 done
984 fi
985 unset $__export_funcs_var
986
987 - has $1 $INHERITED || export INHERITED="$INHERITED $1"
988 + has $1 ${INHERITED} || export INHERITED="${INHERITED} $1"
989 if [[ ${ECLASS_DEPTH} -eq 1 ]]; then
990 export PORTAGE_EXPLICIT_INHERIT="${PORTAGE_EXPLICIT_INHERIT} $1"
991 fi
992 @@ -375,10 +375,10 @@ inherit() {
993 # code will be eval'd:
994 # src_unpack() { base_src_unpack; }
995 EXPORT_FUNCTIONS() {
996 - if [[ -z "$ECLASS" ]]; then
997 + if [[ -z "${ECLASS}" ]]; then
998 die "EXPORT_FUNCTIONS without a defined ECLASS"
999 fi
1000 - eval $__export_funcs_var+=\" $*\"
1001 + eval ${__export_funcs_var}+=\" $*\"
1002 }
1003
1004 PORTAGE_BASHRCS_SOURCED=0
1005 @@ -395,24 +395,25 @@ PORTAGE_BASHRCS_SOURCED=0
1006 # function for the current phase.
1007 #
1008 __source_all_bashrcs() {
1009 - [[ $PORTAGE_BASHRCS_SOURCED = 1 ]] && return 0
1010 + [[ ${PORTAGE_BASHRCS_SOURCED} = 1 ]] && return 0
1011 +
1012 PORTAGE_BASHRCS_SOURCED=1
1013 - local x
1014
1015 + local x
1016 local OCC="${CC}" OCXX="${CXX}"
1017
1018 - if [[ $EBUILD_PHASE != depend ]] ; then
1019 - # source the existing profile.bashrcs.
1020 + if [[ ${EBUILD_PHASE} != depend ]] ; then
1021 + # Source the existing profile.bashrcs.
1022 while read -r x; do
1023 __try_source "${x}"
1024 done <<<"${PORTAGE_BASHRC_FILES}"
1025 fi
1026
1027 - # The user's bashrc is the ONLY non-portage bit of code
1028 + # The user's bashrc is the ONLY non-Portage bit of code
1029 # that can change shopts without a QA violation.
1030 __try_source --no-qa "${PORTAGE_BASHRC}"
1031
1032 - if [[ $EBUILD_PHASE != depend ]] ; then
1033 + if [[ ${EBUILD_PHASE} != depend ]] ; then
1034 __source_env_files --no-qa "${PM_EBUILD_HOOK_DIR}"
1035 fi
1036
1037 @@ -428,10 +429,11 @@ __source_all_bashrcs() {
1038 # files.
1039 __source_env_files() {
1040 local argument=()
1041 - if [[ $1 == --no-qa ]]; then
1042 + if [[ ${1} == --no-qa ]]; then
1043 argument=( --no-qa )
1044 - shift
1045 + shift
1046 fi
1047 +
1048 for x in "${1}"/${CATEGORY}/{${PN},${PN}:${SLOT%/*},${P},${PF}}; do
1049 __try_source "${argument[@]}" "${x}"
1050 done
1051 @@ -445,25 +447,28 @@ __source_env_files() {
1052 # If --no-qa is specified, source the file with source instead of __qa_source.
1053 __try_source() {
1054 local qa=true
1055 - if [[ $1 == --no-qa ]]; then
1056 + if [[ ${1} == --no-qa ]]; then
1057 qa=false
1058 shift
1059 fi
1060 - if [[ -r $1 && -f $1 ]]; then
1061 +
1062 + if [[ -r ${1} && -f ${1} ]]; then
1063 local debug_on=false
1064 - if [[ "$PORTAGE_DEBUG" == "1" ]] && [[ "${-/x/}" == "$-" ]]; then
1065 +
1066 + if [[ "${PORTAGE_DEBUG}" == "1" ]] && [[ "${-/x/}" == "$-" ]]; then
1067 debug_on=true
1068 fi
1069 - $debug_on && set -x
1070 +
1071 + ${debug_on} && set -x
1072 # If $- contains x, then tracing has already been enabled
1073 - # elsewhere for some reason. We preserve it's state so as
1074 + # elsewhere for some reason. We preserve its state so as
1075 # not to interfere.
1076 if ! ${qa} ; then
1077 source "${1}"
1078 else
1079 __qa_source "${1}"
1080 fi
1081 - $debug_on && set +x
1082 + ${debug_on} && set +x
1083 fi
1084 }
1085 # === === === === === === === === === === === === === === === === === ===
1086 @@ -497,7 +502,7 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then
1087 fi
1088 if [[ ${EBUILD_PHASE} == depend ]] ; then
1089 FUNC_SRC="${BIN}() {
1090 - if [[ \$ECLASS_DEPTH -gt 0 ]]; then
1091 + if [[ \${ECLASS_DEPTH} -gt 0 ]]; then
1092 eqawarn \"QA Notice: '${BIN}' called in global scope: eclass \${ECLASS}\"
1093 else
1094 eqawarn \"QA Notice: '${BIN}' called in global scope: \${CATEGORY}/\${PF}\"
1095 @@ -521,7 +526,7 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then
1096 ${BODY}
1097 }"
1098 fi
1099 - eval "$FUNC_SRC" || echo "error creating QA interceptor ${BIN}" >&2
1100 + eval "${FUNC_SRC}" || echo "error creating QA interceptor ${BIN}" >&2
1101 done
1102 unset BIN_PATH BIN BODY FUNC_SRC
1103 fi
1104 @@ -530,23 +535,22 @@ fi
1105 export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)}
1106 trap 'exit 1' SIGTERM
1107
1108 -if ! has "$EBUILD_PHASE" clean cleanrm depend && \
1109 - ! [[ $EMERGE_FROM = ebuild && $EBUILD_PHASE = setup ]] && \
1110 - [[ -f "${T}"/environment ]]; then
1111 +if ! has "${EBUILD_PHASE}" clean cleanrm depend && ! [[ ${EMERGE_FROM} = ebuild && ${EBUILD_PHASE} = setup ]] && [[ -f "${T}"/environment ]]; then
1112 # The environment may have been extracted from environment.bz2 or
1113 # may have come from another version of ebuild.sh or something.
1114 # In any case, preprocess it to prevent any potential interference.
1115 # NOTE: export ${FOO}=... requires quoting, unlike normal exports
1116 - __preprocess_ebuild_env || \
1117 - die "error processing environment"
1118 + __preprocess_ebuild_env || die "error processing environment"
1119 +
1120 # Colon separated SANDBOX_* variables need to be cumulative.
1121 for x in SANDBOX_DENY SANDBOX_READ SANDBOX_PREDICT SANDBOX_WRITE ; do
1122 export PORTAGE_${x}="${!x}"
1123 done
1124 PORTAGE_SANDBOX_ON=${SANDBOX_ON}
1125 export SANDBOX_ON=1
1126 - source "${T}"/environment || \
1127 - die "error sourcing environment"
1128 +
1129 + source "${T}"/environment || die "error sourcing environment"
1130 +
1131 # We have to temporarily disable sandbox since the
1132 # SANDBOX_{DENY,READ,PREDICT,WRITE} values we've just loaded
1133 # may be unusable (triggering in spurious sandbox violations)
1134 @@ -557,17 +561,18 @@ if ! has "$EBUILD_PHASE" clean cleanrm depend && \
1135 if [[ -z "${!x}" ]]; then
1136 export ${x}="${!y}"
1137 elif [[ -n "${!y}" && "${!y}" != "${!x}" ]]; then
1138 - # filter out dupes
1139 + # Filter out dupes
1140 export ${x}="$(printf "${!y}:${!x}" | tr ":" "\0" | \
1141 sort -z -u | tr "\0" ":")"
1142 fi
1143 export ${x}="${!x%:}"
1144 unset PORTAGE_${x}
1145 done
1146 +
1147 unset x y
1148 export SANDBOX_ON=${PORTAGE_SANDBOX_ON}
1149 unset PORTAGE_SANDBOX_ON
1150 - [[ -n $EAPI ]] || EAPI=0
1151 + [[ -n ${EAPI} ]] || EAPI=0
1152 fi
1153
1154 # Convert quoted paths to array.
1155 @@ -575,11 +580,9 @@ eval "PORTAGE_ECLASS_LOCATIONS=(${PORTAGE_ECLASS_LOCATIONS})"
1156
1157 # Source the ebuild every time for FEATURES=noauto, so that ebuild
1158 # modifications take effect immediately.
1159 -if ! has "$EBUILD_PHASE" clean cleanrm ; then
1160 - if [[ $EBUILD_PHASE = setup && $EMERGE_FROM = ebuild ]] || \
1161 - [[ $EBUILD_PHASE = depend || ! -f $T/environment || \
1162 - -f $PORTAGE_BUILDDIR/.ebuild_changed || \
1163 - " ${FEATURES} " == *" noauto "* ]] ; then
1164 +if ! has "${EBUILD_PHASE}" clean cleanrm ; then
1165 + if [[ ${EBUILD_PHASE} = setup && ${EMERGE_FROM} = ebuild ]] || \
1166 + [[ ${EBUILD_PHASE} = depend || ! -f ${T}/environment || -f ${PORTAGE_BUILDDIR}/.ebuild_changed || " ${FEATURES} " == *" noauto "* ]] ; then
1167 # The bashrcs get an opportunity here to set aliases that will be expanded
1168 # during sourcing of ebuilds and eclasses.
1169 __source_all_bashrcs
1170 @@ -588,7 +591,7 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
1171 # from cache. In order to make INHERITED content independent of
1172 # EBUILD_PHASE during inherit() calls, we unset INHERITED after
1173 # we make a backup copy for QA checks.
1174 - __INHERITED_QA_CACHE=$INHERITED
1175 + __INHERITED_QA_CACHE=${INHERITED}
1176
1177 # Catch failed globbing attempts in case ebuild writer forgot to
1178 # escape '*' or likes.
1179 @@ -607,11 +610,11 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
1180 unset E_RESTRICT PROVIDES_EXCLUDE REQUIRES_EXCLUDE
1181 unset PORTAGE_EXPLICIT_INHERIT
1182
1183 - if [[ $PORTAGE_DEBUG != 1 || ${-/x/} != $- ]] ; then
1184 - source "$EBUILD" || die "error sourcing ebuild"
1185 + if [[ ${PORTAGE_DEBUG} != 1 || ${-/x/} != $- ]] ; then
1186 + source "${EBUILD}" || die "error sourcing ebuild"
1187 else
1188 set -x
1189 - source "$EBUILD" || die "error sourcing ebuild"
1190 + source "${EBUILD}" || die "error sourcing ebuild"
1191 set +x
1192 fi
1193
1194 @@ -651,11 +654,10 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
1195 if [[ "${EBUILD_PHASE}" != "depend" ]] ; then
1196 PROPERTIES=${PORTAGE_PROPERTIES}
1197 RESTRICT=${PORTAGE_RESTRICT}
1198 - [[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \
1199 - rm "$PORTAGE_BUILDDIR/.ebuild_changed"
1200 + [[ -e ${PORTAGE_BUILDDIR}/.ebuild_changed ]] && rm "${PORTAGE_BUILDDIR}/.ebuild_changed"
1201 fi
1202
1203 - # alphabetically ordered by $EBUILD_PHASE value
1204 + # alphabetically ordered by ${EBUILD_PHASE} value
1205 case ${EAPI} in
1206 0|1)
1207 _valid_phases="src_compile pkg_config pkg_info src_install
1208 @@ -675,41 +677,39 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
1209 esac
1210
1211 DEFINED_PHASES=
1212 - for _f in $_valid_phases ; do
1213 - if declare -F $_f >/dev/null ; then
1214 + for _f in ${_valid_phases} ; do
1215 + if declare -F ${_f} >/dev/null ; then
1216 _f=${_f#pkg_}
1217 DEFINED_PHASES+=" ${_f#src_}"
1218 fi
1219 done
1220 - [[ -n $DEFINED_PHASES ]] || DEFINED_PHASES=-
1221 + [[ -n ${DEFINED_PHASES} ]] || DEFINED_PHASES=-
1222
1223 unset _f _valid_phases
1224
1225 - if [[ $EBUILD_PHASE != depend ]] ; then
1226 + if [[ ${EBUILD_PHASE} != depend ]] ; then
1227
1228 - if has distcc $FEATURES ; then
1229 - [[ -n $DISTCC_LOG ]] && addwrite "${DISTCC_LOG%/*}"
1230 + if has distcc ${FEATURES} ; then
1231 + [[ -n ${DISTCC_LOG} ]] && addwrite "${DISTCC_LOG%/*}"
1232 fi
1233
1234 - if has ccache $FEATURES ; then
1235 -
1236 - if [[ -n $CCACHE_DIR ]] ; then
1237 - addread "$CCACHE_DIR"
1238 - addwrite "$CCACHE_DIR"
1239 + if has ccache ${FEATURES} ; then
1240 + if [[ -n ${CCACHE_DIR} ]] ; then
1241 + addread "${CCACHE_DIR}"
1242 + addwrite "${CCACHE_DIR}"
1243 fi
1244
1245 - [[ -n $CCACHE_SIZE ]] && ccache -M $CCACHE_SIZE &> /dev/null
1246 + [[ -n ${CCACHE_SIZE} ]] && ccache -M ${CCACHE_SIZE} &> /dev/null
1247 fi
1248 fi
1249 fi
1250 fi
1251
1252 -if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}
1253 -then
1254 +if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT} ; then
1255 export DEBUGBUILD=1
1256 fi
1257
1258 -if [[ $EBUILD_PHASE = depend ]] ; then
1259 +if [[ ${EBUILD_PHASE} = depend ]] ; then
1260 export SANDBOX_ON="0"
1261 set -f
1262
1263 @@ -737,10 +737,11 @@ if [[ $EBUILD_PHASE = depend ]] ; then
1264 else
1265 # Note: readonly variables interfere with __preprocess_ebuild_env(), so
1266 # declare them only after it has already run.
1267 - declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS
1268 + declare -r ${PORTAGE_READONLY_METADATA} ${PORTAGE_READONLY_VARS}
1269 if ___eapi_has_prefix_variables; then
1270 declare -r ED EPREFIX EROOT
1271 fi
1272 +
1273 if ___eapi_has_BROOT; then
1274 declare -r BROOT
1275 fi
1276 @@ -749,11 +750,12 @@ else
1277 # then it might not have USE=test like it's supposed to here.
1278 if [[ ${EBUILD_PHASE} == test && ${EBUILD_FORCE_TEST} == 1 ]] &&
1279 ___in_portage_iuse test && ! has test ${USE} ; then
1280 +
1281 export USE="${USE} test"
1282 fi
1283 declare -r USE
1284
1285 - if [[ -n $EBUILD_SH_ARGS ]] ; then
1286 + if [[ -n ${EBUILD_SH_ARGS} ]] ; then
1287 (
1288 # Don't allow subprocesses to inherit the pipe which
1289 # emerge uses to monitor ebuild.sh.
1290
1291 diff --git a/bin/ecompress b/bin/ecompress
1292 index 30d7888cd..0aa5091dd 100755
1293 --- a/bin/ecompress
1294 +++ b/bin/ecompress
1295 @@ -129,20 +129,24 @@ fi
1296
1297 guess_suffix() {
1298 set -e
1299 +
1300 tmpdir="${T}"/.ecompress$$.${RANDOM}
1301 mkdir "${tmpdir}"
1302 cd "${tmpdir}"
1303 - # we have to fill the file enough so that there is something
1304 +
1305 + # We have to fill the file enough so that there is something
1306 # to compress as some programs will refuse to do compression
1307 # if it cannot actually compress the file
1308 echo {0..1000} > compressme
1309 ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme > /dev/null
1310 +
1311 # If PORTAGE_COMPRESS_FLAGS contains -k then we need to avoid
1312 # having our glob match the uncompressed file here.
1313 suffix=$(echo compressme.*)
1314 - [[ -z $suffix || "$suffix" == "compressme.*" ]] && \
1315 + [[ -z ${suffix} || "${suffix}" == "compressme.*" ]] && \
1316 suffix=$(echo compressme*)
1317 suffix=${suffix#compressme}
1318 +
1319 cd /
1320 rm -rf "${tmpdir}"
1321 echo "${suffix}"
1322 @@ -159,6 +163,7 @@ fix_symlinks() {
1323 local something_changed=
1324 while read -r -d $'\0' brokenlink ; do
1325 [[ -e ${brokenlink} ]] && continue
1326 +
1327 olddest=$(readlink "${brokenlink}")
1328 newdest=${olddest}${PORTAGE_COMPRESS_SUFFIX}
1329 if [[ "${newdest}" == /* ]] ; then
1330 @@ -166,6 +171,7 @@ fix_symlinks() {
1331 else
1332 [[ -f "${brokenlink%/*}/${newdest}" ]] || continue
1333 fi
1334 +
1335 something_changed=${brokenlink}
1336 rm -f "${brokenlink}" &&
1337 ln -snf "${newdest}" "${brokenlink}${PORTAGE_COMPRESS_SUFFIX}"
1338 @@ -174,6 +180,7 @@ fix_symlinks() {
1339
1340 [[ -n ${something_changed} ]] || break
1341 (( indirection++ ))
1342 +
1343 if (( indirection >= 100 )) ; then
1344 # Protect against possibility of a bug triggering an endless loop.
1345 eerror "ecompress: too many levels of indirection for" \
1346 @@ -207,6 +214,6 @@ fi
1347
1348 fix_symlinks
1349 : $(( ret |= ${?} ))
1350 -[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
1351 +[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
1352
1353 exit ${ret}
1354
1355 diff --git a/bin/ecompress-file b/bin/ecompress-file
1356 index 1943ca102..3cee5f90a 100755
1357 --- a/bin/ecompress-file
1358 +++ b/bin/ecompress-file
1359 @@ -6,19 +6,21 @@ source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
1360
1361 compress_file() {
1362 mask_ext_re=""
1363 +
1364 set -f
1365 local x
1366 - for x in $PORTAGE_COMPRESS_EXCLUDE_SUFFIXES ; do
1367 - mask_ext_re+="|$x"
1368 + for x in ${PORTAGE_COMPRESS_EXCLUDE_SUFFIXES} ; do
1369 + mask_ext_re+="|${x}"
1370 done
1371 set +f
1372 +
1373 mask_ext_re="^(${mask_ext_re:1})\$"
1374 local filtered_args=()
1375 for x in "$@" ; do
1376 - [[ ${x##*.} =~ $mask_ext_re ]] && continue
1377 + [[ ${x##*.} =~ ${mask_ext_re} ]] && continue
1378 [[ -s ${x} ]] || continue
1379
1380 - # handle precompressed files
1381 + # Handle precompressed files
1382 case ${x} in
1383 *.gz|*.Z)
1384 gunzip -f "${x}" || __helpers_die "gunzip failed"
1385 @@ -34,7 +36,7 @@ compress_file() {
1386 x=${x%.lz};;
1387 esac
1388
1389 - filtered_args+=( "$x" )
1390 + filtered_args+=( "${x}" )
1391 done
1392 [[ ${#filtered_args[@]} -eq 0 ]] && return 0
1393 set -- "${filtered_args[@]}"
1394 @@ -53,8 +55,9 @@ compress_file() {
1395
1396 # Finally, let's actually do some real work
1397 "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@"
1398 +
1399 ret=$?
1400 - [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
1401 + [[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
1402 return ${ret}
1403 }
1404
1405
1406 diff --git a/bin/egencache b/bin/egencache
1407 index 842f453ea..4d920ea3b 100755
1408 --- a/bin/egencache
1409 +++ b/bin/egencache
1410 @@ -879,10 +879,10 @@ class GenChangeLogs:
1411 # --work-tree=... must be passed to Git if GIT_DIR is used
1412 # and GIT_DIR is not a child of the root of the checkout
1413 # eg:
1414 - # GIT_DIR=$parent/work/.git/
1415 - # work-tree=$parent/staging/
1416 + # GIT_DIR=${parent}/work/.git/
1417 + # work-tree=${parent}/staging/
1418 # If work-tree is not passed, Git tries to use the shared
1419 - # parent of the current directory and the $GIT_DIR, which can
1420 + # parent of the current directory and the ${GIT_DIR}, which can
1421 # be outside the root of the checkout.
1422 self._work_tree = "--work-tree=%s" % self._repo_path
1423
1424 @@ -960,7 +960,7 @@ class GenChangeLogs:
1425 # --no-renames to avoid getting more complex records on the list
1426 # --format to get the timestamp, author and commit description
1427 # --root to make it work fine even with the initial commit
1428 - # --relative=$cp to get paths relative to ebuilddir
1429 + # --relative=${cp} to get paths relative to ebuilddir
1430 # -r (recursive) to get per-file changes
1431 # then the commit-id and path.
1432
1433
1434 diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
1435 index 811bfccb7..7fb98900d 100755
1436 --- a/bin/emerge-webrsync
1437 +++ b/bin/emerge-webrsync
1438 @@ -20,8 +20,8 @@
1439 # Alternative (legacy) PORTAGE_GPG_DIR configuration:
1440 # gpg key import
1441 # KEY_ID=0x96D8BF6D
1442 -# gpg --homedir /etc/portage/gnupg --keyserver subkeys.pgp.net --recv-keys $KEY_ID
1443 -# gpg --homedir /etc/portage/gnupg --edit-key $KEY_ID trust
1444 +# gpg --homedir /etc/portage/gnupg --keyserver subkeys.pgp.net --recv-keys ${KEY_ID}
1445 +# gpg --homedir /etc/portage/gnupg --edit-key ${KEY_ID} trust
1446 #
1447
1448 # Only echo if in verbose mode
1449 @@ -46,6 +46,7 @@ else
1450 eecho "could not find 'portageq'; aborting"
1451 exit 1
1452 fi
1453 +
1454 eval "$("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \
1455 FETCHCOMMAND GENTOO_MIRRORS \
1456 PORTAGE_BIN_PATH PORTAGE_CONFIGROOT PORTAGE_GPG_DIR \
1457 @@ -67,7 +68,7 @@ repo_sync_type=$(__repo_attr "${repo_name}" sync-type)
1458 # If PORTAGE_NICENESS is overriden via the env then it will
1459 # still pass through the portageq call and override properly.
1460 if [ -n "${PORTAGE_NICENESS}" ]; then
1461 - renice $PORTAGE_NICENESS $$ > /dev/null
1462 + renice ${PORTAGE_NICENESS} $$ > /dev/null
1463 fi
1464
1465 do_verbose=0
1466 @@ -83,6 +84,7 @@ fi
1467 if [[ -n ${PORTAGE_TEMP_GPG_DIR} ]] ||
1468 has $(__repo_attr "${repo_name}" sync-webrsync-verify-signature |
1469 LC_ALL=C tr '[:upper:]' '[:lower:]') true yes; then
1470 +
1471 # If FEATURES=webrsync-gpg is enabled then allow direct emerge-webrsync
1472 # calls for backward compatibility (this triggers a deprecation warning
1473 # above). Since direct emerge-webrsync calls do not use gemato for secure
1474 @@ -92,12 +94,14 @@ if [[ -n ${PORTAGE_TEMP_GPG_DIR} ]] ||
1475 eecho "Do not call ${argv0##*/} directly, instead call emerge --sync or emaint sync."
1476 exit 1
1477 fi
1478 +
1479 WEBSYNC_VERIFY_SIGNATURE=1
1480 elif has webrsync-gpg ${FEATURES}; then
1481 WEBSYNC_VERIFY_SIGNATURE=1
1482 else
1483 WEBSYNC_VERIFY_SIGNATURE=0
1484 fi
1485 +
1486 [[ -n ${PORTAGE_TEMP_GPG_DIR} ]] && PORTAGE_GPG_DIR=${PORTAGE_TEMP_GPG_DIR}
1487 if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
1488 eecho "please set PORTAGE_GPG_DIR in make.conf"
1489 @@ -105,8 +109,10 @@ if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
1490 fi
1491
1492 do_tar() {
1493 - local file=$1; shift
1494 + local file=$1
1495 + shift
1496 local decompressor
1497 +
1498 case ${file} in
1499 *.xz) decompressor="xzcat" ;;
1500 *.bz2) decompressor="bzcat" ;;
1501 @@ -126,7 +132,7 @@ get_date_part() {
1502 local utc_time_in_secs="$1"
1503 local part="$2"
1504
1505 - if [[ ${USERLAND} == BSD ]] ; then
1506 + if [[ ${USERLAND} == BSD ]] ; then
1507 date -r ${utc_time_in_secs} -u +"${part}"
1508 else
1509 date -d @${utc_time_in_secs} -u +"${part}"
1510 @@ -135,6 +141,7 @@ get_date_part() {
1511
1512 get_utc_second_from_string() {
1513 local s="$1"
1514 +
1515 if [[ ${USERLAND} == BSD ]] ; then
1516 # Specify zeros for the least significant digits, or else those
1517 # digits are inherited from the current system clock time.
1518 @@ -168,8 +175,9 @@ fetch_file() {
1519 fi
1520
1521 __vecho "Fetching file ${FILE} ..."
1522 - # already set DISTDIR=
1523 + # Already set DISTDIR=
1524 eval "${FETCHCOMMAND} ${opts}"
1525 +
1526 if [[ $? -eq 0 && -s ${DISTDIR}/${FILE} ]] ; then
1527 return 0
1528 else
1529 @@ -205,7 +213,6 @@ check_file_signature() {
1530 local gnupg_status line
1531
1532 if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 ]; then
1533 -
1534 __vecho "Checking signature ..."
1535
1536 if type -P gpg > /dev/null; then
1537 @@ -218,6 +225,7 @@ check_file_signature() {
1538 fi
1539 done <<< "${gnupg_status}"
1540 fi
1541 +
1542 if [[ ${r} -ne 0 ]]; then
1543 # Exit early since it's typically inappropriate to
1544 # try other mirrors in this case (it may indicate
1545 @@ -262,8 +270,10 @@ sync_local() {
1546 if type -P tarsync > /dev/null ; then
1547 local chown_opts="-o ${ownership%:*} -g ${ownership#*:}"
1548 chown ${ownership} "${repo_location}" > /dev/null 2>&1 || chown_opts=""
1549 +
1550 if ! tarsync $(vvecho -v) -s 1 ${chown_opts} \
1551 -e /distfiles -e /packages -e /local "${file}" "${repo_location}"; then
1552 +
1553 eecho "tarsync failed; tarball is corrupt? (${file})"
1554 return 1
1555 fi
1556 @@ -281,6 +291,7 @@ sync_local() {
1557 chown -R ${ownership} .
1558 rsync_opts+=" --owner --group"
1559 fi
1560 +
1561 chmod 755 .
1562 rsync ${rsync_opts} . "${repo_location%%/}"
1563
1564 @@ -291,8 +302,10 @@ sync_local() {
1565 __vecho "Updating cache ..."
1566 emerge --metadata
1567 fi
1568 +
1569 local post_sync=${PORTAGE_CONFIGROOT}etc/portage/bin/post_sync
1570 [ -x "${post_sync}" ] && "${post_sync}"
1571 +
1572 # --quiet suppresses output if there are no relevant news items
1573 has news ${FEATURES} && emerge --check-news --quiet
1574 return 0
1575 @@ -310,16 +323,17 @@ do_snapshot() {
1576 local mirror
1577
1578 local compressions=""
1579 +
1580 type -P xzcat > /dev/null && compressions="${compressions} ${repo_name}:xz portage:xz"
1581 type -P bzcat > /dev/null && compressions="${compressions} ${repo_name}:bz2 portage:bz2"
1582 type -P zcat > /dev/null && compressions="${compressions} ${repo_name}:gz portage:gz"
1583 +
1584 if [[ -z ${compressions} ]] ; then
1585 eecho "unable to locate any decompressors (xzcat or bzcat or zcat)"
1586 exit 1
1587 fi
1588
1589 for mirror in ${GENTOO_MIRRORS} ; do
1590 -
1591 mirror=${mirror%/}
1592 __vecho "Trying to retrieve ${date} snapshot from ${mirror} ..."
1593
1594 @@ -351,7 +365,6 @@ do_snapshot() {
1595 # from a different mirror
1596 #
1597 if [ ${have_files} -eq 1 ]; then
1598 -
1599 __vecho "Getting snapshot timestamp ..."
1600 local snapshot_timestamp=$(get_snapshot_timestamp "${DISTDIR}/${file}")
1601
1602
1603 diff --git a/bin/estrip b/bin/estrip
1604 index 63bd46eb1..6935470d3 100755
1605 --- a/bin/estrip
1606 +++ b/bin/estrip
1607 @@ -6,7 +6,7 @@ source "${PORTAGE_BIN_PATH}"/helper-functions.sh || exit 1
1608
1609 # avoid multiple calls to `has`. this creates things like:
1610 # FEATURES_foo=false
1611 -# if "foo" is not in $FEATURES
1612 +# if "foo" is not in ${FEATURES}
1613 tf() { "$@" && echo true || echo false ; }
1614 exp_tf() {
1615 local flag var=$1
1616 @@ -104,6 +104,7 @@ if [[ ${KERNEL} == linux ]] && ${FEATURES_xattr} ; then
1617 "${PORTAGE_PYTHON:-/usr/bin/python}" \
1618 "${PORTAGE_BIN_PATH}/xattr-helper.py" --dump < <(echo -n "$1")
1619 }
1620 +
1621 restore_xattrs() {
1622 PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
1623 "${PORTAGE_PYTHON:-/usr/bin/python}" \
1624 @@ -112,7 +113,7 @@ if [[ ${KERNEL} == linux ]] && ${FEATURES_xattr} ; then
1625 fi
1626 fi
1627
1628 -# look up the tools we might be using
1629 +# Look up the tools we might be using
1630 for t in STRIP:strip OBJCOPY:objcopy READELF:readelf RANLIB:ranlib ; do
1631 v=${t%:*} # STRIP
1632 t=${t#*:} # strip
1633 @@ -147,6 +148,7 @@ if [[ -z ${debugedit} ]]; then
1634 debugedit_paths=(
1635 "${EPREFIX}/usr/libexec/rpm/debugedit"
1636 )
1637 +
1638 for x in "${debugedit_paths[@]}"; do
1639 if [[ -x ${x} ]]; then
1640 debugedit=${x}
1641 @@ -159,7 +161,7 @@ debugedit_warned=false
1642
1643 __multijob_init
1644
1645 -# Setup $T filesystem layout that we care about.
1646 +# Setup ${T} filesystem layout that we care about.
1647 tmpdir="${T}/prepstrip"
1648 rm -rf "${tmpdir}"
1649 mkdir -p "${tmpdir}"/{inodes,splitdebug,sources}
1650 @@ -168,6 +170,7 @@ mkdir -p "${tmpdir}"/{inodes,splitdebug,sources}
1651 save_elf_sources() {
1652 ${FEATURES_installsources} || return 0
1653 ${PORTAGE_RESTRICT_installsources} && return 0
1654 +
1655 if ! ${debugedit_found} ; then
1656 if ! ${debugedit_warned} ; then
1657 debugedit_warned=true
1658 @@ -194,6 +197,7 @@ save_elf_sources() {
1659 __try_symlink() {
1660 local target=$1
1661 local name=$2
1662 +
1663 # Check for an existing link before and after in case we are racing against
1664 # another process.
1665 [[ -L ${name} ]] ||
1666 @@ -251,20 +255,23 @@ save_elf_debug() {
1667 ${OBJCOPY} ${objcopy_flags} "${src}" "${dst}" &&
1668 ${OBJCOPY} --add-gnu-debuglink="${dst}" "${src}"
1669 fi
1670 +
1671 # Only do the following if the debug file was
1672 # successfully created (see bug #446774).
1673 if [[ $? -eq 0 ]] ; then
1674 local args="a-x,o-w"
1675 [[ -g ${src} || -u ${src} ]] && args+=",go-r"
1676 chmod ${args} "${dst}"
1677 - # symlink so we can read the name back.
1678 +
1679 + # Symlink so we can read the name back.
1680 __try_symlink "${dst}" "${inode_debug}"
1681
1682 - # if we don't already have build-id from debugedit, look it up
1683 + # If we don't already have build-id from debugedit, look it up
1684 if [[ -z ${buildid} ]] ; then
1685 # convert the readelf output to something useful
1686 buildid=$(${READELF} -n "${src}" 2>/dev/null | awk '/Build ID:/{ print $NF; exit }')
1687 fi
1688 +
1689 if [[ -n ${buildid} ]] ; then
1690 local buildid_dir="${ED%/}/usr/lib/debug/.build-id/${buildid:0:2}"
1691 local buildid_file="${buildid_dir}/${buildid:2}"
1692 @@ -309,11 +316,11 @@ process_elf() {
1693 fi
1694
1695 if ${strip_this} ; then
1696 -
1697 - # see if we can split & strip at the same time
1698 + # See if we can split & strip at the same time
1699 if [[ -n ${SPLIT_STRIP_FLAGS} ]] ; then
1700 local shortname="${x##*/}.debug"
1701 local splitdebug="${tmpdir}/splitdebug/${shortname}.${BASHPID:-$(__bashpid)}"
1702 +
1703 ${already_stripped} || \
1704 ${STRIP} ${strip_flags} \
1705 -f "${splitdebug}" \
1706 @@ -322,8 +329,7 @@ process_elf() {
1707 save_elf_debug "${x}" "${inode_link}_debug" "${splitdebug}"
1708 else
1709 save_elf_debug "${x}" "${inode_link}_debug"
1710 - ${already_stripped} || \
1711 - ${STRIP} ${strip_flags} "${x}"
1712 + ${already_stripped} || ${STRIP} ${strip_flags} "${x}"
1713 fi
1714 fi
1715
1716 @@ -367,6 +373,7 @@ if ! ${PORTAGE_RESTRICT_binchecks} ; then
1717 # parallel though.
1718 log=${tmpdir}/scanelf-already-stripped.log
1719 scanelf -yqRBF '#k%F' -k '!.symtab' "$@" | sed -e "s#^${ED%/}/##" > "${log}"
1720 +
1721 (
1722 __multijob_child_init
1723 qa_var="QA_PRESTRIPPED_${ARCH/-/_}"
1724 @@ -402,7 +409,9 @@ if [[ ${USERLAND} == BSD ]] ; then
1725 else
1726 get_inode_number() { stat -c '%i' "$1"; }
1727 fi
1728 +
1729 cd "${tmpdir}/inodes" || die "cd failed unexpectedly"
1730 +
1731 if ${prepstrip}; then
1732 while read -r x ; do
1733 inode_link=$(get_inode_number "${x}") || die "stat failed unexpectedly"
1734 @@ -443,8 +452,8 @@ do
1735 strip_this=true
1736 else
1737 # The noglob funk is to support STRIP_MASK="/*/booga" and to keep
1738 - # the for loop from expanding the globs.
1739 - # The eval echo is to support STRIP_MASK="/*/{booga,bar}" sex.
1740 + # the for loop from expanding the globs.
1741 + # The eval echo is to support STRIP_MASK="/*/{booga,bar}".
1742 set -o noglob
1743 strip_this=true
1744 for m in $(eval echo ${STRIP_MASK}) ; do
1745 @@ -466,7 +475,7 @@ do
1746 # or kernel modules as debuginfo for intermediatary
1747 # files (think crt*.o from gcc/glibc) is useless and
1748 # actually causes problems. install sources for all
1749 - # elf types though cause that stuff is good.
1750 + # elf types though because that stuff is good.
1751
1752 buildid=
1753 if [[ ${f} == *"current ar archive"* ]] ; then
1754 @@ -499,8 +508,9 @@ if [[ -s ${tmpdir}/debug.sources ]] && \
1755 then
1756 __vecho "installsources: rsyncing source files"
1757 [[ -d ${D%/}/${prepstrip_sources_dir#/} ]] || mkdir -p "${D%/}/${prepstrip_sources_dir#/}"
1758 - # skip installation of ".../<foo>" (system headers? why inner slashes are forbidden?)
1759 - # skip syncing of ".../foo/" (complete directories)
1760 +
1761 + # Skip installation of ".../<foo>" (system headers? why inner slashes are forbidden?)
1762 + # Skip syncing of ".../foo/" (complete directories)
1763 grep -zv -e '/<[^/>]*>$' -e '/$' "${tmpdir}"/debug.sources | \
1764 (cd "${WORKDIR}"; LANG=C sort -z -u | \
1765 rsync -tL0 --chmod=ugo-st,a+r,go-w,Da+x,Fa-x --files-from=- "${WORKDIR}/" "${D%/}/${prepstrip_sources_dir#/}/" )
1766 @@ -508,8 +518,7 @@ then
1767 # Preserve directory structure.
1768 # Needed after running save_elf_sources.
1769 # https://bugzilla.redhat.com/show_bug.cgi?id=444310
1770 - while read -r -d $'\0' emptydir
1771 - do
1772 + while read -r -d $'\0' emptydir; do
1773 >> "${emptydir}"/.keepdir
1774 done < <(find "${D%/}/${prepstrip_sources_dir#/}/" -type d -empty -print0)
1775 fi
1776
1777 diff --git a/bin/etc-update b/bin/etc-update
1778 index 148a0f05a..a7d1088da 100755
1779 --- a/bin/etc-update
1780 +++ b/bin/etc-update
1781 @@ -41,7 +41,7 @@ case ${OS_RELEASE_POSSIBLE_IDS} in
1782 *) OS_FAMILY='gentoo';;
1783 esac
1784
1785 -if [[ $OS_FAMILY == 'gentoo' ]]; then
1786 +if [[ ${OS_FAMILY} == 'gentoo' ]]; then
1787 get_basename() {
1788 printf -- '%s\n' "${1:10}"
1789 }
1790 @@ -54,7 +54,7 @@ if [[ $OS_FAMILY == 'gentoo' ]]; then
1791 get_live_file() {
1792 echo "${rpath}/${rfile:10}"
1793 }
1794 -elif [[ $OS_FAMILY == 'arch' ]]; then
1795 +elif [[ ${OS_FAMILY} == 'arch' ]]; then
1796 get_basename() {
1797 printf -- '%s\n' "${1%.${NEW_EXT}}"
1798 }
1799 @@ -68,7 +68,7 @@ elif [[ $OS_FAMILY == 'arch' ]]; then
1800 printf -- '%s\n' "${cfg_file%.${NEW_EXT}}"
1801 }
1802 # In rpm we have rpmsave, rpmorig, and rpmnew.
1803 -elif [[ $OS_FAMILY == 'rpm' ]]; then
1804 +elif [[ ${OS_FAMILY} == 'rpm' ]]; then
1805 get_basename() {
1806 printf -- '%s\n' "${1}" |sed -e 's/\.rpmsave$//' -e 's/\.rpmnew$//' -e 's/\.rpmorig$//'
1807 }
1808 @@ -133,6 +133,7 @@ scan() {
1809 # parent directory doesn't exist, we can safely skip it.
1810 path=${path%/}
1811 [[ -d ${path%/*} ]] || continue
1812 +
1813 local name_opt=$(get_basename_find_opt "${path##*/}")
1814 path="${path%/*}"
1815 find_opts=( -maxdepth 1 )
1816 @@ -141,9 +142,10 @@ scan() {
1817 local name_opt=$(get_basename_find_opt '*')
1818 find_opts=( -name '.*' -type d -prune -o )
1819 fi
1820 +
1821 ${case_insensitive} && \
1822 find_opts+=( -iname ) || find_opts+=( -name )
1823 - find_opts+=( "$name_opt" )
1824 + find_opts+=( "${name_opt}" )
1825 find_opts+=( ! -name '.*~' ! -iname '.*.bak' -print )
1826
1827 if [[ ! -w ${path} ]] ; then
1828 @@ -157,8 +159,8 @@ scan() {
1829 sed \
1830 -e 's://*:/:g' \
1831 -e "${scan_regexp}" |
1832 - sort -t"$b" -k2,2 -k4,4 -k3,3 |
1833 - LC_ALL=C cut -f1 -d"$b")
1834 + sort -t"${b}" -k2,2 -k4,4 -k3,3 |
1835 + LC_ALL=C cut -f1 -d"${b}")
1836 do
1837 local rpath rfile cfg_file live_file
1838 rpath=${file%/*}
1839 @@ -175,6 +177,7 @@ scan() {
1840 continue 2
1841 fi
1842 done
1843 +
1844 if [[ -L ${file} ]] ; then
1845 if [[ -L ${live_file} && \
1846 $(readlink "${live_file}") == $(readlink "${file}") ]]
1847 @@ -182,17 +185,20 @@ scan() {
1848 rm -f "${file}"
1849 continue
1850 fi
1851 +
1852 if [[ $(get_basename "${ofile}") != $(get_basename "${rfile}") ]] ||
1853 [[ ${opath} != ${rpath} ]]
1854 then
1855 : $(( ++count ))
1856 echo "${live_file}" > "${TMP}"/files/${count}
1857 fi
1858 +
1859 echo "${cfg_file}" >> "${TMP}"/files/${count}
1860 ofile="${rfile}"
1861 opath="${rpath}"
1862 continue
1863 fi
1864 +
1865 if [[ ! -f ${file} ]] ; then
1866 ${QUIET} || echo "Skipping non-file ${file} ..."
1867 continue
1868 @@ -202,6 +208,7 @@ scan() {
1869 [[ ${opath} != ${rpath} ]]
1870 then
1871 MATCHES=0
1872 +
1873 if ! [[ -f ${cfg_file} && -f ${live_file} ]] ; then
1874 MATCHES=0
1875 elif [[ ${eu_automerge} == "yes" ]] ; then
1876 @@ -594,7 +601,7 @@ do_merge() {
1877 rm ${rm_opts} "${mfile}"
1878 fi
1879
1880 - # since mfile will be like $TMP/path/to/original-file.merged, we
1881 + # since mfile will be like ${TMP}/path/to/original-file.merged, we
1882 # need to make sure the full /path/to/ exists ahead of time
1883 mkdir -p "${mfile%/*}"
1884
1885 @@ -769,13 +776,13 @@ while [[ -n $1 ]] ; do
1886 done
1887 ${SET_X} && set -x
1888
1889 -if [[ $OS_FAMILY == 'rpm' ]]; then
1890 +if [[ ${OS_FAMILY} == 'rpm' ]]; then
1891 PORTAGE_CONFIGROOT='/'
1892 PORTAGE_TMPDIR='/tmp'
1893 CONFIG_PROTECT='/etc /usr/share'
1894 CONFIG_PROTECT_MASK=''
1895 [[ -f /etc/sysconfig/etc-update ]] && . /etc/sysconfig/etc-update
1896 -elif [[ $OS_FAMILY == 'arch' ]]; then
1897 +elif [[ ${OS_FAMILY} == 'arch' ]]; then
1898 PORTAGE_CONFIGROOT='/'
1899 PORTAGE_TMPDIR='/tmp'
1900 CONFIG_PROTECT='/etc /usr/lib /usr/share/config'
1901 @@ -796,7 +803,7 @@ portage_vars=(
1902 if type -P portageq > /dev/null; then
1903 eval $(${PORTAGE_PYTHON:+"${PORTAGE_PYTHON}"} "$(type -P portageq)" envvar -v "${portage_vars[@]}")
1904 else
1905 - [[ $OS_FAMILY == 'gentoo' ]] && die "missing portageq"
1906 + [[ ${OS_FAMILY} == 'gentoo' ]] && die "missing portageq"
1907 fi
1908
1909 export PORTAGE_TMPDIR
1910
1911 diff --git a/bin/install-qa-check.d/05prefix b/bin/install-qa-check.d/05prefix
1912 index c1a5606d8..7488ad9e4 100644
1913 --- a/bin/install-qa-check.d/05prefix
1914 +++ b/bin/install-qa-check.d/05prefix
1915 @@ -65,7 +65,7 @@ install_qa_check_prefix() {
1916 # does the shebang start with ${EPREFIX}, and does it exist?
1917 if [[ ${line[0]} == ${EPREFIX}/* || ${line[0]} == ${eprefix}/* ]] ; then
1918 if [[ ! -e ${ROOT%/}${line[0]} && ! -e ${D%/}${line[0]} ]] ; then
1919 - # hmm, refers explicitly to $EPREFIX, but doesn't exist,
1920 + # hmm, refers explicitly to ${EPREFIX}, but doesn't exist,
1921 # if it's in PATH that's wrong in any case
1922 if [[ ":${PATH}:" == *":${fp}:"* ]] ; then
1923 echo "${fn#${D}}:${line[0]} (explicit EPREFIX but target not found)" \
1924 @@ -76,7 +76,7 @@ install_qa_check_prefix() {
1925 fi
1926 continue
1927 fi
1928 - # unprefixed shebang, is the script directly in $PATH?
1929 + # unprefixed shebang, is the script directly in ${PATH}?
1930 if [[ ":${PATH}:" == *":${fp}:"* ]] ; then
1931 if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; then
1932 # is it unprefixed, but we can just fix it because a
1933 @@ -90,12 +90,12 @@ install_qa_check_prefix() {
1934 sed -i -e '1s:^#! \?'"${line[0]}"':#!'"${EPREFIX}"${line[0]}':' "${rf}"
1935 continue
1936 else
1937 - # this is definitely wrong: script in $PATH and invalid shebang
1938 + # this is definitely wrong: script in ${PATH} and invalid shebang
1939 echo "${fn#${D}}:${line[0]} (script ${fn##*/} installed in PATH but interpreter ${line[0]} not found)" \
1940 >> "${T}"/non-prefix-shebangs-errs
1941 fi
1942 else
1943 - # unprefixed/invalid shebang, but outside $PATH, this may be
1944 + # unprefixed/invalid shebang, but outside ${PATH}, this may be
1945 # intended (e.g. config.guess) so remain silent by default
1946 has stricter ${FEATURES} && \
1947 eqawarn "invalid shebang in ${fn#${D}}: ${line[0]}"
1948
1949 diff --git a/bin/install-qa-check.d/10executable-issues b/bin/install-qa-check.d/10executable-issues
1950 index c2355ab8f..837a8be81 100644
1951 --- a/bin/install-qa-check.d/10executable-issues
1952 +++ b/bin/install-qa-check.d/10executable-issues
1953 @@ -20,7 +20,7 @@ elf_check() {
1954 # temporary directory.
1955 # 2) If ROOT != "/", references to ROOT are banned because
1956 # that directory won't exist on the target system.
1957 - # 3) Null paths are banned because the loader will search $PWD when
1958 + # 3) Null paths are banned because the loader will search ${PWD} when
1959 # it finds null paths.
1960 local forbidden_dirs=( "${PORTAGE_BUILDDIR}" )
1961 if [[ "${ROOT:-/}" != "/" ]]; then
1962
1963 diff --git a/bin/install-qa-check.d/20deprecated-directories b/bin/install-qa-check.d/20deprecated-directories
1964 index fb82bfe7a..75771a50f 100644
1965 --- a/bin/install-qa-check.d/20deprecated-directories
1966 +++ b/bin/install-qa-check.d/20deprecated-directories
1967 @@ -3,12 +3,12 @@
1968 deprecated_dir_check() {
1969 local x f=
1970 for x in etc/app-defaults usr/man usr/info usr/X11R6 usr/doc usr/locale ; do
1971 - [[ -d ${ED}/$x ]] && f+=" $x\n"
1972 + [[ -d ${ED}/${x} ]] && f+=" ${x}\n"
1973 done
1974 - if [[ -n $f ]] ; then
1975 + if [[ -n ${f} ]] ; then
1976 eqawarn "QA Notice: This ebuild installs into the following deprecated directories:"
1977 eqawarn
1978 - eqawarn "$f"
1979 + eqawarn "${f}"
1980 fi
1981 }
1982
1983
1984 diff --git a/bin/install-qa-check.d/60udev b/bin/install-qa-check.d/60udev
1985 index c48d7d598..9df18da60 100644
1986 --- a/bin/install-qa-check.d/60udev
1987 +++ b/bin/install-qa-check.d/60udev
1988 @@ -8,10 +8,11 @@ udev_check() {
1989 [[ ${x} == ${ED%/}/lib/udev/rules.d/* ]] && continue
1990 f+=" ${x#${ED%/}}\n"
1991 done
1992 - if [[ -n $f ]] ; then
1993 +
1994 + if [[ -n ${f} ]] ; then
1995 eqawarn "QA Notice: udev rules should be installed in /lib/udev/rules.d:"
1996 eqawarn
1997 - eqawarn "$f"
1998 + eqawarn "${f}"
1999 fi
2000 }
2001
2002
2003 diff --git a/bin/install-qa-check.d/80libraries b/bin/install-qa-check.d/80libraries
2004 index 81c926982..9855060aa 100644
2005 --- a/bin/install-qa-check.d/80libraries
2006 +++ b/bin/install-qa-check.d/80libraries
2007 @@ -166,7 +166,7 @@ lib_check() {
2008 die "static archives (*.a) and libtool library files (*.la) belong in /usr/lib*, not /lib*"
2009 fi
2010
2011 - # Verify that the libtool files don't contain bogus $D entries.
2012 + # Verify that the libtool files don't contain bogus ${D} entries.
2013 local abort=no gentoo_bug=no always_overflow=no
2014 for a in "${ED%/}"/usr/lib*/*.la ; do
2015 s=${a##*/}
2016
2017 diff --git a/bin/install-qa-check.d/90bad-bin-owner b/bin/install-qa-check.d/90bad-bin-owner
2018 index c3ee30746..46d4e3947 100644
2019 --- a/bin/install-qa-check.d/90bad-bin-owner
2020 +++ b/bin/install-qa-check.d/90bad-bin-owner
2021 @@ -25,7 +25,7 @@ bad_bin_owner_check() {
2022 # We do want to list non-superuser setuid executables, because
2023 # they can be exploited. The owner can simply wipe the setuid
2024 # bit, and then alter the contents of the file. The superuser
2025 - # will then have a time bomb in his $PATH.
2026 + # will then have a time bomb in his ${PATH}.
2027 while read -r -d '' f; do
2028 found+=( "${f}" )
2029 done < <(find -L "${d}" \
2030
2031 diff --git a/bin/install-qa-check.d/90gcc-warnings b/bin/install-qa-check.d/90gcc-warnings
2032 index bde198c97..041e39c8b 100644
2033 --- a/bin/install-qa-check.d/90gcc-warnings
2034 +++ b/bin/install-qa-check.d/90gcc-warnings
2035 @@ -12,6 +12,7 @@ gcc_warn_check() {
2036 set +x
2037 reset_debug=1
2038 fi
2039 +
2040 local m msgs=(
2041 # only will and does, no might :)
2042 'warning: .*will.*\[-Wstrict-aliasing\]'
2043 @@ -79,9 +80,9 @@ gcc_warn_check() {
2044
2045 local abort="no"
2046 local grep_cmd=grep
2047 - [[ $PORTAGE_LOG_FILE = *.gz ]] && grep_cmd=zgrep
2048 + [[ ${PORTAGE_LOG_FILE} = *.gz ]] && grep_cmd=zgrep
2049
2050 - # Force C locale to work around slow multibyte locales. #160234
2051 + # Force C locale to work around slow multibyte locales, bug #160234
2052 # Force text mode as newer grep will treat non-ASCII (e.g. UTF-8) as
2053 # binary when we run in the C locale.
2054 f=$(LC_CTYPE=C LC_COLLATE=C "${grep_cmd}" -E -a "${joined_msgs}" "${PORTAGE_LOG_FILE}" | uniq)
2055 @@ -91,7 +92,8 @@ gcc_warn_check() {
2056 #if [[ ${f} == *'will always overflow destination buffer'* ]]; then
2057 # always_overflow=yes
2058 #fi
2059 - if [[ $always_overflow = yes ]] ; then
2060 +
2061 + if [[ ${always_overflow} = yes ]] ; then
2062 eerror
2063 eerror "QA Notice: Package triggers severe warnings which indicate that it"
2064 eerror " may exhibit random runtime failures."
2065 @@ -149,7 +151,7 @@ gcc_warn_check() {
2066
2067 fi
2068 if [[ ${abort} == "yes" ]] ; then
2069 - if [[ $gentoo_bug = yes || $always_overflow = yes ]] ; then
2070 + if [[ ${gentoo_bug} = yes || ${always_overflow} = yes ]] ; then
2071 die "install aborted due to severe warnings shown above"
2072 else
2073 echo "Please do not file a Gentoo bug and instead" \
2074
2075 diff --git a/bin/install-qa-check.d/90world-writable b/bin/install-qa-check.d/90world-writable
2076 index c69c43444..6a521b3cc 100644
2077 --- a/bin/install-qa-check.d/90world-writable
2078 +++ b/bin/install-qa-check.d/90world-writable
2079 @@ -5,17 +5,17 @@ world_writable_check() {
2080 local unsafe_files=$(find "${ED}" -type f -perm -2 | sed -e "s:^${D}:/:")
2081 local OLDIFS x prev_shopts=$-
2082
2083 - OLDIFS=$IFS
2084 + OLDIFS=${IFS}
2085 IFS=$'\n'
2086 set -f
2087
2088 if [[ -n ${unsafe_files} ]] ; then
2089 eqawarn "QA Security Notice: world writable file(s):"
2090
2091 - eqatag -v world-writable $unsafe_files
2092 + eqatag -v world-writable ${unsafe_files}
2093
2094 eqawarn "This may or may not be a security problem, most of the time it is one."
2095 - eqawarn "Please double check that $PF really needs a world writeable bit and file bugs accordingly."
2096 + eqawarn "Please double check that ${PF} really needs a world writeable bit and file bugs accordingly."
2097 eqawarn
2098 fi
2099
2100 @@ -23,12 +23,12 @@ world_writable_check() {
2101 if [[ -n ${unsafe_files} ]] ; then
2102 eqawarn "QA Notice: Unsafe files detected (set*id and world writable)"
2103
2104 - eqatag -v world-writable-setid $unsafe_files
2105 + eqatag -v world-writable-setid ${unsafe_files}
2106
2107 die "Unsafe files found in \${D}. Portage will not install them."
2108 fi
2109
2110 - IFS=$OLDIFS
2111 + IFS=${OLDIFS}
2112 [[ ${prev_shopts} == *f* ]] || set +f
2113 }
2114
2115
2116 diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
2117 index 2ec677c69..4542c6715 100644
2118 --- a/bin/isolated-functions.sh
2119 +++ b/bin/isolated-functions.sh
2120 @@ -14,8 +14,8 @@ shopt -s expand_aliases
2121
2122 assert() {
2123 local x pipestatus=${PIPESTATUS[*]}
2124 - for x in $pipestatus ; do
2125 - [[ $x -eq 0 ]] || die "$@"
2126 + for x in ${pipestatus} ; do
2127 + [[ ${x} -eq 0 ]] || die "$@"
2128 done
2129 }
2130
2131 @@ -36,13 +36,13 @@ __assert_sigpipe_ok() {
2132 # as the exit status."
2133
2134 local x pipestatus=${PIPESTATUS[*]}
2135 - for x in $pipestatus ; do
2136 + for x in ${pipestatus} ; do
2137 # Allow SIGPIPE through (128 + 13)
2138 - [[ $x -ne 0 && $x -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && die "$@"
2139 + [[ ${x} -ne 0 && ${x} -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && die "$@"
2140 done
2141
2142 # Require normal success for the last process (tar).
2143 - [[ $x -eq 0 ]] || die "$@"
2144 + [[ ${x} -eq 0 ]] || die "$@"
2145 }
2146
2147 shopt -s extdebug
2148 @@ -91,10 +91,10 @@ __dump_trace() {
2149
2150 nonfatal() {
2151 if ! ___eapi_has_nonfatal; then
2152 - die "$FUNCNAME() not supported in this EAPI"
2153 + die "${FUNCNAME}() not supported in this EAPI"
2154 fi
2155 if [[ $# -lt 1 ]]; then
2156 - die "$FUNCNAME(): Missing argument"
2157 + die "${FUNCNAME}(): Missing argument"
2158 fi
2159
2160 PORTAGE_NONFATAL=1 "$@"
2161 @@ -157,14 +157,14 @@ die() {
2162 # When a helper binary dies automatically in EAPI 4 and later, we don't
2163 # get a stack trace, so at least report the phase that failed.
2164 local phase_str=
2165 - [[ -n $EBUILD_PHASE ]] && phase_str=" ($EBUILD_PHASE phase)"
2166 + [[ -n ${EBUILD_PHASE} ]] && phase_str=" (${EBUILD_PHASE} phase)"
2167 eerror "ERROR: ${CATEGORY}/${PF}::${PORTAGE_REPO_NAME} failed${phase_str}:"
2168 eerror " ${*:-(no error message)}"
2169 eerror
2170 # __dump_trace is useless when the main script is a helper binary
2171 local main_index
2172 (( main_index = ${#BASH_SOURCE[@]} - 1 ))
2173 - if has ${BASH_SOURCE[$main_index]##*/} ebuild.sh misc-functions.sh ; then
2174 + if has ${BASH_SOURCE[${main_index}]##*/} ebuild.sh misc-functions.sh ; then
2175 __dump_trace 2 ${filespacing} ${linespacing}
2176 eerror " $(printf "%${filespacing}s" "${BASH_SOURCE[1]##*/}"), line $(printf "%${linespacing}s" "${BASH_LINENO[0]}"): Called die"
2177 eerror "The specific snippet of code:"
2178 @@ -198,13 +198,13 @@ die() {
2179 # misc-functions.sh, since those are the only cases where the environment
2180 # contains the hook functions. When necessary (like for __helpers_die), die
2181 # hooks are automatically called later by a misc-functions.sh invocation.
2182 - if has ${BASH_SOURCE[$main_index]##*/} ebuild.sh misc-functions.sh && \
2183 + if has ${BASH_SOURCE[${main_index}]##*/} ebuild.sh misc-functions.sh && \
2184 [[ ${EBUILD_PHASE} != depend ]] ; then
2185 local x
2186 - for x in $EBUILD_DEATH_HOOKS; do
2187 + for x in ${EBUILD_DEATH_HOOKS}; do
2188 ${x} "$@" >&2 1>&2
2189 done
2190 - > "$PORTAGE_BUILDDIR/.die_hooks"
2191 + > "${PORTAGE_BUILDDIR}/.die_hooks"
2192 fi
2193
2194 if [[ -n ${PORTAGE_LOG_FILE} ]] ; then
2195 @@ -229,8 +229,8 @@ die() {
2196 eerror "Working directory: '$(pwd)'"
2197 [[ -n ${S} ]] && eerror "S: '${S}'"
2198
2199 - [[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE"
2200 - [[ -n $PORTAGE_IPC_DAEMON ]] && "$PORTAGE_BIN_PATH"/ebuild-ipc exit 1
2201 + [[ -n ${PORTAGE_EBUILD_EXIT_FILE} ]] && > "${PORTAGE_EBUILD_EXIT_FILE}"
2202 + [[ -n ${PORTAGE_IPC_DAEMON} ]] && "${PORTAGE_BIN_PATH}"/ebuild-ipc exit 1
2203
2204 # subshell die support
2205 if [[ -n ${EBUILD_MASTER_PID} && ${BASHPID:-$(__bashpid)} != ${EBUILD_MASTER_PID} ]] ; then
2206 @@ -262,7 +262,7 @@ __elog_base() {
2207 ;;
2208 esac
2209 echo -e "$@" | while read -r ; do
2210 - echo "$messagetype $REPLY" >> \
2211 + echo "${messagetype} ${REPLY}" >> \
2212 "${T}/logging/${EBUILD_PHASE:-other}"
2213 done
2214 return 0
2215 @@ -398,18 +398,20 @@ __unset_colors() {
2216 }
2217
2218 __set_colors() {
2219 - COLS=${COLUMNS:-0} # bash's internal COLUMNS variable
2220 + # bash's internal COLUMNS variable
2221 + COLS=${COLUMNS:-0}
2222 +
2223 # Avoid wasteful stty calls during the "depend" phases.
2224 # If stdout is a pipe, the parent process can export COLUMNS
2225 # if it's relevant. Use an extra subshell for stty calls, in
2226 # order to redirect "/dev/tty: No such device or address"
2227 # error from bash to /dev/null.
2228 - [[ $COLS == 0 && $EBUILD_PHASE != depend ]] && \
2229 + [[ ${COLS} == 0 && ${EBUILD_PHASE} != depend ]] && \
2230 COLS=$(set -- $( ( stty size </dev/tty ) 2>/dev/null || echo 24 80 ) ; echo $2)
2231 (( COLS > 0 )) || (( COLS = 80 ))
2232
2233 # Now, ${ENDCOL} will move us to the end of the
2234 - # column; irregardless of character width
2235 + # column; regardless of character width
2236 ENDCOL=$'\e[A\e['$(( COLS - 8 ))'C'
2237 if [[ -n "${PORTAGE_COLORMAP}" ]]; then
2238 eval ${PORTAGE_COLORMAP}
2239 @@ -617,7 +619,7 @@ else
2240 fi
2241
2242 # debug-print() gets called from many places with verbose status information useful
2243 -# for tracking down problems. The output is in $T/eclass-debug.log.
2244 +# for tracking down problems. The output is in ${T}/eclass-debug.log.
2245 # You can set ECLASS_DEBUG_OUTPUT to redirect the output somewhere else as well.
2246 # The special "on" setting echoes the information, mixing it with the rest of the
2247 # emerge output.
2248 @@ -626,9 +628,9 @@ fi
2249 #
2250 # (TODO: in the future, might use e* from /lib/gentoo/functions.sh?)
2251 debug-print() {
2252 - # if $T isn't defined, we're in dep calculation mode and
2253 + # If ${T} isn't defined, we're in dep calculation mode and
2254 # shouldn't do anything
2255 - [[ $EBUILD_PHASE = depend || ! -d ${T} || ${#} -eq 0 ]] && return 0
2256 + [[ ${EBUILD_PHASE} = depend || ! -d ${T} || ${#} -eq 0 ]] && return 0
2257
2258 if [[ ${ECLASS_DEBUG_OUTPUT} == on ]]; then
2259 printf 'debug: %s\n' "${@}" >&2
2260 @@ -636,10 +638,11 @@ debug-print() {
2261 printf 'debug: %s\n' "${@}" >> "${ECLASS_DEBUG_OUTPUT}"
2262 fi
2263
2264 - if [[ -w $T ]] ; then
2265 - # default target
2266 + if [[ -w ${T} ]] ; then
2267 + # Default target
2268 printf '%s\n' "${@}" >> "${T}/eclass-debug.log"
2269 - # let the portage user own/write to this file
2270 +
2271 + # Let the portage user own/write to this file
2272 chgrp "${PORTAGE_GRPNAME:-portage}" "${T}/eclass-debug.log"
2273 chmod g+w "${T}/eclass-debug.log"
2274 fi
2275
2276 diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
2277 index 466d21dfd..faa8184c6 100755
2278 --- a/bin/misc-functions.sh
2279 +++ b/bin/misc-functions.sh
2280 @@ -135,7 +135,7 @@ install_qa_check() {
2281 )
2282 done < <(printf "%s\0" "${qa_checks[@]}" | LC_ALL=C sort -u -z)
2283
2284 - if has chflags $FEATURES ; then
2285 + if has chflags ${FEATURES} ; then
2286 # Save all the file flags for restoration afterwards.
2287 mtree -c -p "${ED}" -k flags > "${T}/bsdflags.mtree"
2288 # Remove all the file flags so that we can do anything necessary.
2289 @@ -153,7 +153,7 @@ install_qa_check() {
2290 "${PORTAGE_BIN_PATH}"/ecompress --dequeue
2291 fi
2292
2293 - if has chflags $FEATURES ; then
2294 + if has chflags ${FEATURES} ; then
2295 # Restore all the file flags that were saved earlier on.
2296 mtree -U -e -p "${ED}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
2297 fi
2298 @@ -164,7 +164,7 @@ install_qa_check() {
2299 # containing pre-built binaries.
2300 if type -P scanelf > /dev/null ; then
2301 # Save NEEDED information after removing self-contained providers
2302 - rm -f "$PORTAGE_BUILDDIR"/build-info/NEEDED{,.ELF.2}
2303 + rm -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED{,.ELF.2}
2304
2305 # We don't use scanelf -q, since that would omit libraries like
2306 # musl's /usr/lib/libc.so which do not have any DT_NEEDED or
2307 @@ -258,7 +258,7 @@ install_qa_check() {
2308
2309 __dyn_instprep() {
2310 if [[ -e ${PORTAGE_BUILDDIR}/.instprepped ]] ; then
2311 - __vecho ">>> It appears that '$PF' is already instprepped; skipping."
2312 + __vecho ">>> It appears that '${PF}' is already instprepped; skipping."
2313 __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.instprepped' to force instprep."
2314 return 0
2315 fi
2316 @@ -396,29 +396,29 @@ preinst_sfperms() {
2317 fi
2318
2319 # Smart FileSystem Permissions
2320 - if has sfperms $FEATURES; then
2321 + if has sfperms ${FEATURES}; then
2322 local i
2323 find "${ED}" -type f -perm -4000 -print0 | \
2324 while read -r -d $'\0' i ; do
2325 - if [[ -n "$(find "$i" -perm -2000)" ]]; then
2326 + if [[ -n "$(find "${i}" -perm -2000)" ]]; then
2327 ebegin ">>> SetUID and SetGID: [chmod o-r] ${i#${ED%/}}"
2328 - chmod o-r "$i"
2329 + chmod o-r "${i}"
2330 eend $?
2331 else
2332 ebegin ">>> SetUID: [chmod go-r] ${i#${ED%/}}"
2333 - chmod go-r "$i"
2334 + chmod go-r "${i}"
2335 eend $?
2336 fi
2337 done
2338 find "${ED}" -type f -perm -2000 -print0 | \
2339 while read -r -d $'\0' i ; do
2340 - if [[ -n "$(find "$i" -perm -4000)" ]]; then
2341 + if [[ -n "$(find "${i}" -perm -4000)" ]]; then
2342 # This case is already handled
2343 # by the SetUID check above.
2344 true
2345 else
2346 ebegin ">>> SetGID: [chmod o-r] ${i#${ED%/}}"
2347 - chmod o-r "$i"
2348 + chmod o-r "${i}"
2349 eend $?
2350 fi
2351 done
2352 @@ -436,7 +436,7 @@ preinst_suid_scan() {
2353 fi
2354
2355 # Total suid control
2356 - if has suidctl $FEATURES; then
2357 + if has suidctl ${FEATURES}; then
2358 local i sfconf x
2359 sfconf=${PORTAGE_CONFIGROOT}etc/portage/suidctl.conf
2360 # sandbox prevents us from writing directly
2361 @@ -497,17 +497,16 @@ preinst_selinux_labels() {
2362 }
2363
2364 __dyn_package() {
2365 -
2366 if ! ___eapi_has_prefix_variables; then
2367 local EPREFIX=
2368 fi
2369
2370 - # Make sure $PWD is not ${D} so that we don't leave gmon.out files
2371 + # Make sure ${PWD} is not ${D} so that we don't leave gmon.out files
2372 # in there in case any tools were built with -pg in CFLAGS.
2373 cd "${T}" || die
2374
2375 # Sandbox is disabled in case the user wants to use a symlink
2376 - # for $PKGDIR and/or $PKGDIR/All.
2377 + # for ${PKGDIR} and/or ${PKGDIR}/All.
2378 export SANDBOX_ON="0"
2379 [[ -z "${PORTAGE_BINPKG_TMPFILE}" ]] && \
2380 die "PORTAGE_BINPKG_TMPFILE is unset"
2381 @@ -515,20 +514,24 @@ __dyn_package() {
2382
2383 if [[ "${BINPKG_FORMAT}" == "xpak" ]]; then
2384 local tar_options=""
2385 - [[ $PORTAGE_VERBOSE = 1 ]] && tar_options+=" -v"
2386 +
2387 + [[ ${PORTAGE_VERBOSE} = 1 ]] && tar_options+=" -v"
2388 has xattr ${FEATURES} && [[ $(tar --help 2> /dev/null) == *--xattrs* ]] && tar_options+=" --xattrs"
2389 - [[ -z "${PORTAGE_COMPRESSION_COMMAND}" ]] && \
2390 - die "PORTAGE_COMPRESSION_COMMAND is unset"
2391 - tar $tar_options -cf - $PORTAGE_BINPKG_TAR_OPTS -C "${D}" . | \
2392 - $PORTAGE_COMPRESSION_COMMAND > "$PORTAGE_BINPKG_TMPFILE"
2393 - assert "failed to pack binary package: '$PORTAGE_BINPKG_TMPFILE'"
2394 +
2395 + [[ -z "${PORTAGE_COMPRESSION_COMMAND}" ]] && die "PORTAGE_COMPRESSION_COMMAND is unset"
2396 +
2397 + tar ${tar_options} -cf - ${PORTAGE_BINPKG_TAR_OPTS} -C "${D}" . | \
2398 + ${PORTAGE_COMPRESSION_COMMAND} > "${PORTAGE_BINPKG_TMPFILE}"
2399 + assert "failed to pack binary package: '${PORTAGE_BINPKG_TMPFILE}'"
2400 +
2401 PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
2402 - "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH"/xpak-helper.py recompose \
2403 - "$PORTAGE_BINPKG_TMPFILE" "$PORTAGE_BUILDDIR/build-info"
2404 + "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}"/xpak-helper.py recompose \
2405 + "${PORTAGE_BINPKG_TMPFILE}" "${PORTAGE_BUILDDIR}/build-info"
2406 if [[ $? -ne 0 ]]; then
2407 rm -f "${PORTAGE_BINPKG_TMPFILE}"
2408 die "Failed to append metadata to the tbz2 file"
2409 fi
2410 +
2411 local md5_hash=""
2412 if type md5sum &>/dev/null ; then
2413 md5_hash=$(md5sum "${PORTAGE_BINPKG_TMPFILE}")
2414 @@ -537,14 +540,14 @@ __dyn_package() {
2415 md5_hash=$(md5 "${PORTAGE_BINPKG_TMPFILE}")
2416 md5_hash=${md5_hash##* }
2417 fi
2418 - [[ -n "${md5_hash}" ]] && \
2419 - echo ${md5_hash} > "${PORTAGE_BUILDDIR}"/build-info/BINPKGMD5
2420 +
2421 + [[ -n "${md5_hash}" ]] && echo ${md5_hash} > "${PORTAGE_BUILDDIR}"/build-info/BINPKGMD5
2422 __vecho ">>> Done."
2423
2424 elif [[ "${BINPKG_FORMAT}" == "gpkg" ]]; then
2425 PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
2426 - "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH"/gpkg-helper.py compress \
2427 - "${CATEGORY}/${PF}" "$PORTAGE_BINPKG_TMPFILE" "$PORTAGE_BUILDDIR/build-info" "${D}"
2428 + "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}"/gpkg-helper.py compress \
2429 + "${CATEGORY}/${PF}" "${PORTAGE_BINPKG_TMPFILE}" "${PORTAGE_BUILDDIR}/build-info" "${D}"
2430 if [[ $? -ne 0 ]]; then
2431 rm -f "${PORTAGE_BINPKG_TMPFILE}"
2432 die "Failed to create binpkg file"
2433 @@ -555,8 +558,7 @@ __dyn_package() {
2434 fi
2435
2436 cd "${PORTAGE_BUILDDIR}"
2437 - >> "$PORTAGE_BUILDDIR/.packaged" || \
2438 - die "Failed to create $PORTAGE_BUILDDIR/.packaged"
2439 + >> "${PORTAGE_BUILDDIR}/.packaged" || die "Failed to create ${PORTAGE_BUILDDIR}/.packaged"
2440 }
2441
2442 __dyn_spec() {
2443 @@ -602,30 +604,35 @@ __dyn_rpm() {
2444 fi
2445
2446 cd "${T}" || die "cd failed"
2447 +
2448 local machine_name=${CHOST%%-*}
2449 local dest_dir=${T}/rpmbuild/RPMS/${machine_name}
2450 +
2451 addwrite "${RPMDIR}"
2452 __dyn_spec
2453 HOME=${T} \
2454 rpmbuild -bb --clean --nodeps --rmsource "${PF}.spec" --buildroot "${D}" --target "${CHOST}" || die "Failed to integrate rpm spec file"
2455 +
2456 install -D "${dest_dir}/${PN}-${PV}-${PR}.${machine_name}.rpm" \
2457 "${RPMDIR}/${CATEGORY}/${PN}-${PV}-${PR}.rpm" || \
2458 die "Failed to move rpm"
2459 }
2460
2461 die_hooks() {
2462 - [[ -f $PORTAGE_BUILDDIR/.die_hooks ]] && return
2463 + [[ -f ${PORTAGE_BUILDDIR}/.die_hooks ]] && return
2464 +
2465 local x
2466 - for x in $EBUILD_DEATH_HOOKS ; do
2467 - $x >&2
2468 + for x in ${EBUILD_DEATH_HOOKS} ; do
2469 + ${x} >&2
2470 done
2471 - > "$PORTAGE_BUILDDIR/.die_hooks"
2472 +
2473 + > "${PORTAGE_BUILDDIR}/.die_hooks"
2474 }
2475
2476 success_hooks() {
2477 local x
2478 - for x in $EBUILD_SUCCESS_HOOKS ; do
2479 - $x
2480 + for x in ${EBUILD_SUCCESS_HOOKS} ; do
2481 + ${x}
2482 done
2483 }
2484
2485 @@ -633,15 +640,17 @@ install_hooks() {
2486 local hooks_dir="${PORTAGE_CONFIGROOT}etc/portage/hooks/install"
2487 local fp
2488 local ret=0
2489 +
2490 shopt -s nullglob
2491 for fp in "${hooks_dir}"/*; do
2492 - if [[ -x "$fp" ]]; then
2493 - "$fp"
2494 - ret=$(( $ret | $? ))
2495 + if [[ -x "${fp}" ]]; then
2496 + "${fp}"
2497 + ret=$(( ${ret} | $? ))
2498 fi
2499 done
2500 shopt -u nullglob
2501 - return $ret
2502 +
2503 + return ${ret}
2504 }
2505
2506 eqatag() {
2507 @@ -650,15 +659,19 @@ eqatag() {
2508
2509 if [[ -n "${MISC_FUNCTIONS_ARGS}" ]]; then
2510 __source_all_bashrcs
2511 - [[ "$PORTAGE_DEBUG" == "1" ]] && set -x
2512 +
2513 + [[ "${PORTAGE_DEBUG}" == "1" ]] && set -x
2514 +
2515 for x in ${MISC_FUNCTIONS_ARGS}; do
2516 ${x}
2517 done
2518 unset x
2519 - [[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE"
2520 - if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
2521 - [[ ! -s $SANDBOX_LOG ]]
2522 - "$PORTAGE_BIN_PATH"/ebuild-ipc exit $?
2523 +
2524 + [[ -n ${PORTAGE_EBUILD_EXIT_FILE} ]] && > "${PORTAGE_EBUILD_EXIT_FILE}"
2525 +
2526 + if [[ -n ${PORTAGE_IPC_DAEMON} ]] ; then
2527 + [[ ! -s ${SANDBOX_LOG} ]]
2528 + "${PORTAGE_BIN_PATH}"/ebuild-ipc exit $?
2529 fi
2530 fi
2531
2532
2533 diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
2534 index f615ba491..687e1ab03 100644
2535 --- a/bin/phase-functions.sh
2536 +++ b/bin/phase-functions.sh
2537 @@ -97,8 +97,8 @@ __filter_readonly_variables() {
2538 # Untrusted due to possible application of package renames to binpkgs
2539 local binpkg_untrusted_vars="CATEGORY P PF PN PR PV PVR"
2540 local misc_garbage_vars="_portage_filter_opts"
2541 - filtered_vars="___.* $readonly_bash_vars $bash_misc_vars
2542 - $PORTAGE_READONLY_VARS $misc_garbage_vars"
2543 + filtered_vars="___.* ${readonly_bash_vars} ${bash_misc_vars}
2544 + ${PORTAGE_READONLY_VARS} ${misc_garbage_vars}"
2545
2546 # Filter SYSROOT unconditionally. It is propagated in every EAPI
2547 # because it was used unofficially before EAPI 7. See bug #661006.
2548 @@ -165,11 +165,13 @@ __preprocess_ebuild_env() {
2549 # Otherwise, we don't need to filter the environment.
2550 [[ -f "${T}/environment.raw" ]] || return 0
2551
2552 - __filter_readonly_variables $_portage_filter_opts < "${T}"/environment \
2553 - >> "$T/environment.filtered" || return $?
2554 + __filter_readonly_variables ${_portage_filter_opts} < "${T}"/environment \
2555 + >> "${T}/environment.filtered" || return $?
2556 +
2557 unset _portage_filter_opts
2558 mv "${T}"/environment.filtered "${T}"/environment || return $?
2559 rm -f "${T}/environment.success" || return $?
2560 +
2561 # WARNING: Code inside this subshell should avoid making assumptions
2562 # about variables or functions after source "${T}"/environment has been
2563 # called. Any variables that need to be relied upon should already be
2564 @@ -192,8 +194,9 @@ __preprocess_ebuild_env() {
2565 # Rely on __save_ebuild_env() to filter out any remaining variables
2566 # and functions that could interfere with the current environment.
2567 __save_ebuild_env || exit $?
2568 - >> "$T/environment.success" || exit $?
2569 + >> "${T}/environment.success" || exit $?
2570 ) > "${T}/environment.filtered"
2571 +
2572 local retval
2573 if [[ -e "${T}/environment.success" ]]; then
2574 __filter_readonly_variables --filter-features < \
2575 @@ -202,12 +205,14 @@ __preprocess_ebuild_env() {
2576 else
2577 retval=1
2578 fi
2579 +
2580 rm -f "${T}"/environment.{filtered,raw,success}
2581 return ${retval}
2582 }
2583
2584 __ebuild_phase() {
2585 local __EBEGIN_EEND_COUNT=0
2586 +
2587 declare -F "$1" >/dev/null && __qa_call $1
2588 if (( __EBEGIN_EEND_COUNT > 0 )); then
2589 eqawarn "QA Notice: ebegin called without eend in $1"
2590 @@ -222,28 +227,30 @@ __ebuild_phase_with_hooks() {
2591 }
2592
2593 __dyn_pretend() {
2594 - if [[ -e $PORTAGE_BUILDDIR/.pretended ]] ; then
2595 - __vecho ">>> It appears that '$PF' is already pretended; skipping."
2596 - __vecho ">>> Remove '$PORTAGE_BUILDDIR/.pretended' to force pretend."
2597 + if [[ -e ${PORTAGE_BUILDDIR}/.pretended ]] ; then
2598 + __vecho ">>> It appears that '${PF}' is already pretended; skipping."
2599 + __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.pretended' to force pretend."
2600 return 0
2601 fi
2602 +
2603 __ebuild_phase pre_pkg_pretend
2604 __ebuild_phase pkg_pretend
2605 - >> "$PORTAGE_BUILDDIR/.pretended" || \
2606 - die "Failed to create $PORTAGE_BUILDDIR/.pretended"
2607 + >> "${PORTAGE_BUILDDIR}/.pretended" || \
2608 + die "Failed to create ${PORTAGE_BUILDDIR}/.pretended"
2609 __ebuild_phase post_pkg_pretend
2610 }
2611
2612 __dyn_setup() {
2613 - if [[ -e $PORTAGE_BUILDDIR/.setuped ]] ; then
2614 - __vecho ">>> It appears that '$PF' is already setup; skipping."
2615 - __vecho ">>> Remove '$PORTAGE_BUILDDIR/.setuped' to force setup."
2616 + if [[ -e ${PORTAGE_BUILDDIR}/.setuped ]] ; then
2617 + __vecho ">>> It appears that '${PF}' is already setup; skipping."
2618 + __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.setuped' to force setup."
2619 return 0
2620 fi
2621 +
2622 __ebuild_phase pre_pkg_setup
2623 __ebuild_phase pkg_setup
2624 - >> "$PORTAGE_BUILDDIR/.setuped" || \
2625 - die "Failed to create $PORTAGE_BUILDDIR/.setuped"
2626 + >> "${PORTAGE_BUILDDIR}/.setuped" || \
2627 + die "Failed to create ${PORTAGE_BUILDDIR}/.setuped"
2628 __ebuild_phase post_pkg_setup
2629 }
2630
2631 @@ -252,15 +259,17 @@ __dyn_unpack() {
2632 __vecho ">>> WORKDIR is up-to-date, keeping..."
2633 return 0
2634 fi
2635 +
2636 if [[ ! -d "${WORKDIR}" ]]; then
2637 install -m${PORTAGE_WORKDIR_MODE:-0700} -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'"
2638 fi
2639 +
2640 cd "${WORKDIR}" || die "Directory change failed: \`cd '${WORKDIR}'\`"
2641 __ebuild_phase pre_src_unpack
2642 __vecho ">>> Unpacking source..."
2643 __ebuild_phase src_unpack
2644 - >> "$PORTAGE_BUILDDIR/.unpacked" || \
2645 - die "Failed to create $PORTAGE_BUILDDIR/.unpacked"
2646 + >> "${PORTAGE_BUILDDIR}/.unpacked" || \
2647 + die "Failed to create ${PORTAGE_BUILDDIR}/.unpacked"
2648 __vecho ">>> Source unpacked in ${WORKDIR}"
2649 __ebuild_phase post_src_unpack
2650 }
2651 @@ -272,7 +281,8 @@ __dyn_clean() {
2652 elif [[ ! -d "${PORTAGE_BUILDDIR}" ]]; then
2653 return 0
2654 fi
2655 - if has chflags $FEATURES ; then
2656 +
2657 + if has chflags ${FEATURES} ; then
2658 chflags -R noschg,nouchg,nosappnd,nouappnd "${PORTAGE_BUILDDIR}"
2659 chflags -R nosunlnk,nouunlnk "${PORTAGE_BUILDDIR}" 2>/dev/null
2660 fi
2661 @@ -286,16 +296,16 @@ __dyn_clean() {
2662 "${PORTAGE_BUILDDIR}/empty"
2663 rm -f "${PORTAGE_BUILDDIR}/.installed"
2664
2665 - if [[ $EMERGE_FROM = binary ]] || \
2666 - ! has keeptemp $FEATURES && ! has keepwork $FEATURES ; then
2667 + if [[ ${EMERGE_FROM} = binary ]] || \
2668 + ! has keeptemp ${FEATURES} && ! has keepwork ${FEATURES} ; then
2669 rm -rf "${T}"
2670 fi
2671
2672 - if [[ $EMERGE_FROM = binary ]] || ! has keepwork $FEATURES; then
2673 - rm -f "$PORTAGE_BUILDDIR"/.{ebuild_changed,logid,pretended,setuped,unpacked,prepared} \
2674 - "$PORTAGE_BUILDDIR"/.{configured,compiled,tested,packaged,instprepped} \
2675 - "$PORTAGE_BUILDDIR"/.die_hooks \
2676 - "$PORTAGE_BUILDDIR"/.exit_status
2677 + if [[ ${EMERGE_FROM} = binary ]] || ! has keepwork ${FEATURES} ; then
2678 + rm -f "${PORTAGE_BUILDDIR}"/.{ebuild_changed,logid,pretended,setuped,unpacked,prepared} \
2679 + "${PORTAGE_BUILDDIR}"/.{configured,compiled,tested,packaged,instprepped} \
2680 + "${PORTAGE_BUILDDIR}"/.die_hooks \
2681 + "${PORTAGE_BUILDDIR}"/.exit_status
2682
2683 rm -rf "${PORTAGE_BUILDDIR}/build-info" \
2684 "${PORTAGE_BUILDDIR}/.ipc"
2685 @@ -304,14 +314,14 @@ __dyn_clean() {
2686 fi
2687
2688 if [[ -f "${PORTAGE_BUILDDIR}/.unpacked" ]]; then
2689 - find "${PORTAGE_BUILDDIR}" -type d ! -regex "^${WORKDIR}" | sort -r | tr "\n" "\0" | $XARGS -0 rmdir &>/dev/null
2690 + find "${PORTAGE_BUILDDIR}" -type d ! -regex "^${WORKDIR}" | sort -r | tr "\n" "\0" | ${XARGS} -0 rmdir &>/dev/null
2691 fi
2692
2693 - # do not bind this to doebuild defined DISTDIR; don't trust doebuild, and if mistakes are made it'll
2694 + # Do not bind this to doebuild defined DISTDIR; don't trust doebuild, and if mistakes are made it'll
2695 # result in it wiping the users distfiles directory (bad).
2696 rm -rf "${PORTAGE_BUILDDIR}/distdir"
2697
2698 - rmdir "$PORTAGE_BUILDDIR" 2>/dev/null
2699 + rmdir "${PORTAGE_BUILDDIR}" 2>/dev/null
2700
2701 true
2702 }
2703 @@ -324,22 +334,23 @@ __abort_handler() {
2704 msg="${EBUILD}: ${1} failed; exiting."
2705 fi
2706 echo
2707 - echo "$msg"
2708 + echo "${msg}"
2709 echo
2710 eval ${3}
2711 - #unset signal handler
2712 +
2713 + # Unset signal handler
2714 trap - SIGINT SIGQUIT
2715 }
2716
2717 __abort_prepare() {
2718 __abort_handler src_prepare $1
2719 - rm -f "$PORTAGE_BUILDDIR/.prepared"
2720 + rm -f "${PORTAGE_BUILDDIR}/.prepared"
2721 exit 1
2722 }
2723
2724 __abort_configure() {
2725 __abort_handler src_configure $1
2726 - rm -f "$PORTAGE_BUILDDIR/.configured"
2727 + rm -f "${PORTAGE_BUILDDIR}/.configured"
2728 exit 1
2729 }
2730
2731 @@ -373,13 +384,13 @@ __has_phase_defined_up_to() {
2732
2733 __dyn_prepare() {
2734
2735 - if [[ -e $PORTAGE_BUILDDIR/.prepared ]] ; then
2736 - __vecho ">>> It appears that '$PF' is already prepared; skipping."
2737 - __vecho ">>> Remove '$PORTAGE_BUILDDIR/.prepared' to force prepare."
2738 + if [[ -e ${PORTAGE_BUILDDIR}/.prepared ]] ; then
2739 + __vecho ">>> It appears that '${PF}' is already prepared; skipping."
2740 + __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.prepared' to force prepare."
2741 return 0
2742 fi
2743
2744 - if [[ -d $S ]] ; then
2745 + if [[ -d ${S} ]] ; then
2746 cd "${S}"
2747 elif ___eapi_has_S_WORKDIR_fallback; then
2748 cd "${WORKDIR}"
2749 @@ -392,7 +403,7 @@ __dyn_prepare() {
2750 trap __abort_prepare SIGINT SIGQUIT
2751
2752 __ebuild_phase pre_src_prepare
2753 - __vecho ">>> Preparing source in $PWD ..."
2754 + __vecho ">>> Preparing source in ${PWD} ..."
2755 __ebuild_phase src_prepare
2756
2757 # keep path in eapply_user in sync!
2758 @@ -400,8 +411,8 @@ __dyn_prepare() {
2759 die "eapply_user (or default) must be called in src_prepare()!"
2760 fi
2761
2762 - >> "$PORTAGE_BUILDDIR/.prepared" || \
2763 - die "Failed to create $PORTAGE_BUILDDIR/.prepared"
2764 + >> "${PORTAGE_BUILDDIR}/.prepared" || \
2765 + die "Failed to create ${PORTAGE_BUILDDIR}/.prepared"
2766 __vecho ">>> Source prepared."
2767 __ebuild_phase post_src_prepare
2768
2769 @@ -409,14 +420,13 @@ __dyn_prepare() {
2770 }
2771
2772 __dyn_configure() {
2773 -
2774 - if [[ -e $PORTAGE_BUILDDIR/.configured ]] ; then
2775 - __vecho ">>> It appears that '$PF' is already configured; skipping."
2776 - __vecho ">>> Remove '$PORTAGE_BUILDDIR/.configured' to force configuration."
2777 + if [[ -e ${PORTAGE_BUILDDIR}/.configured ]] ; then
2778 + __vecho ">>> It appears that '${PF}' is already configured; skipping."
2779 + __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.configured' to force configuration."
2780 return 0
2781 fi
2782
2783 - if [[ -d $S ]] ; then
2784 + if [[ -d ${S} ]] ; then
2785 cd "${S}"
2786 elif ___eapi_has_S_WORKDIR_fallback; then
2787 cd "${WORKDIR}"
2788 @@ -430,10 +440,10 @@ __dyn_configure() {
2789
2790 __ebuild_phase pre_src_configure
2791
2792 - __vecho ">>> Configuring source in $PWD ..."
2793 + __vecho ">>> Configuring source in ${PWD} ..."
2794 __ebuild_phase src_configure
2795 - >> "$PORTAGE_BUILDDIR/.configured" || \
2796 - die "Failed to create $PORTAGE_BUILDDIR/.configured"
2797 + >> "${PORTAGE_BUILDDIR}/.configured" || \
2798 + die "Failed to create ${PORTAGE_BUILDDIR}/.configured"
2799 __vecho ">>> Source configured."
2800
2801 __ebuild_phase post_src_configure
2802 @@ -442,14 +452,13 @@ __dyn_configure() {
2803 }
2804
2805 __dyn_compile() {
2806 -
2807 - if [[ -e $PORTAGE_BUILDDIR/.compiled ]] ; then
2808 + if [[ -e ${PORTAGE_BUILDDIR}/.compiled ]] ; then
2809 __vecho ">>> It appears that '${PF}' is already compiled; skipping."
2810 - __vecho ">>> Remove '$PORTAGE_BUILDDIR/.compiled' to force compilation."
2811 + __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.compiled' to force compilation."
2812 return 0
2813 fi
2814
2815 - if [[ -d $S ]] ; then
2816 + if [[ -d ${S} ]] ; then
2817 cd "${S}"
2818 elif ___eapi_has_S_WORKDIR_fallback; then
2819 cd "${WORKDIR}"
2820 @@ -463,10 +472,10 @@ __dyn_compile() {
2821
2822 __ebuild_phase pre_src_compile
2823
2824 - __vecho ">>> Compiling source in $PWD ..."
2825 + __vecho ">>> Compiling source in ${PWD} ..."
2826 __ebuild_phase src_compile
2827 - >> "$PORTAGE_BUILDDIR/.compiled" || \
2828 - die "Failed to create $PORTAGE_BUILDDIR/.compiled"
2829 + >> "${PORTAGE_BUILDDIR}/.compiled" || \
2830 + die "Failed to create ${PORTAGE_BUILDDIR}/.compiled"
2831 __vecho ">>> Source compiled."
2832
2833 __ebuild_phase post_src_compile
2834 @@ -475,8 +484,7 @@ __dyn_compile() {
2835 }
2836
2837 __dyn_test() {
2838 -
2839 - if [[ -e $PORTAGE_BUILDDIR/.tested ]] ; then
2840 + if [[ -e ${PORTAGE_BUILDDIR}/.tested ]] ; then
2841 __vecho ">>> It appears that ${PN} has already been tested; skipping."
2842 __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.tested' to force test."
2843 return
2844 @@ -513,8 +521,8 @@ __dyn_test() {
2845 __ebuild_phase src_test
2846 __vecho ">>> Completed testing ${CATEGORY}/${PF}"
2847
2848 - >> "$PORTAGE_BUILDDIR/.tested" || \
2849 - die "Failed to create $PORTAGE_BUILDDIR/.tested"
2850 + >> "${PORTAGE_BUILDDIR}/.tested" || \
2851 + die "Failed to create ${PORTAGE_BUILDDIR}/.tested"
2852 __ebuild_phase post_src_test
2853 SANDBOX_PREDICT=${save_sp}
2854 fi
2855 @@ -523,10 +531,11 @@ __dyn_test() {
2856 }
2857
2858 __dyn_install() {
2859 - [[ -z "$PORTAGE_BUILDDIR" ]] && die "${FUNCNAME}: PORTAGE_BUILDDIR is unset"
2860 - if has noauto $FEATURES ; then
2861 + [[ -z "${PORTAGE_BUILDDIR}" ]] && die "${FUNCNAME}: PORTAGE_BUILDDIR is unset"
2862 +
2863 + if has noauto ${FEATURES} ; then
2864 rm -f "${PORTAGE_BUILDDIR}/.installed"
2865 - elif [[ -e $PORTAGE_BUILDDIR/.installed ]] ; then
2866 + elif [[ -e ${PORTAGE_BUILDDIR}/.installed ]] ; then
2867 __vecho ">>> It appears that '${PF}' is already installed; skipping."
2868 __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.installed' to force install."
2869 return 0
2870 @@ -537,16 +546,16 @@ __dyn_install() {
2871 # Those variables shouldn't be needed before src_install()
2872 # (QA_PRESTRIPPED is used in prepstrip, others in install-qa-checks)
2873 # and delay in setting them allows us to set them in pkg_setup()
2874 - if [[ -n $QA_PREBUILT ]] ; then
2875 - # these ones support fnmatch patterns
2876 - QA_EXECSTACK+=" $QA_PREBUILT"
2877 - QA_TEXTRELS+=" $QA_PREBUILT"
2878 - QA_WX_LOAD+=" $QA_PREBUILT"
2879 + if [[ -n ${QA_PREBUILT} ]] ; then
2880 + # These ones support fnmatch patterns
2881 + QA_EXECSTACK+=" ${QA_PREBUILT}"
2882 + QA_TEXTRELS+=" ${QA_PREBUILT}"
2883 + QA_WX_LOAD+=" ${QA_PREBUILT}"
2884
2885 - # these ones support regular expressions, so translate
2886 + # These ones support regular expressions, so translate
2887 # fnmatch patterns to regular expressions
2888 for x in QA_DT_NEEDED QA_FLAGS_IGNORED QA_PRESTRIPPED QA_SONAME ; do
2889 - if [[ $(declare -p $x 2>/dev/null) = declare\ -a* ]] ; then
2890 + if [[ $(declare -p ${x} 2>/dev/null) = declare\ -a* ]] ; then
2891 eval "${x}=(\"\${${x}[@]}\" ${QA_PREBUILT//\*/.*})"
2892 else
2893 eval "${x}+=\" ${QA_PREBUILT//\*/.*}\""
2894 @@ -555,9 +564,10 @@ __dyn_install() {
2895
2896 unset x
2897 fi
2898 +
2899 # This needs to be exported since prepstrip is a separate shell script.
2900 - [[ -n $QA_PRESTRIPPED ]] && export QA_PRESTRIPPED
2901 - eval "[[ -n \$QA_PRESTRIPPED_${ARCH/-/_} ]] && \
2902 + [[ -n ${QA_PRESTRIPPED} ]] && export QA_PRESTRIPPED
2903 + eval "[[ -n \${QA_PRESTRIPPED_${ARCH/-/_}} ]] && \
2904 export QA_PRESTRIPPED_${ARCH/-/_}"
2905
2906 __ebuild_phase pre_src_install
2907 @@ -571,7 +581,7 @@ __dyn_install() {
2908 mkdir -p "${_x}"
2909 unset _x
2910
2911 - if [[ -d $S ]] ; then
2912 + if [[ -d ${S} ]] ; then
2913 cd "${S}"
2914 elif ___eapi_has_S_WORKDIR_fallback; then
2915 cd "${WORKDIR}"
2916 @@ -583,8 +593,9 @@ __dyn_install() {
2917
2918 __vecho
2919 __vecho ">>> Install ${CATEGORY}/${PF} into ${D}"
2920 - #our custom version of libtool uses $S and $D to fix
2921 - #invalid paths in .la files
2922 +
2923 + # Our custom version of libtool uses ${S} and ${D} to fix
2924 + # invalid paths in .la files
2925 export S D
2926
2927 # Reset exeinto(), docinto(), insinto(), and into() state variables
2928 @@ -601,8 +612,8 @@ __dyn_install() {
2929 export _E_DOCDESTTREE_=""
2930
2931 __ebuild_phase src_install
2932 - >> "$PORTAGE_BUILDDIR/.installed" || \
2933 - die "Failed to create $PORTAGE_BUILDDIR/.installed"
2934 + >> "${PORTAGE_BUILDDIR}/.installed" || \
2935 + die "Failed to create ${PORTAGE_BUILDDIR}/.installed"
2936 __vecho ">>> Completed installing ${CATEGORY}/${PF} into ${D}"
2937 __vecho
2938 __ebuild_phase post_src_install
2939 @@ -675,11 +686,11 @@ __dyn_install() {
2940 PKG_INSTALL_MASK; do
2941
2942 x=$(echo -n ${!f})
2943 - [[ -n $x ]] && echo "$x" > $f
2944 + [[ -n ${x} ]] && echo "${x}" > ${f}
2945 done
2946 # whitespace preserved
2947 for f in QA_AM_MAINTAINER_MODE ; do
2948 - [[ -n ${!f} ]] && echo "${!f}" > $f
2949 + [[ -n ${!f} ]] && echo "${!f}" > ${f}
2950 done
2951 echo "${USE}" > USE
2952 echo "${EAPI:-0}" > EAPI
2953 @@ -708,8 +719,7 @@ __dyn_install() {
2954
2955 cp "${EBUILD}" "${PF}.ebuild"
2956 [[ -n "${PORTAGE_REPO_NAME}" ]] && echo "${PORTAGE_REPO_NAME}" > repository
2957 - if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}
2958 - then
2959 + if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}; then
2960 >> DEBUGBUILD
2961 fi
2962 trap - SIGINT SIGQUIT
2963 @@ -718,7 +728,7 @@ __dyn_install() {
2964 __dyn_help() {
2965 echo
2966 echo "Portage"
2967 - echo "Copyright 1999-2010 Gentoo Foundation"
2968 + echo "Copyright 1999-2022 Gentoo Authors"
2969 echo
2970 echo "How to use the ebuild command:"
2971 echo
2972 @@ -759,19 +769,18 @@ __dyn_help() {
2973 echo " category : ${CATEGORY}"
2974 echo " description : ${DESCRIPTION}"
2975 echo " system : ${CHOST}"
2976 - echo " c flags : ${CFLAGS}"
2977 - echo " c++ flags : ${CXXFLAGS}"
2978 + echo " C flags : ${CFLAGS}"
2979 + echo " C++ flags : ${CXXFLAGS}"
2980 echo " make flags : ${MAKEOPTS}"
2981 echo -n " build mode : "
2982 - if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}
2983 - then
2984 + if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}; then
2985 echo "debug (large)"
2986 else
2987 echo "production (stripped)"
2988 fi
2989 echo " merge to : ${ROOT}"
2990 echo
2991 - if [[ -n "$USE" ]]; then
2992 + if [[ -n "${USE}" ]]; then
2993 echo "Additionally, support for the following optional features will be enabled:"
2994 echo
2995 echo " ${USE}"
2996 @@ -788,7 +797,7 @@ __ebuild_arg_to_phase() {
2997 local arg=$1
2998 local phase_func=""
2999
3000 - case "$arg" in
3001 + case "${arg}" in
3002 pretend)
3003 ___eapi_has_pkg_pretend && \
3004 phase_func=pkg_pretend
3005 @@ -833,13 +842,14 @@ __ebuild_arg_to_phase() {
3006 ;;
3007 esac
3008
3009 - [[ -z $phase_func ]] && return 1
3010 - echo "$phase_func"
3011 + [[ -z ${phase_func} ]] && return 1
3012 + echo "${phase_func}"
3013 return 0
3014 }
3015
3016 __ebuild_phase_funcs() {
3017 [[ $# -ne 2 ]] && die "expected exactly 2 args, got $#: $*"
3018 +
3019 local eapi=$1
3020 local phase_func=$2
3021 local all_phases="src_compile pkg_config src_configure pkg_info
3022 @@ -860,16 +870,16 @@ __ebuild_phase_funcs() {
3023 default_${phase_func}
3024 }"
3025
3026 - case "$eapi" in
3027 + case "${eapi}" in
3028 0|1) # EAPIs not supporting 'default'
3029
3030 for x in pkg_nofetch src_unpack src_test ; do
3031 - declare -F $x >/dev/null || \
3032 - eval "$x() { __eapi0_$x; }"
3033 + declare -F ${x} >/dev/null || \
3034 + eval "$x() { __eapi0_${x}; }"
3035 done
3036
3037 if ! declare -F src_compile >/dev/null ; then
3038 - case "$eapi" in
3039 + case "${eapi}" in
3040 0)
3041 src_compile() { __eapi0_src_compile; }
3042 ;;
3043 @@ -942,43 +952,42 @@ __ebuild_phase_funcs() {
3044 }
3045
3046 __ebuild_main() {
3047 -
3048 # Subshell/helper die support (must export for the die helper).
3049 # Since this function is typically executed in a subshell,
3050 - # setup EBUILD_MASTER_PID to refer to the current $BASHPID,
3051 + # setup EBUILD_MASTER_PID to refer to the current ${BASHPID},
3052 # which seems to give the best results when further
3053 # nested subshells call die.
3054 export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)}
3055 trap 'exit 1' SIGTERM
3056
3057 - #a reasonable default for $S
3058 + # A reasonable default for ${S}
3059 [[ -z ${S} ]] && export S=${WORKDIR}/${P}
3060
3061 - if [[ -s $SANDBOX_LOG ]] ; then
3062 + if [[ -s ${SANDBOX_LOG} ]] ; then
3063 # We use SANDBOX_LOG to check for sandbox violations,
3064 # so we ensure that there can't be a stale log to
3065 # interfere with our logic.
3066 local x=
3067 - if [[ -n $SANDBOX_ON ]] ; then
3068 - x=$SANDBOX_ON
3069 + if [[ -n ${SANDBOX_ON} ]] ; then
3070 + x=${SANDBOX_ON}
3071 export SANDBOX_ON=0
3072 fi
3073
3074 - rm -f "$SANDBOX_LOG" || \
3075 - die "failed to remove stale sandbox log: '$SANDBOX_LOG'"
3076 + rm -f "${SANDBOX_LOG}" || \
3077 + die "failed to remove stale sandbox log: '${SANDBOX_LOG}'"
3078
3079 - if [[ -n $x ]] ; then
3080 - export SANDBOX_ON=$x
3081 + if [[ -n ${x} ]] ; then
3082 + export SANDBOX_ON=${x}
3083 fi
3084 unset x
3085 fi
3086
3087 # Force configure scripts that automatically detect ccache to
3088 # respect FEATURES="-ccache".
3089 - has ccache $FEATURES || export CCACHE_DISABLE=1
3090 + has ccache ${FEATURES} || export CCACHE_DISABLE=1
3091
3092 - local ___phase_func=$(__ebuild_arg_to_phase "$EBUILD_PHASE")
3093 - [[ -n ${___phase_func} ]] && __ebuild_phase_funcs "$EAPI" "${___phase_func}"
3094 + local ___phase_func=$(__ebuild_arg_to_phase "${EBUILD_PHASE}")
3095 + [[ -n ${___phase_func} ]] && __ebuild_phase_funcs "${EAPI}" "${___phase_func}"
3096
3097 __source_all_bashrcs
3098
3099 @@ -999,7 +1008,7 @@ __ebuild_main() {
3100 __ebuild_phase_with_hooks pkg_${1}
3101 set +x
3102 fi
3103 - if [[ -n $PORTAGE_UPDATE_ENV ]] ; then
3104 + if [[ -n ${PORTAGE_UPDATE_ENV} ]] ; then
3105 # Update environment.bz2 in case installation phases
3106 # need to pass some variables to uninstallation phases.
3107 # Use safe cwd, avoiding unsafe import for bug #469338.
3108 @@ -1007,7 +1016,7 @@ __ebuild_main() {
3109 __save_ebuild_env --exclude-init-phases | \
3110 __filter_readonly_variables --filter-path \
3111 --filter-sandbox --allow-extra-vars \
3112 - | ${PORTAGE_BZIP2_COMMAND} -c -f9 > "$PORTAGE_UPDATE_ENV"
3113 + | ${PORTAGE_BZIP2_COMMAND} -c -f9 > "${PORTAGE_UPDATE_ENV}"
3114 assert "__save_ebuild_env failed"
3115 fi
3116 ;;
3117 @@ -1024,16 +1033,16 @@ __ebuild_main() {
3118 local x
3119 for x in ASFLAGS CCACHE_DIR CCACHE_SIZE \
3120 CFLAGS CXXFLAGS LDFLAGS LIBCFLAGS LIBCXXFLAGS ; do
3121 - [[ ${!x+set} = set ]] && export $x
3122 + [[ ${!x+set} = set ]] && export ${x}
3123 done
3124 unset x
3125
3126 - has distcc $FEATURES && [[ -n $DISTCC_DIR ]] && \
3127 - [[ ${SANDBOX_WRITE/$DISTCC_DIR} = $SANDBOX_WRITE ]] && \
3128 - addwrite "$DISTCC_DIR"
3129 + has distcc ${FEATURES} && [[ -n ${DISTCC_DIR} ]] && \
3130 + [[ ${SANDBOX_WRITE/${DISTCC_DIR}} = ${SANDBOX_WRITE} ]] && \
3131 + addwrite "${DISTCC_DIR}"
3132
3133 - if has noauto $FEATURES && \
3134 - [[ ! -f $PORTAGE_BUILDDIR/.unpacked ]] ; then
3135 + if has noauto ${FEATURES} && \
3136 + [[ ! -f ${PORTAGE_BUILDDIR}/.unpacked ]] ; then
3137 echo
3138 echo "!!! We apparently haven't unpacked..." \
3139 "This is probably not what you"
3140 @@ -1046,14 +1055,14 @@ __ebuild_main() {
3141 sleep 5
3142 fi
3143
3144 - cd "$PORTAGE_BUILDDIR"
3145 + cd "${PORTAGE_BUILDDIR}"
3146 if [[ ! -d build-info ]]; then
3147 mkdir build-info
3148 - cp "$EBUILD" "build-info/$PF.ebuild"
3149 + cp "${EBUILD}" "build-info/${PF}.ebuild"
3150 fi
3151
3152 - #our custom version of libtool uses $S and $D to fix
3153 - #invalid paths in .la files
3154 + # Our custom version of libtool uses ${S} and ${D} to fix
3155 + # invalid paths in .la files
3156 export S D
3157
3158 ;;
3159 @@ -1069,9 +1078,9 @@ __ebuild_main() {
3160 export SANDBOX_ON="0"
3161 ;;
3162 help|pretend|setup)
3163 - #pkg_setup needs to be out of the sandbox for tmp file creation;
3164 - #for example, awking and piping a file in /tmp requires a temp file to be created
3165 - #in /etc. If pkg_setup is in the sandbox, both our lilo and apache ebuilds break.
3166 + # pkg_setup needs to be out of the sandbox for tmp file creation;
3167 + # for example, awking and piping a file in /tmp requires a temp file to be created
3168 + # in /etc. If pkg_setup is in the sandbox, both our lilo and apache ebuilds break.
3169 export SANDBOX_ON="0"
3170 if [[ "${PORTAGE_DEBUG}" != "1" || "${-/x/}" != "$-" ]]; then
3171 __dyn_${1}
3172 @@ -1095,17 +1104,21 @@ __ebuild_main() {
3173 # Save the env only for relevant phases.
3174 if ! has "${1}" clean help info nofetch ; then
3175 umask 002
3176 +
3177 # Use safe cwd, avoiding unsafe import for bug #469338.
3178 cd "${PORTAGE_PYM_PATH}"
3179 __save_ebuild_env | __filter_readonly_variables \
3180 - --filter-features > "$T/environment"
3181 + --filter-features > "${T}/environment"
3182 assert "__save_ebuild_env failed"
3183 - chgrp "${PORTAGE_GRPNAME:-portage}" "$T/environment"
3184 - chmod g+w "$T/environment"
3185 +
3186 + chgrp "${PORTAGE_GRPNAME:-portage}" "${T}/environment"
3187 + chmod g+w "${T}/environment"
3188 fi
3189 - [[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE"
3190 - if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
3191 - [[ ! -s $SANDBOX_LOG ]]
3192 - "$PORTAGE_BIN_PATH"/ebuild-ipc exit $?
3193 +
3194 + [[ -n ${PORTAGE_EBUILD_EXIT_FILE} ]] && > "${PORTAGE_EBUILD_EXIT_FILE}"
3195 + if [[ -n ${PORTAGE_IPC_DAEMON} ]] ; then
3196 + [[ ! -s ${SANDBOX_LOG} ]]
3197 +
3198 + "${PORTAGE_BIN_PATH}"/ebuild-ipc exit $?
3199 fi
3200 }
3201
3202 diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
3203 index 481170ebb..0f8973f59 100644
3204 --- a/bin/phase-helpers.sh
3205 +++ b/bin/phase-helpers.sh
3206 @@ -16,7 +16,7 @@ export EXEOPTIONS="-m0755"
3207 export LIBOPTIONS="-m0644"
3208 export DIROPTIONS="-m0755"
3209 export MOPREFIX=${PN}
3210 -# Do not compress files which are smaller than this (in bytes). #169260
3211 +# Do not compress files which are smaller than this (in bytes), bug #169260
3212 export PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
3213 declare -a PORTAGE_DOCOMPRESS=( /usr/share/{doc,info,man} )
3214 declare -a PORTAGE_DOCOMPRESS_SKIP=( /usr/share/doc/${PF}/html )
3215 @@ -34,10 +34,11 @@ into() {
3216 fi
3217 if [[ ! -d "${ED%/}/${_E_DESTTREE_#/}" ]]; then
3218 install -d "${ED%/}/${_E_DESTTREE_#/}"
3219 +
3220 local ret=$?
3221 - if [[ $ret -ne 0 ]] ; then
3222 + if [[ ${ret} -ne 0 ]] ; then
3223 __helpers_die "${FUNCNAME[0]} failed"
3224 - return $ret
3225 + return ${ret}
3226 fi
3227 fi
3228 fi
3229 @@ -48,19 +49,20 @@ into() {
3230 }
3231
3232 insinto() {
3233 - if [[ "$1" == "/" ]]; then
3234 + if [[ "${1}" == "/" ]]; then
3235 export _E_INSDESTTREE_=""
3236 else
3237 - export _E_INSDESTTREE_=$1
3238 + export _E_INSDESTTREE_=${1}
3239 if ! ___eapi_has_prefix_variables; then
3240 local ED=${D}
3241 fi
3242 if [[ ! -d "${ED%/}/${_E_INSDESTTREE_#/}" ]]; then
3243 install -d "${ED%/}/${_E_INSDESTTREE_#/}"
3244 +
3245 local ret=$?
3246 - if [[ $ret -ne 0 ]] ; then
3247 + if [[ ${ret} -ne 0 ]] ; then
3248 __helpers_die "${FUNCNAME[0]} failed"
3249 - return $ret
3250 + return ${ret}
3251 fi
3252 fi
3253 fi
3254 @@ -71,38 +73,39 @@ insinto() {
3255 }
3256
3257 exeinto() {
3258 - if [[ "$1" == "/" ]]; then
3259 + if [[ "${1}" == "/" ]]; then
3260 export _E_EXEDESTTREE_=""
3261 else
3262 - export _E_EXEDESTTREE_="$1"
3263 + export _E_EXEDESTTREE_="${1}"
3264 if ! ___eapi_has_prefix_variables; then
3265 local ED=${D}
3266 fi
3267 if [[ ! -d "${ED%/}/${_E_EXEDESTTREE_#/}" ]]; then
3268 install -d "${ED%/}/${_E_EXEDESTTREE_#/}"
3269 +
3270 local ret=$?
3271 - if [[ $ret -ne 0 ]] ; then
3272 + if [[ ${ret} -ne 0 ]] ; then
3273 __helpers_die "${FUNCNAME[0]} failed"
3274 - return $ret
3275 + return ${ret}
3276 fi
3277 fi
3278 fi
3279 }
3280
3281 docinto() {
3282 - if [[ "$1" == "/" ]]; then
3283 + if [[ "${1}" == "/" ]]; then
3284 export _E_DOCDESTTREE_=""
3285 else
3286 - export _E_DOCDESTTREE_="$1"
3287 + export _E_DOCDESTTREE_="${1}"
3288 if ! ___eapi_has_prefix_variables; then
3289 local ED=${D}
3290 fi
3291 if [[ ! -d "${ED%/}/usr/share/doc/${PF}/${_E_DOCDESTTREE_#/}" ]]; then
3292 install -d "${ED%/}/usr/share/doc/${PF}/${_E_DOCDESTTREE_#/}"
3293 local ret=$?
3294 - if [[ $ret -ne 0 ]] ; then
3295 + if [[ ${ret} -ne 0 ]] ; then
3296 __helpers_die "${FUNCNAME[0]} failed"
3297 - return $ret
3298 + return ${ret}
3299 fi
3300 fi
3301 fi
3302 @@ -128,7 +131,7 @@ exeopts() {
3303
3304 libopts() {
3305 if ! ___eapi_has_dolib_libopts; then
3306 - die "'${FUNCNAME}' has been banned for EAPI '$EAPI'"
3307 + die "'${FUNCNAME}' has been banned for EAPI '${EAPI}'"
3308 fi
3309
3310 export LIBOPTIONS="$@"
3311 @@ -141,8 +144,9 @@ docompress() {
3312 ___eapi_has_docompress || die "'docompress' not supported in this EAPI"
3313
3314 local f g
3315 - if [[ $1 = "-x" ]]; then
3316 + if [[ ${1} = "-x" ]]; then
3317 shift
3318 +
3319 for f; do
3320 f=$(__strip_duplicate_slashes "${f}"); f=${f%/}
3321 [[ ${f:0:1} = / ]] || f="/${f}"
3322 @@ -229,13 +233,13 @@ use() {
3323 found=1
3324 fi
3325
3326 - if [[ $EBUILD_PHASE = depend ]] ; then
3327 + if [[ ${EBUILD_PHASE} = depend ]] ; then
3328 # TODO: Add a registration interface for eclasses to register
3329 # any number of phase hooks, so that global scope eclass
3330 # initialization can by migrated to phase hooks in new EAPIs.
3331 - # Example: add_phase_hook before pkg_setup $ECLASS_pre_pkg_setup
3332 - #if [[ -n $EAPI ]] && ! has "$EAPI" 0 1 2 3 ; then
3333 - # die "use() called during invalid phase: $EBUILD_PHASE"
3334 + # Example: add_phase_hook before pkg_setup ${ECLASS}_pre_pkg_setup
3335 + #if [[ -n ${EAPI} ]] && ! has "${EAPI}" 0 1 2 3 ; then
3336 + # die "use() called during invalid phase: ${EBUILD_PHASE}"
3337 #fi
3338 true
3339
3340 @@ -251,6 +255,7 @@ use() {
3341 # is not well defined for earlier EAPIs (see bug #449708).
3342 die "USE Flag '${u}' not in IUSE for ${CATEGORY}/${PF}"
3343 fi
3344 +
3345 eqawarn "QA Notice: USE Flag '${u}' not" \
3346 "in IUSE for ${CATEGORY}/${PF}"
3347 fi
3348 @@ -268,7 +273,7 @@ use() {
3349 }
3350
3351 use_with() {
3352 - if [[ -z "$1" ]]; then
3353 + if [[ -z "${1}" ]]; then
3354 echo "!!! use_with() called without a parameter." >&2
3355 echo "!!! use_with <USEFLAG> [<flagname> [value]]" >&2
3356 return 1
3357 @@ -281,7 +286,7 @@ use_with() {
3358 fi
3359 local UWORD=${2:-$1}
3360
3361 - if use $1; then
3362 + if use ${1}; then
3363 echo "--with-${UWORD}${UW_SUFFIX}"
3364 else
3365 echo "--without-${UWORD}"
3366 @@ -290,7 +295,7 @@ use_with() {
3367 }
3368
3369 use_enable() {
3370 - if [[ -z "$1" ]]; then
3371 + if [[ -z "${1}" ]]; then
3372 echo "!!! use_enable() called without a parameter." >&2
3373 echo "!!! use_enable <USEFLAG> [<flagname> [value]]" >&2
3374 return 1
3375 @@ -303,7 +308,7 @@ use_enable() {
3376 fi
3377 local UWORD=${2:-$1}
3378
3379 - if use $1; then
3380 + if use ${1}; then
3381 echo "--enable-${UWORD}${UE_SUFFIX}"
3382 else
3383 echo "--disable-${UWORD}"
3384 @@ -318,6 +323,7 @@ unpack() {
3385 local suffix suffix_insensitive
3386 local myfail
3387 local eapi=${EAPI:-0}
3388 +
3389 [[ -z "$*" ]] && die "Nothing passed to the 'unpack' command"
3390
3391 for x in "$@"; do
3392 @@ -362,12 +368,12 @@ unpack() {
3393 "secondary suffix '${y}' which is unofficially" \
3394 "supported with EAPI '${EAPI}'. Instead use 'tar'."
3395 fi
3396 - $1 -c -- "$srcdir$x" | tar xof -
3397 - __assert_sigpipe_ok "$myfail"
3398 + $1 -c -- "${srcdir}${x}" | tar xof -
3399 + __assert_sigpipe_ok "${myfail}"
3400 else
3401 local cwd_dest=${x##*/}
3402 cwd_dest=${cwd_dest%.*}
3403 - $1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "$myfail"
3404 + $1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "${myfail}"
3405 fi
3406 }
3407
3408 @@ -380,7 +386,7 @@ unpack() {
3409 "suffix '${suffix}' which is unofficially supported" \
3410 "with EAPI '${EAPI}'. Instead use 'tar'."
3411 fi
3412 - tar xof "$srcdir$x" || die "$myfail"
3413 + tar xof "${srcdir}${x}" || die "${myfail}"
3414 ;;
3415 tgz)
3416 if ___eapi_unpack_is_case_sensitive && \
3417 @@ -389,7 +395,7 @@ unpack() {
3418 "suffix '${suffix}' which is unofficially supported" \
3419 "with EAPI '${EAPI}'. Instead use 'tgz'."
3420 fi
3421 - tar xozf "$srcdir$x" || die "$myfail"
3422 + tar xozf "${srcdir}${x}" || die "${myfail}"
3423 ;;
3424 tbz|tbz2)
3425 if ___eapi_unpack_is_case_sensitive && \
3426 @@ -398,8 +404,8 @@ unpack() {
3427 "suffix '${suffix}' which is unofficially supported" \
3428 "with EAPI '${EAPI}'. Instead use 'tbz' or 'tbz2'."
3429 fi
3430 - ${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "$srcdir$x" | tar xof -
3431 - __assert_sigpipe_ok "$myfail"
3432 + ${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "${srcdir}${x}" | tar xof -
3433 + __assert_sigpipe_ok "${myfail}"
3434 ;;
3435 zip|jar)
3436 if ___eapi_unpack_is_case_sensitive && \
3437 @@ -412,7 +418,7 @@ unpack() {
3438 # unzip will interactively prompt under some error conditions,
3439 # as reported in bug #336285
3440 ( set +x ; while true ; do echo n || break ; done ) | \
3441 - unzip -qo "${srcdir}${x}" || die "$myfail"
3442 + unzip -qo "${srcdir}${x}" || die "${myfail}"
3443 ;;
3444 gz|z)
3445 if ___eapi_unpack_is_case_sensitive && \
3446 @@ -438,7 +444,7 @@ unpack() {
3447 my_output="$(7z x -y "${srcdir}${x}")"
3448 if [[ $? -ne 0 ]]; then
3449 echo "${my_output}" >&2
3450 - die "$myfail"
3451 + die "${myfail}"
3452 fi
3453 else
3454 __vecho "unpack ${x}: file format not recognized. Ignoring."
3455 @@ -452,7 +458,7 @@ unpack() {
3456 "with EAPI '${EAPI}'. Instead use 'rar' or 'RAR'."
3457 fi
3458 if ___eapi_unpack_supports_rar; then
3459 - unrar x -idq -o+ "${srcdir}${x}" || die "$myfail"
3460 + unrar x -idq -o+ "${srcdir}${x}" || die "${myfail}"
3461 else
3462 __vecho "unpack ${x}: file format not recognized. Ignoring."
3463 fi
3464 @@ -466,7 +472,7 @@ unpack() {
3465 "Instead use 'LHA', 'LHa', 'lha', or 'lzh'."
3466 fi
3467 if ___eapi_unpack_supports_lha; then
3468 - lha xfq "${srcdir}${x}" || die "$myfail"
3469 + lha xfq "${srcdir}${x}" || die "${myfail}"
3470 else
3471 __vecho "unpack ${x}: file format not recognized. Ignoring."
3472 fi
3473 @@ -478,7 +484,7 @@ unpack() {
3474 "suffix '${suffix}' which is unofficially supported" \
3475 "with EAPI '${EAPI}'. Instead use 'a'."
3476 fi
3477 - ar x "${srcdir}${x}" || die "$myfail"
3478 + ar x "${srcdir}${x}" || die "${myfail}"
3479 ;;
3480 deb)
3481 if ___eapi_unpack_is_case_sensitive && \
3482 @@ -487,6 +493,7 @@ unpack() {
3483 "suffix '${suffix}' which is unofficially supported" \
3484 "with EAPI '${EAPI}'. Instead use 'deb'."
3485 fi
3486 +
3487 # Unpacking .deb archives can not always be done with
3488 # `ar`. For instance on AIX this doesn't work out.
3489 # If `ar` is not the GNU binutils version and we have
3490 @@ -497,24 +504,27 @@ unpack() {
3491 type -P deb2targz > /dev/null; then
3492 y=${x##*/}
3493 local created_symlink=0
3494 - if [[ ! "$srcdir$x" -ef "$y" ]]; then
3495 +
3496 + if [[ ! "${srcdir}${x}" -ef "${y}" ]]; then
3497 # deb2targz always extracts into the same directory as
3498 # the source file, so create a symlink in the current
3499 # working directory if necessary.
3500 - ln -sf "$srcdir$x" "$y" || die "$myfail"
3501 + ln -sf "${srcdir}${x}" "${y}" || die "${myfail}"
3502 created_symlink=1
3503 fi
3504 - deb2targz "$y" || die "$myfail"
3505 - if [[ $created_symlink = 1 ]]; then
3506 +
3507 + deb2targz "${y}" || die "${myfail}"
3508 +
3509 + if [[ ${created_symlink} = 1 ]]; then
3510 # Clean up the symlink so the ebuild
3511 # doesn't inadvertently install it.
3512 - rm -f "$y"
3513 + rm -f "${y}"
3514 fi
3515 mv -f "${y%.deb}".tar.gz data.tar.gz \
3516 || mv -f "${y%.deb}".tar.xz data.tar.xz \
3517 - || die "$myfail"
3518 + || die "${myfail}"
3519 else
3520 - ar x "$srcdir$x" || die "$myfail"
3521 + ar x "${srcdir}${x}" || die "${myfail}"
3522 fi
3523 ;;
3524 lzma)
3525 @@ -547,7 +557,7 @@ unpack() {
3526 "with EAPI '${EAPI}'. Instead use 'txz'."
3527 fi
3528 if ___eapi_unpack_supports_txz; then
3529 - tar xof "$srcdir$x" || die "$myfail"
3530 + tar xof "${srcdir}${x}" || die "${myfail}"
3531 else
3532 __vecho "unpack ${x}: file format not recognized. Ignoring."
3533 fi
3534 @@ -557,6 +567,7 @@ unpack() {
3535 ;;
3536 esac
3537 done
3538 +
3539 # Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_MODE
3540 # should be preserved.
3541 find . -mindepth 1 -maxdepth 1 ! -type l -print0 | \
3542 @@ -580,38 +591,42 @@ econf() {
3543
3544 __hasgq() { __hasg "$@" >/dev/null ; }
3545
3546 - local phase_func=$(__ebuild_arg_to_phase "$EBUILD_PHASE")
3547 - if [[ -n $phase_func ]] ; then
3548 + local phase_func=$(__ebuild_arg_to_phase "${EBUILD_PHASE}")
3549 + if [[ -n ${phase_func} ]] ; then
3550 if ! ___eapi_has_src_configure; then
3551 - [[ $phase_func != src_compile ]] && \
3552 + [[ ${phase_func} != src_compile ]] && \
3553 eqawarn "QA Notice: econf called in" \
3554 - "$phase_func instead of src_compile"
3555 + "${phase_func} instead of src_compile"
3556 else
3557 - [[ $phase_func != src_configure ]] && \
3558 + [[ ${phase_func} != src_configure ]] && \
3559 eqawarn "QA Notice: econf called in" \
3560 - "$phase_func instead of src_configure"
3561 + "${phase_func} instead of src_configure"
3562 fi
3563 fi
3564
3565 : ${ECONF_SOURCE:=.}
3566 if [[ -x "${ECONF_SOURCE}/configure" ]]; then
3567 - if [[ -n $CONFIG_SHELL && \
3568 - "$(head -n1 "$ECONF_SOURCE/configure")" =~ ^'#!'[[:space:]]*/bin/sh([[:space:]]|$) ]] ; then
3569 + if [[ -n ${CONFIG_SHELL} && \
3570 + "$(head -n1 "${ECONF_SOURCE}/configure")" =~ ^'#!'[[:space:]]*/bin/sh([[:space:]]|$) ]] ; then
3571 +
3572 cp -p "${ECONF_SOURCE}/configure" "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" || die
3573 sed -i \
3574 - -e "1s:^#![[:space:]]*/bin/sh:#!$CONFIG_SHELL:" \
3575 + -e "1s:^#![[:space:]]*/bin/sh:#!${CONFIG_SHELL}:" \
3576 "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" \
3577 || die "Substition of shebang in '${ECONF_SOURCE}/configure' failed"
3578 +
3579 # Preserve timestamp, see bug #440304
3580 touch -r "${ECONF_SOURCE}/configure" "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" || die
3581 mv -f "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" "${ECONF_SOURCE}/configure" || die
3582 fi
3583 +
3584 if [[ -e "${EPREFIX}"/usr/share/gnuconfig/ ]]; then
3585 find "${WORKDIR}" -type f '(' \
3586 -name config.guess -o -name config.sub ')' -print0 | \
3587 while read -r -d $'\0' x ; do
3588 __vecho " * econf: updating ${x/${WORKDIR}\/} with ${EPREFIX}/usr/share/gnuconfig/${x##*/}"
3589 - # Make sure we do this atomically incase we're run in parallel. #487478
3590 +
3591 + # Make sure we do this atomically incase we're run in parallel, bug #487478
3592 cp -f "${EPREFIX}"/usr/share/gnuconfig/"${x##*/}" "${x}.${pid}"
3593 mv -f "${x}.${pid}" "${x}"
3594 done
3595 @@ -669,13 +684,17 @@ econf() {
3596 if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
3597 CONF_LIBDIR=${!LIBDIR_VAR}
3598 fi
3599 +
3600 if [[ -n ${CONF_LIBDIR} ]] && ! __hasgq --libdir=\* "$@" ; then
3601 export CONF_PREFIX=$(__hasg --exec-prefix=\* "$@")
3602 [[ -z ${CONF_PREFIX} ]] && CONF_PREFIX=$(__hasg --prefix=\* "$@")
3603 +
3604 : ${CONF_PREFIX:=${EPREFIX}/usr}
3605 CONF_PREFIX=${CONF_PREFIX#*=}
3606 +
3607 [[ ${CONF_PREFIX} != /* ]] && CONF_PREFIX="/${CONF_PREFIX}"
3608 [[ ${CONF_LIBDIR} != /* ]] && CONF_LIBDIR="/${CONF_LIBDIR}"
3609 +
3610 conf_args+=(
3611 --libdir="$(__strip_duplicate_slashes "${CONF_PREFIX}${CONF_LIBDIR}")"
3612 )
3613 @@ -700,12 +719,12 @@ econf() {
3614 __vecho "${ECONF_SOURCE}/configure" "$@"
3615
3616 if ! "${ECONF_SOURCE}/configure" "$@" ; then
3617 -
3618 if [[ -s config.log ]]; then
3619 echo
3620 echo "!!! Please attach the following file when seeking support:"
3621 echo "!!! ${PWD}/config.log"
3622 fi
3623 +
3624 # econf dies unconditionally in EAPIs 0 to 3
3625 ___eapi_helpers_can_die || die "econf failed"
3626 __helpers_die "econf failed"
3627 @@ -720,7 +739,7 @@ econf() {
3628
3629 einstall() {
3630 if ! ___eapi_has_einstall; then
3631 - die "'${FUNCNAME}' has been banned for EAPI '$EAPI'"
3632 + die "'${FUNCNAME}' has been banned for EAPI '${EAPI}'"
3633 exit 1
3634 fi
3635
3636 @@ -729,11 +748,13 @@ einstall() {
3637 if ! ___eapi_has_prefix_variables; then
3638 local ED=${D}
3639 fi
3640 +
3641 LIBDIR_VAR="LIBDIR_${ABI}"
3642 if [[ -n "${ABI}" && -n "${!LIBDIR_VAR}" ]]; then
3643 CONF_LIBDIR="${!LIBDIR_VAR}"
3644 fi
3645 unset LIBDIR_VAR
3646 +
3647 if [[ -n "${CONF_LIBDIR}" && "${CONF_PREFIX:+set}" = set ]]; then
3648 EI_DESTLIBDIR="${D%/}/${CONF_PREFIX}/${CONF_LIBDIR}"
3649 EI_DESTLIBDIR="$(__strip_duplicate_slashes "${EI_DESTLIBDIR}")"
3650 @@ -753,6 +774,7 @@ einstall() {
3651 ${MAKEOPTS} -j1 \
3652 "$@" ${EXTRA_EMAKE} install
3653 fi
3654 +
3655 if ! ${MAKE:-make} prefix="${ED%/}/usr" \
3656 datadir="${ED%/}/usr/share" \
3657 infodir="${ED%/}/usr/share/info" \
3658 @@ -803,13 +825,14 @@ __eapi0_src_test() {
3659 if ___eapi_default_src_test_disables_parallel_jobs; then
3660 internal_opts+=" -j1"
3661 fi
3662 - if $emake_cmd ${internal_opts} check -n &> /dev/null; then
3663 +
3664 + if ${emake_cmd} ${internal_opts} check -n &> /dev/null; then
3665 __vecho "${emake_cmd} ${internal_opts} check" >&2
3666 - $emake_cmd ${internal_opts} check || \
3667 + ${emake_cmd} ${internal_opts} check || \
3668 die "Make check failed. See above for details."
3669 - elif $emake_cmd ${internal_opts} test -n &> /dev/null; then
3670 + elif ${emake_cmd} ${internal_opts} test -n &> /dev/null; then
3671 __vecho "${emake_cmd} ${internal_opts} test" >&2
3672 - $emake_cmd ${internal_opts} test || \
3673 + ${emake_cmd} ${internal_opts} test || \
3674 die "Make test failed. See above for details."
3675 fi
3676 }
3677 @@ -904,6 +927,7 @@ ___best_version_and_has_version_common() {
3678 if ! ___eapi_best_version_and_has_version_support_--host-root; then
3679 die "${FUNCNAME[1]}: option ${root_arg} is not supported with EAPI ${EAPI}"
3680 fi
3681 +
3682 if ___eapi_has_prefix_variables; then
3683 # Since portageq requires the root argument be consistent
3684 # with EPREFIX, ensure consistency here (bug #655414).
3685 @@ -936,13 +960,15 @@ ___best_version_and_has_version_common() {
3686 fi ;;
3687 esac
3688
3689 - if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
3690 + if [[ -n ${PORTAGE_IPC_DAEMON} ]] ; then
3691 cmd+=("${PORTAGE_BIN_PATH}"/ebuild-ipc "${FUNCNAME[1]}" "${root}" "${atom}")
3692 else
3693 cmd+=("${PORTAGE_BIN_PATH}"/ebuild-helpers/portageq "${FUNCNAME[1]}" "${root}" "${atom}")
3694 fi
3695 +
3696 "${cmd[@]}"
3697 local retval=$?
3698 +
3699 case "${retval}" in
3700 0|1)
3701 return ${retval}
3702 @@ -1040,6 +1066,7 @@ if ___eapi_has_eapply; then
3703 -p1 -f -g0 --no-backup-if-mismatch
3704 "${patch_options[@]}"
3705 )
3706 +
3707 # Try applying with -F0 first, output a verbose warning
3708 # if fuzz factor is necessary
3709 if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 \
3710 @@ -1056,7 +1083,7 @@ if ___eapi_has_eapply; then
3711
3712 local patch_options=() files=()
3713 local i found_doublehyphen
3714 - # first, try to split on --
3715 + # First, try to split on --
3716 for (( i = 1; i <= ${#@}; ++i )); do
3717 if [[ ${@:i:1} == -- ]]; then
3718 patch_options=( "${@:1:i-1}" )
3719 @@ -1066,7 +1093,7 @@ if ___eapi_has_eapply; then
3720 fi
3721 done
3722
3723 - # then, try to split on first non-option
3724 + # Then, try to split on first non-option
3725 if [[ -z ${found_doublehyphen} ]]; then
3726 for (( i = 1; i <= ${#@}; ++i )); do
3727 if [[ ${@:i:1} != -* ]]; then
3728 @@ -1076,7 +1103,7 @@ if ___eapi_has_eapply; then
3729 fi
3730 done
3731
3732 - # ensure that no options were interspersed with files
3733 + # Ensure that no options were interspersed with files
3734 for i in "${files[@]}"; do
3735 if [[ ${i} == -* ]]; then
3736 die "eapply: all options must be passed before non-options"
3737 @@ -1119,7 +1146,7 @@ if ___eapi_has_eapply; then
3738 else
3739 _eapply_patch "${f}"
3740
3741 - # in case of nonfatal
3742 + # In case of nonfatal
3743 [[ ${failed} -ne 0 ]] && return "${failed}"
3744 fi
3745 done
3746 @@ -1132,6 +1159,7 @@ if ___eapi_has_eapply_user; then
3747 eapply_user() {
3748 [[ ${EBUILD_PHASE} == prepare ]] || \
3749 die "eapply_user() called during invalid phase: ${EBUILD_PHASE}"
3750 +
3751 # Keep path in __dyn_prepare in sync!
3752 local tagfile=${T}/.portage_user_patches_applied
3753 [[ -f ${tagfile} ]] && return
3754
3755 diff --git a/bin/portageq b/bin/portageq
3756 index 6d12c98dd..70c5699bb 100755
3757 --- a/bin/portageq
3758 +++ b/bin/portageq
3759 @@ -956,7 +956,7 @@ def get_repos(argv):
3760 docstrings[
3761 "get_repos"
3762 ] = """<eroot>
3763 - Returns all repos with names (repo_name file) argv[0] = $EROOT
3764 + Returns all repos with names (repo_name file) argv[0] = ${EROOT}
3765 """
3766 get_repos.__doc__ = docstrings["get_repos"]
3767
3768 @@ -1023,7 +1023,7 @@ def get_repo_path(argv):
3769 docstrings[
3770 "get_repo_path"
3771 ] = """<eroot> <repo_id>+
3772 - Returns the path to the repo named argv[1], argv[0] = $EROOT
3773 + Returns the path to the repo named argv[1], argv[0] = ${EROOT}
3774 """
3775 get_repo_path.__doc__ = docstrings["get_repo_path"]
3776
3777
3778 diff --git a/bin/postinst-qa-check.d/50xdg-utils b/bin/postinst-qa-check.d/50xdg-utils
3779 index 9a7c036e6..2951ae05c 100644
3780 --- a/bin/postinst-qa-check.d/50xdg-utils
3781 +++ b/bin/postinst-qa-check.d/50xdg-utils
3782 @@ -1,4 +1,4 @@
3783 -# check for missing calls to xdg-utils regen functions
3784 +# Check for missing calls to xdg-utils regen functions
3785
3786 xdg_desktop_database_check() {
3787 type -P update-desktop-database &>/dev/null || return
3788 @@ -8,19 +8,19 @@ xdg_desktop_database_check() {
3789 [[ -d ${d} ]] || continue
3790
3791 local files=() find_args=()
3792 - # if the cache does not exist at all, we complain for any file
3793 + # If the cache does not exist at all, we complain for any file
3794 # otherwise, we look for files newer than the cache
3795 [[ -f ${d}/mimeinfo.cache ]] &&
3796 find_args+=( -newercm "${d}"/mimeinfo.cache ) || missing=1
3797
3798 - # look for any .desktop files that are newer than the cache
3799 + # Look for any .desktop files that are newer than the cache
3800 # and that have any mime types defined
3801 while read -r -d $'\0' f; do
3802 files+=( "${f}" )
3803 done < <(find "${d}" -name '*.desktop' "${find_args[@]}" \
3804 -exec grep -lZi '^MimeType=' {} +)
3805
3806 - # if any files were found, update the db to avoid repeating
3807 + # If any files were found, update the db to avoid repeating
3808 # the warning for subsequent packages
3809 if [[ ${files[@]} ]]; then
3810 all_files+=("${files[@]}")
3811 @@ -29,10 +29,10 @@ xdg_desktop_database_check() {
3812 fi
3813 done
3814
3815 - # preinst initializes the baseline state for the posinst check
3816 + # Preinst initializes the baseline state for the posinst check
3817 [[ ${PORTAGE_QA_PHASE} == preinst ]] && return
3818
3819 - # parallel-install makes it impossible to blame a specific package
3820 + # Parallel-install makes it impossible to blame a specific package
3821 has parallel-install ${FEATURES} && return
3822
3823 # The eqatag call is prohibitively expensive if the cache is
3824 @@ -60,7 +60,8 @@ xdg_icon_cache_check() {
3825 '(' -name '*.png' -o -name '*.svg'
3826 -o -name '*.xpm' -o -name '*.icon' ')'
3827 )
3828 - # if the cache does not exist at all, we complain for any file
3829 +
3830 + # If the cache does not exist at all, we complain for any file
3831 # otherwise, we look for files newer than the cache
3832 [[ -f ${d}/icon-theme.cache ]] &&
3833 find_args+=( -newercm "${d}"/icon-theme.cache ) || missing=1
3834 @@ -70,7 +71,7 @@ xdg_icon_cache_check() {
3835 files+=( "${f}" )
3836 done < <(find "${d}" -mindepth 2 -type f "${find_args[@]}" -print0)
3837
3838 - # if any files were found, update the db to avoid repeating
3839 + # If any files were found, update the db to avoid repeating
3840 # the warning for subsequent packages
3841 if [[ ${files[@]} ]]; then
3842 all_files+=("${files[@]}")
3843 @@ -85,7 +86,7 @@ xdg_icon_cache_check() {
3844 # parallel-install makes it impossible to blame a specific package
3845 has parallel-install ${FEATURES} && return
3846
3847 - # avoid false-positives on first install (bug 649464)
3848 + # Avoid false-positives on first install (bug #649464)
3849 [[ ${PN} == gtk-update-icon-cache ]] && return
3850
3851 # The eqatag call is prohibitively expensive if the cache is
3852 @@ -107,7 +108,7 @@ xdg_mimeinfo_database_check() {
3853 [[ -d ${d} ]] || continue
3854
3855 local files=() find_args=()
3856 - # if the cache does not exist at all, we complain for any file
3857 + # If the cache does not exist at all, we complain for any file
3858 # otherwise, we look for files newer than the cache
3859 [[ -f ${d}/mime.cache ]] &&
3860 find_args+=( -newercm "${d}"/mime.cache ) || missing=1
3861
3862 diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
3863 index 18a82ad4c..eb57c9208 100644
3864 --- a/bin/save-ebuild-env.sh
3865 +++ b/bin/save-ebuild-env.sh
3866 @@ -16,9 +16,9 @@ __save_ebuild_env() {
3867 unset S _E_DESTTREE _E_INSDESTTREE _E_DOCDESTTREE_ _E_EXEDESTTREE_ \
3868 PORTAGE_DOCOMPRESS_SIZE_LIMIT PORTAGE_DOCOMPRESS \
3869 PORTAGE_DOCOMPRESS_SKIP PORTAGE_DOSTRIP PORTAGE_DOSTRIP_SKIP
3870 - if [[ -n $PYTHONPATH &&
3871 - ${PYTHONPATH%%:*} -ef $PORTAGE_PYM_PATH ]] ; then
3872 - if [[ $PYTHONPATH == *:* ]] ; then
3873 + if [[ -n ${PYTHONPATH} &&
3874 + ${PYTHONPATH%%:*} -ef ${PORTAGE_PYM_PATH} ]] ; then
3875 + if [[ ${PYTHONPATH} == *:* ]] ; then
3876 export PYTHONPATH=${PYTHONPATH#*:}
3877 else
3878 unset PYTHONPATH
3879 @@ -43,7 +43,7 @@ __save_ebuild_env() {
3880 for x in pkg_setup pkg_nofetch src_unpack src_prepare src_configure \
3881 src_compile src_test src_install pkg_preinst pkg_postinst \
3882 pkg_prerm pkg_postrm pkg_config pkg_info pkg_pretend ; do
3883 - unset -f default_$x __eapi{0,1,2,3,4}_$x
3884 + unset -f default_${x} __eapi{0,1,2,3,4}_${x}
3885 done
3886 unset x