* [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eclean/, pym/gentoolkit/ekeyword/, pym/gentoolkit/, man/, ...
@ 2023-03-22 3:36 Sam James
0 siblings, 0 replies; only message in thread
From: Sam James @ 2023-03-22 3:36 UTC (permalink / raw
To: gentoo-commits
commit: 1b82c21ec8897da285728f9e99e135fbd7406462
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 21 17:05:59 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Mar 22 03:36:35 2023 +0000
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=1b82c21e
Support the NO_COLOR environment variable
Bug: https://bugs.gentoo.org/902551
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoolkit/pull/26
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/revdep-rebuild.sh | 18 ++++++++++--------
man/revdep-rebuild.1 | 2 +-
pym/gentoolkit/base.py | 8 ++++++--
pym/gentoolkit/eclean/cli.py | 8 +++++---
pym/gentoolkit/ekeyword/ekeyword.py | 7 +++++--
pym/gentoolkit/equery/__init__.py | 4 ++--
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()
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-22 3:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-22 3:36 [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eclean/, pym/gentoolkit/ekeyword/, pym/gentoolkit/, man/, Sam James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox