* Add a --autounmask[=n] option and for now leave it disable
authorZac Medico <zmedico@gentoo.org>
Thu, 5 Aug 2010 09:45:29 +0000 (02:45 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 5 Aug 2010 09:45:29 +0000 (02:45 -0700)
by default in order to minimize the impact of any bugs.
* If _wrapped_select_pkg_highest_available_imp returns an installed
package when the user has not explicitly requested for this package
to be replaced (typically via an atom on the command line), reject
the installed package and try to unmask one.

man/emerge.1
pym/_emerge/depgraph.py
pym/_emerge/help.py
pym/_emerge/main.py

index 572002d3d7fdc0877c6a10cc4244407838d02e36..73c90d3fd45594e811d0878495f630546922d0a9 100644 (file)
@@ -284,6 +284,15 @@ acceptance of the first choice. This option is
 intended to be set in the \fBmake.conf\fR(5)
 \fBEMERGE_DEFAULT_OPTS\fR variable.
 .TP
+.BR "\-\-autounmask[=n]"
+Automatically unmask packages. 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.
+.TP
 .BR \-\-backtrack=COUNT
 Specifies an integer number of times to backtrack if
 dependency calculation fails due to a conflict or an
index 056c7bdb5286fd5b989c91f85ac452119e8c72de..05c1085922b1d20148bb806c83b97b4b7bc94d6e 100644 (file)
@@ -2483,15 +2483,40 @@ class depgraph(object):
                                self._dynamic_config._visible_pkgs[pkg.root].cpv_inject(pkg)
                return ret
 
+       def _want_installed_pkg(self, pkg):
+               """
+               Given an installed package returned from select_pkg, return
+               True if the user has not explicitly requested for this package
+               to be replaced (typically via an atom on the command line).
+               """
+               if "selective" not in self._dynamic_config.myparams and \
+                       pkg.root == self._frozen_config.target_root:
+                       try:
+                               next(self._iter_atoms_for_pkg(pkg))
+                       except StopIteration:
+                               pass
+                       except portage.exception.InvalidDependString:
+                               pass
+                       else:
+                               return False
+               return True
+
        def _select_pkg_highest_available_imp(self, root, atom, onlydeps=False):
                pkg, existing = self._wrapped_select_pkg_highest_available_imp(root, atom, onlydeps=onlydeps)
 
-               if pkg is None:
-                       pkg, existing = self._wrapped_select_pkg_highest_available_imp(root, atom, \
-                               onlydeps=onlydeps, allow_missing_keywords=True)
-                       
-                       if pkg is not None and not pkg.visible:
-                               self._dynamic_config._needed_user_config_changes.setdefault(pkg, set()).add("unstable keyword")
+               if self._frozen_config.myopts.get('--autounmask', 'n') is True:
+                       if pkg is not None and \
+                               pkg.installed and \
+                               not self._want_installed_pkg(pkg):
+                               pkg = None
+                       if pkg is None:
+                               pkg, existing = \
+                                       self._wrapped_select_pkg_highest_available_imp(
+                                               root, atom, onlydeps=onlydeps,
+                                               allow_missing_keywords=True)
+
+                               if pkg is not None and not pkg.visible:
+                                       self._dynamic_config._needed_user_config_changes.setdefault(pkg, set()).add("unstable keyword")
 
                return pkg, existing
 
index 43e9794eddbbba1fdcbbf323323ddec6298ff22b..72bb56d4138a0ef355aa699f6c67f4bbd7a6b768 100644 (file)
@@ -291,6 +291,17 @@ def help(myopts, havecolor=1):
                        "EMERGE_DEFAULT_OPTS variable."
                for line in wrap(desc, desc_width):
                        print(desc_indent + line)
+               print() 
+               print("       " + green("--autounmask") + "[=%s]" % turquoise("n"))
+               desc = "Automatically unmask packages. 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."
+               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 " + \
index b2bb362f8f94abdd0f6bcc37c6ed45d5b96f6874..92df3bfb402c0c839ed1353f6f73e0cda601540d 100644 (file)
@@ -388,6 +388,7 @@ def insert_optional_args(args):
        new_args = []
 
        default_arg_opts = {
+               '--autounmask'           : ('n',),
                '--complete-graph' : ('n',),
                '--deep'       : valid_integers,
                '--depclean-lib-check'   : ('n',),
@@ -515,6 +516,13 @@ def parse_opts(tmpcmdline, silent=False):
 
        longopt_aliases = {"--cols":"--columns", "--skip-first":"--skipfirst"}
        argument_options = {
+
+               "--autounmask": {
+                       "help"    : "automatically unmask packages",
+                       "type"    : "choice",
+                       "choices" : ("True", "n")
+               },
+
                "--accept-properties": {
                        "help":"temporarily override ACCEPT_PROPERTIES",
                        "action":"store"
@@ -735,6 +743,9 @@ def parse_opts(tmpcmdline, silent=False):
 
        myoptions, myargs = parser.parse_args(args=tmpcmdline)
 
+       if myoptions.autounmask in ("True",):
+               myoptions.autounmask = True
+
        if myoptions.changed_use is not False:
                myoptions.reinstall = "changed-use"
                myoptions.changed_use = False