1 |
commit: 204537a426c8738528063c3c5226642de3b7d097 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Sep 28 12:39:22 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Oct 4 07:27:46 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=204537a4 |
7 |
|
8 |
Prefix color vars with "PORTAGE_COLOR_" |
9 |
|
10 |
Rename color variables used by einfo etc. to use "PORTAGE_COLOR_" |
11 |
prefix. Currently these variables are prone to being accidentally |
12 |
ovewritten e.g. if an ebuild uses GOOD or BAD variables for some |
13 |
purpose. Using PORTAGE prefix should keep us safe. |
14 |
|
15 |
As an extra benefit, this makes it trivial to grep for all uses of color |
16 |
variables. |
17 |
|
18 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
19 |
|
20 |
bin/install-qa-check.d/10ignored-flags | 4 ++-- |
21 |
bin/isolated-functions.sh | 42 +++++++++++++++++----------------- |
22 |
bin/save-ebuild-env.sh | 16 +++++++------ |
23 |
lib/portage/output.py | 4 ++-- |
24 |
4 files changed, 34 insertions(+), 32 deletions(-) |
25 |
|
26 |
diff --git a/bin/install-qa-check.d/10ignored-flags b/bin/install-qa-check.d/10ignored-flags |
27 |
index 89706cd4c..7cd073578 100644 |
28 |
--- a/bin/install-qa-check.d/10ignored-flags |
29 |
+++ b/bin/install-qa-check.d/10ignored-flags |
30 |
@@ -52,7 +52,7 @@ ignored_flag_check() { |
31 |
f=$(<"${T}"/scanelf-ignored-CFLAGS.log) |
32 |
if [[ -n ${f} ]] ; then |
33 |
__vecho -ne '\n' |
34 |
- eqawarn "${BAD}QA Notice: Files built without respecting CFLAGS have been detected${NORMAL}" |
35 |
+ eqawarn "${PORTAGE_COLOR_BAD}QA Notice: Files built without respecting CFLAGS have been detected${PORTAGE_COLOR_NORMAL}" |
36 |
eqawarn " Please include the following list of files in your report:" |
37 |
eqawarn "${f}" |
38 |
__vecho -ne '\n' |
39 |
@@ -82,7 +82,7 @@ ignored_flag_check() { |
40 |
f=$(<"${T}"/scanelf-ignored-LDFLAGS.log) |
41 |
if [[ -n ${f} ]] ; then |
42 |
__vecho -ne '\n' |
43 |
- eqawarn "${BAD}QA Notice: Files built without respecting LDFLAGS have been detected${NORMAL}" |
44 |
+ eqawarn "${PORTAGE_COLOR_BAD}QA Notice: Files built without respecting LDFLAGS have been detected${PORTAGE_COLOR_NORMAL}" |
45 |
eqawarn " Please include the following list of files in your report:" |
46 |
eqawarn "${f}" |
47 |
__vecho -ne '\n' |
48 |
|
49 |
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh |
50 |
index 5630dcf4c..3e79ea6e3 100644 |
51 |
--- a/bin/isolated-functions.sh |
52 |
+++ b/bin/isolated-functions.sh |
53 |
@@ -255,7 +255,7 @@ __elog_base() { |
54 |
shift |
55 |
;; |
56 |
*) |
57 |
- __vecho -e " ${BAD}*${NORMAL} Invalid use of internal function __elog_base(), next message will not be logged" |
58 |
+ __vecho -e " ${PORTAGE_COLOR_BAD}*${PORTAGE_COLOR_NORMAL} Invalid use of internal function __elog_base(), next message will not be logged" |
59 |
return 1 |
60 |
;; |
61 |
esac |
62 |
@@ -270,7 +270,7 @@ eqawarn() { |
63 |
__elog_base QA "$*" |
64 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
65 |
echo -e "$@" | while read -r ; do |
66 |
- echo " $WARN*$NORMAL $REPLY" >&2 |
67 |
+ echo " ${PORTAGE_COLOR_WARN}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 |
68 |
done |
69 |
LAST_E_CMD="eqawarn" |
70 |
return 0 |
71 |
@@ -280,7 +280,7 @@ elog() { |
72 |
__elog_base LOG "$*" |
73 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
74 |
echo -e "$@" | while read -r ; do |
75 |
- echo " $GOOD*$NORMAL $REPLY" >&2 |
76 |
+ echo " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 |
77 |
done |
78 |
LAST_E_CMD="elog" |
79 |
return 0 |
80 |
@@ -290,7 +290,7 @@ einfo() { |
81 |
__elog_base INFO "$*" |
82 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
83 |
echo -e "$@" | while read -r ; do |
84 |
- echo " $GOOD*$NORMAL $REPLY" >&2 |
85 |
+ echo " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 |
86 |
done |
87 |
LAST_E_CMD="einfo" |
88 |
return 0 |
89 |
@@ -299,7 +299,7 @@ einfo() { |
90 |
einfon() { |
91 |
__elog_base INFO "$*" |
92 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
93 |
- echo -ne " ${GOOD}*${NORMAL} $*" >&2 |
94 |
+ echo -ne " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} $*" >&2 |
95 |
LAST_E_CMD="einfon" |
96 |
return 0 |
97 |
} |
98 |
@@ -308,7 +308,7 @@ ewarn() { |
99 |
__elog_base WARN "$*" |
100 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
101 |
echo -e "$@" | while read -r ; do |
102 |
- echo " $WARN*$NORMAL $RC_INDENTATION$REPLY" >&2 |
103 |
+ echo " ${PORTAGE_COLOR_WARN}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2 |
104 |
done |
105 |
LAST_E_CMD="ewarn" |
106 |
return 0 |
107 |
@@ -318,7 +318,7 @@ eerror() { |
108 |
__elog_base ERROR "$*" |
109 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
110 |
echo -e "$@" | while read -r ; do |
111 |
- echo " $BAD*$NORMAL $RC_INDENTATION$REPLY" >&2 |
112 |
+ echo " ${PORTAGE_COLOR_BAD}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2 |
113 |
done |
114 |
LAST_E_CMD="eerror" |
115 |
return 0 |
116 |
@@ -345,12 +345,12 @@ __eend() { |
117 |
shift 2 |
118 |
|
119 |
if [[ ${retval} == "0" ]] ; then |
120 |
- msg="${BRACKET}[ ${GOOD}ok${BRACKET} ]${NORMAL}" |
121 |
+ msg="${PORTAGE_COLOR_BRACKET}[ ${PORTAGE_COLOR_GOOD}ok${PORTAGE_COLOR_BRACKET} ]${PORTAGE_COLOR_NORMAL}" |
122 |
else |
123 |
if [[ -n $* ]] ; then |
124 |
${efunc} "$*" |
125 |
fi |
126 |
- msg="${BRACKET}[ ${BAD}!!${BRACKET} ]${NORMAL}" |
127 |
+ msg="${PORTAGE_COLOR_BRACKET}[ ${PORTAGE_COLOR_BAD}!!${PORTAGE_COLOR_BRACKET} ]${PORTAGE_COLOR_NORMAL}" |
128 |
fi |
129 |
|
130 |
if [[ ${RC_ENDCOL} == "yes" ]] ; then |
131 |
@@ -378,12 +378,12 @@ __unset_colors() { |
132 |
COLS=80 |
133 |
ENDCOL= |
134 |
|
135 |
- GOOD= |
136 |
- WARN= |
137 |
- BAD= |
138 |
- NORMAL= |
139 |
- HILITE= |
140 |
- BRACKET= |
141 |
+ PORTAGE_COLOR_GOOD= |
142 |
+ PORTAGE_COLOR_WARN= |
143 |
+ PORTAGE_COLOR_BAD= |
144 |
+ PORTAGE_COLOR_HILITE= |
145 |
+ PORTAGE_COLOR_NORMAL= |
146 |
+ PORTAGE_COLOR_BRACKET= |
147 |
} |
148 |
|
149 |
__set_colors() { |
150 |
@@ -403,12 +403,12 @@ __set_colors() { |
151 |
if [ -n "${PORTAGE_COLORMAP}" ] ; then |
152 |
eval ${PORTAGE_COLORMAP} |
153 |
else |
154 |
- GOOD=$'\e[32;01m' |
155 |
- WARN=$'\e[33;01m' |
156 |
- BAD=$'\e[31;01m' |
157 |
- HILITE=$'\e[36;01m' |
158 |
- BRACKET=$'\e[34;01m' |
159 |
- NORMAL=$'\e[0m' |
160 |
+ PORTAGE_COLOR_GOOD=$'\e[32;01m' |
161 |
+ PORTAGE_COLOR_WARN=$'\e[33;01m' |
162 |
+ PORTAGE_COLOR_BAD=$'\e[31;01m' |
163 |
+ PORTAGE_COLOR_HILITE=$'\e[36;01m' |
164 |
+ PORTAGE_COLOR_BRACKET=$'\e[34;01m' |
165 |
+ PORTAGE_COLOR_NORMAL=$'\e[0m' |
166 |
fi |
167 |
} |
168 |
|
169 |
|
170 |
diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh |
171 |
index 947ac79d5..8d2ec67ed 100644 |
172 |
--- a/bin/save-ebuild-env.sh |
173 |
+++ b/bin/save-ebuild-env.sh |
174 |
@@ -1,5 +1,5 @@ |
175 |
#!/bin/bash |
176 |
-# Copyright 1999-2018 Gentoo Foundation |
177 |
+# Copyright 1999-2021 Gentoo Authors |
178 |
# Distributed under the terms of the GNU General Public License v2 |
179 |
|
180 |
# @FUNCTION: __save_ebuild_env |
181 |
@@ -94,15 +94,17 @@ __save_ebuild_env() { |
182 |
unset ${!___*} |
183 |
|
184 |
# portage config variables and variables set directly by portage |
185 |
- unset ACCEPT_LICENSE BAD BRACKET BUILD_PREFIX COLS \ |
186 |
+ unset ACCEPT_LICENSE BUILD_PREFIX COLS \ |
187 |
DISTDIR DOC_SYMLINKS_DIR \ |
188 |
EBUILD_FORCE_TEST EBUILD_MASTER_PID \ |
189 |
ECLASS_DEPTH ENDCOL FAKEROOTKEY \ |
190 |
- GOOD HILITE HOME \ |
191 |
+ HOME \ |
192 |
LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \ |
193 |
- NOCOLOR NORMAL PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \ |
194 |
- PORTAGE_BASHRC_FILES PORTAGE_BASHRCS_SOURCED PORTAGE_COMPRESS \ |
195 |
- PORTAGE_COMPRESS_EXCLUDE_SUFFIXES \ |
196 |
+ NOCOLOR PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \ |
197 |
+ PORTAGE_BASHRC_FILES PORTAGE_BASHRCS_SOURCED \ |
198 |
+ PORTAGE_COLOR_BAD PORTAGE_COLOR_BRACKET PORTAGE_COLOR_GOOD \ |
199 |
+ PORTAGE_COLOR_HILITE PORTAGE_COLOR_NORMAL PORTAGE_COLOR_WARN \ |
200 |
+ PORTAGE_COMPRESS PORTAGE_COMPRESS_EXCLUDE_SUFFIXES \ |
201 |
PORTAGE_DOHTML_UNWARNED_SKIPPED_EXTENSIONS \ |
202 |
PORTAGE_DOHTML_UNWARNED_SKIPPED_FILES \ |
203 |
PORTAGE_DOHTML_WARN_ON_SKIPPED_FILES \ |
204 |
@@ -113,7 +115,7 @@ __save_ebuild_env() { |
205 |
QA_INTERCEPTORS \ |
206 |
RC_DEFAULT_INDENT RC_DOT_PATTERN RC_ENDCOL RC_INDENTATION \ |
207 |
ROOT ROOTPATH RPMDIR TEMP TMP TMPDIR USE_EXPAND \ |
208 |
- WARN XARGS _RC_GET_KV_CACHE |
209 |
+ XARGS _RC_GET_KV_CACHE |
210 |
|
211 |
# user config variables |
212 |
unset DOC_SYMLINKS_DIR INSTALL_MASK PKG_INSTALL_MASK |
213 |
|
214 |
diff --git a/lib/portage/output.py b/lib/portage/output.py |
215 |
index c1949717d..9d8601b24 100644 |
216 |
--- a/lib/portage/output.py |
217 |
+++ b/lib/portage/output.py |
218 |
@@ -1,4 +1,4 @@ |
219 |
-# Copyright 1998-2020 Gentoo Authors |
220 |
+# Copyright 1998-2021 Gentoo Authors |
221 |
# Distributed under the terms of the GNU General Public License v2 |
222 |
|
223 |
__docformat__ = "epytext" |
224 |
@@ -378,7 +378,7 @@ def style_to_ansi_code(style): |
225 |
def colormap(): |
226 |
mycolors = [] |
227 |
for c in ("GOOD", "WARN", "BAD", "HILITE", "BRACKET", "NORMAL"): |
228 |
- mycolors.append("%s=$'%s'" % (c, style_to_ansi_code(c))) |
229 |
+ mycolors.append("PORTAGE_COLOR_{}=$'{}'".format(c, style_to_ansi_code(c))) |
230 |
return "\n".join(mycolors) |