public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2017-05-14 18:12 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2017-05-14 18:12 UTC (permalink / raw
  To: gentoo-commits

commit:     cbf9f3c0167a68de7901b2a0992c2d0a264b9b22
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed May 10 03:45:10 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 14 18:11:51 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cbf9f3c0

emerge: default --backtrack=10 (bug 540562)

Since the default behavior is now for emerge to terminate early for
autounmask changes (unless either --autounmask-backtrack=y or
--autounmask-continue is enabled), it is much less likely that time
will be wasted by fruitless backtracking. Therefore, raise the default
backtrack value from 3 to 10, restoring it to the value it had prior
to commit 1891388ea0ae0dd58903a71a3adc779731523601 (see bug 536926).
This will allow many users to avoid having to manually raise the
--backtrack value.

X-Gentoo-bug: 540562
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=540562
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 man/emerge.1            | 2 +-
 pym/_emerge/depgraph.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 94edc9095..240d4de7e 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -412,7 +412,7 @@ precedence over existing changes. This option is automatically enabled with
 .BR \-\-backtrack=COUNT
 Specifies an integer number of times to backtrack if
 dependency calculation fails due to a conflict or an
-unsatisfied dependency (default: \'3\').
+unsatisfied dependency (default: \'10\').
 .TP
 .BR "\-\-binpkg\-changed\-deps [ y | n ]"
 Tells emerge to ignore binary packages for which the corresponding

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 53910dd25..cda497b1d 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -9460,7 +9460,7 @@ def _backtrack_depgraph(settings, trees, myopts, myparams, myaction, myfiles, sp
 
 	debug = "--debug" in myopts
 	mydepgraph = None
-	max_retries = myopts.get('--backtrack', 3)
+	max_retries = myopts.get('--backtrack', 10)
 	max_depth = max(1, (max_retries + 1) // 2)
 	allow_backtracking = max_retries > 0
 	backtracker = Backtracker(max_depth)


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2018-02-03  3:07 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2018-02-03  3:07 UTC (permalink / raw
  To: gentoo-commits

commit:     a6671c73f3d1aa74789534e5eebccbca23b48656
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  3 01:45:21 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb  3 02:21:28 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a6671c73

emerge: enable --dynamic-deps=y by default once again (bug 646458)

There's been a lot of pushback involving the --dynamic-deps=n default.
What we really need is a tool to apply dependency changes in-place,
without the need for a rebuild.

Reverts: 2905e1c2c28d ("Disable dynamic-deps by default")
Bug: https://bugs.gentoo.org/646458

 man/emerge.1                          | 2 +-
 pym/_emerge/Scheduler.py              | 3 ++-
 pym/_emerge/create_depgraph_params.py | 6 +++---
 pym/_emerge/depgraph.py               | 7 +++----
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 189e6f879..f15532a1d 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -558,7 +558,7 @@ In dependency calculations, substitute the dependencies of installed
 packages with the dependencies of corresponding unbuilt ebuilds from
 source repositories. This causes the effective dependencies of
 installed packages to vary dynamically when source ebuild dependencies
-are modified. This option is disabled by default.
+are modified. This option is enabled by default.
 
 \fBWARNING:\fR
 If you want to disable \-\-dynamic\-deps, then it may be necessary to

diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index 9bbc48e0a..eb1cd0108 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -352,7 +352,8 @@ class Scheduler(PollScheduler):
 		"""
 		self._set_graph_config(graph_config)
 		self._blocker_db = {}
-		dynamic_deps = self.myopts.get("--dynamic-deps", "n") != "n"
+		depgraph_params = create_depgraph_params(self.myopts, None)
+		dynamic_deps = "dynamic_deps" in depgraph_params
 		ignore_built_slot_operator_deps = self.myopts.get(
 			"--ignore-built-slot-operator-deps", "n") == "y"
 		for root in self.trees:

diff --git a/pym/_emerge/create_depgraph_params.py b/pym/_emerge/create_depgraph_params.py
index ecd65335c..2fc907d37 100644
--- a/pym/_emerge/create_depgraph_params.py
+++ b/pym/_emerge/create_depgraph_params.py
@@ -46,9 +46,9 @@ def create_depgraph_params(myopts, myaction):
 	myparams["ignore_soname_deps"] = myopts.get(
 		"--ignore-soname-deps", "y")
 
-	dynamic_deps = myopts.get("--dynamic-deps")
-	if dynamic_deps is not None:
-		myparams["dynamic_deps"] = dynamic_deps
+	dynamic_deps = myopts.get("--dynamic-deps", "y") != "n"
+	if dynamic_deps:
+		myparams["dynamic_deps"] = True
 
 	if myaction == "remove":
 		myparams["remove"] = True

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index ac0afdf07..1c47b4b63 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -137,7 +137,7 @@ class _frozen_depgraph_config(object):
 		self.soname_deps_enabled = (
 			("--usepkgonly" in myopts or "remove" in params) and
 			params.get("ignore_soname_deps") != "y")
-		dynamic_deps = myopts.get("--dynamic-deps", "n") != "n"
+		dynamic_deps = "dynamic_deps" in params
 		ignore_built_slot_operator_deps = myopts.get(
 			"--ignore-built-slot-operator-deps", "n") == "y"
 		for myroot in trees:
@@ -627,8 +627,7 @@ class depgraph(object):
 
 		for myroot in self._frozen_config.trees:
 
-			dynamic_deps = self._dynamic_config.myparams.get(
-				"dynamic_deps", "n") != "n"
+			dynamic_deps = "dynamic_deps" in self._dynamic_config.myparams
 			preload_installed_pkgs = \
 				"--nodeps" not in self._frozen_config.myopts
 
@@ -985,7 +984,7 @@ class depgraph(object):
 		  * none of the packages with changed deps are in the graph
 		"""
 		if (self._dynamic_config.myparams.get("changed_deps", "n") == "y" or
-			self._dynamic_config.myparams.get("dynamic_deps", "n") == "y"):
+			"dynamic_deps" in self._dynamic_config.myparams):
 			return
 
 		report_pkgs = []


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2018-01-30  4:24 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2018-01-30  4:24 UTC (permalink / raw
  To: gentoo-commits

commit:     5dbddff5525c6ba6d20b0ab33eae6de9ab3081eb
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 28 14:03:44 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 04:24:03 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5dbddff5

emerge: add --changed-deps-report option (bug 645780)

The --dynamic-deps=n default causes confusion for users that are
accustomed to dynamic deps, therefore add a --changed-deps-report
option that is enabled by default for deep updates (if --usepkgonly
is not enabled).

The report is entirely suppressed in the following cases in which
the packages with changed dependencies are entirely harmless to the
user:

  * --changed-deps or --dynamic-deps is enabled
  * none of the packages with changed deps are in the graph

These cases suppress noise for the unaffected user, even though some
of the changed dependencies might be worthy of revision bumps.

The --quiet option suppresses the NOTE section of the report, but
the HINT section is still displayed since it might help users
resolve problems that are solved by --changed-deps.

Example output is as follows:

!!! Detected ebuild dependency change(s) without revision bump:

    net-misc/openssh-7.5_p1-r3::gentoo
    sys-fs/udisks-2.7.5::gentoo

NOTE: Refer to the following page for more information about dependency
      change(s) without revision bump:

          https://wiki.gentoo.org/wiki/Project:Portage/Changed_Deps

      In order to suppress reports about dependency changes, add
      --changed-deps-report=n to the EMERGE_DEFAULT_OPTS variable in
      '/etc/portage/make.conf'.

HINT: In order to avoid problems involving changed dependencies, use the
      --changed-deps option to automatically trigger rebuilds when changed
      dependencies are detected. Refer to the emerge man page for more
      information about this option.

Bug: https://bugs.gentoo.org/645780

 man/emerge.1                          | 11 ++++
 pym/_emerge/create_depgraph_params.py |  7 +++
 pym/_emerge/depgraph.py               | 99 +++++++++++++++++++++++++++++++++--
 pym/_emerge/main.py                   | 13 +++++
 4 files changed, 127 insertions(+), 3 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 3c81b9c9f..189e6f879 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -465,6 +465,17 @@ option also implies the \fB\-\-selective\fR option. Behavior with
 respect to changed build\-time dependencies is controlled by the
 \fB\-\-with\-bdeps\fR option.
 .TP
+.BR "\-\-changed\-deps\-report [ y | n ]"
+Tells emerge to report ebuilds for which the ebuild dependencies have
+changed since the installed instance was built. Behavior with respect to
+changed build\-time dependencies is controlled by the
+\fB\-\-with\-bdeps\fR option. If the \fB\-\-update\fR and \fB\-\-deep\fR
+options are enabled then this option is enabled automatically for a
+dependency calculation if the cost of report generation is relatively
+insignificant (any calculation exclusively involving binary packages is
+exempt). The \fIEMERGE_DEFAULT_OPTS\fR variable may be used to disable
+this by default.
+.TP
 .BR \-\-changed\-use ", " \-U
 Tells emerge to include installed packages where USE flags have
 changed since installation. This option also implies the

diff --git a/pym/_emerge/create_depgraph_params.py b/pym/_emerge/create_depgraph_params.py
index cdea029ba..ecd65335c 100644
--- a/pym/_emerge/create_depgraph_params.py
+++ b/pym/_emerge/create_depgraph_params.py
@@ -28,6 +28,7 @@ def create_depgraph_params(myopts, myaction):
 	#   failures, or cause packages to be rebuilt or replaced.
 	# with_test_deps: pull in test deps for packages matched by arguments
 	# changed_deps: rebuild installed packages with outdated deps
+	# changed_deps_report: report installed packages with outdated deps
 	# binpkg_changed_deps: reject binary packages with outdated deps
 	myparams = {"recurse" : True}
 
@@ -126,6 +127,12 @@ def create_depgraph_params(myopts, myaction):
 	if changed_deps is not None:
 		myparams['changed_deps'] = changed_deps
 
+	changed_deps_report = myopts.get('--changed-deps-report')
+	if (changed_deps_report != 'n' and
+		not (myaction == 'remove' or '--usepkgonly' in myopts) and
+		deep is True and '--update' in myopts):
+		myparams['changed_deps_report'] = True
+
 	if myopts.get("--selective") == "n":
 		# --selective=n can be used to remove selective
 		# behavior that may have been implied by some

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 27bec3b32..ac0afdf07 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -462,6 +462,7 @@ class _dynamic_depgraph_config(object):
 		self._highest_pkg_cache = {}
 		self._highest_pkg_cache_cp_map = {}
 		self._flatten_atoms_cache = {}
+		self._changed_deps_pkgs = {}
 
 		# Binary packages that have been rejected because their USE
 		# didn't match the user's config. It maps packages to a set
@@ -974,6 +975,86 @@ class depgraph(object):
 
 		return False
 
+	def _changed_deps_report(self):
+		"""
+		Report ebuilds for which the ebuild dependencies have
+		changed since the installed instance was built. This is
+		completely silent in the following cases:
+
+		  * --changed-deps or --dynamic-deps is enabled
+		  * none of the packages with changed deps are in the graph
+		"""
+		if (self._dynamic_config.myparams.get("changed_deps", "n") == "y" or
+			self._dynamic_config.myparams.get("dynamic_deps", "n") == "y"):
+			return
+
+		report_pkgs = []
+		for pkg, ebuild in self._dynamic_config._changed_deps_pkgs.items():
+			if pkg.repo != ebuild.repo:
+				continue
+			report_pkgs.append((pkg, ebuild))
+
+		if not report_pkgs:
+			return
+
+		# TODO: Detect and report various issues:
+		# - packages with unsatisfiable dependencies
+		# - packages involved directly in slot or blocker conflicts
+		# - direct parents of conflict packages
+		# - packages that prevent upgrade of dependencies to latest versions
+		graph = self._dynamic_config.digraph
+		in_graph = False
+		for pkg, ebuild in report_pkgs:
+			if pkg in graph:
+				in_graph = True
+				break
+
+		# Packages with changed deps are harmless if they're not in the
+		# graph, so it's safe to silently ignore them. This suppresses
+		# noise for the unaffected user, even though some of the changed
+		# dependencies might be worthy of revision bumps.
+		if not in_graph:
+			return
+
+		writemsg("\n%s\n\n" % colorize("WARN",
+			"!!! Detected ebuild dependency change(s) without revision bump:"),
+			noiselevel=-1)
+
+		for pkg, ebuild in report_pkgs:
+			writemsg("    %s::%s" % (pkg.cpv, pkg.repo), noiselevel=-1)
+			if pkg.root_config.settings["ROOT"] != "/":
+				writemsg(" for %s" % (pkg.root,), noiselevel=-1)
+			writemsg("\n", noiselevel=-1)
+
+		msg = []
+		if '--quiet' not in self._frozen_config.myopts:
+			msg.extend([
+			"",
+			"NOTE: Refer to the following page for more information about dependency",
+			"      change(s) without revision bump:",
+			"",
+			"          https://wiki.gentoo.org/wiki/Project:Portage/Changed_Deps",
+			"",
+			"      In order to suppress reports about dependency changes, add",
+			"      --changed-deps-report=n to the EMERGE_DEFAULT_OPTS variable in",
+			"      '/etc/portage/make.conf'.",
+			])
+
+		# Include this message for --quiet mode, since the user may be experiencing
+		# problems that are solvable by using --changed-deps.
+		msg.extend([
+			"",
+			"HINT: In order to avoid problems involving changed dependencies, use the",
+			"      --changed-deps option to automatically trigger rebuilds when changed",
+			"      dependencies are detected. Refer to the emerge man page for more",
+			"      information about this option.",
+		])
+
+		for line in msg:
+			if line:
+				line = colorize("INFORM", line)
+			writemsg(line + "\n", noiselevel=-1)
+
 	def _show_ignored_binaries(self):
 		"""
 		Show binaries that have been ignored because their USE didn't
@@ -2569,6 +2650,10 @@ class depgraph(object):
 
 				changed = built_deps != unbuilt_deps
 
+				if (changed and pkg.installed and
+					self._dynamic_config.myparams.get("changed_deps_report")):
+					self._dynamic_config._changed_deps_pkgs[pkg] = ebuild
+
 		return changed
 
 	def _create_graph(self, allow_unsatisfied=False):
@@ -6354,6 +6439,8 @@ class depgraph(object):
 					changed_deps = (
 						self._dynamic_config.myparams.get(
 						"changed_deps", "n") != "n")
+					changed_deps_report = self._dynamic_config.myparams.get(
+						"changed_deps_report")
 					binpkg_changed_deps = (
 						self._dynamic_config.myparams.get(
 						"binpkg_changed_deps", "n") != "n")
@@ -6395,9 +6482,13 @@ class depgraph(object):
 									continue
 								break
 
-						if (((installed and changed_deps) or
-							(not installed and binpkg_changed_deps)) and
-							self._changed_deps(pkg)):
+						installed_changed_deps = False
+						if installed and (changed_deps or changed_deps_report):
+							installed_changed_deps = self._changed_deps(pkg)
+
+						if ((installed_changed_deps and changed_deps) or
+							(not installed and binpkg_changed_deps and
+							self._changed_deps(pkg))):
 							if not installed:
 								self._dynamic_config.\
 									ignored_binaries.setdefault(
@@ -8753,6 +8844,8 @@ class depgraph(object):
 
 		self._show_ignored_binaries()
 
+		self._changed_deps_report()
+
 		self._display_autounmask()
 
 		for depgraph_sets in self._dynamic_config.sets.values():

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 6a4bb87d0..fbc2ce01c 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -136,6 +136,7 @@ def insert_optional_args(args):
 		'--binpkg-changed-deps'  : y_or_n,
 		'--buildpkg'             : y_or_n,
 		'--changed-deps'         : y_or_n,
+		'--changed-deps-report'  : y_or_n,
 		'--complete-graph'       : y_or_n,
 		'--deep'       : valid_integers,
 		'--depclean-lib-check'   : y_or_n,
@@ -408,6 +409,12 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices" : true_y_or_n
 		},
 
+		"--changed-deps-report": {
+			"help"    : ("report installed packages with "
+				"outdated dependencies"),
+			"choices" : true_y_or_n
+		},
+
 		"--config-root": {
 			"help":"specify the location for portage configuration files",
 			"action":"store"
@@ -833,6 +840,12 @@ def parse_opts(tmpcmdline, silent=False):
 		else:
 			myoptions.changed_deps = 'n'
 
+	if myoptions.changed_deps_report is not None:
+		if myoptions.changed_deps_report in true_y:
+			myoptions.changed_deps_report = 'y'
+		else:
+			myoptions.changed_deps_report = 'n'
+
 	if myoptions.changed_use is not False:
 		myoptions.reinstall = "changed-use"
 		myoptions.changed_use = False


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2016-08-08 15:56 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2016-08-08 15:56 UTC (permalink / raw
  To: gentoo-commits

commit:     b7f0937a811ef4859333ccc45f8076dca109dc2f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 25 03:00:15 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Aug  8 15:43:53 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b7f0937a

emerge: add --fuzzy-search and --search-similarity (bug 65566)

Add --fuzzy-search option, and --search-similarity option to adjust
the minimum similarity for search results (defaults to 80%).

X-Gentoo-bug: 65566
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=65566
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org>

 man/emerge.1           | 14 ++++++++++++++
 pym/_emerge/actions.py |  7 +++++--
 pym/_emerge/main.py    | 32 +++++++++++++++++++++++++++++++-
 pym/_emerge/search.py  | 26 ++++++++++++++++++++++++--
 4 files changed, 74 insertions(+), 5 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index da1d852..7442220 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -565,6 +565,14 @@ packages (fetch things from SRC_URI based upon USE setting).
 Instead of doing any package building, just perform fetches for all
 packages (fetch everything in SRC_URI regardless of USE setting).
 .TP
+.BR "\-\-fuzzy\-search [ y | n ]"
+Enable or disable fuzzy search for search actions. When fuzzy search
+is enabled, a result is returned if it is sufficiently similar to the
+search string, without requiring an exact match. This option is enabled
+by default. Fuzzy search does not support regular expressions, therefore
+it is automatically disabled for regular expression searches. Fuzzy
+search is slightly slower than non\-fuzzy search.
+.TP
 .BR "\-\-getbinpkg [ y | n ] (\-g short option)"
 Using the server and location defined in \fIPORTAGE_BINHOST\fR (see
 \fBmake.conf\fR(5)), portage will download the information from each binary
@@ -874,6 +882,12 @@ enabled by default. The search index needs to be regenerated by
 to \fBEMERGE_DEFAULT_OPTS\fR (see \fBmake.conf\fR(5)) and later
 overridden via the command line.
 .TP
+.BR "\-\-search\-similarity PERCENTAGE"
+Set the minimum similarity percentage (a floating-point number between
+0 and 100). Search results with similarity percentages lower than this
+are discarded (default: \'80\'). This option has no effect unless the
+\fB\-\-fuzzy\-search\fR option is enabled.
+.TP
 .BR "\-\-select [ y | n ] (\-w short option)"
 Add specified packages to the world set (inverse of
 \fB\-\-oneshot\fR). This is useful if you want to

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 1dc2b0d..6704afc 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import division, print_function, unicode_literals
@@ -1974,7 +1974,10 @@ def action_search(root_config, myopts, myfiles, spinner):
 			spinner, "--searchdesc" in myopts,
 			"--quiet" not in myopts, "--usepkg" in myopts,
 			"--usepkgonly" in myopts,
-			search_index = myopts.get("--search-index", "y") != "n")
+			search_index=myopts.get("--search-index", "y") != "n",
+			search_similarity=myopts.get("--search-similarity"),
+			fuzzy=myopts.get("--fuzzy-search") != "n",
+			)
 		for mysearch in myfiles:
 			try:
 				searchinstance.execute(mysearch)

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 0e672a2..eae1954 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
@@ -141,6 +141,7 @@ def insert_optional_args(args):
 		'--deselect'             : y_or_n,
 		'--binpkg-respect-use'   : y_or_n,
 		'--fail-clean'           : y_or_n,
+		'--fuzzy-search'         : y_or_n,
 		'--getbinpkg'            : y_or_n,
 		'--getbinpkgonly'        : y_or_n,
 		'--jobs'       : valid_integers,
@@ -458,6 +459,11 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices" : true_y_or_n
 		},
 
+		"--fuzzy-search": {
+			"help": "Enable or disable fuzzy search",
+			"choices": true_y_or_n
+		},
+
 		"--ignore-built-slot-operator-deps": {
 			"help": "Ignore the slot/sub-slot := operator parts of dependencies that have "
 				"been recorded when packages where built. This option is intended "
@@ -658,6 +664,12 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices": y_or_n
 		},
 
+		"--search-similarity": {
+			"help": ("Set minimum similarity percentage for fuzzy seach "
+				"(a floating-point number between 0 and 100)"),
+			"action": "store"
+		},
+
 		"--select": {
 			"shortopt" : "-w",
 			"help"    : "add specified packages to the world set " + \
@@ -855,6 +867,9 @@ def parse_opts(tmpcmdline, silent=False):
 	if myoptions.fail_clean in true_y:
 		myoptions.fail_clean = True
 
+	if myoptions.fuzzy_search in true_y:
+		myoptions.fuzzy_search = True
+
 	if myoptions.getbinpkg in true_y:
 		myoptions.getbinpkg = True
 	else:
@@ -1009,6 +1024,21 @@ def parse_opts(tmpcmdline, silent=False):
 
 		myoptions.rebuilt_binaries_timestamp = rebuilt_binaries_timestamp
 
+	if myoptions.search_similarity:
+		try:
+			search_similarity = float(myoptions.search_similarity)
+		except ValueError:
+			parser.error("Invalid --search-similarity parameter "
+				"(not a number): '{}'\n".format(
+				myoptions.search_similarity))
+
+		if search_similarity < 0 or search_similarity > 100:
+			parser.error("Invalid --search-similarity parameter "
+				"(not between 0 and 100): '{}'\n".format(
+				myoptions.search_similarity))
+
+		myoptions.search_similarity = search_similarity
+
 	if myoptions.use_ebuild_visibility in true_y:
 		myoptions.use_ebuild_visibility = True
 	else:

diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py
index 32d326e..20a0c02 100644
--- a/pym/_emerge/search.py
+++ b/pym/_emerge/search.py
@@ -1,8 +1,9 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
 
+import difflib
 import re
 import portage
 from portage import os
@@ -28,7 +29,8 @@ class search(object):
 	# public interface
 	#
 	def __init__(self, root_config, spinner, searchdesc,
-		verbose, usepkg, usepkgonly, search_index=True):
+		verbose, usepkg, usepkgonly, search_index=True,
+		search_similarity=None, fuzzy=True):
 		"""Searches the available and installed packages for the supplied search key.
 		The list of available and installed packages is created at object instantiation.
 		This makes successive searches faster."""
@@ -42,6 +44,9 @@ class search(object):
 		self.spinner = None
 		self.root_config = root_config
 		self.setconfig = root_config.setconfig
+		self.fuzzy = fuzzy
+		self.search_similarity = (80 if search_similarity is None
+			else search_similarity)
 		self.matches = {"pkg" : []}
 		self.mlen = 0
 
@@ -248,11 +253,26 @@ class search(object):
 		if self.searchkey.startswith('@'):
 			match_category = 1
 			self.searchkey = self.searchkey[1:]
+		fuzzy = False
 		if regexsearch:
 			self.searchre=re.compile(self.searchkey,re.I)
 		else:
 			self.searchre=re.compile(re.escape(self.searchkey), re.I)
 
+			# Fuzzy search does not support regular expressions, therefore
+			# it is disabled for regular expression searches.
+			if self.fuzzy:
+				fuzzy = True
+				cutoff = float(self.search_similarity) / 100
+				seq_match = difflib.SequenceMatcher()
+				seq_match.set_seq2(self.searchkey.lower())
+
+				def fuzzy_search(match_string):
+					seq_match.set_seq1(match_string.lower())
+					return (seq_match.real_quick_ratio() >= cutoff and
+						seq_match.quick_ratio() >= cutoff and
+						seq_match.ratio() >= cutoff)
+
 		for package in self._cp_all():
 			self._spinner_update()
 
@@ -263,6 +283,8 @@ class search(object):
 
 			if self.searchre.search(match_string):
 				yield ("pkg", package)
+			elif fuzzy and fuzzy_search(match_string):
+				yield ("pkg", package)
 			elif self.searchdesc: # DESCRIPTION searching
 				# Use _first_cp to avoid an expensive visibility check,
 				# since the visibility check can be avoided entirely


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2014-12-07 23:14 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2014-12-07 23:14 UTC (permalink / raw
  To: gentoo-commits

commit:     55c8c8bc7a781e3f71ce92922eea64ad4cafce3c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Nov  5 05:07:26 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Dec  7 23:10:48 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=55c8c8bc

Add emerge --search-index option.

The new emerge --search-index option, which is enabled by default,
causes pkg_desc_index to be used for search optimization. The search
index needs to be regenerated by egencache after changes are made to
a repository (see the --update-pkg-desc-index action).

For users that would like to modify ebuilds in a repository without
running egencache afterwards, emerge --search-index=n can be used to
get non-indexed search. Alternatively, the user could simply remove
the stale index file, in order to disable the search index for a
particular repository.

In order to conserve memory, indices are read as streams, and
MultiIterGroupBy is used to group results from IndexedPortdb and
IndexedVardb. Stream-oriented search also makes it possible to
display search results incrementally (for bug #412471).

X-Gentoo-Bug: 525718
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=525718

---
 man/emerge.1            |  8 ++++++++
 pym/_emerge/actions.py  |  3 ++-
 pym/_emerge/depgraph.py |  2 +-
 pym/_emerge/main.py     |  5 +++++
 pym/_emerge/search.py   | 31 ++++++++++++++++++++++++++-----
 5 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index be46a7d..b9ce79c 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -804,6 +804,14 @@ If ebuilds using EAPIs which \fIdo not\fR support \fBHDEPEND\fR are built in
 the same \fBemerge\fR run as those using EAPIs which \fIdo\fR support
 \fBHDEPEND\fR, this option affects only the former.
 .TP
+.BR "\-\-search\-index < y | n >"
+Enable or disable indexed search for search actions. This option is
+enabled by default. The search index needs to be regenerated by
+\fBegencache\fR(1) after changes are made to a repository (see the
+\fB\-\-update\-pkg\-desc\-index\fR action). This setting can be added
+to \fBEMERGE_DEFAULT_OPTS\fR (see \fBmake.conf\fR(5)) and later
+overridden via the command line.
+.TP
 .BR "\-\-select [ y | n ] (\-w short option)"
 Add specified packages to the world set (inverse of
 \fB\-\-oneshot\fR). This is useful if you want to

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 434fc47..c7246a9 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -1901,7 +1901,8 @@ def action_search(root_config, myopts, myfiles, spinner):
 		searchinstance = search(root_config,
 			spinner, "--searchdesc" in myopts,
 			"--quiet" not in myopts, "--usepkg" in myopts,
-			"--usepkgonly" in myopts)
+			"--usepkgonly" in myopts,
+			search_index = myopts.get("--search-index", "y") != "n")
 		for mysearch in myfiles:
 			try:
 				searchinstance.execute(mysearch)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 3455b6b..df1e266 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -8730,7 +8730,7 @@ def ambiguous_package_name(arg, atoms, root_config, spinner, myopts):
 
 	s = search(root_config, spinner, "--searchdesc" in myopts,
 		"--quiet" not in myopts, "--usepkg" in myopts,
-		"--usepkgonly" in myopts)
+		"--usepkgonly" in myopts, search_index = False)
 	null_cp = portage.dep_getkey(insert_category_into_atom(
 		arg, "null"))
 	cat, atom_pn = portage.catsplit(null_cp)

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 1506207..66d4891 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -617,6 +617,11 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices" :("True", "rdeps")
 		},
 
+		"--search-index": {
+			"help": "Enable or disable indexed search (enabled by default)",
+			"choices": y_or_n
+		},
+
 		"--select": {
 			"shortopt" : "-w",
 			"help"    : "add specified packages to the world set " + \

diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py
index e51d206..4b1833a 100644
--- a/pym/_emerge/search.py
+++ b/pym/_emerge/search.py
@@ -5,9 +5,12 @@ import re
 import portage
 from portage import os
 from portage.dbapi.porttree import _parse_uri_map
+from portage.dbapi.IndexedPortdb import IndexedPortdb
+from portage.dbapi.IndexedVardb import IndexedVardb
 from portage.localization import localized_size
 from portage.output import  bold, bold as white, darkgreen, green, red
 from portage.util import writemsg_stdout
+from portage.util.iterators.MultiIterGroupBy import MultiIterGroupBy
 
 from _emerge.Package import Package
 
@@ -23,7 +26,7 @@ class search(object):
 	# public interface
 	#
 	def __init__(self, root_config, spinner, searchdesc,
-		verbose, usepkg, usepkgonly):
+		verbose, usepkg, usepkgonly, search_index=True):
 		"""Searches the available and installed packages for the supplied search key.
 		The list of available and installed packages is created at object instantiation.
 		This makes successive searches faster."""
@@ -45,6 +48,10 @@ class search(object):
 		bindb = root_config.trees["bintree"].dbapi
 		vardb = root_config.trees["vartree"].dbapi
 
+		if search_index:
+			portdb = IndexedPortdb(portdb)
+			vardb = IndexedVardb(vardb)
+
 		if not usepkgonly and portdb._have_root_eclass_dir:
 			self._dbs.append(portdb)
 
@@ -60,10 +67,16 @@ class search(object):
 			self.spinner.update()
 
 	def _cp_all(self):
-		cp_all = set()
+		iterators = []
 		for db in self._dbs:
-			cp_all.update(db.cp_all())
-		return list(sorted(cp_all))
+			i = db.cp_all()
+			try:
+				i = iter(i)
+			except TypeError:
+				pass
+			iterators.append(i)
+		for group in MultiIterGroupBy(iterators):
+			yield group[0]
 
 	def _aux_get(self, *args, **kwargs):
 		for db in self._dbs:
@@ -154,9 +167,17 @@ class search(object):
 						result = cpv
 				else:
 					db_keys = list(db._aux_cache_keys)
+					matches = db.match(atom)
+					try:
+						db.match_unordered
+					except AttributeError:
+						pass
+					else:
+						db._cpv_sort_ascending(matches)
+
 					# break out of this loop with highest visible
 					# match, checked in descending order
-					for cpv in reversed(db.match(atom)):
+					for cpv in reversed(matches):
 						if portage.cpv_getkey(cpv) != cp:
 							continue
 						metadata = zip(db_keys,


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2014-10-21 23:11 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2014-10-21 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     3a22c197d00b81efeb78fe75359b49316844c2e2
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 20 20:04:28 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 21 23:06:57 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3a22c197

emerge --read-news: prompt only if --ask

This fixes any conditional logic that applies to --ask so that it
also applies to --read-news. For example, emerge will bail out
automatically if --ask is enabled and stdin is not a tty.

X-Gentoo-Bug: 517310
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=517310

---
 man/emerge.1           | 5 +++--
 pym/_emerge/actions.py | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 9873ba9..12e8b45 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -716,8 +716,9 @@ Disable the warning message that's shown prior to
 to be set in the \fBmake.conf\fR(5)
 \fBEMERGE_DEFAULT_OPTS\fR variable.
 .TP
-.BR "\-\-read-news [ y | n ]"
-Offer to read news via eselect if there are unread news.
+.BR "\-\-read\-news [ y | n ]"
+Offer to read news via eselect if there are unread news. This option
+has no effect unless \fB\-\-ask\fR is enabled.
 .TP
 .BR "\-\-rebuild\-if\-new\-slot [ y | n ]"
 Automatically rebuild or reinstall packages when slot/sub\-slot :=

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 4e8b83b..7672fe6 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -4064,6 +4064,7 @@ def run_action(emerge_config):
 			uq = UserQuery(emerge_config.opts)
 			if display_news_notification(emerge_config.target_config,
 								emerge_config.opts) \
+				and "--ask" in emerge_config.opt \
 				and "--read-news" in emerge_config.opts \
 				and uq.query("Would you like to read the news items while " \
 						"calculating dependencies?",


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2014-10-20  0:08 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2014-10-20  0:08 UTC (permalink / raw
  To: gentoo-commits

commit:     d55690aa3a1a9b4a78e87acd6ce179c17262966e
Author:     Greg Kubaryk <kurly <AT> vt <DOT> edu>
AuthorDate: Mon Oct 20 00:07:20 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 20 00:07:20 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d55690aa

emerge: add -U option short for --changed-use

X-Gentoo-Bug: 524426
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=524426

---
 man/emerge.1        | 4 ++--
 pym/_emerge/main.py | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 2264b58..9873ba9 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Sep 2014" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Oct 2014" "Portage VERSION" "Portage"
 .SH "NAME"
 emerge \- Command\-line interface to the Portage system
 .SH "SYNOPSIS"
@@ -399,7 +399,7 @@ Creates binary packages for all ebuilds processed without actually
 merging the packages.  This comes with the caveat that all build-time
 dependencies must already be emerged on the system.
 .TP
-.BR "\-\-changed\-use"
+.BR "\-\-changed\-use " (\fB\-U\fR)
 Tells emerge to include installed packages where USE flags have
 changed since installation. This option also implies the
 \fB\-\-selective\fR option. Unlike \fB\-\-newuse\fR, the

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 3883f72..f5f2ec4 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -69,7 +69,7 @@ shortmapping={
 "r":"--resume",
 "s":"--search",    "S":"--searchdesc",
 "t":"--tree",
-"u":"--update",
+"u":"--update",    "U":"--changed-use",
 "V":"--version"
 }
 


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2014-09-24 22:36 Brian Dolbec
  0 siblings, 0 replies; 38+ messages in thread
From: Brian Dolbec @ 2014-09-24 22:36 UTC (permalink / raw
  To: gentoo-commits

commit:     3bdaadba9d326374c978c4a521a9db4125279430
Author:     Alexander Berntsen <alexander <AT> plaimi <DOT> net>
AuthorDate: Mon Sep 22 11:51:21 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Sep 24 22:35:45 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3bdaadba

emerge: --autounmask-write if --ask (bug 481578)

Signed-off-by: Alexander Berntsen <bernalex <AT> gentoo.org>

---
 man/emerge.1            | 5 +++--
 pym/_emerge/depgraph.py | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index e32bb43..a2cb3f6 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Mar 2014" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Sep 2014" "Portage VERSION" "Portage"
 .SH "NAME"
 emerge \- Command\-line interface to the Portage system
 .SH "SYNOPSIS"
@@ -367,7 +367,8 @@ to config files, respecting \fBCONFIG_PROTECT\fR and \fB\-\-ask\fR.
 If the corresponding package.* is a file, the changes are appended to
 it, if it is a directory, changes are written to the lexicographically
 last file. This way it is always ensured that the new changes take
-precedence over existing changes.
+precedence over existing changes. This option is automatically enabled with
+\-\-ask.
 .TP
 .BR \-\-backtrack=COUNT
 Specifies an integer number of times to backtrack if

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index f6f716d..5180db5 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -7517,12 +7517,14 @@ class depgraph(object):
 		(using CONFIG_PROTECT). The message includes the comments and the changes.
 		"""
 
-		autounmask_write = self._frozen_config.myopts.get("--autounmask-write", "n") == True
+		ask = "--ask" in self._frozen_config.myopts
+		autounmask_write = \
+				self._frozen_config.myopts.get("--autounmask-write",
+								   ask) is True
 		autounmask_unrestricted_atoms = \
 			self._frozen_config.myopts.get("--autounmask-unrestricted-atoms", "n") == True
 		quiet = "--quiet" in self._frozen_config.myopts
 		pretend = "--pretend" in self._frozen_config.myopts
-		ask = "--ask" in self._frozen_config.myopts
 		enter_invalid = '--ask-enter-invalid' in self._frozen_config.myopts
 
 		def check_if_latest(pkg):


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2014-06-14 21:46 Alexander Berntsen
  0 siblings, 0 replies; 38+ messages in thread
From: Alexander Berntsen @ 2014-06-14 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     15433c52866e09967142fd2352bd7aad9ad5026f
Author:     Alexander Berntsen <bernalex <AT> gentoo <DOT> org>
AuthorDate: Thu May  8 15:47:58 2014 +0000
Commit:     Alexander Berntsen <bernalex <AT> gentoo <DOT> org>
CommitDate: Sat Jun 14 21:41:48 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=15433c52

emerge: Implement "--alert"

Implement "--alert" (short option "-A"), which adds a terminal bell
character ('\a') to all prompts, when it is set to True or "y".

The patch refactors userquery to a class, UserQuery, to accommodate
--alert. It also adds the option to the emerge man page.

Signed-off-by: Alexander Berntsen <bernalex <AT> gentoo.org>

---
 man/emerge.1             | 14 ++++++++++
 pym/_emerge/UserQuery.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
 pym/_emerge/actions.py   | 19 ++++++++-----
 pym/_emerge/depgraph.py  |  9 ++++--
 pym/_emerge/main.py      | 13 +++++++++
 pym/_emerge/unmerge.py   |  5 ++--
 pym/_emerge/userquery.py | 55 -------------------------------------
 7 files changed, 119 insertions(+), 67 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index abb0ed8..1db41b0 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -297,6 +297,20 @@ re\-distributable. With default
 configuration, this would result in an effective
 \fBACCEPT_RESTRICT\fR value of "* -bindist".
 .TP
+.BR "\-\-alert [ y | n ] (\-A short option)"
+Add a terminal bell character ('\\a') to all interactive prompts. This
+is especially useful if dependency resolution is taking a long time, and
+you want emerge to alert you when it is finished. If you use
+\fBemerge -auAD world\fR, emerge will courteously point out when it has
+finished calculating the graph.
+
+\fB--alert\fR may be 'y' or 'n'. 'true' and 'false' mean the same thing.
+Using \fB--alert\fR without an option is the same as using it with 'y'.
+Try it with 'emerge -aAC gcc'. Remember to answer \fBno\fR!
+
+If your terminal emulator is set up to make '\\a' into a window manager
+urgency hint, move your cursor to a different window to get the effect.
+.TP
 .BR "\-\-alphabetical "
 When displaying USE and other flag output, combines the enabled and
 disabled lists into one list and sorts the whole list alphabetically.

diff --git a/pym/_emerge/UserQuery.py b/pym/_emerge/UserQuery.py
new file mode 100644
index 0000000..c866a0d
--- /dev/null
+++ b/pym/_emerge/UserQuery.py
@@ -0,0 +1,71 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from __future__ import print_function
+
+import signal
+import sys
+
+from portage.output import bold, create_color_func
+
+
+class UserQuery(object):
+	"""The UserQuery class is used to prompt the user with a set of responses,
+	as well as accepting and handling the responses."""
+
+	def __init__(self, myopts):
+		self.myopts = myopts
+
+	def query(self, prompt, enter_invalid, responses=None, colours=None):
+		"""Display a prompt and a set of responses, then waits for user input
+		and check it against the responses. The first match is returned.
+
+		An empty response will match the first value in the list of responses,
+		unless enter_invalid is True. The input buffer is *not* cleared prior
+		to the prompt!
+
+		prompt: The String to display as a prompt.
+		responses: a List of Strings with the acceptable responses.
+		colours: a List of Functions taking and returning a String, used to
+		process the responses for display. Typically these will be functions
+		like red() but could be e.g. lambda x: "DisplayString".
+
+		If responses is omitted, it defaults to ["Yes", "No"], [green, red].
+		If only colours is omitted, it defaults to [bold, ...].
+
+		Returns a member of the List responses. (If called without optional
+		arguments, it returns "Yes" or "No".)
+
+		KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
+		printed."""
+		if responses is None:
+			responses = ["Yes", "No"]
+			colours = [
+				create_color_func("PROMPT_CHOICE_DEFAULT"),
+				create_color_func("PROMPT_CHOICE_OTHER")
+			]
+		elif colours is None:
+			colours=[bold]
+		colours=(colours*len(responses))[:len(responses)]
+		if "--alert" in self.myopts:
+			prompt = '\a' + prompt
+		print(bold(prompt), end=' ')
+		try:
+			while True:
+				if sys.hexversion >= 0x3000000:
+					response=input("["+"/".join([colours[i](responses[i])
+								  for i in range(len(responses))])+"] ")
+				else:
+					response=raw_input("["+"/".join([colours[i](responses[i])
+									  for i in range(len(responses))])+"] ")
+				if response or not enter_invalid:
+					for key in responses:
+						# An empty response will match the
+						# first value in responses.
+						if response.upper()==key[:len(response)].upper():
+							return key
+				print("Sorry, response '%s' not understood." % response,
+		  end=' ')
+		except (EOFError, KeyboardInterrupt):
+			print("Interrupted.")
+			sys.exit(128 + signal.SIGINT)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 4ca2f1c..b935139 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -84,7 +84,7 @@ from _emerge.sync.old_tree_timestamp import old_tree_timestamp_warn
 from _emerge.unmerge import unmerge
 from _emerge.UnmergeDepPriority import UnmergeDepPriority
 from _emerge.UseFlagDisplay import pkg_use_display
-from _emerge.userquery import userquery
+from _emerge.UserQuery import UserQuery
 
 if sys.hexversion >= 0x3000000:
 	long = int
@@ -387,8 +387,9 @@ def action_build(settings, trees, mtimedb,
 			else:
 				prompt="Would you like to merge these packages?"
 		print()
+		uq = UserQuery(myopts)
 		if prompt is not None and "--ask" in myopts and \
-			userquery(prompt, enter_invalid) == "No":
+			uq.query(prompt, enter_invalid) == "No":
 			print()
 			print("Quitting.")
 			print()
@@ -468,6 +469,7 @@ def action_build(settings, trees, mtimedb,
 
 def action_config(settings, trees, myopts, myfiles):
 	enter_invalid = '--ask-enter-invalid' in myopts
+	uq = UserQuery(myopts)
 	if len(myfiles) != 1:
 		print(red("!!! config can only take a single package atom at this time\n"))
 		sys.exit(1)
@@ -497,7 +499,7 @@ def action_config(settings, trees, myopts, myfiles):
 				print(options[-1]+") "+pkg)
 			print("X) Cancel")
 			options.append("X")
-			idx = userquery("Selection?", enter_invalid, responses=options)
+			idx = uq.query("Selection?", enter_invalid, responses=options)
 			if idx == "X":
 				sys.exit(128 + signal.SIGINT)
 			pkg = pkgs[int(idx)-1]
@@ -512,7 +514,7 @@ def action_config(settings, trees, myopts, myfiles):
 
 	print()
 	if "--ask" in myopts:
-		if userquery("Ready to configure %s?" % pkg, enter_invalid) == "No":
+		if uq.query("Ready to configure %s?" % pkg, enter_invalid) == "No":
 			sys.exit(128 + signal.SIGINT)
 	else:
 		print("Configuring pkg...")
@@ -1364,7 +1366,8 @@ def action_deselect(settings, trees, opts, atoms):
 			if '--ask' in opts:
 				prompt = "Would you like to remove these " + \
 					"packages from your world favorites?"
-				if userquery(prompt, enter_invalid) == 'No':
+				uq = UserQuery(opts)
+				if uq.query(prompt, enter_invalid) == 'No':
 					return 128 + signal.SIGINT
 
 			remaining = set(world_set)
@@ -2402,7 +2405,8 @@ def _sync_repo(emerge_config, repo):
 
 			if (retries==0):
 				if "--ask" in myopts:
-					if userquery("Do you want to sync your Portage tree " + \
+					uq = UserQuery(myopts)
+					if uq.query("Do you want to sync your Portage tree " + \
 						"with the mirror at\n" + blue(dosyncuri) + bold("?"),
 						enter_invalid) == "No":
 						print()
@@ -3841,7 +3845,8 @@ def run_action(emerge_config):
 						(access_desc,), noiselevel=-1)
 					if portage.data.secpass < 1 and not need_superuser:
 						portage.data.portage_group_warning()
-					if userquery("Would you like to add --pretend to options?",
+					uq = UserQuery(emerge_config.opts)
+					if uq.query("Would you like to add --pretend to options?",
 						"--ask-enter-invalid" in emerge_config.opts) == "No":
 						return 128 + signal.SIGINT
 					emerge_config.opts["--pretend"] = True

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index bede7c6..8177b74 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -73,7 +73,7 @@ from _emerge.SetArg import SetArg
 from _emerge.show_invalid_depstring_notice import show_invalid_depstring_notice
 from _emerge.UnmergeDepPriority import UnmergeDepPriority
 from _emerge.UseFlagDisplay import pkg_use_display
-from _emerge.userquery import userquery
+from _emerge.UserQuery import UserQuery
 
 from _emerge.resolver.backtracking import Backtracker, BacktrackParameter
 from _emerge.resolver.package_tracker import PackageTracker, PackageTrackerDbapiWrapper
@@ -520,6 +520,9 @@ class depgraph(object):
 		self._event_loop = (portage._internal_caller and
 			global_event_loop() or EventLoop(main=False))
 
+		self.uq = UserQuery(myopts)
+		self.query = UserQuery.query
+
 	def _load_vdb(self):
 		"""
 		Load installed package metadata if appropriate. This used to be called
@@ -7655,7 +7658,7 @@ class depgraph(object):
 		if ask and write_to_file and file_to_write_to:
 			prompt = "\nWould you like to add these " + \
 				"changes to your config files?"
-			if userquery(prompt, enter_invalid) == 'No':
+			if self.query(prompt, enter_invalid) == 'No':
 				write_to_file = False
 
 		if write_to_file and file_to_write_to:
@@ -7922,7 +7925,7 @@ class depgraph(object):
 					"favorites?"
 				enter_invalid = '--ask-enter-invalid' in \
 					self._frozen_config.myopts
-				if userquery(prompt, enter_invalid) == "No":
+				if self.query(prompt, enter_invalid) == "No":
 					skip = True
 
 			if not skip:

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index eddb16c..1a920f7 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -124,6 +124,7 @@ def insert_optional_args(args):
 	new_args = []
 
 	default_arg_opts = {
+		'--alert'                : y_or_n,
 		'--ask'                  : y_or_n,
 		'--autounmask'           : y_or_n,
 		'--autounmask-keep-masks': y_or_n,
@@ -169,6 +170,7 @@ def insert_optional_args(args):
 	# since existence of -n makes it too ambiguous.
 	short_arg_opts_n = {
 		'a' : y_or_n,
+		'A' : y_or_n,
 		'b' : y_or_n,
 		'g' : y_or_n,
 		'G' : y_or_n,
@@ -300,6 +302,12 @@ def parse_opts(tmpcmdline, silent=False):
 	true_y = ("True", "y")
 	argument_options = {
 
+		"--alert": {
+			"shortopt" : "-A",
+			"help"    : "alert (terminal bell) on prompts",
+			"choices" : true_y_or_n
+		},
+
 		"--ask": {
 			"shortopt" : "-a",
 			"help"    : "prompt before performing any actions",
@@ -675,6 +683,11 @@ def parse_opts(tmpcmdline, silent=False):
 
 	myoptions, myargs = parser.parse_known_args(args=tmpcmdline)
 
+	if myoptions.alert in true_y:
+		myoptions.alert = True
+	else:
+		myoptions.alert = None
+
 	if myoptions.ask in true_y:
 		myoptions.ask = True
 	else:

diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py
index b04f8f3..8f98563 100644
--- a/pym/_emerge/unmerge.py
+++ b/pym/_emerge/unmerge.py
@@ -17,8 +17,8 @@ from portage.versions import cpv_sort_key, _pkg_str
 
 from _emerge.emergelog import emergelog
 from _emerge.Package import Package
+from _emerge.UserQuery import UserQuery
 from _emerge.UninstallFailure import UninstallFailure
-from _emerge.userquery import userquery
 from _emerge.countdown import countdown
 
 def _unmerge_display(root_config, myopts, unmerge_action,
@@ -529,7 +529,8 @@ def unmerge(root_config, myopts, unmerge_action,
 		#we're done... return
 		return os.EX_OK
 	if "--ask" in myopts:
-		if userquery("Would you like to unmerge these packages?",
+		uq = UserQuery(myopts)
+		if uq.query("Would you like to unmerge these packages?",
 			enter_invalid) == "No":
 			# enter pretend mode for correct formatting of results
 			myopts["--pretend"] = True

diff --git a/pym/_emerge/userquery.py b/pym/_emerge/userquery.py
deleted file mode 100644
index efae80a..0000000
--- a/pym/_emerge/userquery.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-from __future__ import print_function
-
-import signal
-import sys
-
-from portage.output import bold, create_color_func
-
-def userquery(prompt, enter_invalid, responses=None, colours=None):
-	"""Displays a prompt and a set of responses, then waits for a response
-	which is checked against the responses and the first to match is
-	returned. An empty response will match the first value in responses,
-	unless enter_invalid is True. The input buffer is *not* cleared prior
-	to the prompt!
-
-	prompt: a String.
-	responses: a List of Strings.
-	colours: a List of Functions taking and returning a String, used to
-	process the responses for display. Typically these will be functions
-	like red() but could be e.g. lambda x: "DisplayString".
-	If responses is omitted, defaults to ["Yes", "No"], [green, red].
-	If only colours is omitted, defaults to [bold, ...].
-
-	Returns a member of the List responses. (If called without optional
-	arguments, returns "Yes" or "No".)
-	KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
-	printed."""
-	if responses is None:
-		responses = ["Yes", "No"]
-		colours = [
-			create_color_func("PROMPT_CHOICE_DEFAULT"),
-			create_color_func("PROMPT_CHOICE_OTHER")
-		]
-	elif colours is None:
-		colours=[bold]
-	colours=(colours*len(responses))[:len(responses)]
-	print(bold(prompt), end=' ')
-	try:
-		while True:
-			if sys.hexversion >= 0x3000000:
-				response=input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
-			else:
-				response=raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
-			if response or not enter_invalid:
-				for key in responses:
-					# An empty response will match the
-					# first value in responses.
-					if response.upper()==key[:len(response)].upper():
-						return key
-			print("Sorry, response '%s' not understood." % response, end=' ')
-	except (EOFError, KeyboardInterrupt):
-		print("Interrupted.")
-		sys.exit(128 + signal.SIGINT)


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2014-06-14 21:46 Alexander Berntsen
  0 siblings, 0 replies; 38+ messages in thread
From: Alexander Berntsen @ 2014-06-14 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     22637f20342dfd65d571212e9b426e697de1642a
Author:     Alexander Berntsen <bernalex <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 14 21:14:12 2014 +0000
Commit:     Alexander Berntsen <bernalex <AT> gentoo <DOT> org>
CommitDate: Sat Jun 14 21:33:16 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=22637f20

Revert "emerge: Implement "--alert""

This reverts commit 1a00ddf5fb089724a127c8dc72d63f10ae72abbf. It had
some furiously annoying mistakes in the commit message. Also, someone
alluded to the man page being too short. Thanks, Brian.

Signed-off-by: Alexander Berntsen <bernalex <AT> gentoo.org>

---
 man/emerge.1             |  5 ----
 pym/_emerge/UserQuery.py | 71 ------------------------------------------------
 pym/_emerge/actions.py   | 19 +++++--------
 pym/_emerge/depgraph.py  |  9 ++----
 pym/_emerge/main.py      | 13 ---------
 pym/_emerge/unmerge.py   |  5 ++--
 pym/_emerge/userquery.py | 55 +++++++++++++++++++++++++++++++++++++
 7 files changed, 67 insertions(+), 110 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index bbcf569..abb0ed8 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -297,11 +297,6 @@ re\-distributable. With default
 configuration, this would result in an effective
 \fBACCEPT_RESTRICT\fR value of "* -bindist".
 .TP
-.BR "\-\-alert "
-Add a terminal bell character ('\\a') to all interactive prompts. This is
-especially useful if dependency resolution is taking a long time, and
-you want emerge to alert you when it is finished.
-.TP
 .BR "\-\-alphabetical "
 When displaying USE and other flag output, combines the enabled and
 disabled lists into one list and sorts the whole list alphabetically.

diff --git a/pym/_emerge/UserQuery.py b/pym/_emerge/UserQuery.py
deleted file mode 100644
index c866a0d..0000000
--- a/pym/_emerge/UserQuery.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-from __future__ import print_function
-
-import signal
-import sys
-
-from portage.output import bold, create_color_func
-
-
-class UserQuery(object):
-	"""The UserQuery class is used to prompt the user with a set of responses,
-	as well as accepting and handling the responses."""
-
-	def __init__(self, myopts):
-		self.myopts = myopts
-
-	def query(self, prompt, enter_invalid, responses=None, colours=None):
-		"""Display a prompt and a set of responses, then waits for user input
-		and check it against the responses. The first match is returned.
-
-		An empty response will match the first value in the list of responses,
-		unless enter_invalid is True. The input buffer is *not* cleared prior
-		to the prompt!
-
-		prompt: The String to display as a prompt.
-		responses: a List of Strings with the acceptable responses.
-		colours: a List of Functions taking and returning a String, used to
-		process the responses for display. Typically these will be functions
-		like red() but could be e.g. lambda x: "DisplayString".
-
-		If responses is omitted, it defaults to ["Yes", "No"], [green, red].
-		If only colours is omitted, it defaults to [bold, ...].
-
-		Returns a member of the List responses. (If called without optional
-		arguments, it returns "Yes" or "No".)
-
-		KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
-		printed."""
-		if responses is None:
-			responses = ["Yes", "No"]
-			colours = [
-				create_color_func("PROMPT_CHOICE_DEFAULT"),
-				create_color_func("PROMPT_CHOICE_OTHER")
-			]
-		elif colours is None:
-			colours=[bold]
-		colours=(colours*len(responses))[:len(responses)]
-		if "--alert" in self.myopts:
-			prompt = '\a' + prompt
-		print(bold(prompt), end=' ')
-		try:
-			while True:
-				if sys.hexversion >= 0x3000000:
-					response=input("["+"/".join([colours[i](responses[i])
-								  for i in range(len(responses))])+"] ")
-				else:
-					response=raw_input("["+"/".join([colours[i](responses[i])
-									  for i in range(len(responses))])+"] ")
-				if response or not enter_invalid:
-					for key in responses:
-						# An empty response will match the
-						# first value in responses.
-						if response.upper()==key[:len(response)].upper():
-							return key
-				print("Sorry, response '%s' not understood." % response,
-		  end=' ')
-		except (EOFError, KeyboardInterrupt):
-			print("Interrupted.")
-			sys.exit(128 + signal.SIGINT)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index b935139..4ca2f1c 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -84,7 +84,7 @@ from _emerge.sync.old_tree_timestamp import old_tree_timestamp_warn
 from _emerge.unmerge import unmerge
 from _emerge.UnmergeDepPriority import UnmergeDepPriority
 from _emerge.UseFlagDisplay import pkg_use_display
-from _emerge.UserQuery import UserQuery
+from _emerge.userquery import userquery
 
 if sys.hexversion >= 0x3000000:
 	long = int
@@ -387,9 +387,8 @@ def action_build(settings, trees, mtimedb,
 			else:
 				prompt="Would you like to merge these packages?"
 		print()
-		uq = UserQuery(myopts)
 		if prompt is not None and "--ask" in myopts and \
-			uq.query(prompt, enter_invalid) == "No":
+			userquery(prompt, enter_invalid) == "No":
 			print()
 			print("Quitting.")
 			print()
@@ -469,7 +468,6 @@ def action_build(settings, trees, mtimedb,
 
 def action_config(settings, trees, myopts, myfiles):
 	enter_invalid = '--ask-enter-invalid' in myopts
-	uq = UserQuery(myopts)
 	if len(myfiles) != 1:
 		print(red("!!! config can only take a single package atom at this time\n"))
 		sys.exit(1)
@@ -499,7 +497,7 @@ def action_config(settings, trees, myopts, myfiles):
 				print(options[-1]+") "+pkg)
 			print("X) Cancel")
 			options.append("X")
-			idx = uq.query("Selection?", enter_invalid, responses=options)
+			idx = userquery("Selection?", enter_invalid, responses=options)
 			if idx == "X":
 				sys.exit(128 + signal.SIGINT)
 			pkg = pkgs[int(idx)-1]
@@ -514,7 +512,7 @@ def action_config(settings, trees, myopts, myfiles):
 
 	print()
 	if "--ask" in myopts:
-		if uq.query("Ready to configure %s?" % pkg, enter_invalid) == "No":
+		if userquery("Ready to configure %s?" % pkg, enter_invalid) == "No":
 			sys.exit(128 + signal.SIGINT)
 	else:
 		print("Configuring pkg...")
@@ -1366,8 +1364,7 @@ def action_deselect(settings, trees, opts, atoms):
 			if '--ask' in opts:
 				prompt = "Would you like to remove these " + \
 					"packages from your world favorites?"
-				uq = UserQuery(opts)
-				if uq.query(prompt, enter_invalid) == 'No':
+				if userquery(prompt, enter_invalid) == 'No':
 					return 128 + signal.SIGINT
 
 			remaining = set(world_set)
@@ -2405,8 +2402,7 @@ def _sync_repo(emerge_config, repo):
 
 			if (retries==0):
 				if "--ask" in myopts:
-					uq = UserQuery(myopts)
-					if uq.query("Do you want to sync your Portage tree " + \
+					if userquery("Do you want to sync your Portage tree " + \
 						"with the mirror at\n" + blue(dosyncuri) + bold("?"),
 						enter_invalid) == "No":
 						print()
@@ -3845,8 +3841,7 @@ def run_action(emerge_config):
 						(access_desc,), noiselevel=-1)
 					if portage.data.secpass < 1 and not need_superuser:
 						portage.data.portage_group_warning()
-					uq = UserQuery(emerge_config.opts)
-					if uq.query("Would you like to add --pretend to options?",
+					if userquery("Would you like to add --pretend to options?",
 						"--ask-enter-invalid" in emerge_config.opts) == "No":
 						return 128 + signal.SIGINT
 					emerge_config.opts["--pretend"] = True

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 8177b74..bede7c6 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -73,7 +73,7 @@ from _emerge.SetArg import SetArg
 from _emerge.show_invalid_depstring_notice import show_invalid_depstring_notice
 from _emerge.UnmergeDepPriority import UnmergeDepPriority
 from _emerge.UseFlagDisplay import pkg_use_display
-from _emerge.UserQuery import UserQuery
+from _emerge.userquery import userquery
 
 from _emerge.resolver.backtracking import Backtracker, BacktrackParameter
 from _emerge.resolver.package_tracker import PackageTracker, PackageTrackerDbapiWrapper
@@ -520,9 +520,6 @@ class depgraph(object):
 		self._event_loop = (portage._internal_caller and
 			global_event_loop() or EventLoop(main=False))
 
-		self.uq = UserQuery(myopts)
-		self.query = UserQuery.query
-
 	def _load_vdb(self):
 		"""
 		Load installed package metadata if appropriate. This used to be called
@@ -7658,7 +7655,7 @@ class depgraph(object):
 		if ask and write_to_file and file_to_write_to:
 			prompt = "\nWould you like to add these " + \
 				"changes to your config files?"
-			if self.query(prompt, enter_invalid) == 'No':
+			if userquery(prompt, enter_invalid) == 'No':
 				write_to_file = False
 
 		if write_to_file and file_to_write_to:
@@ -7925,7 +7922,7 @@ class depgraph(object):
 					"favorites?"
 				enter_invalid = '--ask-enter-invalid' in \
 					self._frozen_config.myopts
-				if self.query(prompt, enter_invalid) == "No":
+				if userquery(prompt, enter_invalid) == "No":
 					skip = True
 
 			if not skip:

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 1a920f7..eddb16c 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -124,7 +124,6 @@ def insert_optional_args(args):
 	new_args = []
 
 	default_arg_opts = {
-		'--alert'                : y_or_n,
 		'--ask'                  : y_or_n,
 		'--autounmask'           : y_or_n,
 		'--autounmask-keep-masks': y_or_n,
@@ -170,7 +169,6 @@ def insert_optional_args(args):
 	# since existence of -n makes it too ambiguous.
 	short_arg_opts_n = {
 		'a' : y_or_n,
-		'A' : y_or_n,
 		'b' : y_or_n,
 		'g' : y_or_n,
 		'G' : y_or_n,
@@ -302,12 +300,6 @@ def parse_opts(tmpcmdline, silent=False):
 	true_y = ("True", "y")
 	argument_options = {
 
-		"--alert": {
-			"shortopt" : "-A",
-			"help"    : "alert (terminal bell) on prompts",
-			"choices" : true_y_or_n
-		},
-
 		"--ask": {
 			"shortopt" : "-a",
 			"help"    : "prompt before performing any actions",
@@ -683,11 +675,6 @@ def parse_opts(tmpcmdline, silent=False):
 
 	myoptions, myargs = parser.parse_known_args(args=tmpcmdline)
 
-	if myoptions.alert in true_y:
-		myoptions.alert = True
-	else:
-		myoptions.alert = None
-
 	if myoptions.ask in true_y:
 		myoptions.ask = True
 	else:

diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py
index 8f98563..b04f8f3 100644
--- a/pym/_emerge/unmerge.py
+++ b/pym/_emerge/unmerge.py
@@ -17,8 +17,8 @@ from portage.versions import cpv_sort_key, _pkg_str
 
 from _emerge.emergelog import emergelog
 from _emerge.Package import Package
-from _emerge.UserQuery import UserQuery
 from _emerge.UninstallFailure import UninstallFailure
+from _emerge.userquery import userquery
 from _emerge.countdown import countdown
 
 def _unmerge_display(root_config, myopts, unmerge_action,
@@ -529,8 +529,7 @@ def unmerge(root_config, myopts, unmerge_action,
 		#we're done... return
 		return os.EX_OK
 	if "--ask" in myopts:
-		uq = UserQuery(myopts)
-		if uq.query("Would you like to unmerge these packages?",
+		if userquery("Would you like to unmerge these packages?",
 			enter_invalid) == "No":
 			# enter pretend mode for correct formatting of results
 			myopts["--pretend"] = True

diff --git a/pym/_emerge/userquery.py b/pym/_emerge/userquery.py
new file mode 100644
index 0000000..efae80a
--- /dev/null
+++ b/pym/_emerge/userquery.py
@@ -0,0 +1,55 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from __future__ import print_function
+
+import signal
+import sys
+
+from portage.output import bold, create_color_func
+
+def userquery(prompt, enter_invalid, responses=None, colours=None):
+	"""Displays a prompt and a set of responses, then waits for a response
+	which is checked against the responses and the first to match is
+	returned. An empty response will match the first value in responses,
+	unless enter_invalid is True. The input buffer is *not* cleared prior
+	to the prompt!
+
+	prompt: a String.
+	responses: a List of Strings.
+	colours: a List of Functions taking and returning a String, used to
+	process the responses for display. Typically these will be functions
+	like red() but could be e.g. lambda x: "DisplayString".
+	If responses is omitted, defaults to ["Yes", "No"], [green, red].
+	If only colours is omitted, defaults to [bold, ...].
+
+	Returns a member of the List responses. (If called without optional
+	arguments, returns "Yes" or "No".)
+	KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
+	printed."""
+	if responses is None:
+		responses = ["Yes", "No"]
+		colours = [
+			create_color_func("PROMPT_CHOICE_DEFAULT"),
+			create_color_func("PROMPT_CHOICE_OTHER")
+		]
+	elif colours is None:
+		colours=[bold]
+	colours=(colours*len(responses))[:len(responses)]
+	print(bold(prompt), end=' ')
+	try:
+		while True:
+			if sys.hexversion >= 0x3000000:
+				response=input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
+			else:
+				response=raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
+			if response or not enter_invalid:
+				for key in responses:
+					# An empty response will match the
+					# first value in responses.
+					if response.upper()==key[:len(response)].upper():
+						return key
+			print("Sorry, response '%s' not understood." % response, end=' ')
+	except (EOFError, KeyboardInterrupt):
+		print("Interrupted.")
+		sys.exit(128 + signal.SIGINT)


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2014-06-14 20:58 Alexander Berntsen
  0 siblings, 0 replies; 38+ messages in thread
From: Alexander Berntsen @ 2014-06-14 20:58 UTC (permalink / raw
  To: gentoo-commits

commit:     1a00ddf5fb089724a127c8dc72d63f10ae72abbf
Author:     Alexander Berntsen <bernalex <AT> gentoo <DOT> org>
AuthorDate: Thu May  8 15:47:58 2014 +0000
Commit:     Alexander Berntsen <bernalex <AT> gentoo <DOT> org>
CommitDate: Sat Jun 14 20:49:14 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1a00ddf5

emerge: Implement "--alert"

Implement "--alert" (short option "-A"), which adds a terminal bell
character ('\a') to all prompts, when it is set to True or "y". It may
be used without an option, like e.g. --ask, to mean True.

The patch refactors userquery to a class, UserQuery, to accommodate
--alert. It also adds the option to the emerge man page.

A quick example is to do 'emerge -PAc portage'.

If you have your terminal emulator set up to make '\a' into a window
manager urgency hint, move your cursor to a different window to get the
effect. 'sleep 2 && emerge' is another way to test this.

The --alert option is especially useful if you, like me, tend to fire up
a big world update when you get to the office in the morning (or night),
and then immediately change your focus to something else. If you now do
'emerge -auAD world', emerge will courteously point out when it has
finished calculating the graph, and again when it has finished emerging.

Signed-off-by: Alexander Berntsen <bernalex <AT> gentoo.org>

---
 man/emerge.1             |  5 ++++
 pym/_emerge/UserQuery.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
 pym/_emerge/actions.py   | 19 ++++++++-----
 pym/_emerge/depgraph.py  |  9 ++++--
 pym/_emerge/main.py      | 13 +++++++++
 pym/_emerge/unmerge.py   |  5 ++--
 pym/_emerge/userquery.py | 55 -------------------------------------
 7 files changed, 110 insertions(+), 67 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index abb0ed8..bbcf569 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -297,6 +297,11 @@ re\-distributable. With default
 configuration, this would result in an effective
 \fBACCEPT_RESTRICT\fR value of "* -bindist".
 .TP
+.BR "\-\-alert "
+Add a terminal bell character ('\\a') to all interactive prompts. This is
+especially useful if dependency resolution is taking a long time, and
+you want emerge to alert you when it is finished.
+.TP
 .BR "\-\-alphabetical "
 When displaying USE and other flag output, combines the enabled and
 disabled lists into one list and sorts the whole list alphabetically.

diff --git a/pym/_emerge/UserQuery.py b/pym/_emerge/UserQuery.py
new file mode 100644
index 0000000..c866a0d
--- /dev/null
+++ b/pym/_emerge/UserQuery.py
@@ -0,0 +1,71 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from __future__ import print_function
+
+import signal
+import sys
+
+from portage.output import bold, create_color_func
+
+
+class UserQuery(object):
+	"""The UserQuery class is used to prompt the user with a set of responses,
+	as well as accepting and handling the responses."""
+
+	def __init__(self, myopts):
+		self.myopts = myopts
+
+	def query(self, prompt, enter_invalid, responses=None, colours=None):
+		"""Display a prompt and a set of responses, then waits for user input
+		and check it against the responses. The first match is returned.
+
+		An empty response will match the first value in the list of responses,
+		unless enter_invalid is True. The input buffer is *not* cleared prior
+		to the prompt!
+
+		prompt: The String to display as a prompt.
+		responses: a List of Strings with the acceptable responses.
+		colours: a List of Functions taking and returning a String, used to
+		process the responses for display. Typically these will be functions
+		like red() but could be e.g. lambda x: "DisplayString".
+
+		If responses is omitted, it defaults to ["Yes", "No"], [green, red].
+		If only colours is omitted, it defaults to [bold, ...].
+
+		Returns a member of the List responses. (If called without optional
+		arguments, it returns "Yes" or "No".)
+
+		KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
+		printed."""
+		if responses is None:
+			responses = ["Yes", "No"]
+			colours = [
+				create_color_func("PROMPT_CHOICE_DEFAULT"),
+				create_color_func("PROMPT_CHOICE_OTHER")
+			]
+		elif colours is None:
+			colours=[bold]
+		colours=(colours*len(responses))[:len(responses)]
+		if "--alert" in self.myopts:
+			prompt = '\a' + prompt
+		print(bold(prompt), end=' ')
+		try:
+			while True:
+				if sys.hexversion >= 0x3000000:
+					response=input("["+"/".join([colours[i](responses[i])
+								  for i in range(len(responses))])+"] ")
+				else:
+					response=raw_input("["+"/".join([colours[i](responses[i])
+									  for i in range(len(responses))])+"] ")
+				if response or not enter_invalid:
+					for key in responses:
+						# An empty response will match the
+						# first value in responses.
+						if response.upper()==key[:len(response)].upper():
+							return key
+				print("Sorry, response '%s' not understood." % response,
+		  end=' ')
+		except (EOFError, KeyboardInterrupt):
+			print("Interrupted.")
+			sys.exit(128 + signal.SIGINT)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 4ca2f1c..b935139 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -84,7 +84,7 @@ from _emerge.sync.old_tree_timestamp import old_tree_timestamp_warn
 from _emerge.unmerge import unmerge
 from _emerge.UnmergeDepPriority import UnmergeDepPriority
 from _emerge.UseFlagDisplay import pkg_use_display
-from _emerge.userquery import userquery
+from _emerge.UserQuery import UserQuery
 
 if sys.hexversion >= 0x3000000:
 	long = int
@@ -387,8 +387,9 @@ def action_build(settings, trees, mtimedb,
 			else:
 				prompt="Would you like to merge these packages?"
 		print()
+		uq = UserQuery(myopts)
 		if prompt is not None and "--ask" in myopts and \
-			userquery(prompt, enter_invalid) == "No":
+			uq.query(prompt, enter_invalid) == "No":
 			print()
 			print("Quitting.")
 			print()
@@ -468,6 +469,7 @@ def action_build(settings, trees, mtimedb,
 
 def action_config(settings, trees, myopts, myfiles):
 	enter_invalid = '--ask-enter-invalid' in myopts
+	uq = UserQuery(myopts)
 	if len(myfiles) != 1:
 		print(red("!!! config can only take a single package atom at this time\n"))
 		sys.exit(1)
@@ -497,7 +499,7 @@ def action_config(settings, trees, myopts, myfiles):
 				print(options[-1]+") "+pkg)
 			print("X) Cancel")
 			options.append("X")
-			idx = userquery("Selection?", enter_invalid, responses=options)
+			idx = uq.query("Selection?", enter_invalid, responses=options)
 			if idx == "X":
 				sys.exit(128 + signal.SIGINT)
 			pkg = pkgs[int(idx)-1]
@@ -512,7 +514,7 @@ def action_config(settings, trees, myopts, myfiles):
 
 	print()
 	if "--ask" in myopts:
-		if userquery("Ready to configure %s?" % pkg, enter_invalid) == "No":
+		if uq.query("Ready to configure %s?" % pkg, enter_invalid) == "No":
 			sys.exit(128 + signal.SIGINT)
 	else:
 		print("Configuring pkg...")
@@ -1364,7 +1366,8 @@ def action_deselect(settings, trees, opts, atoms):
 			if '--ask' in opts:
 				prompt = "Would you like to remove these " + \
 					"packages from your world favorites?"
-				if userquery(prompt, enter_invalid) == 'No':
+				uq = UserQuery(opts)
+				if uq.query(prompt, enter_invalid) == 'No':
 					return 128 + signal.SIGINT
 
 			remaining = set(world_set)
@@ -2402,7 +2405,8 @@ def _sync_repo(emerge_config, repo):
 
 			if (retries==0):
 				if "--ask" in myopts:
-					if userquery("Do you want to sync your Portage tree " + \
+					uq = UserQuery(myopts)
+					if uq.query("Do you want to sync your Portage tree " + \
 						"with the mirror at\n" + blue(dosyncuri) + bold("?"),
 						enter_invalid) == "No":
 						print()
@@ -3841,7 +3845,8 @@ def run_action(emerge_config):
 						(access_desc,), noiselevel=-1)
 					if portage.data.secpass < 1 and not need_superuser:
 						portage.data.portage_group_warning()
-					if userquery("Would you like to add --pretend to options?",
+					uq = UserQuery(emerge_config.opts)
+					if uq.query("Would you like to add --pretend to options?",
 						"--ask-enter-invalid" in emerge_config.opts) == "No":
 						return 128 + signal.SIGINT
 					emerge_config.opts["--pretend"] = True

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index bede7c6..8177b74 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -73,7 +73,7 @@ from _emerge.SetArg import SetArg
 from _emerge.show_invalid_depstring_notice import show_invalid_depstring_notice
 from _emerge.UnmergeDepPriority import UnmergeDepPriority
 from _emerge.UseFlagDisplay import pkg_use_display
-from _emerge.userquery import userquery
+from _emerge.UserQuery import UserQuery
 
 from _emerge.resolver.backtracking import Backtracker, BacktrackParameter
 from _emerge.resolver.package_tracker import PackageTracker, PackageTrackerDbapiWrapper
@@ -520,6 +520,9 @@ class depgraph(object):
 		self._event_loop = (portage._internal_caller and
 			global_event_loop() or EventLoop(main=False))
 
+		self.uq = UserQuery(myopts)
+		self.query = UserQuery.query
+
 	def _load_vdb(self):
 		"""
 		Load installed package metadata if appropriate. This used to be called
@@ -7655,7 +7658,7 @@ class depgraph(object):
 		if ask and write_to_file and file_to_write_to:
 			prompt = "\nWould you like to add these " + \
 				"changes to your config files?"
-			if userquery(prompt, enter_invalid) == 'No':
+			if self.query(prompt, enter_invalid) == 'No':
 				write_to_file = False
 
 		if write_to_file and file_to_write_to:
@@ -7922,7 +7925,7 @@ class depgraph(object):
 					"favorites?"
 				enter_invalid = '--ask-enter-invalid' in \
 					self._frozen_config.myopts
-				if userquery(prompt, enter_invalid) == "No":
+				if self.query(prompt, enter_invalid) == "No":
 					skip = True
 
 			if not skip:

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index eddb16c..1a920f7 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -124,6 +124,7 @@ def insert_optional_args(args):
 	new_args = []
 
 	default_arg_opts = {
+		'--alert'                : y_or_n,
 		'--ask'                  : y_or_n,
 		'--autounmask'           : y_or_n,
 		'--autounmask-keep-masks': y_or_n,
@@ -169,6 +170,7 @@ def insert_optional_args(args):
 	# since existence of -n makes it too ambiguous.
 	short_arg_opts_n = {
 		'a' : y_or_n,
+		'A' : y_or_n,
 		'b' : y_or_n,
 		'g' : y_or_n,
 		'G' : y_or_n,
@@ -300,6 +302,12 @@ def parse_opts(tmpcmdline, silent=False):
 	true_y = ("True", "y")
 	argument_options = {
 
+		"--alert": {
+			"shortopt" : "-A",
+			"help"    : "alert (terminal bell) on prompts",
+			"choices" : true_y_or_n
+		},
+
 		"--ask": {
 			"shortopt" : "-a",
 			"help"    : "prompt before performing any actions",
@@ -675,6 +683,11 @@ def parse_opts(tmpcmdline, silent=False):
 
 	myoptions, myargs = parser.parse_known_args(args=tmpcmdline)
 
+	if myoptions.alert in true_y:
+		myoptions.alert = True
+	else:
+		myoptions.alert = None
+
 	if myoptions.ask in true_y:
 		myoptions.ask = True
 	else:

diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py
index b04f8f3..8f98563 100644
--- a/pym/_emerge/unmerge.py
+++ b/pym/_emerge/unmerge.py
@@ -17,8 +17,8 @@ from portage.versions import cpv_sort_key, _pkg_str
 
 from _emerge.emergelog import emergelog
 from _emerge.Package import Package
+from _emerge.UserQuery import UserQuery
 from _emerge.UninstallFailure import UninstallFailure
-from _emerge.userquery import userquery
 from _emerge.countdown import countdown
 
 def _unmerge_display(root_config, myopts, unmerge_action,
@@ -529,7 +529,8 @@ def unmerge(root_config, myopts, unmerge_action,
 		#we're done... return
 		return os.EX_OK
 	if "--ask" in myopts:
-		if userquery("Would you like to unmerge these packages?",
+		uq = UserQuery(myopts)
+		if uq.query("Would you like to unmerge these packages?",
 			enter_invalid) == "No":
 			# enter pretend mode for correct formatting of results
 			myopts["--pretend"] = True

diff --git a/pym/_emerge/userquery.py b/pym/_emerge/userquery.py
deleted file mode 100644
index efae80a..0000000
--- a/pym/_emerge/userquery.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-from __future__ import print_function
-
-import signal
-import sys
-
-from portage.output import bold, create_color_func
-
-def userquery(prompt, enter_invalid, responses=None, colours=None):
-	"""Displays a prompt and a set of responses, then waits for a response
-	which is checked against the responses and the first to match is
-	returned. An empty response will match the first value in responses,
-	unless enter_invalid is True. The input buffer is *not* cleared prior
-	to the prompt!
-
-	prompt: a String.
-	responses: a List of Strings.
-	colours: a List of Functions taking and returning a String, used to
-	process the responses for display. Typically these will be functions
-	like red() but could be e.g. lambda x: "DisplayString".
-	If responses is omitted, defaults to ["Yes", "No"], [green, red].
-	If only colours is omitted, defaults to [bold, ...].
-
-	Returns a member of the List responses. (If called without optional
-	arguments, returns "Yes" or "No".)
-	KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
-	printed."""
-	if responses is None:
-		responses = ["Yes", "No"]
-		colours = [
-			create_color_func("PROMPT_CHOICE_DEFAULT"),
-			create_color_func("PROMPT_CHOICE_OTHER")
-		]
-	elif colours is None:
-		colours=[bold]
-	colours=(colours*len(responses))[:len(responses)]
-	print(bold(prompt), end=' ')
-	try:
-		while True:
-			if sys.hexversion >= 0x3000000:
-				response=input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
-			else:
-				response=raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
-			if response or not enter_invalid:
-				for key in responses:
-					# An empty response will match the
-					# first value in responses.
-					if response.upper()==key[:len(response)].upper():
-						return key
-			print("Sorry, response '%s' not understood." % response, end=' ')
-	except (EOFError, KeyboardInterrupt):
-		print("Interrupted.")
-		sys.exit(128 + signal.SIGINT)


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2013-07-18 20:25 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2013-07-18 20:25 UTC (permalink / raw
  To: gentoo-commits

commit:     6e66def727088b3322538444c582951243fc3741
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 18 20:23:02 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jul 18 20:25:31 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6e66def7

emerge --resume: reject atom or set arguments

It is an error to provide atoms or sets as arguments to --resume, since
the arguments from the resumed command are used instead.

---
 man/emerge.1           | 6 ++++--
 pym/_emerge/actions.py | 6 ++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 6090202..da6bcba 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -202,9 +202,11 @@ generate and distribute cache for use by others, use \fBegencache\fR(1).
 .TP
 .BR "\-\-resume" (\fB\-r\fR)
 Resumes the most recent merge list that has been aborted due to an error.
-This re\-uses the options that were given with the original
+This re\-uses the arguments and options that were given with the original
 command that's being resumed, and the user may also provide
-additional options when calling \fB\-\-resume\fR.
+additional options when calling \fB\-\-resume\fR. It is an error to provide
+atoms or sets as arguments to \fB\-\-resume\fR, since the arguments from the
+resumed command are used instead.
 Please note that this operation will only return an error on failure.  If there
 is nothing for portage to do, then portage will exit with a message and a
 success condition. A resume list will persist until it has been completed in

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 730868e..6d5d535 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -3657,6 +3657,12 @@ def run_action(emerge_config):
 
 	ensure_required_sets(emerge_config.trees)
 
+	if emerge_config.action is None and \
+		"--resume" in emerge_config.opts and emerge_config.args:
+		writemsg("emerge: unexpected argument(s) for --resume: %s\n" %
+		   " ".join(emerge_config.args), noiselevel=-1)
+		return 1
+
 	# only expand sets for actions taking package arguments
 	oldargs = emerge_config.args[:]
 	if emerge_config.action in ("clean", "config", "depclean",


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2013-07-18 20:23 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2013-07-18 20:23 UTC (permalink / raw
  To: gentoo-commits

commit:     a9d19a4fb1900d1376aa5102e4bf5523df5e8752
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 18 20:23:02 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jul 18 20:23:02 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a9d19a4f

emerge --resume: reject atom or set arguments

It is an error to provide atoms or sets as arguments to --resume, since
the arguments from the resumed command are used instead.

---
 man/emerge.1           | 6 ++++--
 pym/_emerge/actions.py | 6 ++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 6090202..da6bcba 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -202,9 +202,11 @@ generate and distribute cache for use by others, use \fBegencache\fR(1).
 .TP
 .BR "\-\-resume" (\fB\-r\fR)
 Resumes the most recent merge list that has been aborted due to an error.
-This re\-uses the options that were given with the original
+This re\-uses the arguments and options that were given with the original
 command that's being resumed, and the user may also provide
-additional options when calling \fB\-\-resume\fR.
+additional options when calling \fB\-\-resume\fR. It is an error to provide
+atoms or sets as arguments to \fB\-\-resume\fR, since the arguments from the
+resumed command are used instead.
 Please note that this operation will only return an error on failure.  If there
 is nothing for portage to do, then portage will exit with a message and a
 success condition. A resume list will persist until it has been completed in

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 730868e..44c7ea0 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -3657,6 +3657,12 @@ def run_action(emerge_config):
 
 	ensure_required_sets(emerge_config.trees)
 
+	if emerge_config.action is None and \
+		"--resume" in emerge_config.opts and emerge_config.args:
+		writemsg("emerge: unexpected argument(s) for --resume: %s\n" %
+		   "".join(emerge_config.args), noiselevel=-1)
+		return 1
+
 	# only expand sets for actions taking package arguments
 	oldargs = emerge_config.args[:]
 	if emerge_config.action in ("clean", "config", "depclean",


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2013-02-23 19:17 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2013-02-23 19:17 UTC (permalink / raw
  To: gentoo-commits

commit:     94fadd2ba5296976657c005ab88be691a4e7af29
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 23 19:13:53 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 23 19:16:15 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=94fadd2b

emerge --help: remove [--verbose], bug #458730

Since commit f127d25373a42f3200a331b7f2641a1cf0e90b50, --verbose has no
effect.

---
 man/emerge.1        |    4 ++--
 pym/_emerge/help.py |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 9e0e4f2..f477429 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Jan 2013" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Feb 2013" "Portage VERSION" "Portage"
 .SH "NAME"
 emerge \- Command\-line interface to the Portage system
 .SH "SYNOPSIS"
@@ -16,7 +16,7 @@ emerge \- Command\-line interface to the Portage system
 \fB\-\-search\fR \fIsomestring\fR
 .TP
 .BR emerge
-\fB\-\-help\fR [\fB\-\-verbose\fR]
+\fB\-\-help\fR
 .SH "DESCRIPTION"
 \fBemerge\fR is the definitive command\-line interface to the Portage
 system.  It is primarily used for installing packages, and \fBemerge\fR

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 69f6505..52cfd00 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -12,7 +12,7 @@ def help():
 	print("   "+turquoise("emerge")+" [ "+green("options")+" ] [ "+green("action")+" ] < "+turquoise("@system")+" | "+turquoise("@world")+" >")
 	print("   "+turquoise("emerge")+" < "+turquoise("--sync")+" | "+turquoise("--metadata")+" | "+turquoise("--info")+" >")
 	print("   "+turquoise("emerge")+" "+turquoise("--resume")+" [ "+green("--pretend")+" | "+green("--ask")+" | "+green("--skipfirst")+" ]")
-	print("   "+turquoise("emerge")+" "+turquoise("--help")+" [ "+green("--verbose")+" ] ")
+	print("   "+turquoise("emerge")+" "+turquoise("--help"))
 	print(bold("Options:")+" "+green("-")+"["+green("abBcCdDefgGhjkKlnNoOpPqrsStuvVw")+"]")
 	print("          [ " + green("--color")+" < " + turquoise("y") + " | "+ turquoise("n")+" >            ] [ "+green("--columns")+"    ]")
 	print("          [ "+green("--complete-graph")+"             ] [ "+green("--deep")+"       ]")


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2012-12-29 22:35 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2012-12-29 22:35 UTC (permalink / raw
  To: gentoo-commits

commit:     84139803585a9a415c6f94c765dadcdeb7592915
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 29 22:34:42 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 29 22:34:42 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=84139803

emerge --select: add -w short option

---
 man/emerge.1        |    2 +-
 pym/_emerge/help.py |    4 ++--
 pym/_emerge/main.py |    2 ++
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 356bb93..0807a4b 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -726,7 +726,7 @@ If ebuilds using EAPIs which \fIdo not\fR support \fBHDEPEND\fR are built in
 the same \fBemerge\fR run as those using EAPIs which \fIdo\fR support
 \fBHDEPEND\fR, this option affects only the former.
 .TP
-.BR "\-\-select [ y | n ]"
+.BR "\-\-select [ y | n ] (\-w short option)"
 Add specified packages to the world set (inverse of
 \fB\-\-oneshot\fR). This is useful if you want to
 use \fBEMERGE_DEFAULT_OPTS\fR to make

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index a0d2870..69f6505 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
@@ -13,7 +13,7 @@ def help():
 	print("   "+turquoise("emerge")+" < "+turquoise("--sync")+" | "+turquoise("--metadata")+" | "+turquoise("--info")+" >")
 	print("   "+turquoise("emerge")+" "+turquoise("--resume")+" [ "+green("--pretend")+" | "+green("--ask")+" | "+green("--skipfirst")+" ]")
 	print("   "+turquoise("emerge")+" "+turquoise("--help")+" [ "+green("--verbose")+" ] ")
-	print(bold("Options:")+" "+green("-")+"["+green("abBcCdDefgGhjkKlnNoOpPqrsStuvV")+"]")
+	print(bold("Options:")+" "+green("-")+"["+green("abBcCdDefgGhjkKlnNoOpPqrsStuvVw")+"]")
 	print("          [ " + green("--color")+" < " + turquoise("y") + " | "+ turquoise("n")+" >            ] [ "+green("--columns")+"    ]")
 	print("          [ "+green("--complete-graph")+"             ] [ "+green("--deep")+"       ]")
 	print("          [ "+green("--jobs") + " " + turquoise("JOBS")+" ] [ "+green("--keep-going")+" ] [ " + green("--load-average")+" " + turquoise("LOAD") + "            ]")

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 6223a13..96d6a16 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -169,6 +169,7 @@ def insert_optional_args(args):
 		'K' : y_or_n,
 		'q' : y_or_n,
 		'v' : y_or_n,
+		'w' : y_or_n,
 	}
 
 	arg_stack = args[:]
@@ -608,6 +609,7 @@ def parse_opts(tmpcmdline, silent=False):
 		},
 
 		"--select": {
+			"shortopt" : "-w",
 			"help"    : "add specified packages to the world set " + \
 			            "(inverse of --oneshot)",
 			"type"    : "choice",


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2012-12-08  9:25 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2012-12-08  9:25 UTC (permalink / raw
  To: gentoo-commits

commit:     184b2ed92e83491b81b5894814e6935e870133df
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec  8 09:24:52 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec  8 09:24:52 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=184b2ed9

emerge --verbose: [ y | n ] for bug #446324

---
 man/emerge.1        |    4 ++--
 pym/_emerge/main.py |   17 +++++++++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 850a241..cd54dab 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Nov 2012" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Dec 2012" "Portage VERSION" "Portage"
 .SH "NAME"
 emerge \- Command\-line interface to the Portage system
 .SH "SYNOPSIS"
@@ -785,7 +785,7 @@ packages must be available at the time of dependency calculation or emerge
 will simply abort.  Portage does not use $PORTDIR when calculating dependency 
 information so all masking information is ignored.
 .TP
-.BR "\-\-verbose " (\fB\-v\fR)
+.BR "\-\-verbose [ y | n ] (\-v short option)"
 Tell emerge to run in verbose mode.  Currently this flag causes emerge to print 
 out GNU info errors, if any, and to show the USE flags that will be used for 
 each package when pretending. The following symbols are affixed to USE flags

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index cdadbec..6223a13 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -44,7 +44,6 @@ options=[
 "--tree",
 "--unordered-display",
 "--update",
-"--verbose",
 "--verbose-main-repo-display",
 ]
 
@@ -65,7 +64,7 @@ shortmapping={
 "s":"--search",    "S":"--searchdesc",
 "t":"--tree",
 "u":"--update",
-"v":"--verbose",   "V":"--version"
+"V":"--version"
 }
 
 COWSAY_MOO = """
@@ -151,6 +150,7 @@ def insert_optional_args(args):
 		"--use-ebuild-visibility": y_or_n,
 		'--usepkg'               : y_or_n,
 		'--usepkgonly'           : y_or_n,
+		'--verbose'              : y_or_n,
 	}
 
 	short_arg_opts = {
@@ -168,6 +168,7 @@ def insert_optional_args(args):
 		'k' : y_or_n,
 		'K' : y_or_n,
 		'q' : y_or_n,
+		'v' : y_or_n,
 	}
 
 	arg_stack = args[:]
@@ -645,6 +646,13 @@ def parse_opts(tmpcmdline, silent=False):
 			"type"     : "choice",
 			"choices"  : true_y_or_n
 		},
+
+		"--verbose": {
+			"shortopt" : "-v",
+			"help"     : "verbose output",
+			"type"     : "choice",
+			"choices"  : true_y_or_n
+		},
 	}
 
 	from optparse import OptionParser
@@ -927,6 +935,11 @@ def parse_opts(tmpcmdline, silent=False):
 	else:
 		myoptions.usepkgonly = None
 
+	if myoptions.verbose in true_y:
+		myoptions.verbose = True
+	else:
+		myoptions.verbose = None
+
 	for myopt in options:
 		v = getattr(myoptions, myopt.lstrip("--").replace("-", "_"))
 		if v:


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2012-11-29  7:53 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2012-11-29  7:53 UTC (permalink / raw
  To: gentoo-commits

commit:     c74a19691f5cbc0ec070d5fd4ffe1983bde05a09
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 29 07:52:49 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Nov 29 07:53:28 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c74a1969

emerge: add --quiet-fail for bug #440982

---
 man/emerge.1             |   11 +++++++++--
 pym/_emerge/Scheduler.py |    3 ++-
 pym/_emerge/main.py      |   10 ++++++++++
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index a6c20a9..850a241 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Oct 2012" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Nov 2012" "Portage VERSION" "Portage"
 .SH "NAME"
 emerge \- Command\-line interface to the Portage system
 .SH "SYNOPSIS"
@@ -635,7 +635,8 @@ output from portage's displays.
 .BR "\-\-quiet\-build [ y | n ]"
 Redirect all build output to logs alone, and do not display it on
 stdout. If a build failure occurs for a single package, the build
-log will be automatically displayed on stdout. If there are multiple
+log will be automatically displayed on stdout (unless the
+\fI\-\-quiet\-fail\fR option is enabled). If there are multiple
 build failures (due to options like \-\-keep\-going or \-\-jobs),
 then the content of the log files will not be displayed, and instead
 the paths of the log files will be displayed together with the
@@ -644,6 +645,12 @@ Note that interactive packages currently force all build output to
 be displayed on stdout. This issue can be temporarily avoided
 by specifying \fI\-\-accept\-properties=\-interactive\fR.
 .TP
+.BR "\-\-quiet\-fail [ y | n ]"
+Suppresses display of the build log on stdout when build output is hidden
+due to options such as \fI\-\-jobs\fR, \fI\-\-quiet\fR, or
+\fI\-\-quiet\-build\fR. Only the die message and the path of the build log
+will be displayed on stdout.
+.TP
 .BR "\-\-quiet\-repo\-display"
 In the package merge list display, suppress ::repository output, and
 instead use numbers to indicate which repositories package come from.

diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index 708af12..6a49497 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -1065,7 +1065,8 @@ class Scheduler(PollScheduler):
 		printer = portage.output.EOutput()
 		background = self._background
 		failure_log_shown = False
-		if background and len(self._failed_pkgs_all) == 1:
+		if background and len(self._failed_pkgs_all) == 1 and \
+			self.myopts.get('--quiet-fail', 'n') != 'y':
 			# If only one package failed then just show it's
 			# whole log for easy viewing.
 			failed_pkg = self._failed_pkgs_all[-1]

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index be5a5ca..cdadbec 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -139,6 +139,7 @@ def insert_optional_args(args):
 		'--package-moves'        : y_or_n,
 		'--quiet'                : y_or_n,
 		'--quiet-build'          : y_or_n,
+		'--quiet-fail'           : y_or_n,
 		'--rebuild-if-new-slot': y_or_n,
 		'--rebuild-if-new-rev'   : y_or_n,
 		'--rebuild-if-new-ver'   : y_or_n,
@@ -541,6 +542,12 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices"  : true_y_or_n,
 		},
 
+		"--quiet-fail": {
+			"help"     : "suppresses display of the build log on stdout",
+			"type"     : "choice",
+			"choices"  : true_y_or_n,
+		},
+
 		"--rebuild-if-new-slot": {
 			"help"     : ("Automatically rebuild or reinstall packages when slot/sub-slot := "
 				"operator dependencies can be satisfied by a newer slot, so that "
@@ -782,6 +789,9 @@ def parse_opts(tmpcmdline, silent=False):
 	if myoptions.quiet_build in true_y:
 		myoptions.quiet_build = 'y'
 
+	if myoptions.quiet_fail in true_y:
+		myoptions.quiet_fail = 'y'
+
 	if myoptions.rebuild_if_new_slot in true_y:
 		myoptions.rebuild_if_new_slot = 'y'
 


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2012-10-08 20:30 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2012-10-08 20:30 UTC (permalink / raw
  To: gentoo-commits

commit:     1ddda9a8db7b1e09a04220a8677b60015b2fe849
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct  8 20:30:08 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct  8 20:30:08 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1ddda9a8

emerge: handle --load-average with no arg

With no argument, removes a previous load limit (same behavior as
make).

---
 man/emerge.1        |    3 ++-
 pym/_emerge/main.py |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index c030307..9299967 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -511,9 +511,10 @@ dependencies are recalculated for remaining packages and any with
 unsatisfied dependencies are automatically dropped. Also see
 the related \fB\-\-skipfirst\fR option.
 .TP
-.BR \-\-load\-average=LOAD
+.BR "\-\-load\-average [LOAD]"
 Specifies that no new builds should be started if there are other builds
 running and the load average is at least LOAD (a floating-point number).
+With no argument, removes a previous load limit.
 This option is recommended for use in combination with \fB\-\-jobs\fR in
 order to avoid excess load. See \fBmake\fR(1) for information about
 analogous options that should be configured via \fBMAKEOPTS\fR in

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index c3e9646..e3557e5 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -454,6 +454,16 @@ def insert_optional_args(args):
 				return False
 
 	valid_integers = valid_integers()
+
+	class valid_floats(object):
+		def __contains__(self, s):
+			try:
+				return float(s) >= 0
+			except (ValueError, OverflowError):
+				return False
+
+	valid_floats = valid_floats()
+
 	y_or_n = ('y', 'n',)
 
 	new_args = []
@@ -475,6 +485,7 @@ def insert_optional_args(args):
 		'--getbinpkgonly'        : y_or_n,
 		'--jobs'       : valid_integers,
 		'--keep-going'           : y_or_n,
+		'--load-average'         : valid_floats,
 		'--package-moves'        : y_or_n,
 		'--quiet'                : y_or_n,
 		'--quiet-build'          : y_or_n,
@@ -1209,6 +1220,9 @@ def parse_opts(tmpcmdline, silent=False):
 
 		myoptions.jobs = jobs
 
+	if myoptions.load_average == "True":
+		myoptions.load_average = None
+
 	if myoptions.load_average:
 		try:
 			load_average = float(myoptions.load_average)


^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-12-14  4:47 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-12-14  4:47 UTC (permalink / raw
  To: gentoo-commits

commit:     028f0b0e223861826747b531824319520ef26ddd
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 04:47:22 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 04:47:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=028f0b0e

emerge: disable --quiet-build by default

This reverts the behavior change from commit
0cc174b6fc28feb26ea151d76f794e0ff2c2fa39, since Gentoo's council has
voted to revert it in their 20111213 meeting, as requested on the
gentoo-project mailing list:

http://archives.gentoo.org/gentoo-project/msg_4e282bb4e6ac2611de2a39171a803c48.xml

---
 man/emerge.1             |    4 +---
 pym/_emerge/Scheduler.py |    2 +-
 pym/_emerge/main.py      |    2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index b4da69c..ba29d60 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -609,9 +609,7 @@ log will be automatically displayed on stdout. If there are multiple
 build failures (due to options like \-\-keep\-going or \-\-jobs),
 then the content of the log files will not be displayed, and instead
 the paths of the log files will be displayed together with the
-corresponding die messages. This option is enabled by default. In
-order to disable \-\-quiet\-build by default, set \-\-quiet\-build=n
-in the \fBEMERGE_DEFAULT_OPTS\fR variable in \fBmake.conf\fR(5).
+corresponding die messages.
 Note that interactive packages currently force all build output to
 be displayed on stdout. This issue can be temporarily avoided
 by specifying \fI\-\-accept\-properties=\-interactive\fR.

diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index 26c3794..302b905 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -412,7 +412,7 @@ class Scheduler(PollScheduler):
 		"""
 		background = (self._max_jobs is True or \
 			self._max_jobs > 1 or "--quiet" in self.myopts \
-			or self.myopts.get("--quiet-build", "y") == "y") and \
+			or self.myopts.get("--quiet-build") == "y") and \
 			not bool(self._opts_no_background.intersection(self.myopts))
 
 		if background:

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 6acc80e..ce73c17 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -1091,7 +1091,7 @@ def parse_opts(tmpcmdline, silent=False):
 		myoptions.quiet = None
 
 	if myoptions.quiet_build in true_y:
-		myoptions.quiet_build = None
+		myoptions.quiet_build = 'y'
 
 	if myoptions.rebuild_if_new_ver in true_y:
 		myoptions.rebuild_if_new_ver = True



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-10-16 18:58 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-10-16 18:58 UTC (permalink / raw
  To: gentoo-commits

commit:     2d78dcda11d753a54f821c7fb482b4bb3b511d0b
Author:     Sebastian Luther <SebastianLuther <AT> gmx <DOT> de>
AuthorDate: Sun Oct 16 18:43:17 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct 16 18:58:12 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2d78dcda

Add --binpkg-exclude option

This options disables creation of binary packages, no matter
what enabled it in the first place. See bug 386903.

---
 man/emerge.1               |    5 +++++
 pym/_emerge/EbuildBuild.py |    3 ++-
 pym/_emerge/Scheduler.py   |    7 ++++++-
 pym/_emerge/main.py        |   28 ++++++++++++++++++++++++----
 4 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 1eab6e5..0a1ec03 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -344,6 +344,11 @@ An alternative for already\-merged
 packages is to use \fBquickpkg\fR(1) which creates a tbz2 from the
 live filesystem.
 .TP
+.BR "\-\-buildpkg\-exclude " ATOMS
+A space separated list of package atoms for which
+no binary packages should be built. This option overrides all
+possible ways to enable building of binary packages.
+.TP
 .BR "\-\-buildpkgonly " (\fB\-B\fR)
 Creates binary packages for all ebuilds processed without actually
 merging the packages.  This comes with the caveat that all build-time 

diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py
index 012a1ef..d44dcf3 100644
--- a/pym/_emerge/EbuildBuild.py
+++ b/pym/_emerge/EbuildBuild.py
@@ -226,7 +226,8 @@ class EbuildBuild(CompositeTask):
 				system_set.findAtomForPackage(pkg) and \
 				not opts.buildpkg
 
-		if opts.buildpkg or "buildpkg" in features or self._issyspkg:
+		if (opts.buildpkg or "buildpkg" in features or self._issyspkg) \
+			and not self.opts.buildpkg_exclude.findAtomForPackage(pkg):
 
 			self._buildpkg = True
 

diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index 95cc104..3221b86 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -96,7 +96,7 @@ class Scheduler(PollScheduler):
 		("merge", "jobs", "ebuild_locks", "fetch", "unpack"), prefix="")
 
 	class _build_opts_class(SlotObject):
-		__slots__ = ("buildpkg", "buildpkgonly",
+		__slots__ = ("buildpkg", "buildpkg_exclude", "buildpkgonly",
 			"fetch_all_uri", "fetchonly", "pretend")
 
 	class _binpkg_opts_class(SlotObject):
@@ -159,8 +159,13 @@ class Scheduler(PollScheduler):
 		self._favorites = favorites
 		self._args_set = InternalPackageSet(favorites, allow_repo=True)
 		self._build_opts = self._build_opts_class()
+
 		for k in self._build_opts.__slots__:
 			setattr(self._build_opts, k, "--" + k.replace("_", "-") in myopts)
+		self._build_opts.buildpkg_exclude = InternalPackageSet( \
+			initial_atoms=" ".join(myopts.get("--buildpkg-exclude", [])).split(), \
+			allow_wildcard=True, allow_repo=True)
+
 		self._binpkg_opts = self._binpkg_opts_class()
 		for k in self._binpkg_opts.__slots__:
 			setattr(self._binpkg_opts, k, "--" + k.replace("_", "-") in myopts)

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index ed07c09..26f3766 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -556,19 +556,25 @@ def insert_optional_args(args):
 
 	return new_args
 
-def _find_bad_atoms(atoms):
+def _find_bad_atoms(atoms, less_strict=False):
+	"""
+	Declares all atoms as invalid that have an operator,
+	a use dependency, a blocker or a repo spec.
+	It accepts atoms with wildcards.
+	In less_strict mode it accepts operators and repo specs.
+	"""
 	bad_atoms = []
 	for x in ' '.join(atoms).split():
 		bad_atom = False
 		try:
-			atom = portage.dep.Atom(x, allow_wildcard=True)
+			atom = portage.dep.Atom(x, allow_wildcard=True, allow_repo=less_strict)
 		except portage.exception.InvalidAtom:
 			try:
-				atom = portage.dep.Atom("*/"+x, allow_wildcard=True)
+				atom = portage.dep.Atom("*/"+x, allow_wildcard=True, allow_repo=less_strict)
 			except portage.exception.InvalidAtom:
 				bad_atom = True
 
-		if bad_atom or atom.operator or atom.blocker or atom.use:
+		if bad_atom or (atom.operator and not less_strict) or atom.blocker or atom.use:
 			bad_atoms.append(x)
 	return bad_atoms
 
@@ -644,6 +650,14 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices"  : true_y_or_n
 		},
 
+		"--buildpkg-exclude": {
+			"help"   :"A space separated list of package atoms for which " + \
+				"no binary packages should be built. This option overrides all " + \
+				"possible ways to enable building of binary packages.",
+
+			"action" : "append"
+		},
+
 		"--config-root": {
 			"help":"specify the location for portage configuration files",
 			"action":"store"
@@ -967,6 +981,12 @@ def parse_opts(tmpcmdline, silent=False):
 	else:
 		myoptions.buildpkg = None
 
+	if myoptions.buildpkg_exclude:
+		bad_atoms = _find_bad_atoms(myoptions.buildpkg_exclude, less_strict=True)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --buildpkg-exclude parameter: '%s'\n" % \
+				(",".join(bad_atoms),))
+
 	if myoptions.changed_use is not False:
 		myoptions.reinstall = "changed-use"
 		myoptions.changed_use = False



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-10-10 18:05 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-10-10 18:05 UTC (permalink / raw
  To: gentoo-commits

commit:     f8e0c75e0952d04cb518ad0914ad440f1b43f52d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 10 18:01:36 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 10 18:01:36 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f8e0c75e

Add emerge --dynamic-deps <y|n> option.

This makes it possible to disable the dynamic dependency updates that
FakeVartree performs by default.

WARNING: If --dynamic-deps is disabled, then it is necessary to
ensure that an alternative method is used to handle package moves
in dependencies of installed packages. Normally, this is handled
by FEATURES="fixpackages", which is enabled by default and may be
disabled via make.conf(5). Alternatively, in order to manually apply
package moves, run `emaint --fix moveinst` after each emerge --sync
operation (see emaint(1)).

---
 man/emerge.1                          |   16 ++++++++++++++++
 pym/_emerge/FakeVartree.py            |    7 +++++--
 pym/_emerge/Scheduler.py              |    3 ++-
 pym/_emerge/create_depgraph_params.py |    4 ++++
 pym/_emerge/depgraph.py               |   13 ++++++++++---
 pym/_emerge/main.py                   |    6 ++++++
 6 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 62bfd5e..10be789 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -407,6 +407,22 @@ when FEATURES="preserve\-libs" is enabled in
 \fBmake.conf\fR(5), since any libraries that have
 consumers will simply be preserved.
 .TP
+.BR "\-\-dynamic\-deps < y | n >"
+In dependency calculations, substitute the dependencies of installed
+packages with the dependencies of corresponding unbuilt ebuilds from
+source repositories. This causes the effective dependencies of
+installed packages to vary dynamically when source ebuild dependencies
+are modified. This option is enabled by default.
+
+\fBWARNING:\fR
+If \-\-dynamic\-deps is disabled, then it is necessary to ensure that
+an alternative method is used to handle package moves in dependencies
+of installed packages. Normally, this is handled by
+FEATURES="fixpackages", which is enabled by default and may be
+disabled via \fBmake.conf\fR(5). Alternatively, in order to manually
+apply package moves, run `emaint \-\-fix moveinst` after each
+emerge \-\-sync operation (see \fBemaint\fR(1)).
+.TP
 .BR "\-\-emptytree " (\fB\-e\fR)
 Reinstalls target atoms and their entire deep
 dependency tree, as though no packages are currently

diff --git a/pym/_emerge/FakeVartree.py b/pym/_emerge/FakeVartree.py
index a11966f..a9c1b90 100644
--- a/pym/_emerge/FakeVartree.py
+++ b/pym/_emerge/FakeVartree.py
@@ -37,8 +37,10 @@ class FakeVartree(vartree):
 	global updates are necessary (updates are performed when necessary if there
 	is not a matching ebuild in the tree). Instances of this class are not
 	populated until the sync() method is called."""
-	def __init__(self, root_config, pkg_cache=None, pkg_root_config=None):
+	def __init__(self, root_config, pkg_cache=None, pkg_root_config=None,
+		dynamic_deps=True):
 		self._root_config = root_config
+		self._dynamic_deps = dynamic_deps
 		if pkg_root_config is None:
 			pkg_root_config = self._root_config
 		self._pkg_root_config = pkg_root_config
@@ -60,7 +62,8 @@ class FakeVartree(vartree):
 		# metadata.  This ensures that the vardb lock is released ASAP, without
 		# being delayed in case cache generation is triggered.
 		self._aux_get = self.dbapi.aux_get
-		self.dbapi.aux_get = self._aux_get_wrapper
+		if dynamic_deps:
+			self.dbapi.aux_get = self._aux_get_wrapper
 		self._match = self.dbapi.match
 		self.dbapi.match = self._match_wrapper
 		self._aux_get_history = set()

diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index a6dd98c..11a72f3 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -304,10 +304,11 @@ class Scheduler(PollScheduler):
 		"""
 		self._set_graph_config(graph_config)
 		self._blocker_db = {}
+		dynamic_deps = myopts.get("--dynamic-deps", "y") != "n"
 		for root in self.trees:
 			if graph_config is None:
 				fake_vartree = FakeVartree(self.trees[root]["root_config"],
-					pkg_cache=self._pkg_cache)
+					pkg_cache=self._pkg_cache, dynamic_deps=dynamic_deps)
 				fake_vartree.sync()
 			else:
 				fake_vartree = graph_config.trees[root]['vartree']

diff --git a/pym/_emerge/create_depgraph_params.py b/pym/_emerge/create_depgraph_params.py
index 42983fe..8f15c68 100644
--- a/pym/_emerge/create_depgraph_params.py
+++ b/pym/_emerge/create_depgraph_params.py
@@ -21,6 +21,10 @@ def create_depgraph_params(myopts, myaction):
 	if bdeps is not None:
 		myparams["bdeps"] = bdeps
 
+	dynamic_deps = myopts.get("--dynamic-deps")
+	if dynamic_deps is not None:
+		myparams["dynamic_deps"] = dynamic_deps
+
 	if myaction == "remove":
 		myparams["remove"] = True
 		myparams["complete"] = True

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index a409bed..ab62dc7 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -109,6 +109,7 @@ class _frozen_depgraph_config(object):
 		# All Package instances
 		self._pkg_cache = {}
 		self._highest_license_masked = {}
+		dynamic_deps = myopts.get("--dynamic-deps", "y") != "n"
 		for myroot in trees:
 			self.trees[myroot] = {}
 			# Create a RootConfig instance that references
@@ -122,7 +123,8 @@ class _frozen_depgraph_config(object):
 			self.trees[myroot]["vartree"] = \
 				FakeVartree(trees[myroot]["root_config"],
 					pkg_cache=self._pkg_cache,
-					pkg_root_config=self.roots[myroot])
+					pkg_root_config=self.roots[myroot],
+					dynamic_deps=dynamic_deps)
 			self.pkgsettings[myroot] = portage.config(
 				clone=self.trees[myroot]["vartree"].settings)
 
@@ -514,6 +516,8 @@ class depgraph(object):
 
 		for myroot in self._frozen_config.trees:
 
+			dynamic_deps = self._dynamic_config.myparams.get(
+				"dynamic_deps", "y") != "n"
 			preload_installed_pkgs = \
 				"--nodeps" not in self._frozen_config.myopts
 
@@ -535,8 +539,11 @@ class depgraph(object):
 
 				for pkg in vardb:
 					self._spinner_update()
-					# This triggers metadata updates via FakeVartree.
-					vardb.aux_get(pkg.cpv, [])
+					if dynamic_deps:
+						# This causes FakeVartree to update the
+						# Package instance dependencies via
+						# PackageVirtualDbapi.aux_update()
+						vardb.aux_get(pkg.cpv, [])
 					fakedb.cpv_inject(pkg)
 
 		self._dynamic_config._vdb_loaded = True

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index f4ea36c..ed07c09 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -684,6 +684,12 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices" : true_y_or_n
 		},
 
+		"--dynamic-deps": {
+			"help": "substitute the dependencies of installed packages with the dependencies of unbuilt ebuilds",
+			"type": "choice",
+			"choices": y_or_n
+		},
+
 		"--exclude": {
 			"help"   :"A space separated list of package names or slot atoms. " + \
 				"Emerge won't  install any ebuild or binary package that " + \



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-09-21 14:00 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-09-21 14:00 UTC (permalink / raw
  To: gentoo-commits

commit:     5f3826d1b1a82f4e0b2c2ffdb663e8b785d7e7fa
Author:     Sebastian Luther <SebastianLuther <AT> gmx <DOT> de>
AuthorDate: Wed Sep 21 12:23:44 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Sep 21 14:00:35 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5f3826d1

autounmask: Always use unresticted atoms for license and USE changes

See bug 379333.

---
 man/emerge.1            |    7 ++++---
 pym/_emerge/depgraph.py |   22 ++++++++--------------
 pym/_emerge/help.py     |    7 ++++---
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 72b5569..6d9ce4c 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -305,9 +305,10 @@ the specified configuration file(s), or enable the
 disable this option by default in \fBmake.conf\fR(5).
 .TP
 .BR "\-\-autounmask\-unrestricted\-atoms [ y | n ]"
-If \-\-autounmask is enabled, changes using the \'=\' operator
-will be written. With this option, \'>=\' operators will be used
-whenever possible.
+If \-\-autounmask is enabled, keyword and mask changes
+using the \'=\' operator will be written. With this
+option, \'>=\' operators will be used whenever possible.
+USE and license changes always use the latter behvior.
 .TP
 .BR "\-\-autounmask\-keep\-masks [ y | n ]"
 If \-\-autounmask is enabled, no package.unmask or ** keyword changes

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 8b2bfd3..ffa7e16 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -5848,13 +5848,10 @@ class depgraph(object):
 					else:
 						adjustments.append("-" + flag)
 				use_changes_msg[root].append(self._get_dep_chain_as_comment(pkg, unsatisfied_dependency=True))
-				if autounmask_unrestricted_atoms:
-					if is_latest:
-						use_changes_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
-					elif is_latest_in_slot:
-						use_changes_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(adjustments)))
-					else:
-						use_changes_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
+				if is_latest:
+					use_changes_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
+				elif is_latest_in_slot:
+					use_changes_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(adjustments)))
 				else:
 					use_changes_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
 
@@ -5868,13 +5865,10 @@ class depgraph(object):
 				is_latest, is_latest_in_slot = check_if_latest(pkg)
 
 				license_msg[root].append(self._get_dep_chain_as_comment(pkg))
-				if autounmask_unrestricted_atoms:
-					if is_latest:
-						license_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
-					elif is_latest_in_slot:
-						license_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(sorted(missing_licenses))))
-					else:
-						license_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
+				if is_latest:
+					license_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
+				elif is_latest_in_slot:
+					license_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(sorted(missing_licenses))))
 				else:
 					license_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
 

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index e6828c0..7e73ec0 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -325,9 +325,10 @@ def help(myopts, havecolor=1):
 		print()
 		print("       " + green("--autounmask-unrestricted-atoms") + " [ %s | %s ]" % \
 			(turquoise("y"), turquoise("n")))
-		desc = "If --autounmask is enabled, changes using the '=' operator " + \
-			"will be written. With this option, '>=' operators will be used " + \
-			"whenever possible."
+		desc = "If --autounmask is enabled, keyword and mask changes" + \
+			"using the '=' operator will be written. With this option, " + \
+			"'>=' operators will be used whenever possible. USE and " + \
+			"license changes always use the latter behvior."
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-09-19 16:03 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-09-19 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     72ef29a6adaa053cf2d538349a3a1555909ed697
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 19 16:03:24 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Sep 19 16:03:24 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=72ef29a6

Document ** keyword for --autounmask-keep-masks.

---
 man/emerge.1        |    2 +-
 pym/_emerge/help.py |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index cf7b0e2..72b5569 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -310,7 +310,7 @@ will be written. With this option, \'>=\' operators will be used
 whenever possible.
 .TP
 .BR "\-\-autounmask\-keep\-masks [ y | n ]"
-If \-\-autounmask is enabled, no changes to package.unmask
+If \-\-autounmask is enabled, no package.unmask or ** keyword changes
 will be created. This leads to unsatisfied dependencies if
 no other solution exists.
 .TP

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 4334bcb..e6828c0 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -333,8 +333,8 @@ def help(myopts, havecolor=1):
 		print()
 		print("       " + green("--autounmask-keep-masks") + " [ %s | %s ]" % \
 			(turquoise("y"), turquoise("n")))
-		desc = "If --autounmask is enabled, no changes to " + \
-			"package.unmask will be created. This leads to unsatisfied " + \
+		desc = "If --autounmask is enabled, no package.unmask or ** keyword " + \
+			"changes will be created. This leads to unsatisfied " + \
 			"dependencies if no other solution exists."
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-09-19 14:15 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-09-19 14:15 UTC (permalink / raw
  To: gentoo-commits

commit:     7e956a6ec65b9b48a9fca3e928e7c7b56fd066b6
Author:     Sebastian Luther <SebastianLuther <AT> gmx <DOT> de>
AuthorDate: Mon Sep 19 11:45:35 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Sep 19 14:10:04 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7e956a6e

autounmask: Add --autounmask-unrestricted-atoms option

The default behavior of --autounmask is now changed back to
the original one, namely to use '=' operators. The
--autounmask-unrestricted-atoms option allows the use of '>='
operators whenever possible. This addresses the issues raised
in bugs 372405, 374331 and 379333.

---
 man/emerge.1            |    5 +++++
 pym/_emerge/depgraph.py |   46 ++++++++++++++++++++++++++++++----------------
 pym/_emerge/help.py     |    8 ++++++++
 pym/_emerge/main.py     |   10 ++++++++++
 4 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index aa85a7b..d6d74e0 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -304,6 +304,11 @@ the specified configuration file(s), or enable the
 \fBEMERGE_DEFAULT_OPTS\fR variable may be used to
 disable this option by default in \fBmake.conf\fR(5).
 .TP
+.BR "\-\-autounmask\-unrestricted\-atoms [ y | n ]"
+If \-\-autounmask is enabled, changes using the \'=\' operator
+will be written. With this option, \'>=\' operators will be used
+whenever possible.
+.TP
 .BR "\-\-autounmask\-write [ y | n ]"
 If \-\-autounmask is enabled, changes are written
 to config files, respecting \fBCONFIG_PROTECT\fR and \fB\-\-ask\fR.

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index deda441..a5015b8 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -5728,6 +5728,8 @@ class depgraph(object):
 		"""
 
 		autounmask_write = self._frozen_config.myopts.get("--autounmask-write", "n") == True
+		autounmask_unrestricted_atoms = \
+			self._frozen_config.myopts.get("--autounmask-unrestricted-atoms", "n") == True
 		quiet = "--quiet" in self._frozen_config.myopts
 		pretend = "--pretend" in self._frozen_config.myopts
 		ask = "--ask" in self._frozen_config.myopts
@@ -5780,10 +5782,13 @@ class depgraph(object):
 						keyword = reason.unmask_hint.value
 
 						unstable_keyword_msg[root].append(self._get_dep_chain_as_comment(pkg))
-						if is_latest:
-							unstable_keyword_msg[root].append(">=%s %s\n" % (pkg.cpv, keyword))
-						elif is_latest_in_slot:
-							unstable_keyword_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], keyword))
+						if autounmask_unrestricted_atoms:
+							if is_latest:
+								unstable_keyword_msg[root].append(">=%s %s\n" % (pkg.cpv, keyword))
+							elif is_latest_in_slot:
+								unstable_keyword_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], keyword))
+							else:
+								unstable_keyword_msg[root].append("=%s %s\n" % (pkg.cpv, keyword))
 						else:
 							unstable_keyword_msg[root].append("=%s %s\n" % (pkg.cpv, keyword))
 
@@ -5817,10 +5822,13 @@ class depgraph(object):
 								comment.splitlines() if line]
 							for line in comment:
 								p_mask_change_msg[root].append("%s\n" % line)
-						if is_latest:
-							p_mask_change_msg[root].append(">=%s\n" % pkg.cpv)
-						elif is_latest_in_slot:
-							p_mask_change_msg[root].append(">=%s:%s\n" % (pkg.cpv, pkg.metadata["SLOT"]))
+						if autounmask_unrestricted_atoms:
+							if is_latest:
+								p_mask_change_msg[root].append(">=%s\n" % pkg.cpv)
+							elif is_latest_in_slot:
+								p_mask_change_msg[root].append(">=%s:%s\n" % (pkg.cpv, pkg.metadata["SLOT"]))
+							else:
+								p_mask_change_msg[root].append("=%s\n" % pkg.cpv)
 						else:
 							p_mask_change_msg[root].append("=%s\n" % pkg.cpv)
 
@@ -5840,10 +5848,13 @@ class depgraph(object):
 					else:
 						adjustments.append("-" + flag)
 				use_changes_msg[root].append(self._get_dep_chain_as_comment(pkg, unsatisfied_dependency=True))
-				if is_latest:
-					use_changes_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
-				elif is_latest_in_slot:
-					use_changes_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(adjustments)))
+				if autounmask_unrestricted_atoms:
+					if is_latest:
+						use_changes_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
+					elif is_latest_in_slot:
+						use_changes_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(adjustments)))
+					else:
+						use_changes_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
 				else:
 					use_changes_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
 
@@ -5857,10 +5868,13 @@ class depgraph(object):
 				is_latest, is_latest_in_slot = check_if_latest(pkg)
 
 				license_msg[root].append(self._get_dep_chain_as_comment(pkg))
-				if is_latest:
-					license_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
-				elif is_latest_in_slot:
-					license_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(sorted(missing_licenses))))
+				if autounmask_unrestricted_atoms:
+					if is_latest:
+						license_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
+					elif is_latest_in_slot:
+						license_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(sorted(missing_licenses))))
+					else:
+						license_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
 				else:
 					license_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
 

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 1e62ccf..f5ff7a3 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -323,6 +323,14 @@ def help(myopts, havecolor=1):
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()
+		print("       " + green("--autounmask-unrestricted-atoms") + " [ %s | %s ]" % \
+			(turquoise("y"), turquoise("n")))
+		desc = "If --autounmask is enabled, changes using the '=' operator " + \
+			"will be written. With this option, '>=' operators will be used " + \
+			"whenever possible."
+		for line in wrap(desc, desc_width):
+			print(desc_indent + line)
+		print()
 		print("       " + green("--autounmask-write") + " [ %s | %s ]" % \
 			(turquoise("y"), turquoise("n")))
 		desc = "If --autounmask is enabled, changes are written " + \

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index b6b63e2..73d0795 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -431,6 +431,7 @@ def insert_optional_args(args):
 	default_arg_opts = {
 		'--ask'                  : y_or_n,
 		'--autounmask'           : y_or_n,
+		'--autounmask-unrestricted-atoms' : y_or_n,
 		'--autounmask-write'     : y_or_n,
 		'--buildpkg'             : y_or_n,
 		'--complete-graph'       : y_or_n,
@@ -603,6 +604,12 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices" : true_y_or_n
 		},
 
+		"--autounmask-unrestricted-atoms": {
+			"help"    : "write autounmask changes with >= atoms if possible",
+			"type"    : "choice",
+			"choices" : true_y_or_n
+		},
+
 		"--autounmask-write": {
 			"help"    : "write changes made by --autounmask to disk",
 			"type"    : "choice",
@@ -926,6 +933,9 @@ def parse_opts(tmpcmdline, silent=False):
 	if myoptions.autounmask in true_y:
 		myoptions.autounmask = True
 
+	if myoptions.autounmask_unrestricted_atoms in true_y:
+		myoptions.autounmask_unrestricted_atoms = True
+
 	if myoptions.autounmask_write in true_y:
 		myoptions.autounmask_write = True
 



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-09-18 20:16 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-09-18 20:16 UTC (permalink / raw
  To: gentoo-commits

commit:     424f8f8d6587f015e074e3e915746929a990a52f
Author:     Sebastian Luther <SebastianLuther <AT> gmx <DOT> de>
AuthorDate: Sun Sep 18 20:00:57 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Sep 18 20:15:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=424f8f8d

autounmask: Document where changes are writen

---
 man/emerge.1        |    4 ++++
 pym/_emerge/help.py |    6 +++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index f7ad3ed..aa85a7b 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -307,6 +307,10 @@ disable this option by default in \fBmake.conf\fR(5).
 .BR "\-\-autounmask\-write [ y | n ]"
 If \-\-autounmask is enabled, changes are written
 to config files, respecting \fBCONFIG_PROTECT\fR and \fB\-\-ask\fR.
+If the corresponding package.* is a file, the changes are appended to
+it, if it is a directory, changes are written to the lexicographically
+last file. This way it is always ensured that the new changes take
+precedence over existing changes.
 .TP
 .BR \-\-backtrack=COUNT
 Specifies an integer number of times to backtrack if

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 57b376d..1e62ccf 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -326,7 +326,11 @@ def help(myopts, havecolor=1):
 		print("       " + green("--autounmask-write") + " [ %s | %s ]" % \
 			(turquoise("y"), turquoise("n")))
 		desc = "If --autounmask is enabled, changes are written " + \
-			"to config files, respecting CONFIG_PROTECT and --ask."
+			"to config files, respecting CONFIG_PROTECT and --ask. " + \
+			"If the corresponding package.* is a file, the changes are " + \
+			"appended to it, if it is a directory, changes are written to " + \
+			"the lexicographically last file. This way it is always ensured " + \
+			"that the new changes take precedence over existing changes."
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-07-19  8:38 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-07-19  8:38 UTC (permalink / raw
  To: gentoo-commits

commit:     72f83d8078da7aab7be9236b86be1526c15a4185
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 19 08:36:58 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jul 19 08:36:58 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=72f83d80

Make emerge --noreplace identical to --selective.

This removes a very subtle difference in --noreplace package selection
logic which is not very useful and triggers strange package selection
choices in some cases, as reported in bug #375571.

---
 man/emerge.1            |    8 ++------
 pym/_emerge/actions.py  |    8 ++++----
 pym/_emerge/depgraph.py |   11 -----------
 pym/_emerge/help.py     |    9 +--------
 pym/_emerge/main.py     |    3 +--
 5 files changed, 8 insertions(+), 31 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index df576ee..4a19bdb 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -488,10 +488,7 @@ Skips the packages specified on the command\-line that have already
 been installed.  Without this option, any packages, ebuilds, or deps
 you specify on the command\-line \fBwill\fR cause Portage to remerge
 the package, even if it is already installed.  Note that Portage will
-not remerge dependencies by default. Also note that this option takes
-precedence over options such as \fB\-\-newuse\fR, preventing a package
-from being reinstalled even though the corresponding USE flag settings
-may have changed.
+not remerge dependencies by default.
 .TP
 .BR "\-\-nospinner"
 Disables the spinner for the session.  The spinner is active when the
@@ -619,8 +616,7 @@ use \fBEMERGE_DEFAULT_OPTS\fR to make
 \fB\-\-oneshot\fR behavior default.
 .TP
 .BR "\-\-selective [ y | n ]"
-This is similar to the \fB\-\-noreplace\fR option, except that it
-does not take precedence over options such as \fB\-\-newuse\fR.
+This is identical to the \fB\-\-noreplace\fR option.
 Some options, such as \fB\-\-update\fR, imply \fB\-\-selective\fR.
 Use \fB\-\-selective=n\fR if you want to forcefully disable
 \fB\-\-selective\fR, regardless of options like \fB\-\-update\fR.

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index f6c2721..219ed71 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -163,6 +163,8 @@ def action_build(settings, trees, mtimedb,
 	debug = "--debug" in myopts
 	verbose = "--verbose" in myopts
 	quiet = "--quiet" in myopts
+	myparams = create_depgraph_params(myopts, myaction)
+
 	if pretend or fetchonly:
 		# make the mtimedb readonly
 		mtimedb.filename = None
@@ -187,7 +189,6 @@ def action_build(settings, trees, mtimedb,
 		favorites = mtimedb["resume"].get("favorites")
 		if not isinstance(favorites, list):
 			favorites = []
-		myparams = create_depgraph_params(myopts, myaction)
 
 		resume_data = mtimedb["resume"]
 		mergelist = resume_data["mergelist"]
@@ -286,7 +287,6 @@ def action_build(settings, trees, mtimedb,
 			print(darkgreen("emerge: It seems we have nothing to resume..."))
 			return os.EX_OK
 
-		myparams = create_depgraph_params(myopts, myaction)
 		try:
 			success, mydepgraph, favorites = backtrack_depgraph(
 				settings, trees, myopts, myparams, myaction, myfiles, spinner)
@@ -331,7 +331,7 @@ def action_build(settings, trees, mtimedb,
 			if mergecount==0:
 				sets = trees[settings["ROOT"]]["root_config"].sets
 				world_candidates = None
-				if "--noreplace" in myopts and \
+				if "selective" in myparams and \
 					not oneshot and favorites:
 					# Sets that are not world candidates are filtered
 					# out here since the favorites list needs to be
@@ -340,7 +340,7 @@ def action_build(settings, trees, mtimedb,
 					world_candidates = [x for x in favorites \
 						if not (x.startswith(SETPREFIX) and \
 						not sets[x[1:]].world_candidate)]
-				if "--noreplace" in myopts and \
+				if "selective" in myparams and \
 					not oneshot and world_candidates:
 					print()
 					for x in world_candidates:

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index a5923dd..9e3064d 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -3591,7 +3591,6 @@ class depgraph(object):
 		empty = "empty" in self._dynamic_config.myparams
 		selective = "selective" in self._dynamic_config.myparams
 		reinstall = False
-		noreplace = "--noreplace" in self._frozen_config.myopts
 		avoid_update = "--update" not in self._frozen_config.myopts
 		dont_miss_updates = "--update" in self._frozen_config.myopts
 		use_ebuild_visibility = self._frozen_config.myopts.get(
@@ -3679,16 +3678,6 @@ class depgraph(object):
 							continue
 
 					cpv = pkg.cpv
-					# Make --noreplace take precedence over --newuse.
-					if not pkg.installed and noreplace and \
-						cpv in vardb.match(atom):
-						inst_pkg = self._pkg(pkg.cpv, "installed",
-							root_config, installed=True)
-						if inst_pkg.visible:
-							# If the installed version is masked, it may
-							# be necessary to look at lower versions,
-							# in case there is a visible downgrade.
-							continue
 					reinstall_for_flags = None
 
 					if not pkg.installed or \

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 5b5658d..c978ce2 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -565,12 +565,6 @@ def help(myopts, havecolor=1):
 		print("              ebuilds, or deps you specify on the command-line *will* cause")
 		print("              Portage to remerge the package, even if it is already installed.")
 		print("              Note that Portage won't remerge dependencies by default.")
-		desc = "Also note that this option takes " + \
-			"precedence over options such as --newuse, preventing a package " + \
-			"from being reinstalled even though the corresponding USE flag settings " + \
-			"may have changed."
-		for line in wrap(desc, desc_width):
-			print(desc_indent + line)
 		print() 
 		print("       "+green("--nospinner"))
 		print("              Disables the spinner regardless of terminal type.")
@@ -733,8 +727,7 @@ def help(myopts, havecolor=1):
 		print()
 		print("       " + green("--selective") + " [ %s | %s ]" % \
 			(turquoise("y"), turquoise("n")))
-		desc = "This is similar to the --noreplace option, except that it " + \
-			"does not take precedence over options such as --newuse. " + \
+		desc = "This identical to the --noreplace option. " + \
 			"Some options, such as --update, imply --selective. " + \
 			"Use --selective=n if you want to forcefully disable " + \
 			"--selective, regardless of options like --update."

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 42ce810..11a3314 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -842,8 +842,7 @@ def parse_opts(tmpcmdline, silent=False):
 		},
 
 		"--selective": {
-			"help"    : "similar to the --noreplace but does not take " + \
-			            "precedence over options such as --newuse",
+			"help"    : "identical to --noreplace",
 			"type"    : "choice",
 			"choices" : true_y_or_n
 		},



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-06-04 23:32 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-06-04 23:32 UTC (permalink / raw
  To: gentoo-commits

commit:     1ba2da580203f52d12871aee87f2fdbcb87f8128
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  4 13:01:26 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jun  4 13:01:26 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1ba2da58

autounmask: reference EMERGE_DEFAULT_OPTS in docs

---
 man/emerge.1        |    4 +++-
 pym/_emerge/help.py |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 1ab8e4b..df576ee 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -300,7 +300,9 @@ after the merge list and emerge will immediately
 abort. If the displayed configuration changes are
 satisfactory, you should copy and paste them into
 the specified configuration file(s), or enable the
-\fB\-\-autounmask\-write\fR option.
+\fB\-\-autounmask\-write\fR option. The
+\fBEMERGE_DEFAULT_OPTS\fR variable may be used to
+disable this option by default in \fBmake.conf\fR(5).
 .TP
 .BR "\-\-autounmask\-write [ y | n ]"
 If \-\-autounmask is enabled, changes are written

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 9d60f3a..5b5658d 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -317,7 +317,9 @@ def help(myopts, havecolor=1):
 			"abort. If the displayed configuration changes are " + \
 			"satisfactory, you should copy and paste them into " + \
 			"the specified configuration file(s), or enable the " + \
-			"--autounmask-write option."
+			"--autounmask-write option. The " + \
+			"EMERGE_DEFAULT_OPTS variable may be used to " + \
+			"disable this option by default in make.conf(5)."
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-06-03  5:40 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-06-03  5:40 UTC (permalink / raw
  To: gentoo-commits

commit:     7e4de7782079b4030e8f19582204f500bf9c4902
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  3 05:40:39 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jun  3 05:40:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7e4de778

autounmask-write: mention --ask in docs

---
 man/emerge.1        |    2 +-
 pym/_emerge/help.py |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 0129347..1ab8e4b 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -304,7 +304,7 @@ the specified configuration file(s), or enable the
 .TP
 .BR "\-\-autounmask\-write [ y | n ]"
 If \-\-autounmask is enabled, changes are written
-to config files, respecting \fBCONFIG_PROTECT\fR.
+to config files, respecting \fBCONFIG_PROTECT\fR and \fB\-\-ask\fR.
 .TP
 .BR \-\-backtrack=COUNT
 Specifies an integer number of times to backtrack if

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 9dc38b7..9d60f3a 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -324,7 +324,7 @@ def help(myopts, havecolor=1):
 		print("       " + green("--autounmask-write") + " [ %s | %s ]" % \
 			(turquoise("y"), turquoise("n")))
 		desc = "If --autounmask is enabled, changes are written " + \
-			"to config files, respecting CONFIG_PROTECT."
+			"to config files, respecting CONFIG_PROTECT and --ask."
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-05-17  4:31 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-05-17  4:31 UTC (permalink / raw
  To: gentoo-commits

commit:     5e225f13ad40759698469c7bfe63579e86ea2567
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue May 17 04:30:08 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue May 17 04:30:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5e225f13

Document that --autounmask is enabled by default.

---
 man/emerge.1        |    9 +++++----
 pym/_emerge/help.py |    9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 0f2acc1..0760e52 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -292,14 +292,15 @@ intended to be set in the \fBmake.conf\fR(5)
 \fBEMERGE_DEFAULT_OPTS\fR variable.
 .TP
 .BR "\-\-autounmask [ y | n ]"
-Automatically unmask packages. If any configuration
+Automatically unmask packages and generate package.use
+settings as necessary to satisfy dependencies. This
+option is enabled by default. If any configuration
 changes are required, then they will be displayed
 after the merge list and emerge will immediately
 abort. If the displayed configuration changes are
 satisfactory, you should copy and paste them into
-the specified configuration file(s). Currently,
-this only works for unstable KEYWORDS masks,
-LICENSE masks, and package.use settings.
+the specified configuration file(s), or enable the
+\fB\-\-autounmask\-write\fR option.
 .TP
 .BR "\-\-autounmask\-write [ y | n ]"
 If \-\-autounmask is enabled, changes are written

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index ddaa626..9dc38b7 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -309,14 +309,15 @@ def help(myopts, havecolor=1):
 		print() 
 		print("       " + green("--autounmask") + " [ %s | %s ]" % \
 			(turquoise("y"), turquoise("n")))
-		desc = "Automatically unmask packages. If any configuration " + \
+		desc = "Automatically unmask packages and generate package.use " + \
+			"settings as necessary to satisfy dependencies. This " + \
+			"option is enabled by default. If any configuration " + \
 			"changes are required, then they will be displayed " + \
 			"after the merge list and emerge will immediately " + \
 			"abort. If the displayed configuration changes are " + \
 			"satisfactory, you should copy and paste them into " + \
-			"the specified configuration file(s). Currently, " + \
-			"this only works for unstable KEYWORDS masks, " + \
-			"LICENSE masks, and package.use settings."
+			"the specified configuration file(s), or enable the " + \
+			"--autounmask-write option."
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-05-15 19:20 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-05-15 19:20 UTC (permalink / raw
  To: gentoo-commits

commit:     c492b1b3ed631b6802ef1192f59d2ef93967fb0a
Author:     Sebastian Luther <SebastianLuther <AT> gmx <DOT> de>
AuthorDate: Sun May 15 19:01:03 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 15 19:01:03 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c492b1b3

Implement --autounmask-write

Enabling this option together with --autounmask writes proposed
changes to config files, honoring CONFIG_PROTECT.

---
 man/emerge.1            |    4 +
 pym/_emerge/depgraph.py |  271 ++++++++++++++++++++++++++++++++++-------------
 pym/_emerge/help.py     |    7 ++
 pym/_emerge/main.py     |   10 ++
 4 files changed, 216 insertions(+), 76 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 539b2e3..0f2acc1 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -301,6 +301,10 @@ the specified configuration file(s). Currently,
 this only works for unstable KEYWORDS masks,
 LICENSE masks, and package.use settings.
 .TP
+.BR "\-\-autounmask\-write [ y | n ]"
+If \-\-autounmask is enabled, changes are written
+to config files, respecting \fBCONFIG_PROTECT\fR.
+.TP
 .BR \-\-backtrack=COUNT
 Specifies an integer number of times to backtrack if
 dependency calculation fails due to a conflict or an

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 16cb7fc..8558436 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -3,6 +3,7 @@
 
 from __future__ import print_function
 
+import codecs
 import difflib
 import gc
 import logging
@@ -14,12 +15,12 @@ from itertools import chain
 
 import portage
 from portage import os, OrderedDict
-from portage import _unicode_decode
-from portage.const import PORTAGE_PACKAGE_ATOM
+from portage import _unicode_decode, _unicode_encode, _encodings
+from portage.const import PORTAGE_PACKAGE_ATOM, USER_CONFIG_PATH
 from portage.dbapi import dbapi
 from portage.dep import Atom, extract_affecting_use, check_required_use, human_readable_required_use, _repo_separator
 from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use
-from portage.exception import InvalidAtom, InvalidDependString
+from portage.exception import InvalidAtom, InvalidDependString, PortageException
 from portage.output import colorize, create_color_func, \
 	darkgreen, green
 bad = create_color_func("BAD")
@@ -27,8 +28,9 @@ from portage.package.ebuild.getmaskingstatus import \
 	_getmaskingstatus, _MaskReason
 from portage._sets import SETPREFIX
 from portage._sets.base import InternalPackageSet
+from portage.util import ConfigProtect, shlex_split, new_protect_filename
 from portage.util import cmp_sort_key, writemsg, writemsg_stdout
-from portage.util import writemsg_level
+from portage.util import writemsg_level, write_atomic
 from portage.util.digraph import digraph
 from portage.versions import catpkgsplit
 
@@ -5493,55 +5495,14 @@ class depgraph(object):
 
 		return display(self, mylist, favorites, verbosity)
 
-	def display_problems(self):
+	def _display_autounmask(self):
 		"""
-		Display problems with the dependency graph such as slot collisions.
-		This is called internally by display() to show the problems _after_
-		the merge list where it is most likely to be seen, but if display()
-		is not going to be called then this method should be called explicitly
-		to ensure that the user is notified of problems with the graph.
-
-		All output goes to stderr, except for unsatisfied dependencies which
-		go to stdout for parsing by programs such as autounmask.
+		Display --autounmask message and optionally write them to config files
+		(using CONFIG_PROTECT). The message includes the comments and the changes.
 		"""
 
-		# Note that show_masked_packages() sends it's output to
-		# stdout, and some programs such as autounmask parse the
-		# output in cases when emerge bails out. However, when
-		# show_masked_packages() is called for installed packages
-		# here, the message is a warning that is more appropriate
-		# to send to stderr, so temporarily redirect stdout to
-		# stderr. TODO: Fix output code so there's a cleaner way
-		# to redirect everything to stderr.
-		sys.stdout.flush()
-		sys.stderr.flush()
-		stdout = sys.stdout
-		try:
-			sys.stdout = sys.stderr
-			self._display_problems()
-		finally:
-			sys.stdout = stdout
-			sys.stdout.flush()
-			sys.stderr.flush()
-
-		# This goes to stdout for parsing by programs like autounmask.
-		for pargs, kwargs in self._dynamic_config._unsatisfied_deps_for_display:
-			self._show_unsatisfied_dep(*pargs, **kwargs)
-
-	def _display_problems(self):
-		if self._dynamic_config._circular_deps_for_display is not None:
-			self._show_circular_deps(
-				self._dynamic_config._circular_deps_for_display)
-
-		# The user is only notified of a slot conflict if
-		# there are no unresolvable blocker conflicts.
-		if self._dynamic_config._unsatisfied_blockers_for_display is not None:
-			self._show_unsatisfied_blockers(
-				self._dynamic_config._unsatisfied_blockers_for_display)
-		elif self._dynamic_config._slot_collision_info:
-			self._show_slot_collision_notice()
-		else:
-			self._show_missed_update()
+		autounmask_write = self._frozen_config.myopts.get("--autounmask-write", "n") == True
+		pretend = "--pretend" in self._frozen_config.myopts
 
 		def check_if_latest(pkg):
 			is_latest = True
@@ -5569,11 +5530,16 @@ class depgraph(object):
 
 			return is_latest, is_latest_in_slot
 
+		#Set of roots we have autounmask changes for.
+		roots = set()
 
-		unstable_keyword_msg = []
+		unstable_keyword_msg = {}
 		for pkg in self._dynamic_config._needed_unstable_keywords:
 			self._show_merge_list()
 			if pkg in self._dynamic_config.digraph:
+				root = pkg.root
+				roots.add(root)
+				unstable_keyword_msg.setdefault(root, [])
 				is_latest, is_latest_in_slot = check_if_latest(pkg)
 				pkgsettings = self._frozen_config.pkgsettings[pkg.root]
 				mreasons = _get_masking_status(pkg, pkgsettings, pkg.root_config,
@@ -5583,18 +5549,21 @@ class depgraph(object):
 						reason.unmask_hint.key == 'unstable keyword':
 						keyword = reason.unmask_hint.value
 
-						unstable_keyword_msg.append(self._get_dep_chain_as_comment(pkg))
+						unstable_keyword_msg[root].append(self._get_dep_chain_as_comment(pkg))
 						if is_latest:
-							unstable_keyword_msg.append(">=%s %s\n" % (pkg.cpv, keyword))
+							unstable_keyword_msg[root].append(">=%s %s\n" % (pkg.cpv, keyword))
 						elif is_latest_in_slot:
-							unstable_keyword_msg.append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], keyword))
+							unstable_keyword_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], keyword))
 						else:
-							unstable_keyword_msg.append("=%s %s\n" % (pkg.cpv, keyword))
+							unstable_keyword_msg[root].append("=%s %s\n" % (pkg.cpv, keyword))
 
-		use_changes_msg = []
+		use_changes_msg = {}
 		for pkg, needed_use_config_change in self._dynamic_config._needed_use_config_changes.items():
 			self._show_merge_list()
 			if pkg in self._dynamic_config.digraph:
+				root = pkg.root
+				roots.add(root)
+				use_changes_msg.setdefault(root, [])
 				is_latest, is_latest_in_slot = check_if_latest(pkg)
 				changes = needed_use_config_change[1]
 				adjustments = []
@@ -5603,42 +5572,192 @@ class depgraph(object):
 						adjustments.append(flag)
 					else:
 						adjustments.append("-" + flag)
-				use_changes_msg.append(self._get_dep_chain_as_comment(pkg, unsatisfied_dependency=True))
+				use_changes_msg[root].append(self._get_dep_chain_as_comment(pkg, unsatisfied_dependency=True))
 				if is_latest:
-					use_changes_msg.append(">=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
+					use_changes_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
 				elif is_latest_in_slot:
-					use_changes_msg.append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(adjustments)))
+					use_changes_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(adjustments)))
 				else:
-					use_changes_msg.append("=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
+					use_changes_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(adjustments)))
 
-		license_msg = []
+		license_msg = {}
 		for pkg, missing_licenses in self._dynamic_config._needed_license_changes.items():
 			self._show_merge_list()
 			if pkg in self._dynamic_config.digraph:
+				root = pkg.root
+				roots.add(root)
+				license_msg.setdefault(root, [])
 				is_latest, is_latest_in_slot = check_if_latest(pkg)
 
-				license_msg.append(self._get_dep_chain_as_comment(pkg))
+				license_msg[root].append(self._get_dep_chain_as_comment(pkg))
 				if is_latest:
-					license_msg.append(">=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
+					license_msg[root].append(">=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
 				elif is_latest_in_slot:
-					license_msg.append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(sorted(missing_licenses))))
+					license_msg[root].append(">=%s:%s %s\n" % (pkg.cpv, pkg.metadata["SLOT"], " ".join(sorted(missing_licenses))))
 				else:
-					license_msg.append("=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
+					license_msg[root].append("=%s %s\n" % (pkg.cpv, " ".join(sorted(missing_licenses))))
 
-		if unstable_keyword_msg:
-			writemsg_stdout("\nThe following " + colorize("BAD", "keyword changes") + \
-				" are necessary to proceed:\n", noiselevel=-1)
-			writemsg_stdout("".join(unstable_keyword_msg), noiselevel=-1)
+		def find_config_file(abs_user_config, file_name):
+			"""
+			Searches /etc/portage for an appropiate file to append changes to.
+			If the file_name is a file it is returned, if it is a directoy, the
+			last file in it is returned.
 
-		if use_changes_msg:
-			writemsg_stdout("\nThe following " + colorize("BAD", "USE changes") + \
-				" are necessary to proceed:\n", noiselevel=-1)
-			writemsg_stdout("".join(use_changes_msg), noiselevel=-1)
+			file_name - String containg a file name like "package.use"
+			return value - String. Absolte path of file to write to. None if
+			no suitable file exists.
+			"""
+			file_path = os.path.join(abs_user_config, file_name)
+			if os.path.exists(file_path):
+				if os.path.isfile(file_path):
+					return file_path
+				elif os.path.isdir(file_path):
+					try:
+						files = sorted(f for f in os.listdir(file_path) \
+							if os.path.isfile(os.path.join(file_path, f)))
+						if len(files) != 0:
+							return  os.path.join(file_path, files[-1])
+					except OSError:
+						pass
+
+
+		write_to_file = autounmask_write and not pretend
+		#Make sure we have a file to write to before doing any write.
+		file_to_write_to = {}
+		problems = []
+		if write_to_file:
+			for root in roots:
+				abs_user_config = os.path.join(root, USER_CONFIG_PATH)
+
+				if root in unstable_keyword_msg:
+					file_to_write_to[(abs_user_config, "package.keywords")] = \
+						find_config_file(abs_user_config, "package.keywords")
 
-		if license_msg:
-			writemsg_stdout("\nThe following " + colorize("BAD", "license changes") + \
+				if root in use_changes_msg:
+					file_to_write_to[(abs_user_config, "package.use")] = \
+						find_config_file(abs_user_config, "package.use")
+
+				if root in license_msg:
+					file_to_write_to[(abs_user_config, "package.license")] = \
+						find_config_file(abs_user_config, "package.license")
+
+			for (abs_user_config, f), path in file_to_write_to.items():
+				if path is None:
+					problems.append("!!! No file to write for '%s'\n" % os.path.join(abs_user_config, f))
+
+			write_to_file = not problems
+
+
+		protect_obj = {}
+		if write_to_file:
+			for root in roots:
+				settings = self._frozen_config.pkgsettings[root]
+				protect_obj[root] = ConfigProtect(root, \
+					shlex_split(settings.get("CONFIG_PROTECT", "")),
+					shlex_split(settings.get("CONFIG_PROTECT_MASK", "")))
+
+		def write_changes(root, change_type, changes, file_to_write_to):
+			writemsg_stdout("\nThe following " + colorize("BAD", "%s changes" % change_type) + \
 				" are necessary to proceed:\n", noiselevel=-1)
-			writemsg_stdout("".join(license_msg), noiselevel=-1)
+			writemsg_stdout("".join(changes), noiselevel=-1)
+			if write_to_file:
+				try:
+					file_contents = codecs.open(
+						_unicode_encode(file_to_write_to,
+						encoding=_encodings['fs'], errors='strict'),
+						mode='r', encoding=_encodings['content'],
+						errors='replace').readlines()
+				except IOError as e:
+					problems.append("!!! Failed to read '%s': %s\n" % (file_to_write_to, e))
+				else:
+					file_contents.extend(changes)
+					if protect_obj[root].isprotected(file_to_write_to):
+						file_to_write_to = new_protect_filename(file_to_write_to)
+					try:
+						write_atomic(file_to_write_to, "".join(file_contents))
+					except PortageException:
+						problems.append("!!! Failed to write '%s'\n" % file_to_write_to)
+
+		for root in roots:
+			abs_user_config = os.path.join(root, USER_CONFIG_PATH)
+			if len(roots) > 1:
+				writemsg_stdout("\nFor %s:\n" % abs_user_config, noiselevel=-1)
+
+			if root in unstable_keyword_msg:
+				write_changes(root, "keyword", unstable_keyword_msg[root],
+					file_to_write_to.get((abs_user_config, "package.keywords")))
+
+			if root in use_changes_msg:
+				write_changes(root, "USE", use_changes_msg[root],
+					file_to_write_to.get((abs_user_config, "package.use")))
+
+			if root in license_msg:
+				write_changes(root, "license", license_msg[root],
+					file_to_write_to.get((abs_user_config, "package.license")))
+
+		if problems:
+			writemsg_stdout("\nThe following problems occured while writing autounmask changes:\n", \
+				noiselevel=-1)
+			writemsg_stdout("".join(problems), noiselevel=-1)
+		elif write_to_file and roots:
+			writemsg_stdout("\nAutounmask changes successfully written. Remeber to run etc-update.\n", \
+				noiselevel=-1)
+		elif not pretend and not autounmask_write and roots:
+			writemsg_stdout("\nUse --autounmask-write to write changes to config files (honoring CONFIG_PROTECT).\n", \
+				noiselevel=-1)
+
+
+	def display_problems(self):
+		"""
+		Display problems with the dependency graph such as slot collisions.
+		This is called internally by display() to show the problems _after_
+		the merge list where it is most likely to be seen, but if display()
+		is not going to be called then this method should be called explicitly
+		to ensure that the user is notified of problems with the graph.
+
+		All output goes to stderr, except for unsatisfied dependencies which
+		go to stdout for parsing by programs such as autounmask.
+		"""
+
+		# Note that show_masked_packages() sends it's output to
+		# stdout, and some programs such as autounmask parse the
+		# output in cases when emerge bails out. However, when
+		# show_masked_packages() is called for installed packages
+		# here, the message is a warning that is more appropriate
+		# to send to stderr, so temporarily redirect stdout to
+		# stderr. TODO: Fix output code so there's a cleaner way
+		# to redirect everything to stderr.
+		sys.stdout.flush()
+		sys.stderr.flush()
+		stdout = sys.stdout
+		try:
+			sys.stdout = sys.stderr
+			self._display_problems()
+		finally:
+			sys.stdout = stdout
+			sys.stdout.flush()
+			sys.stderr.flush()
+
+		# This goes to stdout for parsing by programs like autounmask.
+		for pargs, kwargs in self._dynamic_config._unsatisfied_deps_for_display:
+			self._show_unsatisfied_dep(*pargs, **kwargs)
+
+	def _display_problems(self):
+		if self._dynamic_config._circular_deps_for_display is not None:
+			self._show_circular_deps(
+				self._dynamic_config._circular_deps_for_display)
+
+		# The user is only notified of a slot conflict if
+		# there are no unresolvable blocker conflicts.
+		if self._dynamic_config._unsatisfied_blockers_for_display is not None:
+			self._show_unsatisfied_blockers(
+				self._dynamic_config._unsatisfied_blockers_for_display)
+		elif self._dynamic_config._slot_collision_info:
+			self._show_slot_collision_notice()
+		else:
+			self._show_missed_update()
+
+		self._display_autounmask()
 
 		# TODO: Add generic support for "set problem" handlers so that
 		# the below warnings aren't special cases for world only.

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 46b29ec..ddaa626 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -320,6 +320,13 @@ def help(myopts, havecolor=1):
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()
+		print("       " + green("--autounmask-write") + " [ %s | %s ]" % \
+			(turquoise("y"), turquoise("n")))
+		desc = "If --autounmask is enabled, changes are written " + \
+			"to config files, respecting CONFIG_PROTECT."
+		for line in wrap(desc, desc_width):
+			print(desc_indent + line)
+		print()
 		print("       " + green("--backtrack") + " " + turquoise("COUNT"))
 		desc = "Specifies an integer number of times to backtrack if " + \
 			"dependency calculation fails due to a conflict or an " + \

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index ee0fc4e..7921d7d 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -427,6 +427,7 @@ def insert_optional_args(args):
 	default_arg_opts = {
 		'--ask'                  : y_or_n,
 		'--autounmask'           : y_or_n,
+		'--autounmask-write'     : y_or_n,
 		'--buildpkg'             : y_or_n,
 		'--complete-graph'       : y_or_n,
 		'--deep'       : valid_integers,
@@ -598,6 +599,12 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices" : true_y_or_n
 		},
 
+		"--autounmask-write": {
+			"help"    : "write changes made by --autounmask to disk",
+			"type"    : "choice",
+			"choices" : true_y_or_n
+		},
+
 		"--accept-properties": {
 			"help":"temporarily override ACCEPT_PROPERTIES",
 			"action":"store"
@@ -916,6 +923,9 @@ def parse_opts(tmpcmdline, silent=False):
 	if myoptions.autounmask in true_y:
 		myoptions.autounmask = True
 
+	if myoptions.autounmask_write in true_y:
+		myoptions.autounmask_write = True
+
 	if myoptions.buildpkg in true_y:
 		myoptions.buildpkg = True
 	else:



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-05-11 19:04 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-05-11 19:04 UTC (permalink / raw
  To: gentoo-commits

commit:     e6cb6af7cf6a443b892f32f1408a98c6bd4d3c10
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed May 11 19:00:27 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed May 11 19:00:27 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e6cb6af7

depgraph: in complete mode respect --with-bdeps

If you want the graph as complete as possible, now you'll have to use
--with-bdeps=y together with --complete-graph.

---
 man/emerge.1            |    2 ++
 pym/_emerge/depgraph.py |   10 +++-------
 pym/_emerge/help.py     |    5 ++++-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 907bb4f..d4cf42d 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -351,6 +351,8 @@ option will significantly increase the time taken for dependency
 calculations. Note that, unlike the \fB\-\-deep\fR option, the
 \fB\-\-complete\-graph\fR option does not cause any more packages to
 be updated than would have otherwise been updated with the option disabled.
+Using \fB\-\-with\-bdeps=y\fR together with \fB\-\-complete\-graph\fR makes
+the graph as complete as possible.
 .TP
 .BR \-\-config\-root=DIR
 Set the \fBPORTAGE_CONFIGROOT\fR environment variable.

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index b8089ae..3169d19 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -1343,11 +1343,10 @@ class depgraph(object):
 					ignore_build_time_deps = True
 
 		# If rebuild mode is not enabled, it's safe to discard ignored
-		# build-time dependencies. However, keep them if "complete" mode
-		# is enabled, since they make the graph more complete.
+		# build-time dependencies. If you want these deps to be traversed
+		# in "complete" mode then you need to specify --with-bdeps=y.
 		if ignore_build_time_deps and \
-			not self._rebuild.rebuild and \
-			"complete" not in self._dynamic_config.myparams:
+			not self._rebuild.rebuild:
 			edepend["DEPEND"] = ""
 
 		deps = (
@@ -4000,9 +3999,6 @@ class depgraph(object):
 			self._select_package = self._select_pkg_from_installed
 		else:
 			self._select_package = self._select_pkg_from_graph
-			# Make the graph as complete as possible by traversing build-time
-			# dependencies if they happen to be installed already.
-			self._dynamic_config.myparams["bdeps"] = "y"
 			self._dynamic_config._traverse_ignored_deps = True
 		already_deep = self._dynamic_config.myparams.get("deep") is True
 		if not already_deep:

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index de50b75..9de6aad 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -383,7 +383,10 @@ def help(myopts, havecolor=1):
 			" option will significantly increase the time taken for dependency" + \
 			" calculations. Note that, unlike the --deep option, the" + \
 			" --complete-graph option does not cause any more packages to" + \
-			" be updated than would have otherwise been updated with the option disabled."
+			" be updated than would have otherwise " + \
+			"been updated with the option disabled. " + \
+			"Using --with-bdeps=y together with --complete-graph makes " + \
+			"the graph as complete as possible."
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-04-28 16:16 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-04-28 16:16 UTC (permalink / raw
  To: gentoo-commits

commit:     ebb887ee7606ec2dd7b266dd3538e68b31ac3a38
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 28 16:10:02 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Apr 28 16:10:02 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ebb887ee

emerge: add --misspell-suggestions=n option

This will fix bug #363137.

---
 man/emerge.1            |    8 +++++++-
 pym/_emerge/depgraph.py |    4 +++-
 pym/_emerge/help.py     |    9 +++++++++
 pym/_emerge/main.py     |    6 ++++++
 4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 67f3e47..56823a8 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Mar 2011" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Apr 2011" "Portage VERSION" "Portage"
 .SH "NAME"
 emerge \- Command\-line interface to the Portage system
 .SH "SYNOPSIS"
@@ -438,6 +438,12 @@ order to avoid excess load. See \fBmake\fR(1) for information about
 analogous options that should be configured via \fBMAKEOPTS\fR in
 \fBmake.conf\fR(5).
 .TP
+.BR "\-\-misspell\-suggestions < y | n >"
+Enable or disable misspell suggestions. By default, emerge will show
+a list of packages with similar names when a package doesn't exist.
+The \fIEMERGE_DEFAULT_OPTS\fR variable may be used to disable this
+option by default.
+.TP
 .BR "\-\-newuse " (\fB\-N\fR)
 Tells emerge to include installed packages where USE
 flags have changed since compilation. This option

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 84e7d24..7db5ae3 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -2757,7 +2757,9 @@ class depgraph(object):
 			mask_docs = True
 		else:
 			writemsg_stdout("\nemerge: there are no ebuilds to satisfy "+green(xinfo)+".\n", noiselevel=-1)
-			if isinstance(myparent, AtomArg):
+			if isinstance(myparent, AtomArg) and \
+				self._frozen_config.myopts.get(
+				"--misspell-suggestions", "y") != "n":
 				cp = myparent.atom.cp.lower()
 				cat, pkg = portage.catsplit(cp)
 				if cat == "null":

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index a928a85..fb1e129 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -512,6 +512,15 @@ def help(myopts, havecolor=1):
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()
+		print("       " + green("--misspell-suggestions") + " < %s | %s >" % \
+			(turquoise("y"), turquoise("n")))
+		desc = "Enable or disable misspell suggestions. By default, " + \
+			"emerge will show a list of packages with similar names " + \
+			"when a package doesn't exist. The EMERGE_DEFAULT_OPTS " + \
+			"variable may be used to disable this option by default"
+		for line in wrap(desc, desc_width):
+			print(desc_indent + line)
+		print()
 		print("       "+green("--newuse")+" ("+green("-N")+" short option)")
 		desc = "Tells emerge to include installed packages where USE " + \
 			"flags have changed since compilation. This option " + \

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 6ae267f..82b1444 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -686,6 +686,12 @@ def parse_opts(tmpcmdline, silent=False):
 			"action" : "store"
 		},
 
+		"--misspell-suggestions": {
+			"help"    : "enable package name misspell suggestions",
+			"type"    : "choice",
+			"choices" : ("y", "n")
+		},
+
 		"--with-bdeps": {
 			"help":"include unnecessary build time dependencies",
 			"type":"choice",



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-04-27 22:07 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-04-27 22:07 UTC (permalink / raw
  To: gentoo-commits

commit:     80b72a3e8a1d0e04f430db3a7f5924f123362d7c
Author:     David James <davidjames <AT> google <DOT> com>
AuthorDate: Wed Apr 27 22:07:12 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Apr 27 22:07:12 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=80b72a3e

emerge: add 3 new options similar to --exclude

Add --nousepkg-atoms, --useoldpkg-atoms, and --reinstall-atoms flag
to Portage

reinstall-atoms accepts a space separated list of package names or
slot atoms. Emerge will treat matching packages as if they are not
installed, and reinstall them if necessary.

useoldpkg-atoms accepts a space separated list of package names or
slot atoms. Emerge will prefer matching binary packages over newer
unbuilt packages. This is useful in case you want to request that a
particular package won't be rebuilt from source.

nousepkg-atoms accepts a space separated list of package names or
slot atoms. Emerge will ignore matching binary packages.

Change-Id: I0d73039c6a4cd63695b28ffc80215628e0e05c95

BUG=chromium-os:12507 TEST=Try out the flag

Review URL: http://codereview.chromium.org/6577024

---
 man/emerge.1            |   13 ++++++++
 pym/_emerge/depgraph.py |   78 +++++++++++++++++++++++++++++++++++------------
 pym/_emerge/main.py     |   78 +++++++++++++++++++++++++++++++++++------------
 3 files changed, 129 insertions(+), 40 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 2693b67..67f3e47 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -479,6 +479,10 @@ may have changed.
 Disables the spinner for the session.  The spinner is active when the
 terminal device is determined to be a TTY.  This flag disables it regardless.
 .TP
+.BR "\-\-nousepkg\-atoms " ATOMS
+A space separated list of package names or slot atoms. Emerge will ignore
+matching binary packages.
+.TP
 .BR "\-\-oneshot " (\fB\-1\fR)
 Emerge as normal, but do not add the packages to the world file
 for later updating.
@@ -549,6 +553,11 @@ changed since installation.  Unlike \fB\-\-newuse\fR, this option does
 not trigger reinstallation when flags that the user has not
 enabled are added or removed.
 .TP
+.BR "\-\-reinstall\-atoms " ATOMS
+A space separated list of package names or slot atoms. Emerge will treat
+matching packages as if they are not installed, and reinstall them if
+necessary.
+.TP
 .BR \-\-root=DIR
 Set the \fBROOT\fR environment variable.
 .TP
@@ -606,6 +615,10 @@ atoms may match multiple versions of slotted packages.
 Use unbuilt ebuild metadata for visibility
 checks on built packages.
 .TP
+.BR "\-\-useoldpkg\-atoms " ATOMS
+A space separated list of package names or slot atoms. Emerge will prefer
+matching binary packages over newer unbuilt packages.
+.TP
 .BR "\-\-usepkg [ y | n ] (\-k short option)"
 Tells emerge to use binary packages (from $PKGDIR) if they are available, thus 
 possibly avoiding some time\-consuming compiles.  This option is useful for CD 

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index a0a4622..84e7d24 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -70,6 +70,16 @@ class _scheduler_graph_config(object):
 		self.graph = graph
 		self.mergelist = mergelist
 
+def _wildcard_set(atoms):
+	pkgs = InternalPackageSet(allow_wildcard=True)
+	for x in atoms:
+		try:
+			x = Atom(x, allow_wildcard=True)
+		except portage.exception.InvalidAtom:
+			x = Atom("*/" + x, allow_wildcard=True)
+		pkgs.add(x)
+	return pkgs
+
 class _frozen_depgraph_config(object):
 
 	def __init__(self, settings, trees, myopts, spinner):
@@ -109,13 +119,14 @@ class _frozen_depgraph_config(object):
 
 		self._required_set_names = set(["world"])
 
-		self.excluded_pkgs = InternalPackageSet(allow_wildcard=True)
-		for x in ' '.join(myopts.get("--exclude", [])).split():
-			try:
-				x = Atom(x, allow_wildcard=True)
-			except portage.exception.InvalidAtom:
-				x = Atom("*/" + x, allow_wildcard=True)
-			self.excluded_pkgs.add(x)
+		atoms = ' '.join(myopts.get("--exclude", [])).split()
+		self.excluded_pkgs = _wildcard_set(atoms)
+		atoms = ' '.join(myopts.get("--reinstall-atoms", [])).split()
+		self.reinstall_atoms = _wildcard_set(atoms)
+		atoms = ' '.join(myopts.get("--nousepkg-atoms", [])).split()
+		self.nousepkg_atoms = _wildcard_set(atoms)
+		atoms = ' '.join(myopts.get("--useoldpkg-atoms", [])).split()
+		self.useoldpkg_atoms = _wildcard_set(atoms)
 
 class _depgraph_sets(object):
 	def __init__(self):
@@ -1237,6 +1248,7 @@ class depgraph(object):
 		vardb = root_config.trees["vartree"].dbapi
 		traversed_virt_pkgs = set()
 
+		reinstall_atoms = self._frozen_config.reinstall_atoms
 		for atom, child in self._minimize_children(
 			pkg, dep_priority, root_config, selected_atoms[pkg]):
 
@@ -1254,7 +1266,9 @@ class depgraph(object):
 
 			mypriority = dep_priority.copy()
 			if not atom.blocker:
-				inst_pkgs = vardb.match_pkgs(atom)
+				inst_pkgs = [inst_pkg for inst_pkg in vardb.match_pkgs(atom)
+					if not reinstall_atoms.findAtomForPackage(inst_pkg,
+							modified_use=self._pkg_use_enabled(inst_pkg))]
 				if inst_pkgs:
 					for inst_pkg in inst_pkgs:
 						if self._pkg_visibility_check(inst_pkg):
@@ -1344,7 +1358,9 @@ class depgraph(object):
 				# This is a GLEP 37 virtual, so its deps are all runtime.
 				mypriority = self._priority(runtime=True)
 				if not atom.blocker:
-					inst_pkgs = vardb.match_pkgs(atom)
+					inst_pkgs = [inst_pkg for inst_pkg in vardb.match_pkgs(atom)
+						if not reinstall_atoms.findAtomForPackage(inst_pkg,
+								modified_use=self._pkg_use_enabled(inst_pkg))]
 					if inst_pkgs:
 						for inst_pkg in inst_pkgs:
 							if self._pkg_visibility_check(inst_pkg):
@@ -3161,6 +3177,10 @@ class depgraph(object):
 		dont_miss_updates = "--update" in self._frozen_config.myopts
 		use_ebuild_visibility = self._frozen_config.myopts.get(
 			'--use-ebuild-visibility', 'n') != 'n'
+		reinstall_atoms = self._frozen_config.reinstall_atoms
+		nousepkg_atoms = self._frozen_config.nousepkg_atoms
+		useoldpkg_atoms = self._frozen_config.useoldpkg_atoms
+		matched_oldpkg = []
 		# Behavior of the "selective" parameter depends on
 		# whether or not a package matches an argument atom.
 		# If an installed package provides an old-style
@@ -3200,7 +3220,14 @@ class depgraph(object):
 							modified_use=self._pkg_use_enabled(pkg)):
 						continue
 
-					if packages_with_invalid_use_config and \
+					if built and not installed and nousepkg_atoms.findAtomForPackage(pkg, \
+						modified_use=self._pkg_use_enabled(pkg)):
+						break
+
+					useoldpkg = useoldpkg_atoms.findAtomForPackage(pkg, \
+						modified_use=self._pkg_use_enabled(pkg))
+
+					if packages_with_invalid_use_config and (not built or not useoldpkg) and \
 						(not pkg.installed or dont_miss_updates):
 						# Check if a higher version was rejected due to user
 						# USE configuration. The packages_with_invalid_use_config
@@ -3282,7 +3309,7 @@ class depgraph(object):
 								# instances (installed or binary).
 								# If --usepkgonly is enabled, assume that
 								# the ebuild status should be ignored.
-								if not use_ebuild_visibility and usepkgonly:
+								if not use_ebuild_visibility and (usepkgonly or useoldpkg):
 									if pkg.installed and pkg.masks:
 										continue
 								else:
@@ -3419,7 +3446,7 @@ class depgraph(object):
 						break
 					# Compare built package to current config and
 					# reject the built package if necessary.
-					if built and (not installed or matched_pkgs_ignore_use) and \
+					if built and not useoldpkg and (not installed or matched_pkgs_ignore_use) and \
 						("--newuse" in self._frozen_config.myopts or \
 						"--reinstall" in self._frozen_config.myopts or \
 						"--binpkg-respect-use" in self._frozen_config.myopts):
@@ -3434,7 +3461,7 @@ class depgraph(object):
 						forced_flags.update(pkgsettings.useforce)
 						forced_flags.update(pkgsettings.usemask)
 						cur_iuse = iuses
-						if myeb and not usepkgonly:
+						if myeb and not usepkgonly and not useoldpkg:
 							cur_iuse = myeb.iuse.all
 						if self._reinstall_for_flags(forced_flags,
 							old_use, iuses,
@@ -3442,7 +3469,7 @@ class depgraph(object):
 							break
 					# Compare current config to installed package
 					# and do not reinstall if possible.
-					if not installed and \
+					if not installed and not useoldpkg and \
 						("--newuse" in self._frozen_config.myopts or \
 						"--reinstall" in self._frozen_config.myopts) and \
 						cpv in vardb.match(atom):
@@ -3460,8 +3487,13 @@ class depgraph(object):
 							cur_use, cur_iuse)
 						if reinstall_for_flags:
 							reinstall = True
+					if reinstall_atoms.findAtomForPackage(pkg, \
+							modified_use=self._pkg_use_enabled(pkg)):
+						reinstall = True
 					if not built:
 						myeb = pkg
+					elif useoldpkg:
+						matched_oldpkg.append(pkg)
 					matched_packages.append(pkg)
 					if reinstall_for_flags:
 						self._dynamic_config._reinstall_nodes[pkg] = \
@@ -3545,14 +3577,20 @@ class depgraph(object):
 						allow_license_changes=allow_license_changes):
 						return pkg, existing_node
 
-			bestmatch = portage.best(
-				[pkg.cpv for pkg in matched_packages \
+			visible_matches = []
+			if matched_oldpkg:
+				visible_matches = [pkg.cpv for pkg in matched_oldpkg \
 					if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords,
-						allow_license_changes=allow_license_changes)])
-			if not bestmatch:
+						allow_license_changes=allow_license_changes)]
+			if not visible_matches:
+				visible_matches = [pkg.cpv for pkg in matched_packages \
+					if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords,
+						allow_license_changes=allow_license_changes)]
+			if visible_matches:
+				bestmatch = portage.best(visible_matches)
+			else:
 				# all are masked, so ignore visibility
-				bestmatch = portage.best(
-					[pkg.cpv for pkg in matched_packages])
+				bestmatch = portage.best([pkg.cpv for pkg in matched_packages])
 			matched_packages = [pkg for pkg in matched_packages \
 				if portage.dep.cpvequal(pkg.cpv, bestmatch)]
 

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 96fee89..6ae267f 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -544,6 +544,23 @@ def insert_optional_args(args):
 
 	return new_args
 
+def _find_bad_atoms(atoms):
+	bad_atoms = []
+	for x in ' '.join(atoms).split():
+		bad_atom = False
+		try:
+			atom = portage.dep.Atom(x, allow_wildcard=True)
+		except portage.exception.InvalidAtom:
+			try:
+				atom = portage.dep.Atom("*/"+x, allow_wildcard=True)
+			except portage.exception.InvalidAtom:
+				bad_atom = True
+
+		if bad_atom or atom.operator or atom.blocker or atom.use:
+			bad_atoms.append(x)
+	return bad_atoms
+
+
 def parse_opts(tmpcmdline, silent=False):
 	myaction=None
 	myopts = {}
@@ -680,6 +697,14 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices":["changed-use"]
 		},
 
+		"--reinstall-atoms": {
+			"help"   :"A space separated list of package names or slot atoms. " + \
+				"Emerge will treat matching packages as if they are not " + \
+				"installed, and reinstall them if necessary. Implies --deep.",
+
+			"action" : "append",
+		},
+
 		"--binpkg-respect-use": {
 			"help"    : "discard binary packages if their use flags \
 				don't match the current configuration",
@@ -701,6 +726,13 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices"  : true_y_or_n
 		},
 
+		"--nousepkg-atoms": {
+			"help"   :"A space separated list of package names or slot atoms. " + \
+				"Emerge will ignore matching binary packages. ",
+
+			"action" : "append",
+		},
+
 		"--package-moves": {
 			"help"     : "perform package moves when necessary",
 			"type"     : "choice",
@@ -764,6 +796,13 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices"  : true_y_or_n
 		},
 
+		"--useoldpkg-atoms": {
+			"help"   :"A space separated list of package names or slot atoms. " + \
+				"Emerge will prefer matching binary packages over newer unbuilt packages. ",
+
+			"action" : "append",
+		},
+
 		"--usepkg": {
 			"shortopt" : "-k",
 			"help"     : "use binary packages",
@@ -852,30 +891,29 @@ def parse_opts(tmpcmdline, silent=False):
 			myoptions.depclean_lib_check = True
 
 	if myoptions.exclude:
-		exclude = []
-		bad_atoms = []
-		for x in ' '.join(myoptions.exclude).split():
-			bad_atom = False
-			try:
-				atom = portage.dep.Atom(x, allow_wildcard=True)
-			except portage.exception.InvalidAtom:
-				try:
-					atom = portage.dep.Atom("*/"+x, allow_wildcard=True)
-				except portage.exception.InvalidAtom:
-					bad_atom = True
-			
-			if bad_atom:
-				bad_atoms.append(x)
-			else:
-				if atom.operator or atom.blocker or atom.use:
-					bad_atoms.append(x)
-				else:
-					exclude.append(atom)
-
+		bad_atoms = _find_bad_atoms(myoptions.exclude)
 		if bad_atoms and not silent:
 			parser.error("Invalid Atom(s) in --exclude parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
 				(",".join(bad_atoms),))
 
+	if myoptions.reinstall_atoms:
+		bad_atoms = _find_bad_atoms(myoptions.reinstall_atoms)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --reinstall-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
+				(",".join(bad_atoms),))
+
+	if myoptions.nousepkg_atoms:
+		bad_atoms = _find_bad_atoms(myoptions.nousepkg_atoms)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --nousepkg-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
+				(",".join(bad_atoms),))
+
+	if myoptions.useoldpkg_atoms:
+		bad_atoms = _find_bad_atoms(myoptions.useoldpkg_atoms)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --useoldpkg-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
+				(",".join(bad_atoms),))
+
 	if myoptions.fail_clean in true_y:
 		myoptions.fail_clean = True
 



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-04-27 22:03 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-04-27 22:03 UTC (permalink / raw
  To: gentoo-commits

commit:     3bfc83bb03b7c7edd031df62a7a38acba4d628e2
Author:     David James <davidjames <AT> google <DOT> com>
AuthorDate: Wed Apr 27 22:02:39 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Apr 27 22:02:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3bfc83bb

emerge: add 3 new options similar to --exclude

Add --nousepkg-atoms, --useoldpkg-atoms, and --reinstall-atoms flag
to Portage

reinstall-atoms accepts a space separated list of package names or
slot atoms. Emerge will treat matching packages as if they are not
installed, and reinstall them if necessary.

useoldpkg-atoms accepts a space separated list of package names or
slot atoms. Emerge will prefer matching binary packages over newer
unbuilt packages. This is useful in case you want to request that a
particular package won't be rebuilt from source.

nousepkg-atoms accepts a space separated list of package names or
slot atoms. Emerge will ignore matching binary packages.

Change-Id: I0d73039c6a4cd63695b28ffc80215628e0e05c95

BUG=chromium-os:12507 TEST=Try out the flag

Review URL: http://codereview.chromium.org/6577024

---
 man/emerge.1            |   13 ++++++++
 pym/_emerge/depgraph.py |   78 ++++++++++++++++++++++++++++++++++------------
 pym/_emerge/main.py     |   79 ++++++++++++++++++++++++++++++++++-------------
 3 files changed, 128 insertions(+), 42 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 2693b67..67f3e47 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -479,6 +479,10 @@ may have changed.
 Disables the spinner for the session.  The spinner is active when the
 terminal device is determined to be a TTY.  This flag disables it regardless.
 .TP
+.BR "\-\-nousepkg\-atoms " ATOMS
+A space separated list of package names or slot atoms. Emerge will ignore
+matching binary packages.
+.TP
 .BR "\-\-oneshot " (\fB\-1\fR)
 Emerge as normal, but do not add the packages to the world file
 for later updating.
@@ -549,6 +553,11 @@ changed since installation.  Unlike \fB\-\-newuse\fR, this option does
 not trigger reinstallation when flags that the user has not
 enabled are added or removed.
 .TP
+.BR "\-\-reinstall\-atoms " ATOMS
+A space separated list of package names or slot atoms. Emerge will treat
+matching packages as if they are not installed, and reinstall them if
+necessary.
+.TP
 .BR \-\-root=DIR
 Set the \fBROOT\fR environment variable.
 .TP
@@ -606,6 +615,10 @@ atoms may match multiple versions of slotted packages.
 Use unbuilt ebuild metadata for visibility
 checks on built packages.
 .TP
+.BR "\-\-useoldpkg\-atoms " ATOMS
+A space separated list of package names or slot atoms. Emerge will prefer
+matching binary packages over newer unbuilt packages.
+.TP
 .BR "\-\-usepkg [ y | n ] (\-k short option)"
 Tells emerge to use binary packages (from $PKGDIR) if they are available, thus 
 possibly avoiding some time\-consuming compiles.  This option is useful for CD 

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index a0a4622..84e7d24 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -70,6 +70,16 @@ class _scheduler_graph_config(object):
 		self.graph = graph
 		self.mergelist = mergelist
 
+def _wildcard_set(atoms):
+	pkgs = InternalPackageSet(allow_wildcard=True)
+	for x in atoms:
+		try:
+			x = Atom(x, allow_wildcard=True)
+		except portage.exception.InvalidAtom:
+			x = Atom("*/" + x, allow_wildcard=True)
+		pkgs.add(x)
+	return pkgs
+
 class _frozen_depgraph_config(object):
 
 	def __init__(self, settings, trees, myopts, spinner):
@@ -109,13 +119,14 @@ class _frozen_depgraph_config(object):
 
 		self._required_set_names = set(["world"])
 
-		self.excluded_pkgs = InternalPackageSet(allow_wildcard=True)
-		for x in ' '.join(myopts.get("--exclude", [])).split():
-			try:
-				x = Atom(x, allow_wildcard=True)
-			except portage.exception.InvalidAtom:
-				x = Atom("*/" + x, allow_wildcard=True)
-			self.excluded_pkgs.add(x)
+		atoms = ' '.join(myopts.get("--exclude", [])).split()
+		self.excluded_pkgs = _wildcard_set(atoms)
+		atoms = ' '.join(myopts.get("--reinstall-atoms", [])).split()
+		self.reinstall_atoms = _wildcard_set(atoms)
+		atoms = ' '.join(myopts.get("--nousepkg-atoms", [])).split()
+		self.nousepkg_atoms = _wildcard_set(atoms)
+		atoms = ' '.join(myopts.get("--useoldpkg-atoms", [])).split()
+		self.useoldpkg_atoms = _wildcard_set(atoms)
 
 class _depgraph_sets(object):
 	def __init__(self):
@@ -1237,6 +1248,7 @@ class depgraph(object):
 		vardb = root_config.trees["vartree"].dbapi
 		traversed_virt_pkgs = set()
 
+		reinstall_atoms = self._frozen_config.reinstall_atoms
 		for atom, child in self._minimize_children(
 			pkg, dep_priority, root_config, selected_atoms[pkg]):
 
@@ -1254,7 +1266,9 @@ class depgraph(object):
 
 			mypriority = dep_priority.copy()
 			if not atom.blocker:
-				inst_pkgs = vardb.match_pkgs(atom)
+				inst_pkgs = [inst_pkg for inst_pkg in vardb.match_pkgs(atom)
+					if not reinstall_atoms.findAtomForPackage(inst_pkg,
+							modified_use=self._pkg_use_enabled(inst_pkg))]
 				if inst_pkgs:
 					for inst_pkg in inst_pkgs:
 						if self._pkg_visibility_check(inst_pkg):
@@ -1344,7 +1358,9 @@ class depgraph(object):
 				# This is a GLEP 37 virtual, so its deps are all runtime.
 				mypriority = self._priority(runtime=True)
 				if not atom.blocker:
-					inst_pkgs = vardb.match_pkgs(atom)
+					inst_pkgs = [inst_pkg for inst_pkg in vardb.match_pkgs(atom)
+						if not reinstall_atoms.findAtomForPackage(inst_pkg,
+								modified_use=self._pkg_use_enabled(inst_pkg))]
 					if inst_pkgs:
 						for inst_pkg in inst_pkgs:
 							if self._pkg_visibility_check(inst_pkg):
@@ -3161,6 +3177,10 @@ class depgraph(object):
 		dont_miss_updates = "--update" in self._frozen_config.myopts
 		use_ebuild_visibility = self._frozen_config.myopts.get(
 			'--use-ebuild-visibility', 'n') != 'n'
+		reinstall_atoms = self._frozen_config.reinstall_atoms
+		nousepkg_atoms = self._frozen_config.nousepkg_atoms
+		useoldpkg_atoms = self._frozen_config.useoldpkg_atoms
+		matched_oldpkg = []
 		# Behavior of the "selective" parameter depends on
 		# whether or not a package matches an argument atom.
 		# If an installed package provides an old-style
@@ -3200,7 +3220,14 @@ class depgraph(object):
 							modified_use=self._pkg_use_enabled(pkg)):
 						continue
 
-					if packages_with_invalid_use_config and \
+					if built and not installed and nousepkg_atoms.findAtomForPackage(pkg, \
+						modified_use=self._pkg_use_enabled(pkg)):
+						break
+
+					useoldpkg = useoldpkg_atoms.findAtomForPackage(pkg, \
+						modified_use=self._pkg_use_enabled(pkg))
+
+					if packages_with_invalid_use_config and (not built or not useoldpkg) and \
 						(not pkg.installed or dont_miss_updates):
 						# Check if a higher version was rejected due to user
 						# USE configuration. The packages_with_invalid_use_config
@@ -3282,7 +3309,7 @@ class depgraph(object):
 								# instances (installed or binary).
 								# If --usepkgonly is enabled, assume that
 								# the ebuild status should be ignored.
-								if not use_ebuild_visibility and usepkgonly:
+								if not use_ebuild_visibility and (usepkgonly or useoldpkg):
 									if pkg.installed and pkg.masks:
 										continue
 								else:
@@ -3419,7 +3446,7 @@ class depgraph(object):
 						break
 					# Compare built package to current config and
 					# reject the built package if necessary.
-					if built and (not installed or matched_pkgs_ignore_use) and \
+					if built and not useoldpkg and (not installed or matched_pkgs_ignore_use) and \
 						("--newuse" in self._frozen_config.myopts or \
 						"--reinstall" in self._frozen_config.myopts or \
 						"--binpkg-respect-use" in self._frozen_config.myopts):
@@ -3434,7 +3461,7 @@ class depgraph(object):
 						forced_flags.update(pkgsettings.useforce)
 						forced_flags.update(pkgsettings.usemask)
 						cur_iuse = iuses
-						if myeb and not usepkgonly:
+						if myeb and not usepkgonly and not useoldpkg:
 							cur_iuse = myeb.iuse.all
 						if self._reinstall_for_flags(forced_flags,
 							old_use, iuses,
@@ -3442,7 +3469,7 @@ class depgraph(object):
 							break
 					# Compare current config to installed package
 					# and do not reinstall if possible.
-					if not installed and \
+					if not installed and not useoldpkg and \
 						("--newuse" in self._frozen_config.myopts or \
 						"--reinstall" in self._frozen_config.myopts) and \
 						cpv in vardb.match(atom):
@@ -3460,8 +3487,13 @@ class depgraph(object):
 							cur_use, cur_iuse)
 						if reinstall_for_flags:
 							reinstall = True
+					if reinstall_atoms.findAtomForPackage(pkg, \
+							modified_use=self._pkg_use_enabled(pkg)):
+						reinstall = True
 					if not built:
 						myeb = pkg
+					elif useoldpkg:
+						matched_oldpkg.append(pkg)
 					matched_packages.append(pkg)
 					if reinstall_for_flags:
 						self._dynamic_config._reinstall_nodes[pkg] = \
@@ -3545,14 +3577,20 @@ class depgraph(object):
 						allow_license_changes=allow_license_changes):
 						return pkg, existing_node
 
-			bestmatch = portage.best(
-				[pkg.cpv for pkg in matched_packages \
+			visible_matches = []
+			if matched_oldpkg:
+				visible_matches = [pkg.cpv for pkg in matched_oldpkg \
 					if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords,
-						allow_license_changes=allow_license_changes)])
-			if not bestmatch:
+						allow_license_changes=allow_license_changes)]
+			if not visible_matches:
+				visible_matches = [pkg.cpv for pkg in matched_packages \
+					if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords,
+						allow_license_changes=allow_license_changes)]
+			if visible_matches:
+				bestmatch = portage.best(visible_matches)
+			else:
 				# all are masked, so ignore visibility
-				bestmatch = portage.best(
-					[pkg.cpv for pkg in matched_packages])
+				bestmatch = portage.best([pkg.cpv for pkg in matched_packages])
 			matched_packages = [pkg for pkg in matched_packages \
 				if portage.dep.cpvequal(pkg.cpv, bestmatch)]
 

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 96fee89..af243c0 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -544,6 +544,23 @@ def insert_optional_args(args):
 
 	return new_args
 
+def _find_bad_atoms(atoms):
+	bad_atoms = []
+	for x in ' '.join(atoms).split():
+		bad_atom = False
+		try:
+			atom = portage.dep.Atom(x, allow_wildcard=True)
+		except portage.exception.InvalidAtom:
+			try:
+				atom = portage.dep.Atom("*/"+x, allow_wildcard=True)
+			except portage.exception.InvalidAtom:
+				bad_atom = True
+
+		if bad_atom or atom.operator or atom.blocker or atom.use:
+			bad_atoms.append(x)
+	return bad_atoms
+
+
 def parse_opts(tmpcmdline, silent=False):
 	myaction=None
 	myopts = {}
@@ -680,6 +697,14 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices":["changed-use"]
 		},
 
+		"--reinstall-atoms": {
+			"help"   :"A space separated list of package names or slot atoms. " + \
+				"Emerge will treat matching packages as if they are not " + \
+				"installed, and reinstall them if necessary. Implies --deep.",
+
+			"action" : "append",
+		},
+
 		"--binpkg-respect-use": {
 			"help"    : "discard binary packages if their use flags \
 				don't match the current configuration",
@@ -701,6 +726,13 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices"  : true_y_or_n
 		},
 
+		"--nousepkg-atoms": {
+			"help"   :"A space separated list of package names or slot atoms. " + \
+				"Emerge will ignore matching binary packages. ",
+
+			"action" : "append",
+		},
+
 		"--package-moves": {
 			"help"     : "perform package moves when necessary",
 			"type"     : "choice",
@@ -764,6 +796,13 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices"  : true_y_or_n
 		},
 
+		"--useoldpkg-atoms": {
+			"help"   :"A space separated list of package names or slot atoms. " + \
+				"Emerge will prefer matching binary packages over newer unbuilt packages. ",
+
+			"action" : "append",
+		},
+
 		"--usepkg": {
 			"shortopt" : "-k",
 			"help"     : "use binary packages",
@@ -852,32 +891,28 @@ def parse_opts(tmpcmdline, silent=False):
 			myoptions.depclean_lib_check = True
 
 	if myoptions.exclude:
-		exclude = []
-		bad_atoms = []
-		for x in ' '.join(myoptions.exclude).split():
-			bad_atom = False
-			try:
-				atom = portage.dep.Atom(x, allow_wildcard=True)
-			except portage.exception.InvalidAtom:
-				try:
-					atom = portage.dep.Atom("*/"+x, allow_wildcard=True)
-				except portage.exception.InvalidAtom:
-					bad_atom = True
-			
-			if bad_atom:
-				bad_atoms.append(x)
-			else:
-				if atom.operator or atom.blocker or atom.use:
-					bad_atoms.append(x)
-				else:
-					exclude.append(atom)
-
+		bad_atoms = _find_bad_atoms(myoptions.exclude)
 		if bad_atoms and not silent:
 			parser.error("Invalid Atom(s) in --exclude parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
 				(",".join(bad_atoms),))
 
-	if myoptions.fail_clean in true_y:
-		myoptions.fail_clean = True
+	if myoptions.reinstall_atoms:
+		bad_atoms = _find_bad_atoms(myoptions.reinstall_atoms)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --reinstall-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
+				(",".join(bad_atoms),))
+
+	if myoptions.nousepkg_atoms:
+		bad_atoms = _find_bad_atoms(myoptions.nousepkg_atoms)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --nousepkg-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
+				(",".join(bad_atoms),))
+
+	if myoptions.useoldpkg_atoms:
+		bad_atoms = _find_bad_atoms(myoptions.useoldpkg_atoms)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --useoldpkg-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
+				(",".join(bad_atoms),))
 
 	if myoptions.getbinpkg in true_y:
 		myoptions.getbinpkg = True



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-04-27 22:00 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-04-27 22:00 UTC (permalink / raw
  To: gentoo-commits

commit:     43f027c59cdbaf10907ba4f8acbe4b8dd91daf61
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 27 21:56:31 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Apr 27 21:56:31 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=43f027c5

emerge: add 3 new options similar to --exclude

Add --nousepkg-atoms, --useoldpkg-atoms, and --reinstall-atoms flag
to Portage

reinstall-atoms accepts a space separated list of package names or
slot atoms. Emerge will treat matching packages as if they are not
installed, and reinstall them if necessary.

useoldpkg-atoms accepts a space separated list of package names or
slot atoms. Emerge will prefer matching binary packages over newer
unbuilt packages. This is useful in case you want to request that a
particular package won't be rebuilt from source.

nousepkg-atoms accepts a space separated list of package names or
slot atoms. Emerge will ignore matching binary packages.

Change-Id: I0d73039c6a4cd63695b28ffc80215628e0e05c95

BUG=chromium-os:12507 TEST=Try out the flag

Review URL: http://codereview.chromium.org/6577024

---
 man/emerge.1            |   13 ++++++++
 pym/_emerge/depgraph.py |   78 +++++++++++++++++++++++++++++++++++------------
 pym/_emerge/main.py     |   78 +++++++++++++++++++++++++++++++++++------------
 3 files changed, 129 insertions(+), 40 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 2693b67..67f3e47 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -479,6 +479,10 @@ may have changed.
 Disables the spinner for the session.  The spinner is active when the
 terminal device is determined to be a TTY.  This flag disables it regardless.
 .TP
+.BR "\-\-nousepkg\-atoms " ATOMS
+A space separated list of package names or slot atoms. Emerge will ignore
+matching binary packages.
+.TP
 .BR "\-\-oneshot " (\fB\-1\fR)
 Emerge as normal, but do not add the packages to the world file
 for later updating.
@@ -549,6 +553,11 @@ changed since installation.  Unlike \fB\-\-newuse\fR, this option does
 not trigger reinstallation when flags that the user has not
 enabled are added or removed.
 .TP
+.BR "\-\-reinstall\-atoms " ATOMS
+A space separated list of package names or slot atoms. Emerge will treat
+matching packages as if they are not installed, and reinstall them if
+necessary.
+.TP
 .BR \-\-root=DIR
 Set the \fBROOT\fR environment variable.
 .TP
@@ -606,6 +615,10 @@ atoms may match multiple versions of slotted packages.
 Use unbuilt ebuild metadata for visibility
 checks on built packages.
 .TP
+.BR "\-\-useoldpkg\-atoms " ATOMS
+A space separated list of package names or slot atoms. Emerge will prefer
+matching binary packages over newer unbuilt packages.
+.TP
 .BR "\-\-usepkg [ y | n ] (\-k short option)"
 Tells emerge to use binary packages (from $PKGDIR) if they are available, thus 
 possibly avoiding some time\-consuming compiles.  This option is useful for CD 

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index a0a4622..84e7d24 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -70,6 +70,16 @@ class _scheduler_graph_config(object):
 		self.graph = graph
 		self.mergelist = mergelist
 
+def _wildcard_set(atoms):
+	pkgs = InternalPackageSet(allow_wildcard=True)
+	for x in atoms:
+		try:
+			x = Atom(x, allow_wildcard=True)
+		except portage.exception.InvalidAtom:
+			x = Atom("*/" + x, allow_wildcard=True)
+		pkgs.add(x)
+	return pkgs
+
 class _frozen_depgraph_config(object):
 
 	def __init__(self, settings, trees, myopts, spinner):
@@ -109,13 +119,14 @@ class _frozen_depgraph_config(object):
 
 		self._required_set_names = set(["world"])
 
-		self.excluded_pkgs = InternalPackageSet(allow_wildcard=True)
-		for x in ' '.join(myopts.get("--exclude", [])).split():
-			try:
-				x = Atom(x, allow_wildcard=True)
-			except portage.exception.InvalidAtom:
-				x = Atom("*/" + x, allow_wildcard=True)
-			self.excluded_pkgs.add(x)
+		atoms = ' '.join(myopts.get("--exclude", [])).split()
+		self.excluded_pkgs = _wildcard_set(atoms)
+		atoms = ' '.join(myopts.get("--reinstall-atoms", [])).split()
+		self.reinstall_atoms = _wildcard_set(atoms)
+		atoms = ' '.join(myopts.get("--nousepkg-atoms", [])).split()
+		self.nousepkg_atoms = _wildcard_set(atoms)
+		atoms = ' '.join(myopts.get("--useoldpkg-atoms", [])).split()
+		self.useoldpkg_atoms = _wildcard_set(atoms)
 
 class _depgraph_sets(object):
 	def __init__(self):
@@ -1237,6 +1248,7 @@ class depgraph(object):
 		vardb = root_config.trees["vartree"].dbapi
 		traversed_virt_pkgs = set()
 
+		reinstall_atoms = self._frozen_config.reinstall_atoms
 		for atom, child in self._minimize_children(
 			pkg, dep_priority, root_config, selected_atoms[pkg]):
 
@@ -1254,7 +1266,9 @@ class depgraph(object):
 
 			mypriority = dep_priority.copy()
 			if not atom.blocker:
-				inst_pkgs = vardb.match_pkgs(atom)
+				inst_pkgs = [inst_pkg for inst_pkg in vardb.match_pkgs(atom)
+					if not reinstall_atoms.findAtomForPackage(inst_pkg,
+							modified_use=self._pkg_use_enabled(inst_pkg))]
 				if inst_pkgs:
 					for inst_pkg in inst_pkgs:
 						if self._pkg_visibility_check(inst_pkg):
@@ -1344,7 +1358,9 @@ class depgraph(object):
 				# This is a GLEP 37 virtual, so its deps are all runtime.
 				mypriority = self._priority(runtime=True)
 				if not atom.blocker:
-					inst_pkgs = vardb.match_pkgs(atom)
+					inst_pkgs = [inst_pkg for inst_pkg in vardb.match_pkgs(atom)
+						if not reinstall_atoms.findAtomForPackage(inst_pkg,
+								modified_use=self._pkg_use_enabled(inst_pkg))]
 					if inst_pkgs:
 						for inst_pkg in inst_pkgs:
 							if self._pkg_visibility_check(inst_pkg):
@@ -3161,6 +3177,10 @@ class depgraph(object):
 		dont_miss_updates = "--update" in self._frozen_config.myopts
 		use_ebuild_visibility = self._frozen_config.myopts.get(
 			'--use-ebuild-visibility', 'n') != 'n'
+		reinstall_atoms = self._frozen_config.reinstall_atoms
+		nousepkg_atoms = self._frozen_config.nousepkg_atoms
+		useoldpkg_atoms = self._frozen_config.useoldpkg_atoms
+		matched_oldpkg = []
 		# Behavior of the "selective" parameter depends on
 		# whether or not a package matches an argument atom.
 		# If an installed package provides an old-style
@@ -3200,7 +3220,14 @@ class depgraph(object):
 							modified_use=self._pkg_use_enabled(pkg)):
 						continue
 
-					if packages_with_invalid_use_config and \
+					if built and not installed and nousepkg_atoms.findAtomForPackage(pkg, \
+						modified_use=self._pkg_use_enabled(pkg)):
+						break
+
+					useoldpkg = useoldpkg_atoms.findAtomForPackage(pkg, \
+						modified_use=self._pkg_use_enabled(pkg))
+
+					if packages_with_invalid_use_config and (not built or not useoldpkg) and \
 						(not pkg.installed or dont_miss_updates):
 						# Check if a higher version was rejected due to user
 						# USE configuration. The packages_with_invalid_use_config
@@ -3282,7 +3309,7 @@ class depgraph(object):
 								# instances (installed or binary).
 								# If --usepkgonly is enabled, assume that
 								# the ebuild status should be ignored.
-								if not use_ebuild_visibility and usepkgonly:
+								if not use_ebuild_visibility and (usepkgonly or useoldpkg):
 									if pkg.installed and pkg.masks:
 										continue
 								else:
@@ -3419,7 +3446,7 @@ class depgraph(object):
 						break
 					# Compare built package to current config and
 					# reject the built package if necessary.
-					if built and (not installed or matched_pkgs_ignore_use) and \
+					if built and not useoldpkg and (not installed or matched_pkgs_ignore_use) and \
 						("--newuse" in self._frozen_config.myopts or \
 						"--reinstall" in self._frozen_config.myopts or \
 						"--binpkg-respect-use" in self._frozen_config.myopts):
@@ -3434,7 +3461,7 @@ class depgraph(object):
 						forced_flags.update(pkgsettings.useforce)
 						forced_flags.update(pkgsettings.usemask)
 						cur_iuse = iuses
-						if myeb and not usepkgonly:
+						if myeb and not usepkgonly and not useoldpkg:
 							cur_iuse = myeb.iuse.all
 						if self._reinstall_for_flags(forced_flags,
 							old_use, iuses,
@@ -3442,7 +3469,7 @@ class depgraph(object):
 							break
 					# Compare current config to installed package
 					# and do not reinstall if possible.
-					if not installed and \
+					if not installed and not useoldpkg and \
 						("--newuse" in self._frozen_config.myopts or \
 						"--reinstall" in self._frozen_config.myopts) and \
 						cpv in vardb.match(atom):
@@ -3460,8 +3487,13 @@ class depgraph(object):
 							cur_use, cur_iuse)
 						if reinstall_for_flags:
 							reinstall = True
+					if reinstall_atoms.findAtomForPackage(pkg, \
+							modified_use=self._pkg_use_enabled(pkg)):
+						reinstall = True
 					if not built:
 						myeb = pkg
+					elif useoldpkg:
+						matched_oldpkg.append(pkg)
 					matched_packages.append(pkg)
 					if reinstall_for_flags:
 						self._dynamic_config._reinstall_nodes[pkg] = \
@@ -3545,14 +3577,20 @@ class depgraph(object):
 						allow_license_changes=allow_license_changes):
 						return pkg, existing_node
 
-			bestmatch = portage.best(
-				[pkg.cpv for pkg in matched_packages \
+			visible_matches = []
+			if matched_oldpkg:
+				visible_matches = [pkg.cpv for pkg in matched_oldpkg \
 					if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords,
-						allow_license_changes=allow_license_changes)])
-			if not bestmatch:
+						allow_license_changes=allow_license_changes)]
+			if not visible_matches:
+				visible_matches = [pkg.cpv for pkg in matched_packages \
+					if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords,
+						allow_license_changes=allow_license_changes)]
+			if visible_matches:
+				bestmatch = portage.best(visible_matches)
+			else:
 				# all are masked, so ignore visibility
-				bestmatch = portage.best(
-					[pkg.cpv for pkg in matched_packages])
+				bestmatch = portage.best([pkg.cpv for pkg in matched_packages])
 			matched_packages = [pkg for pkg in matched_packages \
 				if portage.dep.cpvequal(pkg.cpv, bestmatch)]
 

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 96fee89..6ae267f 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -544,6 +544,23 @@ def insert_optional_args(args):
 
 	return new_args
 
+def _find_bad_atoms(atoms):
+	bad_atoms = []
+	for x in ' '.join(atoms).split():
+		bad_atom = False
+		try:
+			atom = portage.dep.Atom(x, allow_wildcard=True)
+		except portage.exception.InvalidAtom:
+			try:
+				atom = portage.dep.Atom("*/"+x, allow_wildcard=True)
+			except portage.exception.InvalidAtom:
+				bad_atom = True
+
+		if bad_atom or atom.operator or atom.blocker or atom.use:
+			bad_atoms.append(x)
+	return bad_atoms
+
+
 def parse_opts(tmpcmdline, silent=False):
 	myaction=None
 	myopts = {}
@@ -680,6 +697,14 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices":["changed-use"]
 		},
 
+		"--reinstall-atoms": {
+			"help"   :"A space separated list of package names or slot atoms. " + \
+				"Emerge will treat matching packages as if they are not " + \
+				"installed, and reinstall them if necessary. Implies --deep.",
+
+			"action" : "append",
+		},
+
 		"--binpkg-respect-use": {
 			"help"    : "discard binary packages if their use flags \
 				don't match the current configuration",
@@ -701,6 +726,13 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices"  : true_y_or_n
 		},
 
+		"--nousepkg-atoms": {
+			"help"   :"A space separated list of package names or slot atoms. " + \
+				"Emerge will ignore matching binary packages. ",
+
+			"action" : "append",
+		},
+
 		"--package-moves": {
 			"help"     : "perform package moves when necessary",
 			"type"     : "choice",
@@ -764,6 +796,13 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices"  : true_y_or_n
 		},
 
+		"--useoldpkg-atoms": {
+			"help"   :"A space separated list of package names or slot atoms. " + \
+				"Emerge will prefer matching binary packages over newer unbuilt packages. ",
+
+			"action" : "append",
+		},
+
 		"--usepkg": {
 			"shortopt" : "-k",
 			"help"     : "use binary packages",
@@ -852,30 +891,29 @@ def parse_opts(tmpcmdline, silent=False):
 			myoptions.depclean_lib_check = True
 
 	if myoptions.exclude:
-		exclude = []
-		bad_atoms = []
-		for x in ' '.join(myoptions.exclude).split():
-			bad_atom = False
-			try:
-				atom = portage.dep.Atom(x, allow_wildcard=True)
-			except portage.exception.InvalidAtom:
-				try:
-					atom = portage.dep.Atom("*/"+x, allow_wildcard=True)
-				except portage.exception.InvalidAtom:
-					bad_atom = True
-			
-			if bad_atom:
-				bad_atoms.append(x)
-			else:
-				if atom.operator or atom.blocker or atom.use:
-					bad_atoms.append(x)
-				else:
-					exclude.append(atom)
-
+		bad_atoms = _find_bad_atoms(myoptions.exclude)
 		if bad_atoms and not silent:
 			parser.error("Invalid Atom(s) in --exclude parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
 				(",".join(bad_atoms),))
 
+	if myoptions.reinstall_atoms:
+		bad_atoms = _find_bad_atoms(myoptions.reinstall_atoms)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --reinstall-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
+				(",".join(bad_atoms),))
+
+	if myoptions.nousepkg_atoms:
+		bad_atoms = _find_bad_atoms(myoptions.nousepkg_atoms)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --nousepkg-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
+				(",".join(bad_atoms),))
+
+	if myoptions.useoldpkg_atoms:
+		bad_atoms = _find_bad_atoms(myoptions.useoldpkg_atoms)
+		if bad_atoms and not silent:
+			parser.error("Invalid Atom(s) in --useoldpkg-atoms parameter: '%s' (only package names and slot atoms (with wildcards) allowed)\n" % \
+				(",".join(bad_atoms),))
+
 	if myoptions.fail_clean in true_y:
 		myoptions.fail_clean = True
 



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-03-24 18:18 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-03-24 18:18 UTC (permalink / raw
  To: gentoo-commits

commit:     39911a4fc3859ae528dfe541ae9d9119291ae0e2
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 24 18:15:47 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Mar 24 18:15:47 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=39911a4f

emerge: support [ y | n ] for --ask

This allows --ask to be enabled via EMERGE_DEFAULT_OPTS, and then
temporarily disabled via the command-line. This may be useful for
programs that call emerge non-interactively, as in bug #360233.

---
 man/emerge.1        |    2 +-
 pym/_emerge/help.py |    4 +++-
 pym/_emerge/main.py |   17 +++++++++++++++--
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 0e3eb13..2693b67 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -270,7 +270,7 @@ configuration, this would result in an effective
 When displaying USE and other flag output, combines the enabled and
 disabled lists into one list and sorts the whole list alphabetically.
 .TP
-.BR "\-\-ask " (\fB\-a\fR)
+.BR "\-\-ask [ y | n ] (\-a short option)"
 Before performing the action, display what will take place (server info for
 \fB\-\-sync\fR, \fB\-\-pretend\fR output for merge, and so forth), then ask
 whether to proceed with the action or abort.  Using \fB\-\-ask\fR is more

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 020bc42..a120f54 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -280,7 +280,9 @@ def help(myopts, havecolor=1):
 		print("              With this option, output such as USE=\"dar -bar -foo\" will instead")
 		print("              be displayed as USE=\"-bar dar -foo\"")
 		print()
-		print("       "+green("--ask")+" ("+green("-a")+" short option)")
+		print("       " + green("--ask") + \
+			" [ %s | %s ] (%s short option)" % \
+			(turquoise("y"), turquoise("n"), green("-a")))
 		desc = "Before performing the action, display what will take place (server info for " + \
 			"--sync, --pretend output for merge, and so forth), then ask " + \
 			"whether to proceed with the action or abort.  Using --ask is more " + \

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 1a63bc7..d4b14fc 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -50,7 +50,7 @@ if sys.hexversion >= 0x3000000:
 	long = int
 
 options=[
-"--ask",          "--alphabetical",
+"--alphabetical",
 "--ask-enter-invalid",
 "--buildpkgonly",
 "--changed-use",
@@ -77,7 +77,6 @@ options=[
 
 shortmapping={
 "1":"--oneshot",
-"a":"--ask",
 "B":"--buildpkgonly",
 "c":"--depclean",
 "C":"--unmerge",
@@ -422,6 +421,7 @@ def insert_optional_args(args):
 	new_args = []
 
 	default_arg_opts = {
+		'--ask'                  : y_or_n,
 		'--autounmask'           : y_or_n,
 		'--buildpkg'             : y_or_n,
 		'--complete-graph'       : y_or_n,
@@ -456,6 +456,7 @@ def insert_optional_args(args):
 	# Don't make things like "-kn" expand to "-k n"
 	# since existence of -n makes it too ambiguous.
 	short_arg_opts_n = {
+		'a' : y_or_n,
 		'b' : y_or_n,
 		'g' : y_or_n,
 		'G' : y_or_n,
@@ -560,6 +561,13 @@ def parse_opts(tmpcmdline, silent=False):
 	true_y = ("True", "y")
 	argument_options = {
 
+		"--ask": {
+			"shortopt" : "-a",
+			"help"    : "prompt before performing any actions",
+			"type"    : "choice",
+			"choices" : true_y_or_n
+		},
+
 		"--autounmask": {
 			"help"    : "automatically unmask packages",
 			"type"    : "choice",
@@ -807,6 +815,11 @@ def parse_opts(tmpcmdline, silent=False):
 
 	myoptions, myargs = parser.parse_args(args=tmpcmdline)
 
+	if myoptions.ask in true_y:
+		myoptions.ask = True
+	else:
+		myoptions.ask = None
+
 	if myoptions.autounmask in true_y:
 		myoptions.autounmask = True
 



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-03-14 17:52 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-03-14 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     9bdc01a9ef0c5c6373a4a4ac5ad288dc9018372c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 14 17:52:17 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Mar 14 17:52:17 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9bdc01a9

emerge: support [ y | n ] for --quiet

This allows --quiet and --quiet-build to be enabled via
EMERGE_DEFAULT_OPTS, and then temporarily disabled via the command-
line.

---
 man/emerge.1        |    6 +++---
 pym/_emerge/help.py |    7 +++++--
 pym/_emerge/main.py |   29 ++++++++++++++++++++++++++---
 3 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 42bd398..0e3eb13 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Feb 2011" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Mar 2011" "Portage VERSION" "Portage"
 .SH "NAME"
 emerge \- Command\-line interface to the Portage system
 .SH "SYNOPSIS"
@@ -514,11 +514,11 @@ B	blocked by another package (unresolved conflict)
 b	blocked by another package (automatically resolved conflict)
 .TE
 .TP
-.BR "\-\-quiet " (\fB\-q\fR)
+.BR "\-\-quiet [ y | n ] (\-q short option)"
 Results may vary, but the general outcome is a reduced or condensed
 output from portage's displays.
 .TP
-.BR \-\-quiet\-build
+.BR "\-\-quiet\-build [ y | n ]"
 Redirect all build output to logs alone, and do not
 display it on stdout.
 .TP

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 2f8b342..020bc42 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -578,11 +578,14 @@ def help(myopts, havecolor=1):
 		print("              printed out accompanied by a '+' for enabled and a '-' for")
 		print("              disabled USE flags.")
 		print()
-		print("       "+green("--quiet")+" ("+green("-q")+" short option)")
+		print("       " + green("--quiet") + \
+			" [ %s | %s ] (%s short option)" % \
+			(turquoise("y"), turquoise("n"), green("-q")))
 		print("              Effects vary, but the general outcome is a reduced or condensed")
 		print("              output from portage's displays.")
 		print()
-		print("       "+green("--quiet-build"))
+		print("       " + green("--quiet-build") + \
+			" [ %s | %s ]" % (turquoise("y"), turquoise("n")))
 		desc = "Redirect all build output to logs alone, and do not " + \
 			"display it on stdout."
 		for line in wrap(desc, desc_width):

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index fb75ba9..f061ae4 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -65,8 +65,6 @@ options=[
 "--nodeps",       "--noreplace",
 "--nospinner",    "--oneshot",
 "--onlydeps",     "--pretend",
-"--quiet",
-"--quiet-build",
 "--quiet-unmerge-warn",
 "--resume",
 "--searchdesc",
@@ -91,7 +89,6 @@ shortmapping={
 "n":"--noreplace", "N":"--newuse",
 "o":"--onlydeps",  "O":"--nodeps",
 "p":"--pretend",   "P":"--prune",
-"q":"--quiet",
 "r":"--resume",
 "s":"--search",    "S":"--searchdesc",
 "t":"--tree",
@@ -437,6 +434,8 @@ def insert_optional_args(args):
 		'--jobs'       : valid_integers,
 		'--keep-going'           : y_or_n,
 		'--package-moves'        : y_or_n,
+		'--quiet'                : y_or_n,
+		'--quiet-build'          : y_or_n,
 		'--rebuilt-binaries'     : y_or_n,
 		'--root-deps'  : ('rdeps',),
 		'--select'               : y_or_n,
@@ -462,6 +461,7 @@ def insert_optional_args(args):
 		'G' : y_or_n,
 		'k' : y_or_n,
 		'K' : y_or_n,
+		'q' : y_or_n,
 	}
 
 	arg_stack = args[:]
@@ -697,6 +697,19 @@ def parse_opts(tmpcmdline, silent=False):
 			"choices"  : true_y_or_n
 		},
 
+		"--quiet": {
+			"shortopt" : "-q",
+			"help"     : "reduced or condensed output",
+			"type"     : "choice",
+			"choices"  : true_y_or_n
+		},
+
+		"--quiet-build": {
+			"help"     : "redirect build output to logs",
+			"type"     : "choice",
+			"choices"  : true_y_or_n
+		},
+
 		"--rebuilt-binaries": {
 			"help"     : "replace installed packages with binary " + \
 			             "packages that have been rebuilt",
@@ -869,6 +882,16 @@ def parse_opts(tmpcmdline, silent=False):
 	if myoptions.package_moves in true_y:
 		myoptions.package_moves = True
 
+	if myoptions.quiet in true_y:
+		myoptions.quiet = True
+	else:
+		myoptions.quiet = None
+
+	if myoptions.quiet_build in true_y:
+		myoptions.quiet_build = True
+	else:
+		myoptions.quiet_build = None
+
 	if myoptions.rebuilt_binaries in true_y:
 		myoptions.rebuilt_binaries = True
 



^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/
@ 2011-02-13  0:24 Zac Medico
  0 siblings, 0 replies; 38+ messages in thread
From: Zac Medico @ 2011-02-13  0:24 UTC (permalink / raw
  To: gentoo-commits

commit:     cbc252bbfe3f2650995e429005122c0539c691cf
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 13 00:22:49 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Feb 13 00:22:49 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cbc252bb

emerge.1: cross-ref --newuse and --changed-use

This will fix bug #354437.

---
 man/emerge.1        |    4 +++-
 pym/_emerge/help.py |    5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index 42b26cd..05498ff 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -445,7 +445,9 @@ A USE flag was turned on for a package.
 A USE flag was turned off for a package.
 
 USE flags may be toggled by your profile as well as your USE and package.use
-settings.
+settings. If you would like to skip rebuilds for which disabled flags have
+been added to or removed from IUSE, see the related
+\-\-reinstall=changed\-use option.
 .TP
 .BR "\-\-noconfmem"
 Causes portage to disregard merge records indicating that a config file

diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index ab8985d..6a1bae4 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -508,7 +508,10 @@ def help(myopts, havecolor=1):
 		print("       "+green("--newuse")+" ("+green("-N")+" short option)")
 		desc = "Tells emerge to include installed packages where USE " + \
 			"flags have changed since compilation. This option " + \
-			"also implies the --selective option."
+			"also implies the --selective option. If you would " + \
+			"like to skip rebuilds for which disabled flags have " + \
+			"been added to or removed from IUSE, see the related " + \
+			"--reinstall=changed-use option."
 		for line in wrap(desc, desc_width):
 			print(desc_indent + line)
 		print()



^ permalink raw reply related	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2018-02-03  3:07 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-14 18:12 [gentoo-commits] proj/portage:master commit in: man/, pym/_emerge/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2018-02-03  3:07 Zac Medico
2018-01-30  4:24 Zac Medico
2016-08-08 15:56 Zac Medico
2014-12-07 23:14 Zac Medico
2014-10-21 23:11 Zac Medico
2014-10-20  0:08 Zac Medico
2014-09-24 22:36 Brian Dolbec
2014-06-14 21:46 Alexander Berntsen
2014-06-14 21:46 Alexander Berntsen
2014-06-14 20:58 Alexander Berntsen
2013-07-18 20:25 Zac Medico
2013-07-18 20:23 Zac Medico
2013-02-23 19:17 Zac Medico
2012-12-29 22:35 Zac Medico
2012-12-08  9:25 Zac Medico
2012-11-29  7:53 Zac Medico
2012-10-08 20:30 Zac Medico
2011-12-14  4:47 Zac Medico
2011-10-16 18:58 Zac Medico
2011-10-10 18:05 Zac Medico
2011-09-21 14:00 Zac Medico
2011-09-19 16:03 Zac Medico
2011-09-19 14:15 Zac Medico
2011-09-18 20:16 Zac Medico
2011-07-19  8:38 Zac Medico
2011-06-04 23:32 Zac Medico
2011-06-03  5:40 Zac Medico
2011-05-17  4:31 Zac Medico
2011-05-15 19:20 Zac Medico
2011-05-11 19:04 Zac Medico
2011-04-28 16:16 Zac Medico
2011-04-27 22:07 Zac Medico
2011-04-27 22:03 Zac Medico
2011-04-27 22:00 Zac Medico
2011-03-24 18:18 Zac Medico
2011-03-14 17:52 Zac Medico
2011-02-13  0:24 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox