summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2023-03-21 18:05:59 +0100
committerSam James <sam@gentoo.org>2023-03-22 03:36:35 +0000
commit1b82c21ec8897da285728f9e99e135fbd7406462 (patch)
tree334e467e44a1dcfda17639c2d72c1b4734ff9309
parent.gitignorerevs: update for Black reformatting (diff)
downloadgentoolkit-1b82c21ec8897da285728f9e99e135fbd7406462.tar.gz
gentoolkit-1b82c21ec8897da285728f9e99e135fbd7406462.tar.bz2
gentoolkit-1b82c21ec8897da285728f9e99e135fbd7406462.zip
Support the NO_COLOR environment variable
Bug: https://bugs.gentoo.org/902551 Signed-off-by: Ulrich Müller <ulm@gentoo.org> Closes: https://github.com/gentoo/gentoolkit/pull/26 Signed-off-by: Sam James <sam@gentoo.org>
-rwxr-xr-xbin/revdep-rebuild.sh18
-rw-r--r--man/revdep-rebuild.12
-rw-r--r--pym/gentoolkit/base.py8
-rw-r--r--pym/gentoolkit/eclean/cli.py8
-rwxr-xr-xpym/gentoolkit/ekeyword/ekeyword.py7
-rw-r--r--pym/gentoolkit/equery/__init__.py4
6 files changed, 29 insertions, 18 deletions
diff --git a/bin/revdep-rebuild.sh b/bin/revdep-rebuild.sh
index 7ee3647..09b0d1c 100755
--- a/bin/revdep-rebuild.sh
+++ b/bin/revdep-rebuild.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 2003-2023 Gentoo Authors
# revdep-rebuild: Reverse dependency rebuilder.
# Original Author: Stanislav Brabec
@@ -80,6 +80,7 @@ declare SEARCH_DIRS_MASK # List of dirs not to search
declare OLDPROG # Previous pass through the progress meter
declare EXACT_PKG # Versionated atom to emerge
declare HEAD_TEXT # Feedback string about the search
+declare NO_COLOR # Set to nonempty not to output term colors
declare NOCOLOR # Set to "true" not to output term colors
declare OK_TEXT # Feedback about a search which found no errors
declare RC_NOCOLOR # Hack to insure we respect NOCOLOR
@@ -169,7 +170,7 @@ print_usage() {
cat << EOF
${APP_NAME}: (${VERSION})
-Copyright (C) 2003-2010 Gentoo Foundation, Inc.
+Copyright (C) 2003-2023 Gentoo Authors
This is free software; see the source for copying conditions.
Usage: $APP_NAME [OPTIONS] [--] [EMERGE_OPTIONS]
@@ -320,7 +321,8 @@ normalize_emerge_opts() {
setup_color() {
# This should still work if NOCOLOR is set by the -C flag or in the user's
# environment.
- [[ $NOCOLOR = yes || $NOCOLOR = true ]] && export RC_NOCOLOR=yes # HACK! (grr)
+ [[ -n $NO_COLOR || $NOCOLOR = yes || $NOCOLOR = true ]] &&
+ export RC_NOCOLOR=yes # HACK! (grr)
# TODO: Change location according to Bug 373219
# Remove /etc/init.d/functions.sh once everything is migrated
if [ -e /lib/gentoo/functions.sh ]; then
@@ -367,9 +369,9 @@ warn_deprecated_opt() {
# Get whole-word commandline options preceded by two dashes.
get_longopts() {
case $1 in
- --nocolor) export NOCOLOR="yes";;
+ --nocolor) export NO_COLOR=1 NOCOLOR="yes";;
--no-color) warn_deprecated_opt "$1" "--nocolor"
- export NOCOLOR="yes";;
+ export NO_COLOR=1 NOCOLOR="yes";;
--debug) set -xv;;
--exact) unset PACKAGE_NAMES;;
--help) print_usage
@@ -424,7 +426,7 @@ get_shortopts() {
while getopts ":CdehikL:loPpquvX" OPT; do
case "$OPT" in
C) # TODO: Match syntax with the rest of gentoolkit
- export NOCOLOR="yes";;
+ export NO_COLOR=1 NOCOLOR="yes";;
d) set -xv;;
e) unset PACKAGE_NAMES;;
h) print_usage
@@ -1092,8 +1094,8 @@ portage_settings() {
unset SEARCH_DIRS_MASK
unset LD_LIBRARY_MASK
- eval $(portageq envvar -v PORTAGE_ROOT PORTAGE_NICENESS EMERGE_DEFAULT_OPTS NOCOLOR SEARCH_DIRS SEARCH_DIRS_MASK LD_LIBRARY_MASK REVDEP_REBUILD_DEFAULT_OPTS)
- export NOCOLOR
+ eval $(portageq envvar -v PORTAGE_ROOT PORTAGE_NICENESS EMERGE_DEFAULT_OPTS NO_COLOR NOCOLOR SEARCH_DIRS SEARCH_DIRS_MASK LD_LIBRARY_MASK REVDEP_REBUILD_DEFAULT_OPTS)
+ export NO_COLOR NOCOLOR
# Convert quoted paths to array.
eval "EMERGE_DEFAULT_OPTS=(${EMERGE_DEFAULT_OPTS})"
diff --git a/man/revdep-rebuild.1 b/man/revdep-rebuild.1
index fad5f47..bff995c 100644
--- a/man/revdep-rebuild.1
+++ b/man/revdep-rebuild.1
@@ -82,7 +82,7 @@ REVDEP_REBUILD_DEFAULT_OPTS \- List of default emerge options for revdep-rebuild
The REVDEP_REBUILD_DEFAULT_OPTS variable can be used to override EMERGE_DEFAULT_OPTS for revdep\-rebuild. This variable replaces the values of EMERGE_DEFAULT_OPTS and can still be overridden by command line options. Please note that this variable is only for options to pass to emerge and not options for revdep\-rebuild itself.
-revdep\-rebuild honors the NOCOLOR and PORTAGE_NICENESS variables from make.conf
+revdep\-rebuild honors the NO_COLOR, NOCOLOR, and PORTAGE_NICENESS variables from make.conf.
.SH "EXAMPLES"
It is recommended that when running revdep\-rebuild that the following command be used initially:
.br
diff --git a/pym/gentoolkit/base.py b/pym/gentoolkit/base.py
index 8dfa2db..230e040 100644
--- a/pym/gentoolkit/base.py
+++ b/pym/gentoolkit/base.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
-# Copyright(c) 2009 - 2010, Gentoo Foundation
+# Copyright(c) 2009-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
"""Gentoolkit Base Module class to hold common module operation functions
@@ -39,7 +39,11 @@ def initialize_configuration():
# Guess color output
if (
gentoolkit.CONFIG["color"] == -1
- and (not sys.stdout.isatty() or os.getenv("NOCOLOR") in ("yes", "true"))
+ and (
+ not sys.stdout.isatty()
+ or os.getenv("NO_COLOR")
+ or os.getenv("NOCOLOR") in ("yes", "true")
+ )
or gentoolkit.CONFIG["color"] == 0
):
pp.output.nocolor()
diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py
index 23c7f3b..4902354 100644
--- a/pym/gentoolkit/eclean/cli.py
+++ b/pym/gentoolkit/eclean/cli.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
-# Copyright 2003-2016 Gentoo Foundation
+# Copyright 2003-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
@@ -43,7 +43,7 @@ def printVersion():
print("%s (%s) - %s" % (__productname__, __version__, __description__))
print()
print("Author: %s <%s>" % (__author__, __email__))
- print("Copyright 2003-2009 Gentoo Foundation")
+ print("Copyright 2003-2023 Gentoo Authors")
print("Distributed under the terms of the GNU General Public License v2")
@@ -615,7 +615,9 @@ def main():
# set default options
options = {}
options["nocolor"] = (
- port_settings.get("NOCOLOR") in ("yes", "true") or not sys.stdout.isatty()
+ port_settings.get("NO_COLOR")
+ or port_settings.get("NOCOLOR") in ("yes", "true")
+ or not sys.stdout.isatty()
)
if options["nocolor"]:
pp.output.nocolor()
diff --git a/pym/gentoolkit/ekeyword/ekeyword.py b/pym/gentoolkit/ekeyword/ekeyword.py
index d031c2f..70f44ea 100755
--- a/pym/gentoolkit/ekeyword/ekeyword.py
+++ b/pym/gentoolkit/ekeyword/ekeyword.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright 2014 Gentoo Foundation
+# Copyright 2014-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# Written by Mike Frysinger <vapier@gentoo.org>
@@ -533,7 +533,10 @@ def main(argv):
parser.error("need ebuilds to process")
if opts.style == "auto":
- if not portage_settings().get("NOCOLOR", "false").lower() in ("no", "false"):
+ if not (
+ portage_settings().get("NO_COLOR")
+ or portage_settings().get("NOCOLOR", "false").lower() in ("no", "false")
+ ):
nocolor()
opts.style = "short"
else:
diff --git a/pym/gentoolkit/equery/__init__.py b/pym/gentoolkit/equery/__init__.py
index ae760c1..a83d31a 100644
--- a/pym/gentoolkit/equery/__init__.py
+++ b/pym/gentoolkit/equery/__init__.py
@@ -1,4 +1,4 @@
-# Copyright(c) 2009, Gentoo Foundation
+# Copyright(c) 2009-2023 Gentoo Authors
#
# Licensed under the GNU General Public License, v2
@@ -218,7 +218,7 @@ def initialize_configuration():
# Guess color output
if (
CONFIG["color"] == -1
- and os.getenv("NOCOLOR") in ("yes", "true")
+ and (os.getenv("NO_COLOR") or os.getenv("NOCOLOR") in ("yes", "true"))
or CONFIG["color"] == 0
):
pp.output.nocolor()