From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A7786158017 for ; Tue, 28 Sep 2021 14:20:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 86BA4E089A; Tue, 28 Sep 2021 14:20:10 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5C20EE089A for ; Tue, 28 Sep 2021 14:20:10 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-portage-dev] [PATCH 1/4] Prefix color vars with "PORTAGE_COLOR_" Date: Tue, 28 Sep 2021 16:20:01 +0200 Message-Id: <20210928142004.1375262-2-mgorny@gentoo.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928142004.1375262-1-mgorny@gentoo.org> References: <20210928142004.1375262-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: da8e2493-f3d9-4106-9486-3af71a03ffa5 X-Archives-Hash: 4e1c761bb039f4d6c0f150fd66cf7c11 Rename color variables used by einfo etc. to use "PORTAGE_COLOR_" prefix. Currently these variables are prone to being accidentally ovewritten e.g. if an ebuild uses GOOD or BAD variables for some purpose. Using PORTAGE prefix should keep us safe. As an extra benefit, this makes it trivial to grep for all uses of color variables. Signed-off-by: Michał Górny --- bin/install-qa-check.d/10ignored-flags | 4 +-- bin/isolated-functions.sh | 42 +++++++++++++------------- bin/save-ebuild-env.sh | 16 +++++----- lib/portage/output.py | 4 +-- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/bin/install-qa-check.d/10ignored-flags b/bin/install-qa-check.d/10ignored-flags index 89706cd4c..7cd073578 100644 --- a/bin/install-qa-check.d/10ignored-flags +++ b/bin/install-qa-check.d/10ignored-flags @@ -52,7 +52,7 @@ ignored_flag_check() { f=$(<"${T}"/scanelf-ignored-CFLAGS.log) if [[ -n ${f} ]] ; then __vecho -ne '\n' - eqawarn "${BAD}QA Notice: Files built without respecting CFLAGS have been detected${NORMAL}" + eqawarn "${PORTAGE_COLOR_BAD}QA Notice: Files built without respecting CFLAGS have been detected${PORTAGE_COLOR_NORMAL}" eqawarn " Please include the following list of files in your report:" eqawarn "${f}" __vecho -ne '\n' @@ -82,7 +82,7 @@ ignored_flag_check() { f=$(<"${T}"/scanelf-ignored-LDFLAGS.log) if [[ -n ${f} ]] ; then __vecho -ne '\n' - eqawarn "${BAD}QA Notice: Files built without respecting LDFLAGS have been detected${NORMAL}" + eqawarn "${PORTAGE_COLOR_BAD}QA Notice: Files built without respecting LDFLAGS have been detected${PORTAGE_COLOR_NORMAL}" eqawarn " Please include the following list of files in your report:" eqawarn "${f}" __vecho -ne '\n' diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 5630dcf4c..3e79ea6e3 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -255,7 +255,7 @@ __elog_base() { shift ;; *) - __vecho -e " ${BAD}*${NORMAL} Invalid use of internal function __elog_base(), next message will not be logged" + __vecho -e " ${PORTAGE_COLOR_BAD}*${PORTAGE_COLOR_NORMAL} Invalid use of internal function __elog_base(), next message will not be logged" return 1 ;; esac @@ -270,7 +270,7 @@ eqawarn() { __elog_base QA "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 echo -e "$@" | while read -r ; do - echo " $WARN*$NORMAL $REPLY" >&2 + echo " ${PORTAGE_COLOR_WARN}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 done LAST_E_CMD="eqawarn" return 0 @@ -280,7 +280,7 @@ elog() { __elog_base LOG "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 echo -e "$@" | while read -r ; do - echo " $GOOD*$NORMAL $REPLY" >&2 + echo " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 done LAST_E_CMD="elog" return 0 @@ -290,7 +290,7 @@ einfo() { __elog_base INFO "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 echo -e "$@" | while read -r ; do - echo " $GOOD*$NORMAL $REPLY" >&2 + echo " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 done LAST_E_CMD="einfo" return 0 @@ -299,7 +299,7 @@ einfo() { einfon() { __elog_base INFO "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 - echo -ne " ${GOOD}*${NORMAL} $*" >&2 + echo -ne " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} $*" >&2 LAST_E_CMD="einfon" return 0 } @@ -308,7 +308,7 @@ ewarn() { __elog_base WARN "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 echo -e "$@" | while read -r ; do - echo " $WARN*$NORMAL $RC_INDENTATION$REPLY" >&2 + echo " ${PORTAGE_COLOR_WARN}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2 done LAST_E_CMD="ewarn" return 0 @@ -318,7 +318,7 @@ eerror() { __elog_base ERROR "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 echo -e "$@" | while read -r ; do - echo " $BAD*$NORMAL $RC_INDENTATION$REPLY" >&2 + echo " ${PORTAGE_COLOR_BAD}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2 done LAST_E_CMD="eerror" return 0 @@ -345,12 +345,12 @@ __eend() { shift 2 if [[ ${retval} == "0" ]] ; then - msg="${BRACKET}[ ${GOOD}ok${BRACKET} ]${NORMAL}" + msg="${PORTAGE_COLOR_BRACKET}[ ${PORTAGE_COLOR_GOOD}ok${PORTAGE_COLOR_BRACKET} ]${PORTAGE_COLOR_NORMAL}" else if [[ -n $* ]] ; then ${efunc} "$*" fi - msg="${BRACKET}[ ${BAD}!!${BRACKET} ]${NORMAL}" + msg="${PORTAGE_COLOR_BRACKET}[ ${PORTAGE_COLOR_BAD}!!${PORTAGE_COLOR_BRACKET} ]${PORTAGE_COLOR_NORMAL}" fi if [[ ${RC_ENDCOL} == "yes" ]] ; then @@ -378,12 +378,12 @@ __unset_colors() { COLS=80 ENDCOL= - GOOD= - WARN= - BAD= - NORMAL= - HILITE= - BRACKET= + PORTAGE_COLOR_GOOD= + PORTAGE_COLOR_WARN= + PORTAGE_COLOR_BAD= + PORTAGE_COLOR_HILITE= + PORTAGE_COLOR_NORMAL= + PORTAGE_COLOR_BRACKET= } __set_colors() { @@ -403,12 +403,12 @@ __set_colors() { if [ -n "${PORTAGE_COLORMAP}" ] ; then eval ${PORTAGE_COLORMAP} else - GOOD=$'\e[32;01m' - WARN=$'\e[33;01m' - BAD=$'\e[31;01m' - HILITE=$'\e[36;01m' - BRACKET=$'\e[34;01m' - NORMAL=$'\e[0m' + PORTAGE_COLOR_GOOD=$'\e[32;01m' + PORTAGE_COLOR_WARN=$'\e[33;01m' + PORTAGE_COLOR_BAD=$'\e[31;01m' + PORTAGE_COLOR_HILITE=$'\e[36;01m' + PORTAGE_COLOR_BRACKET=$'\e[34;01m' + PORTAGE_COLOR_NORMAL=$'\e[0m' fi } diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index 947ac79d5..8d2ec67ed 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2018 Gentoo Foundation +# Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @FUNCTION: __save_ebuild_env @@ -94,15 +94,17 @@ __save_ebuild_env() { unset ${!___*} # portage config variables and variables set directly by portage - unset ACCEPT_LICENSE BAD BRACKET BUILD_PREFIX COLS \ + unset ACCEPT_LICENSE BUILD_PREFIX COLS \ DISTDIR DOC_SYMLINKS_DIR \ EBUILD_FORCE_TEST EBUILD_MASTER_PID \ ECLASS_DEPTH ENDCOL FAKEROOTKEY \ - GOOD HILITE HOME \ + HOME \ LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \ - NOCOLOR NORMAL PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \ - PORTAGE_BASHRC_FILES PORTAGE_BASHRCS_SOURCED PORTAGE_COMPRESS \ - PORTAGE_COMPRESS_EXCLUDE_SUFFIXES \ + NOCOLOR PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \ + PORTAGE_BASHRC_FILES PORTAGE_BASHRCS_SOURCED \ + PORTAGE_COLOR_BAD PORTAGE_COLOR_BRACKET PORTAGE_COLOR_GOOD \ + PORTAGE_COLOR_HILITE PORTAGE_COLOR_NORMAL PORTAGE_COLOR_WARN \ + PORTAGE_COMPRESS PORTAGE_COMPRESS_EXCLUDE_SUFFIXES \ PORTAGE_DOHTML_UNWARNED_SKIPPED_EXTENSIONS \ PORTAGE_DOHTML_UNWARNED_SKIPPED_FILES \ PORTAGE_DOHTML_WARN_ON_SKIPPED_FILES \ @@ -113,7 +115,7 @@ __save_ebuild_env() { QA_INTERCEPTORS \ RC_DEFAULT_INDENT RC_DOT_PATTERN RC_ENDCOL RC_INDENTATION \ ROOT ROOTPATH RPMDIR TEMP TMP TMPDIR USE_EXPAND \ - WARN XARGS _RC_GET_KV_CACHE + XARGS _RC_GET_KV_CACHE # user config variables unset DOC_SYMLINKS_DIR INSTALL_MASK PKG_INSTALL_MASK diff --git a/lib/portage/output.py b/lib/portage/output.py index c1949717d..9d8601b24 100644 --- a/lib/portage/output.py +++ b/lib/portage/output.py @@ -1,4 +1,4 @@ -# Copyright 1998-2020 Gentoo Authors +# Copyright 1998-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 __docformat__ = "epytext" @@ -378,7 +378,7 @@ def style_to_ansi_code(style): def colormap(): mycolors = [] for c in ("GOOD", "WARN", "BAD", "HILITE", "BRACKET", "NORMAL"): - mycolors.append("%s=$'%s'" % (c, style_to_ansi_code(c))) + mycolors.append("PORTAGE_COLOR_{}=$'{}'".format(c, style_to_ansi_code(c))) return "\n".join(mycolors) -- 2.33.0