autounmask: Add --autounmask-keep-masks option
authorSebastian Luther <SebastianLuther@gmx.de>
Mon, 19 Sep 2011 14:32:08 +0000 (07:32 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 19 Sep 2011 14:32:08 +0000 (07:32 -0700)
Disables creation of p.unmask entries to allow users
to insist on their masks and hope for another conflict
resolution (i.e. missed update). This fixes bug 372485.

man/emerge.1
pym/_emerge/depgraph.py
pym/_emerge/help.py
pym/_emerge/main.py
pym/portage/tests/resolver/test_autounmask.py

index d6d74e01d9d21a5b4e6b83d7b04da4d1fef79d2f..cf7b0e2da13ef65d0a9ff1dc7107b52cfbf37529 100644 (file)
@@ -309,6 +309,11 @@ If \-\-autounmask is enabled, changes using the \'=\' operator
 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
+will be created. This leads to unsatisfied dependencies if
+no other solution exists.
+.TP
 .BR "\-\-autounmask\-write [ y | n ]"
 If \-\-autounmask is enabled, changes are written
 to config files, respecting \fBCONFIG_PROTECT\fR and \fB\-\-ask\fR.
index a5015b8e68620417805539d457f4432f736d00d3..52d4545550524d7aa342cc03b4299ad582b31489 100644 (file)
@@ -3411,6 +3411,8 @@ class depgraph(object):
 
                default_selection = (pkg, existing)
 
+               autounmask_keep_masks = self._frozen_config.myopts.get("--autounmask-keep-masks", "n") != "n"
+
                if self._dynamic_config._autounmask is True:
                        if pkg is not None and \
                                pkg.installed and \
@@ -3422,7 +3424,7 @@ class depgraph(object):
                                        break
 
                                for allow_unmasks in (False, True):
-                                       if only_use_changes and allow_unmasks:
+                                       if allow_unmasks and (only_use_changes or autounmask_keep_masks):
                                                continue
 
                                        if pkg is not None:
index f5ff7a367e34140881e6f229c9baf55a26765c03..4334bcbdb13f0ba30a6bc24681c2ac276d1574e8 100644 (file)
@@ -331,6 +331,14 @@ def help(myopts, havecolor=1):
                for line in wrap(desc, desc_width):
                        print(desc_indent + line)
                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 " + \
+                       "dependencies if no other solution exists."
+               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 " + \
index 73d07953e00bb44a312f47d22ede6b6dec83e5ea..3f47af78906507882d2c62e0fa29348036087ca5 100644 (file)
@@ -431,6 +431,7 @@ def insert_optional_args(args):
        default_arg_opts = {
                '--ask'                  : y_or_n,
                '--autounmask'           : y_or_n,
+               '--autounmask-keep-masks': y_or_n,
                '--autounmask-unrestricted-atoms' : y_or_n,
                '--autounmask-write'     : y_or_n,
                '--buildpkg'             : y_or_n,
@@ -610,6 +611,12 @@ def parse_opts(tmpcmdline, silent=False):
                        "choices" : true_y_or_n
                },
 
+               "--autounmask-keep-masks": {
+                       "help"    : "don't add package.unmask entries",
+                       "type"    : "choice",
+                       "choices" : true_y_or_n
+               },
+
                "--autounmask-write": {
                        "help"    : "write changes made by --autounmask to disk",
                        "type"    : "choice",
@@ -936,6 +943,9 @@ def parse_opts(tmpcmdline, silent=False):
        if myoptions.autounmask_unrestricted_atoms in true_y:
                myoptions.autounmask_unrestricted_atoms = True
 
+       if myoptions.autounmask_keep_masks in true_y:
+               myoptions.autounmask_keep_masks = True
+
        if myoptions.autounmask_write in true_y:
                myoptions.autounmask_write = True
 
index ff13789dc31585e628038427a0a284c413884b5c..3da1c25105df32073a16816a4a9de43e38969d6e 100644 (file)
@@ -388,3 +388,42 @@ class AutounmaskTestCase(TestCase):
                                self.assertEqual(test_case.test_success, True, test_case.fail_msg)
                finally:
                        playground.cleanup()
+
+
+       def testAutounmaskKeepMasks(self):
+
+               ebuilds = {
+                       "app-text/A-1": {},
+                       }
+
+               test_cases = (
+                               #Test mask and keyword changes.
+                               ResolverPlaygroundTestCase(
+                                       ["app-text/A"],
+                                       options = {"--autounmask": True,
+                                                               "--autounmask-keep-masks": "y"},
+                                       success = False),
+                               ResolverPlaygroundTestCase(
+                                       ["app-text/A"],
+                                       options = {"--autounmask": True,
+                                                               "--autounmask-keep-masks": "n"},
+                                       success = False,
+                                       mergelist = ["app-text/A-1"],
+                                       needed_p_mask_changes = ["app-text/A-1"]),
+                       )
+
+               profile = {
+                       "package.mask":
+                               (
+                                       "app-text/A",
+                               ),
+               }
+
+               playground = ResolverPlayground(ebuilds=ebuilds, profile=profile)
+
+               try:
+                       for test_case in test_cases:
+                               playground.run_TestCase(test_case)
+                               self.assertEqual(test_case.test_success, True, test_case.fail_msg)
+               finally:
+                       playground.cleanup()