Implement --color < y | n > for bug #42115 and deprecate --nocolor.
When --color is not specified, rely on the old NOCOLOR variable and/or
stdout auto-detection.
Document the new --color < y | n > option for bug #42115.
Add --color < y | n > help output for bug #42115.
Remove broken nocolor() call, since thats handled internally by the
output module anyway.
Fix the USE_ORDER docs for bug #153764. Thanks to Alec Warner for the
initial patch.
svn path=/main/branches/prefix/; revision=4914
from portage import digraph
import emergehelp, xpak, commands, errno, re, socket, string, time, types
+import output
from output import blue, bold, colorize, darkblue, darkgreen, darkred, green, \
havecolor, nc_len, nocolor, red, teal, turquoise, white, xtermTitle, \
xtermTitleReset, yellow
longopt_aliases = {"--cols":"--columns", "--skip-first":"--skipfirst"}
argument_options = {
+ "--color": {
+ "help":"enable or disable color output",
+ "type":"choice",
+ "choices":("y", "n")
+ },
"--with-bdeps": {
"help":"include unnecessary build time dependencies",
"type":"choice",
else:
myfiles.append(x)
+ if "--nocolor" in myopts:
+ print "*** Deprecated use of '--nocolor', use '--color=n' instead."
+ del myopts["--nocolor"]
+ myopts["--color"] = "n"
+
return myaction, myopts, myfiles
def validate_ebuild_environment(trees):
settings["PORTAGE_DEBUG"] = str(PORTAGE_DEBUG)
settings.backup_changes("PORTAGE_DEBUG")
- # Set color output
- if "--nocolor" in myopts:
+ """The explicit --color < y | n > option overrides the NOCOLOR environment
+ variable and stdout auto-detection."""
+ if "--color" in myopts:
+ if "y" == myopts["--color"]:
+ output.havecolor = 1
+ settings["NOCOLOR"] = "false"
+ else:
+ output.havecolor = 0
+ settings["NOCOLOR"] = "true"
+ settings.backup_changes("NOCOLOR")
+ elif not sys.stdout.isatty():
+ output.havecolor = 0
settings["NOCOLOR"] = "true"
settings.backup_changes("NOCOLOR")
ldpath_mtimes = mtimedb["ldpath"]
xterm_titles = "notitles" not in settings.features
+ """Disable color as early as possible via NOCOLOR and stdout
+ auto-detection. This initial setting may later be overridden via the
+ --color < yes | no > option."""
if settings.get("NOCOLOR","").lower() in ("yes","true"):
nocolor()
elif (not sys.stdout.isatty()) and \
print "* --tree is currently broken with --resume. Disabling..."
del myopts["--tree"]
- # Set color output
- if "--nocolor" in myopts or \
- settings["NOCOLOR"] in ("yes","true"):
- nocolor()
-
if not ("--quiet" in myopts):
if not sys.stdout.isatty() or ("--nospinner" in myopts):
spinner.update = spinner.update_basic
trees[settings["ROOT"]]["vartree"].dbapi)
sys.exit(0)
elif "--help" in myopts:
- emergehelp.help(myaction, myopts, havecolor)
+ emergehelp.help(myaction, myopts, output.havecolor)
sys.exit(0)
if portage.wheelgid == portage.portage_gid and portage.wheelgid < 500:
print "myopts", myopts
if not myaction and not myfiles and "--resume" not in myopts:
- emergehelp.help(myaction, myopts, havecolor)
+ emergehelp.help(myaction, myopts, output.havecolor)
sys.exit(1)
# check if root user is the current user for the actions where emerge needs this
Use this in conjunction with the \fB\-\-pretend\fR option. This will
show the ChangeLog entries for all the packages that will be upgraded.
.TP
+.BR "\-\-color < y | n >"
+Enable or disable color output. This option will override \fINOCOLOR\fR
+(see \fBmake.conf\fR(5)) and may also be used to force color output when stdout
+is not a tty (by default, color is disabled unless stdout is a tty).
+.TP
.BR "\-\-columns"
Used alongside \fB\-\-pretend\fR to cause the package name, new version,
and old version to be displayed in an aligned format for easy cut\-n\-paste.
compilation. An asterisk marks when a USE flag has changed since the package
was compiled.
.TP
-.BR "\-\-nocolor "
-Suppresses all coloring of portage's output.
-.TP
.BR "\-\-noconfmem"
Causes portage to disregard merge records indicating that a config file
inside of a \fBCONFIG_PROTECT\fR directory has been merged already. Portage
Names of \fBUSE_EXPAND\fR variables that should not be shown in the verbose merge
list output of the \fBemerge\fR(1) command.
.TP
-\fBUSE_ORDER\fR = \fI"env:pkg:conf:auto:defaults"\fR
-Determines precedence for incrementing the setting of the USE variable.
-The above setting will cause the environment (env) to override per package (pkg)
-settings to override make.conf (conf) to override auto generated values
-from merged packages (auto) to override make.defaults (defaults).
-.br
+\fBUSE_ORDER\fR = \fI"env:pkg:conf:defaults:pkginternal"\fR
+Determines the precedence of layers in the incremental stacking of the USE
+variable. Precedence decreases from left to right such that env overrides
+pkg, pkg overrides conf, and so forth.
+
\fB***warning***\fR
.br
Do not modify this value unless you're a developer and you know what
you're doing. If you change this and something breaks, we will not help
you fix it.
.br
-Defaults to "env:pkg:conf:defaults".
+.RS
+.TP
+.B env
+USE from the current USE environment variable if it exists
+.TP
+.B pkg
+Per-package USE from \fB/etc/portage/package.use\fR (see \fBportage\fR(5))
+.TP
+.B conf
+USE from make.conf
+.TP
+.B defaults
+USE from make.defaults and package.use in the profile (see \fBportage\fR(5))
+.TP
+.B pkginternal
+USE from ebuild IUSE defaults (flags enabled via a + prefix; see \fBebuild\fR(5))
+.RE
.SH "REPORTING BUGS"
Please report bugs via http://bugs.gentoo.org/
print " "+turquoise("emerge")+" "+turquoise("--resume")+" [ "+green("--pretend")+" | "+green("--ask")+" | "+green("--skipfirst")+" ]"
print " "+turquoise("emerge")+" "+turquoise("--help")+" [ "+green("system")+" | "+green("world")+" | "+green("config")+" | "+green("--sync")+" ] "
print bold("Options:")+" "+green("-")+"["+green("abBcCdDefgGhikKlnNoOpqPsStuvV")+"] ["+green("--oneshot")+"] ["+green("--newuse")+"] ["+green("--noconfmem")+"]"
- print " ["+green("--columns")+"] ["+green("--nocolor")+"] ["+green("--nospinner")+"]"
+ print " [ " + green("--color")+" < " + turquoise("y") + " | "+ turquoise("n")+" > ] [ "+green("--columns")+" ]"
+ print " ["+green("--nospinner")+"]"
print " [ "+green("--deep")+" ] [" + green("--with-bdeps")+" < " + turquoise("y") + " | "+ turquoise("n")+" > ]"
print bold("Actions:")+" [ "+green("--clean")+" | "+green("--depclean")+" | "+green("--prune")+" | "+green("--regen")+" | "+green("--search")+" | "+green("--unmerge")+" ]"
print
def help(myaction,myopts,havecolor=1):
- if not havecolor:
- nocolor()
if not myaction and ("--help" not in myopts):
shorthelp()
print
print " When pretending, also display the ChangeLog entries for packages"
print " that will be upgraded."
print
+ print " "+green("--color") + " < " + turquoise("y") + " | "+ turquoise("n")+" >"
+ print " Enable or disable color output. This option will override NOCOLOR"
+ print " (see make.conf(5)) and may also be used to force color output when"
+ print " stdout is not a tty (by default, color is disabled unless stdout"
+ print " is a tty)."
+ print
print " "+green("--columns")
print " Display the pretend output in a tabular form. Versions are"
print " aligned vertically."
print " Tells emerge to include installed packages where USE flags have "
print " changed since installation."
print
- print " "+green("--nocolor")
- print " Suppresses color in the output."
- print
print " "+green("--noconfmem")
print " Portage keeps track of files that have been placed into"
print " CONFIG_PROTECT directories, and normally it will not merge the"
def nocolor():
"turn off colorization"
+ global havecolor
havecolor=0
- for x in codes.keys():
- codes[x]=""
def resetColor():
return codes["reset"]
def colorize(color_key, text):
- return codes[color_key] + text + codes["reset"]
+ global havecolor
+ if havecolor:
+ return codes[color_key] + text + codes["reset"]
+ else:
+ return text
compat_functions_colors = ["bold","white","teal","turquoise","darkteal",
"fuscia","fuchsia","purple","blue","darkblue","green","darkgreen","yellow",