diff options
author | Chris Lumens <clumens@redhat.com> | 2006-03-22 19:43:03 +0000 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2006-03-22 19:43:03 +0000 |
commit | 205ad15b10bfdccfad61621ba3b4b7fef392c40f (patch) | |
tree | b0089a49f0f2b34d494f2b28ee43579a1406c959 | |
parent | dc78bd8e55b9b59a40b023bbbb43393f38582288 (diff) | |
download | anaconda-205ad15b10bfdccfad61621ba3b4b7fef392c40f.tar.gz anaconda-205ad15b10bfdccfad61621ba3b4b7fef392c40f.tar.xz anaconda-205ad15b10bfdccfad61621ba3b4b7fef392c40f.zip |
Create a dictionary in flags.py for storing /proc/cmdline. Nuke all
references to /proc/cmdline from everywhere else in favor of this dict.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | constants.py | 6 | ||||
-rw-r--r-- | flags.py | 37 | ||||
-rw-r--r-- | fsset.py | 38 | ||||
-rwxr-xr-x | gui.py | 11 | ||||
-rw-r--r-- | installclass.py | 6 | ||||
-rw-r--r-- | instdata.py | 11 | ||||
-rw-r--r-- | iutil.py | 9 | ||||
-rw-r--r-- | network.py | 8 | ||||
-rw-r--r-- | partedUtils.py | 17 | ||||
-rw-r--r-- | text.py | 6 | ||||
-rw-r--r-- | yuminstall.py | 3 |
12 files changed, 68 insertions, 90 deletions
@@ -28,6 +28,12 @@ * isys/isys.c, isys/isys.py, isys/smp.c, isys.smp.h: Remove summitavailable support. + * constants.py: Removed DEBUG since we can use cmdline for that. + * flags.py: Add a dictionary representing /proc/cmdline. + * fsset.py, gui.py, installclass.py, instdata.py, iutil.py, + network.py, partedUtils.py, text.py, yuminstall.py: Use flags instead + of opening /proc/cmdline yet again. + 2006-03-21 Jeremy Katz <katzj@redhat.com> * anaconda.spec: Bump version. diff --git a/constants.py b/constants.py index d4c1f4673..c9bc109b5 100644 --- a/constants.py +++ b/constants.py @@ -17,14 +17,8 @@ from rhpl.translate import _, N_ BETANAG = 1 -DEBUG = 0 - SELINUX_DEFAULT = 1 -cmdline = open("/proc/cmdline", "r").read() -if cmdline.find("debug") != -1: - DEBUG = 1 - DISPATCH_BACK = -1 DISPATCH_FORWARD = 1 DISPATCH_NOOP = None @@ -12,6 +12,7 @@ # import os +import shlex from constants import * # A lot of effort, but it only allows a limited set of flags to be referenced @@ -28,6 +29,22 @@ class Flags: self.__dict__['flags'][attr] = val else: raise AttributeError, attr + + def createCmdlineDict(self): + cmdlineDict = {} + cmdline = open("/proc/cmdline", "r").read() + lst = shlex.split(cmdline) + + for i in lst: + try: + (key, val) = i.split("=", 1) + except: + key = i + val = True + + cmdlineDict[key] = val + + return cmdlineDict def __init__(self): self.__dict__['flags'] = {} @@ -42,26 +59,22 @@ class Flags: self.__dict__['flags']['usevnc'] = 0 self.__dict__['flags']['dmraid'] = 1 self.__dict__['flags']['selinux'] = SELINUX_DEFAULT + self.__dict__['flags']['debug'] = 0 + self.__dict__['flags']['cmdline'] = self.createCmdlineDict() # for non-physical consoles like some ppc and sgi altix, # we need to preserve the console device and not try to # do things like bogl on them. this preserves what that # device is self.__dict__['flags']['virtpconsole'] = None - - # determine if selinux is enabled or not - f = open("/proc/cmdline", "r") - line = f.readline() - f.close() - - tokens = line.split() - for tok in tokens: - if tok == "selinux": + if self.__dict__['flags']['cmdline'].has_key("selinux"): + if self.__dict__['flags']['cmdline']["selinux"]: self.__dict__['flags']['selinux'] = 1 - elif tok == "selinux=0": + else: self.__dict__['flags']['selinux'] = 0 - elif tok == "selinux=1": - self.__dict__['flags']['selinux'] = 1 + + if self.__dict__['flags']['cmdline'].has_key("debug"): + self.__dict__['flags']['debug'] = self.__dict__['flags']['cmdline']['debug'] if not os.path.exists("/selinux/load"): self.__dict__['flags']['selinux'] = 0 @@ -28,6 +28,7 @@ import partedUtils import raid import lvm import types +from flags import flags from rhpl.translate import _, N_ @@ -391,16 +392,11 @@ class reiserfsFileSystem(FileSystemType): # at the boot: prompt will let you make new reiserfs filesystems # in the installer. Bugs filed when you use this will be closed # WONTFIX. - try: - f = open("/proc/cmdline") - line = f.readline() - if string.find(line, " reiserfs") != -1: - self.supported = -1 - else: - self.supported = 0 - del f - except: + if flags.cmdline.has_key("resierfs"): + self.supported = -1 + else: self.supported = 0 + self.name = "reiserfs" self.packages = [ "reiserfs-utils" ] @@ -451,15 +447,9 @@ class xfsFileSystem(FileSystemType): # at the boot: prompt will let you make new xfs filesystems # in the installer. Bugs filed when you use this will be closed # WONTFIX. - try: - f = open("/proc/cmdline") - line = f.readline() - if string.find(line, " xfs") != -1: - self.supported = -1 - else: - self.supported = 0 - del f - except: + if flags.cmdline.has_key("xfs"): + self.supported = -1 + else: self.supported = 0 self.packages = [ "xfsprogs" ] @@ -509,15 +499,9 @@ class jfsFileSystem(FileSystemType): # at the boot: prompt will let you make new reiserfs filesystems # in the installer. Bugs filed when you use this will be closed # WONTFIX. - try: - f = open("/proc/cmdline") - line = f.readline() - if string.find(line, " jfs") != -1: - self.supported = -1 - else: - self.supported = 0 - del f - except: + if flags.cmdline.has_key("jfs"): + self.supported = -1 + else: self.supported = 0 if not os.access("/usr/sbin/mkfs.jfs", os.X_OK): @@ -15,12 +15,12 @@ # import os +from flags import flags os.environ["PYGTK_DISABLE_THREADS"] = "1" os.environ["GNOME_DISABLE_CRASH_DIALOG"] = "1" # we only want to enable the accessibility stuff if requested for now... -buf = open("/proc/cmdline").read() -if buf.find("dogtail") != -1: +if flags.cmdline.has_key("dogtail"): os.environ["GTK_MODULES"] = "gail:atk-bridge" import errno @@ -38,7 +38,6 @@ import kudzu import gettext import warnings from language import expandLangs -from flags import flags from constants import * from network import hasActiveNetDev import floppy @@ -600,13 +599,13 @@ class ExceptionWindow: textbuf.set_text(shortTraceback) # Remove the floppy button if we don't need it. - if not floppy.hasFloppyDevice() and not DEBUG: + if not floppy.hasFloppyDevice() and not flags.debug: buttonBox = exnxml.get_widget("buttonBox") floppyButton = exnxml.get_widget("floppyButton") buttonBox.remove(floppyButton) # Remove the remote button if there's no network. - if not hasActiveNetDev() and not DEBUG: + if not hasActiveNetDev() and not flags.debug: buttonBox = exnxml.get_widget("buttonBox") remoteButton = exnxml.get_widget("remoteButton") buttonBox.remove(remoteButton) @@ -1385,7 +1384,7 @@ class InstallControlWindow: if p is None: print _("Unable to load title bar") - if DEBUG: + if flags.debug: self.mainxml.get_widget("debugButton").show_now() self.installFrame = self.mainxml.get_widget("installFrame") diff --git a/installclass.py b/installclass.py index 2ebc76d3c..1399470d8 100644 --- a/installclass.py +++ b/installclass.py @@ -174,13 +174,11 @@ class BaseInstallClass: # 'noupgrade' can be used on the command line to force not looking # for partitions to upgrade. useful in some cases... - cmdline = open("/proc/cmdline", "r").read() - cmdline = cmdline.split() - if "noupgrade" in cmdline: + if flags.cmdline.has_key("noupgrade"): dispatch.skipStep("findrootparts", skip = 1) # upgrade will also always force looking for an upgrade. - if "upgrade" in cmdline: + if flags.cmdline.has_key("upgrade"): dispatch.skipStep("findrootparts", skip = 0) # Ask for iscsi configuration only when specifically requested diff --git a/instdata.py b/instdata.py index 72a1f01ba..33aad350a 100644 --- a/instdata.py +++ b/instdata.py @@ -234,14 +234,9 @@ class InstallData: self.floppyDevice = floppyDevice self.fsset = fsset.FileSystemSet() self.excludeDocs = 0 - try: - f = open("/proc/cmdline") - line = f.readline() - if line.find(" excludedocs") != -1: - self.excludeDocs = 1 - close(f) - except: - pass + + if flags.cmdline.has_key("excludedocs"): + self.excludeDocs = 1 self.methodstr = methodstr self.reset() @@ -470,13 +470,8 @@ def writeRpmPlatform(root="/"): myarch = rhpl.arch.canonArch # now allow an override with rpmarch=i586 on the command line (#101971) - f = open("/proc/cmdline", "r") - buf = f.read() - f.close() - args = buf.split() - for arg in args: - if arg.startswith("rpmarch="): - myarch = arg[8:] + if flags.cmdline.has_key("rpmarch"): + myarch = flags.cmdline["rpmarch"] # now make the current install believe it, too rhpl.arch.canonArch = myarch diff --git a/network.py b/network.py index 23abe270e..2c5e22ca0 100644 --- a/network.py +++ b/network.py @@ -23,6 +23,7 @@ import socket import os import re import kudzu +from flags import flags from rhpl.translate import _, N_ from rhpl.simpleconfig import SimpleConfigFile @@ -262,11 +263,8 @@ class Network: def available(self): ksdevice = None - cmdline = open("/proc/cmdline").read() - if cmdline.find("ksdevice=") != -1: - ksdevice = \ - cmdline[cmdline.index("ksdevice="):].split(" ")[0] - ksdevice = ksdevice.split("=")[1].strip() + if flags.cmdline.has_key("ksdevice"): + ksdevice = flags.cmdline["ksdevice"] f = open("/proc/net/dev") lines = f.readlines() diff --git a/partedUtils.py b/partedUtils.py index b8539930a..a8be5ea88 100644 --- a/partedUtils.py +++ b/partedUtils.py @@ -646,6 +646,9 @@ class DiskSet: self.startAllRaid() + if flags.cmdline.has_key("upgradeany"): + upgradeany = 1 + for dev, devices, level, numActive in self.mdList: (errno, msg) = (None, None) found = 0 @@ -660,10 +663,8 @@ class DiskSet: if found: if os.access (mountpoint + '/etc/fstab', os.R_OK): relstr = getReleaseString(mountpoint) - cmdline = open('/proc/cmdline', 'r').read() - - if ((cmdline.find("upgradeany") != -1) or - (upgradeany == 1) or + + if ((upgradeany == 1) or (productMatches(relstr, productName))): rootparts.append ((dev, fs, relstr)) isys.umount(mountpoint) @@ -688,10 +689,8 @@ class DiskSet: if found: if os.access (mountpoint + '/etc/fstab', os.R_OK): relstr = getReleaseString(mountpoint) - cmdline = open('/proc/cmdline', 'r').read() - if ((cmdline.find("upgradeany") != -1) or - (upgradeany == 1) or + if ((upgradeany == 1) or (productMatches(relstr, productName))): rootparts.append ((dev, fs, relstr)) isys.umount(mountpoint) @@ -725,10 +724,8 @@ class DiskSet: continue if os.access (mountpoint + '/etc/fstab', os.R_OK): relstr = getReleaseString(mountpoint) - cmdline = open('/proc/cmdline', 'r').read() - if ((cmdline.find("upgradeany") != -1) or - (upgradeany == 1) or + if ((upgradeany == 1) or (productMatches(relstr, productName))): rootparts.append ((node, part.fs_type.name, relstr)) @@ -146,10 +146,10 @@ class ExceptionWindow: self.buttons=[TEXT_OK_BUTTON] - if floppy.hasFloppyDevice() == True or DEBUG: + if floppy.hasFloppyDevice() == True or flags.debug: self.buttons.append(_("Save")) - if hasActiveNetDev() or DEBUG: + if hasActiveNetDev() or flags.debug: self.buttons.append(_("Remote")) self.buttons.append(_("Debug")) @@ -463,7 +463,7 @@ class InstallInterface: self.screen.suspendCallback(spawnShell, self.screen) # drop into the python debugger on ctrl-z if we're running in test mode - if DEBUG or flags.test: + if flags.debug or flags.test: self.screen.suspendCallback(debugSelf, self.screen) # clear out the old root text by writing spaces in the blank diff --git a/yuminstall.py b/yuminstall.py index 054151f4c..b3a83a86e 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -722,8 +722,7 @@ class YumBackend(AnacondaBackend): log.debug("selecting kernel-xenU-devel") self.selectPackage("kernel-xenU-devel.%s" % (kxen.arch,)) - if not foundkernel and \ - (open("/proc/cmdline").read().find("xen0") != -1): + if not foundkernel and flags.cmdline.has_key("xen0"): try: kxen = getBestKernelByArch("kernel-xen0", self.ayum) log.info("selecting kernel-xen0 package for kernel") |