[PATCH f17-branch 1/2] Fix "memcheck=0" (and other store_true boot args)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



optparse.Option will ignore the value for options that have the action
"store_true" or "store_false". This is fine if the boolean values match,
but wrong otherwise (e.g. memcheck=yes sets memcheck=True, but so does
memcheck=0).

So: if we have a store_true option with a value that's False, skip the
normal behavior and just set the value to False.

As for store_false.. all our existing "store_false" options start with
"no", which means that negating them yields a double-negative
(e.g. nomemcheck=yes). We've decided that's just too confusing to
accept. so nomemcheck=yes should still set memcheck=False. So we don't
need to do anything special for "store_false".
---
 anaconda                        |    6 +++++-
 pyanaconda/anaconda_optparse.py |    4 ++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/anaconda b/anaconda
index 6a673b1..0a214dc 100755
--- a/anaconda
+++ b/anaconda
@@ -192,6 +192,10 @@ def parseOptions(argv=None, cmdline=None):
     op = AnacondaOptionParser(version="%prog " + getAnacondaVersion(),
                               bootarg_prefix="inst.", require_prefix=False)
 
+    # NOTE: store_false options will *not* get negated when the user does
+    # "option=0" on the boot commandline (store_true options do, though).
+    # Basically, don't use store_false unless the option starts with "no".
+
     # Interface
     op.add_option("-C", "--cmdline", dest="display_mode", action="store_const", const="c",
                   default="g")
@@ -262,7 +266,7 @@ def parseOptions(argv=None, cmdline=None):
     op.add_option("--dlabel", action="store_true", default=False)
     op.add_option("--image", action="append", dest="images", default=[])
     op.add_option("--memcheck", action="store_true", default=True)
-    op.add_option("--no-memcheck", action="store_false", dest="memcheck")
+    op.add_option("--nomemcheck", action="store_false", dest="memcheck")
 
     # some defaults change based on cmdline flags
     if cmdline is not None:
diff --git a/pyanaconda/anaconda_optparse.py b/pyanaconda/anaconda_optparse.py
index 7653716..ccb0361 100644
--- a/pyanaconda/anaconda_optparse.py
+++ b/pyanaconda/anaconda_optparse.py
@@ -107,6 +107,10 @@ class AnacondaOptionParser(OptionParser):
                 continue
             if option.takes_value() and val is None:
                 continue # TODO: emit a warning or something there?
+            if option.action == "store_true" and val in ("0", "no", "off"):
+                # special case: "mpath=0" would otherwise set mpath to True
+                setattr(values, option.dest, False)
+                continue
             option.process(arg, val, values, self)
         return values
 
-- 
1.7.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux