]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
I shrinked the installer a little bit.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Dec 2008 21:00:17 +0000 (22:00 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Dec 2008 21:00:17 +0000 (22:00 +0100)
InstallClass was banished.
Though, I extended the Pomona Class and InstData.

src/pomona/autopart.py
src/pomona/backend.py
src/pomona/dispatch.py
src/pomona/installclass.py [deleted file]
src/pomona/installer.py
src/pomona/instdata.py
src/pomona/keyboard.py
src/pomona/language.py
src/pomona/network.py
src/pomona/packages.py

index 4cd6609ad7f17a18e1ba55e04329d399d646ea93..ee14a31269ca1a27674fdd64255cd8647484f678 100644 (file)
@@ -895,7 +895,6 @@ def doClearPartAction(pomona, partitions, diskset):
             continue
 
 def doAutoPartition(pomona):
-    instClass = pomona.id.instClass
     diskset = pomona.id.diskset
     partitions = pomona.id.partitions
 
index 3c89fb4595a3b062663c0081150e65cf267da3aa..7afe5424f4a3afc9f9c0f3bd7bdf0ec81b332109 100644 (file)
@@ -116,11 +116,6 @@ def doPostInstall(pomona):
 def doInstall(pomona):
     pomona.backend.doInstall(pomona)
 
-# does this need to be per-backend?  we'll just leave here until it does :)
-def doBasePackageSelect(pomona):
-    pomona.id.instClass.setPackageSelection(pomona)
-    pomona.id.instClass.setGroupSelection(pomona)
-
 def writeConfiguration(pomona):
     log.info("Writing main configuration")
     pomona.id.write(pomona)
index e2d8f6e3137cb4769b437c7c31567623c9c26523..c231719836d7dec717a2aca4de588d4ab583e6a3 100644 (file)
@@ -27,7 +27,7 @@ from packages import copyPomonaLogs
 
 from flags import flags
 
-#from backend import doPostSelection, doRepoSetup, doBasePackageSelect
+#from backend import doPostSelection, doRepoSetup
 from backend import doPreInstall, doPostInstall, doInstall
 from backend import writeConfiguration
 
@@ -61,7 +61,6 @@ installSteps = [
                 ("timezone", ),
                 ("accounts", ),
                 #("reposetup", doRepoSetup, ),
-                #("basepkgsel", doBasePackageSelect, ),
                 #("tasksel", ),
                 #("group-selection", ),
                 #("postselection", doPostSelection, ),
diff --git a/src/pomona/installclass.py b/src/pomona/installclass.py
deleted file mode 100644 (file)
index 6087612..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-# this is the prototypical class for workstation, server, and kickstart
-# installs
-#
-# The interface to BaseInstallClass is *public* -- ISVs/OEMs can customize the
-# install by creating a new derived type of this class.
-#
-# Copyright 1999-2006 Red Hat, Inc.
-#
-# This software may be freely redistributed under the terms of the GNU
-# library public license.
-#
-# You should have received a copy of the GNU Library Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-import os, sys, inutil
-import string
-import language
-import imputil
-
-from instdata import InstallData
-from partitioning import *
-from autopart import getAutopartitionBoot, autoCreatePartitionRequests
-#import pakfireinstall
-
-from pyfire.translate import _, N_
-
-import logging
-log = logging.getLogger("pomona")
-
-from flags import flags
-from constants import *
-
-class BaseInstallClass:
-    # default to not being hidden
-    hidden = 0
-    pixmap = None
-    showMinimal = 1
-    showLoginChoice = 0
-    _description = ""
-    _descriptionFields = ()
-    regkeydesc = None
-    name = "base"
-    pkgstext = ""
-    # default to showing the upgrade option
-    showUpgrade = True
-
-    # list of of (txt, grplist) tuples for task selection screen
-    tasks = []
-
-    # dict of repoid: (baseurl, mirrorurl) tuples for additional repos
-    repos = {}
-
-    # don't select this class by default
-    default = 0
-
-    # don't force text mode
-    forceTextMode = 0
-
-    # allow additional software repositories beyond the base to be configured
-    allowExtraRepos = True
-
-    # by default, place this under the "install" category; it gets it's
-    # own toplevel category otherwise
-    parentClass = ( _("Install on System"), "install.png" )
-
-    # we can use a different install data class
-    installDataClass = InstallData
-
-    # install key related bits
-    skipkeytext = None
-    instkeyname = None
-    allowinstkeyskip = True
-    instkeydesc = None
-    installkey = None
-    skipkey = False
-
-    def setBootloader(self, id, location=None, forceLBA=0, password=None,
-                      md5pass=None, appendLine="", driveorder = []):
-        if appendLine:
-            id.bootloader.args.set(appendLine)
-            id.bootloader.setForceLBA(forceLBA)
-        if password:
-            id.bootloader.setPassword(password, isCrypted = 0)
-        if md5pass:
-            id.bootloader.setPassword(md5pass)
-        if location != None:
-            id.bootloader.defaultDevice = location
-        else:
-            id.bootloader.defaultDevice = -1
-
-        # XXX throw out drives specified that don't exist.  anything else
-        # seems silly
-        if driveorder and len(driveorder) > 0:
-            new = []
-            for drive in driveorder:
-                if drive in id.bootloader.drivelist:
-                    new.append(drive)
-                else:
-                    log.warning("requested drive %s in boot drive order "
-                                "doesn't exist" %(drive,))
-            id.bootloader.drivelist = new
-
-    def setIgnoredDisks(self, id, drives):
-        diskset = id.diskset
-        for drive in drives:
-            if not drive in diskset.skippedDisks:
-                diskset.skippedDisks.append(drive)
-
-    def setClearParts(self, id, clear, drives = None, initAll = False):
-        id.partitions.autoClearPartType = clear
-        id.partitions.autoClearPartDrives = drives
-        if initAll:
-            id.partitions.reinitializeDisks = initAll
-
-    def setSteps(self, pomona):
-        dispatch = pomona.dispatch
-        dispatch.setStepList(
-            "language",
-            "keyboard",
-            "welcome",
-            "findrootparts",
-            "betanag",
-            "installtype",
-            "partitionobjinit",
-            "parttype",
-            "autopartitionexecute",
-            "partition",
-            "partitiondone",
-            "bootloadersetup",
-            "bootloader",
-            "networkdevicecheck",
-            "network",
-            "timezone",
-            "accounts",
-            "reposetup",
-            "basepkgsel",
-            "tasksel",
-            "postselection",
-            "confirminstall",
-            "install",
-            "enablefilesystems",
-            "migratefilesystems",
-            "setuptime",
-            "preinstallconfig",
-            "installpackages",
-            "postinstallconfig",
-            "writeconfig",
-            "firstboot",
-            "instbootloader",
-            "dopostaction",
-            "postscripts",
-            "writexconfig",
-            "writeksconfig",
-            "writeregkey",
-            "methodcomplete",
-            "copylogs",
-            "setfilecon",
-            "complete"
-        )
-
-    def setZeroMbr(self, id, zeroMbr):
-        id.partitions.zeroMbr = zeroMbr
-
-    def setKeyboard(self, id, kb):
-        id.keyboard.set(kb)
-
-    def setTimezoneInfo(self, id, timezone, asUtc = 0, asArc = 0):
-        id.timezone.setTimezoneInfo(timezone, asUtc, asArc)
-
-    def setLanguageDefault(self, id, default):
-        id.instLanguage.setDefault(default)
-
-    def setLanguage(self, id, nick):
-        id.instLanguage.setRuntimeLanguage(nick)
-
-    def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_ALL,
-                               doClear = 1):
-        autorequests = [ ("/", None, 1024, None, 1, 1, 1) ]
-
-        bootreq = getAutopartitionBoot()
-        if bootreq:
-            autorequests.extend(bootreq)
-
-        (minswap, maxswap) = inutil.swapSuggestion()
-        autorequests.append((None, "swap", minswap, maxswap, 1, 1, 1))
-
-        if doClear:
-            partitions.autoClearPartType = clear
-            partitions.autoClearPartDrives = []
-
-        partitions.autoPartitionRequests = autoCreatePartitionRequests(autorequests)
-
-    def setInstallData(self, pomona):
-        pomona.id.reset(pomona)
-        pomona.id.instClass = self
-
-    def getMethod(self, methodstr):
-        if methodstr.startswith('cdrom://'):
-            from image import CdromInstallMethod
-            return CdromInstallMethod
-        elif methodstr.startswith('ftp://') or methodstr.startswith('http://'):
-            from urlinstall import UrlInstallMethod
-            return UrlInstallMethod
-        ### XXX Currently out of order :)
-        #elif methodstr.startswith('hd://'):
-        #       from harddrive import HardDriveInstallMethod
-        #       return HardDriveInstallMethod
-        else:
-            return None
-
-    def getBackend(self):
-        #return pakfireinstall.PakfireBackend
-        return None ### XXX
-
-    # Classes should call these on __init__ to set up install data
-    #id.setKeyboard()
-    #id.setLanguage()
-    #id.setLanguageDefault()
-    #id.setTimezone()
-
-    def __init__(self, expert):
-        pass
-
-    def postAction(self, pomona):
-        pomona.backend.postAction(pomona)
-
-# we need to be able to differentiate between this and custom
-class DefaultInstall(BaseInstallClass):
-    def __init__(self, expert):
-        BaseInstallClass.__init__(self, expert)
-
-# custom installs are easy :-)
-class InstallClass(BaseInstallClass):
-    # name has underscore used for mnemonics, strip if you dont need it
-    id = "ipfire"
-    name = N_("IPFire")
-
-    def setInstallData(self, pomona):
-        BaseInstallClass.setInstallData(self, pomona)
-        BaseInstallClass.setDefaultPartitioning(self, pomona.id.partitions,
-                                                CLEARPART_TYPE_ALL)
-
-    def setSteps(self, pomona):
-        dispatch = pomona.dispatch
-        BaseInstallClass.setSteps(self, dispatch)
-        dispatch.skipStep("partition")
-
-    def __init__(self, expert):
-        BaseInstallClass.__init__(self, expert)
index 7ffa39329640f078c5e39b290c71901f7c3ca644..de44c32258be660b6e0748f453c308ba9d544a24 100644 (file)
 #                                                                             #
 ###############################################################################
 
-import sys, os, re
-import users
+import os
+import sys
+import re
+import signal
+import warnings
 from optparse import OptionParser
-import inutil, isys, dispatch
+
+import isys
+import users
+import inutil
+import dispatch
 from flags import flags
 from constants import *
-import signal
+
+from tui import InstallInterface
+from pakfireinstall import PakfireBackend
+from instdata import InstallData
+from autopart import getAutopartitionBoot, autoCreatePartitionRequests
 
 # Make sure messages sent through python's warnings module get logged.
 def PomonaShowWarning(message, category, filename, lineno, file=sys.stderr):
     log.warning("%s" % warnings.formatwarning(message, category, filename, lineno))
 
-def setupEnvironment():
-    if not os.environ.has_key("LANG"):
-        os.environ["LANG"] = "en_US.UTF-8"
-    os.environ['HOME'] = '/tmp'
-    os.environ['LC_NUMERIC'] = 'C'
-
-    signal.signal(signal.SIGINT, signal.SIG_DFL)
-    signal.signal(signal.SIGSEGV, isys.handleSegv)
-
-def getInstClass():
-    from installclass import DefaultInstall
-    return DefaultInstall(flags.expert)
+warnings.showwarning = PomonaShowWarning
 
 def parseOptions():
 
@@ -77,12 +77,6 @@ def setupLoggingFromOpts(opts):
         else:
             logger.addSysLogHandler(log, opts.syslog)
 
-def expandFTPMethod(opts):
-    filename = opts.method[1:]
-    opts.method = open(filename, "r").readline()
-    opts.method = opts.method[:len(opts.method) - 1]
-    os.unlink(filename)
-
 def checkMemory():
     if inutil.memInstalled() < isys.MIN_RAM:
         from snack import SnackScreen, ButtonChoiceWindow
@@ -102,20 +96,45 @@ class Pomona:
         self.intf = None
         self.id = None
         self.rootPath = HARDDISK_PATH
-        self.backend = None
-
-    def setDispatch(self):
         self.dispatch = dispatch.Dispatcher(self)
 
-    def setBackend(self):
-        from pakfireinstall import PakfireBackend
         self.backend = PakfireBackend(self.rootPath)
 
+    def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_ALL, doClear = 1):
+        autorequests = [ ("/", None, 1024, None, 1, 1, 1) ]
+
+        bootreq = getAutopartitionBoot()
+        if bootreq:
+            autorequests.extend(bootreq)
+
+        (minswap, maxswap) = inutil.swapSuggestion()
+        autorequests.append((None, "swap", minswap, maxswap, 1, 1, 1))
+
+        if doClear:
+            partitions.autoClearPartType = clear
+            partitions.autoClearPartDrives = []
+
+        partitions.autoPartitionRequests = autoCreatePartitionRequests(autorequests)
+
+    def setZeroMbr(self, zeroMbr):
+        self.id.partitions.zeroMbr = zeroMbr
+
+    def setKeyboard(self, kb):
+        self.id.keyboard.set(kb)
+
+    def setTimezoneInfo(self, timezone, asUtc = 0, asArc = 0):
+        self.id.timezone.setTimezoneInfo(timezone, asUtc, asArc)
+
+    def setLanguageDefault(self, default):
+        self.id.instLanguage.setDefault(default)
+
+    def setLanguage(self, nick):
+        self.id.instLanguage.setRuntimeLanguage(nick)
+
 if __name__ == "__main__":
     pomona = Pomona()
 
-    ### Set up logging
-    #
+    # Set up logging
     import logging
     from pomona_log import logger, logLevelMap
 
@@ -126,17 +145,20 @@ if __name__ == "__main__":
 
     log.info("pomona called with cmdline = %s" %(sys.argv,))
 
-    ### Set up environment
-    #
-    setupEnvironment()
+    # Set up environment
+    if not os.environ.has_key("LANG"):
+        os.environ["LANG"] = "en_US.UTF-8"
+    os.environ['HOME'] = '/tmp'
+    os.environ['LC_NUMERIC'] = 'C'
 
-    ### Set up i18n
-    #
+    signal.signal(signal.SIGINT, signal.SIG_DFL)
+    signal.signal(signal.SIGSEGV, isys.handleSegv)
+
+    # Set up i18n
     from pyfire.translate import _, textdomain
     textdomain("pomona")
 
-    ### Reading command line options
-    #
+    # Reading command line options
     (opts, args) = parseOptions()
 
     setupLoggingFromOpts(opts)
@@ -154,36 +176,112 @@ if __name__ == "__main__":
 
     log.info (_("Starting text installation..."))
 
-    instClass = getInstClass()
-
     checkMemory()
 
-    from tui import InstallInterface
     pomona.intf = InstallInterface()
 
-    import warnings, signal
-    warnings.showwarning = PomonaShowWarning
+    pomona.id = InstallData(pomona)
+    pomona.id.reset(pomona)
+    pomona.setDefaultPartitioning(pomona.id.partitions, CLEARPART_TYPE_ALL)
+
+    if flags.expert:
+        pomona.dispatch.setStepList(
+            "language",
+            "keyboard",
+            "welcome",
+            "betanag",
+            "installtype",
+            "partitionobjinit",
+            "parttype",
+            "autopartitionexecute",
+            "partition",
+            "partitiondone",
+            "bootloadersetup",
+            "bootloader",
+            "networkdevicecheck",
+            "network",
+            "timezone",
+            "accounts",
+            "reposetup",
+            "basepkgsel",
+            "tasksel",
+            "postselection",
+            "confirminstall",
+            "install",
+            "enablefilesystems",
+            "migratefilesystems",
+            "setuptime",
+            "preinstallconfig",
+            "installpackages",
+            "postinstallconfig",
+            "writeconfig",
+            "firstboot",
+            "instbootloader",
+            "dopostaction",
+            "postscripts",
+            "writexconfig",
+            "writeksconfig",
+            "writeregkey",
+            "methodcomplete",
+            "copylogs",
+            "setfilecon",
+            "complete"
+        )
+    else:
+        pomona.dispatch.setStepList(
+            "language",
+            "keyboard",
+            "welcome",
+            "betanag",
+            "installtype",
+            "partitionobjinit",
+            "parttype",
+            "autopartitionexecute",
+            "partition",
+            "partitiondone",
+            "bootloadersetup",
+            "bootloader",
+            "networkdevicecheck",
+            "network",
+            "timezone",
+            "accounts",
+            "reposetup",
+            "basepkgsel",
+            "tasksel",
+            "postselection",
+            "confirminstall",
+            "install",
+            "enablefilesystems",
+            "migratefilesystems",
+            "setuptime",
+            "preinstallconfig",
+            "installpackages",
+            "postinstallconfig",
+            "writeconfig",
+            "firstboot",
+            "instbootloader",
+            "dopostaction",
+            "postscripts",
+            "writexconfig",
+            "writeksconfig",
+            "writeregkey",
+            "methodcomplete",
+            "copylogs",
+            "setfilecon",
+            "complete"
+        )
 
-    # reset python's default SIGINT handler
-    signal.signal(signal.SIGINT, signal.SIG_DFL)
-
-    pomona.setBackend()
-
-    pomona.id = instClass.installDataClass(pomona)
-    instClass.setInstallData(pomona)
     users.createLuserConf(pomona.rootPath)
 
-    pomona.setDispatch()
-
-    #if opts.lang:
-    #       anaconda.dispatch.skipStep("language", permanent = 1)
-    #       instClass.setLanguage(anaconda.id, opts.lang)
-    #       instClass.setLanguageDefault(anaconda.id, opts.lang)
-    #       anaconda.id.timezone.setTimezoneInfo(anaconda.id.instLanguage.getDefaultTimeZone())
+    if opts.lang:
+        pomona.dispatch.skipStep("language", permanent = 1)
+        pomona.setLanguage(opts.lang)
+        pomona.setLanguageDefault(opts.lang)
+        pomona.id.timezone.setTimezoneInfo(pomona.id.instLanguage.getDefaultTimeZone())
 
-    #if opts.keymap:
-    #       anaconda.dispatch.skipStep("keyboard", permanent = 1)
-    #       instClass.setKeyboard(anaconda.id, opts.keymap)
+    if opts.keymap:
+        pomona.dispatch.skipStep("keyboard", permanent = 1)
+        pomona.setKeyboard(opts.keymap)
 
     from exception import handleException
     sys.excepthook = lambda type, value, tb, pomona=pomona: handleException(pomona, (type, value, tb))
index 0c6c4199f7a06f8d59d8f5085aa0ec99369af64f..268a6165a345d5f2686d28ab4c088645d91b2b35 100644 (file)
@@ -39,7 +39,6 @@ class InstallData:
         #       - The install language
         #       - The keyboard
 
-        self.instClass = None
         self.network = network.Network()
         self.timezone = timezone.Timezone()
         self.timezone.setTimezoneInfo(self.instLanguage.getDefaultTimeZone())
index 5c76ee87090b3d1a12c2062c9125f94f5d8bb339..a9e9194390d4e834af2a64fa62c34129b79bb640 100644 (file)
@@ -34,9 +34,9 @@ class Keyboard(ConfigFile):
         self.beenset = 0
         self.info = {}
 
-        # default to us
-        self.info["KEYTABLE"] = "us"
-        self.info["KEYBOARDTYPE"] = "pc"
+        # default to us and unicode enabled
+        self.info["KEYMAP"] = "us"
+        self.info["UNICODE"] = "yes"
 
         self._mods = keyboard_models.KeyboardModels()
 
@@ -46,10 +46,10 @@ class Keyboard(ConfigFile):
     modelDict = property(_get_models)
 
     def set(self, keytable):
-        self.info["KEYTABLE"] = keytable
+        self.info["KEYMAP"] = keytable
 
     def get(self):
-        return self.info["KEYTABLE"]
+        return self.info["KEYMAP"]
 
     def getKeymapName(self):
         kbd = self.modelDict[self.get()]
@@ -59,7 +59,7 @@ class Keyboard(ConfigFile):
         return name
 
     def __getitem__(self, item):
-        table = self.info["KEYTABLE"]
+        table = self.info["KEYMAP"]
         if not self.modelDict.has_key(table):
             raise KeyError, "No such keyboard type %s" % (table,)
 
@@ -81,12 +81,12 @@ class Keyboard(ConfigFile):
         else:
             raise KeyError, item
 
-    #def read(self, instPath = "/"):
-    #       ConfigFile.read(self, instPath + "/etc/sysconfig/keyboard")
-    #       self.beenset = 1
+    def read(self, instPath = "/"):
+        ConfigFile.read(self, instPath + "/etc/sysconfig/console")
+        self.beenset = 1
 
     def write(self, instPath = "/"):
-        ConfigFile.write(self, instPath + "/etc/sysconfig/keyboard")
+        ConfigFile.write(self, instPath + "/etc/sysconfig/console")
 
     def activate(self):
         console_kbd = self.get()
index fa5a3c05ed1d3696f207197a88bcb128ca062174..5b7c9913445eaa66548a41eadbc46a8c51bcad82 100644 (file)
@@ -170,13 +170,9 @@ class Language:
         self.info['LANG'] = dispLang
 
         if self.localeInfo[dispLang][2] == "none":
-            self.info['SYSFONT'] = None
+            self.info['FONT'] = None
         else:
-            self.info['SYSFONT'] = self.localeInfo[dispLang][2]
-
-        # XXX hack - because of exceptional cases on the var - zh_CN.GB2312
-        if nick == "zh_CN.GB18030":
-            self.info['LANGUAGE'] = "zh_CN.GB18030:zh_CN.GB2312:zh_CN"
+            self.info['FONT'] = self.localeInfo[dispLang][2]
 
     def setRuntimeDefaults(self, nick):
         canonNick = self.fixLang(self.canonLangNick(nick))
index aa9fc6429fc51976026bc2809ec3a4a3efbf1e02..1ea44fd9014ca29a74478a2d0fa5274c847ffedf 100644 (file)
@@ -50,7 +50,7 @@ def sanityCheckHostname(hostname):
 
 # Try to determine what the hostname should be for this system
 def getDefaultHostname(pomona):
-       return pomona.id.network.hostname
+    return pomona.id.network.hostname
 
 # sanity check an IP string.
 def sanityCheckIPString(ip_string):
@@ -91,7 +91,7 @@ class Network:
         self.isConfigured = 0
         self.hostname = sname + ".localdomain"
 
-               # now initialize devices
+        # now initialize devices
         self.available()
 
     def getDevice(self, device):
@@ -109,7 +109,7 @@ class Network:
         return self.netdevices
 
     def setHostname(self, hn):
-               self.hostname = hn
+        self.hostname = hn
 
     def setDNS(self, ns):
         dns = ns.split(',')
index 55cb5d9d09180b15cab0443e2045234a7718fa61..8865c5384a4cb88158ce8628b8db89a39f253390 100644 (file)
@@ -31,7 +31,7 @@ import logging
 log = logging.getLogger("pomona")
 
 def doPostAction(pomona):
-    pomona.id.instClass.postAction(pomona)
+    pomona.backend.postAction(pomona)
 
 def copyPomonaLogs(pomona):
     log.info("Copying pomona logs")