diff options
Diffstat (limited to 'anaconda')
-rwxr-xr-x | anaconda | 173 |
1 files changed, 102 insertions, 71 deletions
@@ -36,7 +36,7 @@ from tempfile import mkstemp # keep up with process ID of the window manager if we start it wm_pid = None -def exitHandler(anaconda, exitCode=None): +def exitHandler(rebootData, storage, exitCode=None): from pyanaconda import isys from pyanaconda.flags import flags @@ -64,19 +64,19 @@ def exitHandler(anaconda, exitCode=None): from pykickstart.constants import KS_SHUTDOWN, KS_WAIT, KS_REBOOT from pyanaconda.iutil import dracut_eject - if anaconda.ksdata.reboot.eject: - for drive in anaconda.storage.devicetree.devices: + if rebootData.eject: + for drive in storage.devicetree.devices: if drive.type != "cdrom": continue dracut_eject(drive.path) - if anaconda.ksdata.reboot.action == KS_SHUTDOWN: + if rebootData.action == KS_SHUTDOWN: os.system("systemctl --force --no-wall poweroff") - elif anaconda.ksdata.reboot.action == KS_WAIT: + elif rebootData.action == KS_WAIT: os.system("systemctl --force --no-wall halt") else: # reboot action is KS_REBOOT or None os.system("systemctl --force --no-wall reboot") - elif not flags.imageInstall: + elif flags.livecdInstall: os.system("systemctl --force --no-wall reboot") def startMetacityWM(): @@ -111,15 +111,35 @@ def startAuditDaemon(): os.waitpid(childpid, 0) # function to handle X startup special issues for anaconda -def doStartupX11Actions(): - global wm_pid # pid of the anaconda fork where the window manager is running +def doStartupX11Actions(keyboard): + """ + Start window manager and set up keyboard layouts if requested in kickstart + or on command line. + + @param keyboard: ksdata.keyboard object - setupGraphicalLinks() + """ + + global wm_pid # pid of the anaconda fork where the window manager is running # now start up the window manager wm_pid = startMetacityWM() log.info("Starting window manager, pid %s." % (wm_pid,)) + # setup layouts + if keyboard.layouts_list: + from pyanaconda.keyboard import XklWrapper, XklWrapperError + + layouts = keyboard.layouts_list + xklwrapper = XklWrapper.get_instance() + + try: + xklwrapper.replace_layouts(layouts) + + except XklWrapperError as xklerr: + msg = "Failed to activate layouts %s" % ",".join(layouts) + log.error(msg) + def set_x_resolution(runres): # cant do this if no window manager is running because otherwise when we # open and close an X connection in the xutils calls the X server will exit @@ -429,15 +449,6 @@ def check_memory(anaconda, opts, display_mode=None): anaconda.displayMode = 't' time.sleep(2) -def setupGraphicalLinks(): - for i in ( "imrc", "im_palette.pal", "gtk-2.0", "pango", "fonts", - "fb.modes"): - try: - if os.path.exists("/mnt/runtime/etc/%s" %(i,)): - os.symlink ("../mnt/runtime/etc/" + i, "/etc/" + i) - except: - pass - def startDebugger(signum, frame): import epdb epdb.serve(skip=1) @@ -569,7 +580,7 @@ def setupDisplay(anaconda, opts): signal.pause() os.environ["DISPLAY"] = ":1" - doStartupX11Actions() + doStartupX11Actions(anaconda.ksdata.keyboard) except (OSError, RuntimeError): stdoutLog.warning("X startup failed, falling back to text mode") anaconda.displayMode = 't' @@ -593,7 +604,7 @@ def setupDisplay(anaconda, opts): # if they want us to use VNC do that now if anaconda.displayMode == 'g' and flags.usevnc: runVNC(vncS) - doStartupX11Actions() + doStartupX11Actions(anaconda.ksdata.keyboard) # with X running we can initialize the UI interface anaconda.initInterface() @@ -658,8 +669,6 @@ def prompt_for_ssh(): if __name__ == "__main__": - setupPythonPath() - # Allow a file to be loaded as early as possible try: import updates_disk_hook @@ -719,6 +728,7 @@ if __name__ == "__main__": from pyanaconda import iutil from pyanaconda import vnc from pyanaconda import kickstart + from pyanaconda import ntp # to set UTF8 mode on the terminal, we need LANG to be set usefully if os.environ.get("LANG", "C") == "C": @@ -846,41 +856,63 @@ if __name__ == "__main__": # parse (not execute) kickstart now, the ks commands can affect things like # UI interface type or enabling rescue mode if opts.ksfile: + flags.automatedInstall = True + kickstart.preScriptPass(anaconda, opts.ksfile) - anaconda.ksdata = kickstart.parseKickstart(anaconda, opts.ksfile) - if anaconda.ksdata.rescue.rescue: + ksdata = kickstart.parseKickstart(anaconda, opts.ksfile) + if ksdata.rescue.rescue: anaconda.rescue = True - - # Setup the storage config options from the kickstart file - anaconda.storage.config.zeroMbr = anaconda.ksdata.zerombr.zerombr - anaconda.storage.config.ignoreDiskInteractive = anaconda.ksdata.ignoredisk.interactive - anaconda.storage.config.ignoredDisks = anaconda.ksdata.ignoredisk.ignoredisk - anaconda.storage.config.exclusiveDisks = anaconda.ksdata.ignoredisk.onlyuse - - if anaconda.ksdata.clearpart.type is not None: - anaconda.storage.config.clearPartType = anaconda.ksdata.clearpart.type - anaconda.storage.config.clearPartDisks = anaconda.ksdata.clearpart.drives - if anaconda.ksdata.clearpart.initAll: - anaconda.storage.config.reinitializeDisks = anaconda.ksdata.clearpart.initAll - - # Set up display options. - # NOTE: kickstart overrides cmdline, because kickstart gets parsed last - if anaconda.ksdata.displaymode.displayMode is not None: - # this is derived from pykickstart.constants.DISPLAY_MODE_* - displaymap = ['cmdline', 'graphical', 'text'] - display_mode = displaymap[anaconda.ksdata.displaymode.displayMode] - log.info("kickstart forcing %s mode" % display_mode) - opts.display_mode = display_mode[0] # 'c', 'g', or 't' + else: + ksdata = kickstart.AnacondaKSHandler(anaconda) + + anaconda.ksdata = ksdata + + # Some post-install parts of anaconda are implemented as kickstart + # scripts. Add those to the ksdata now. + kickstart.appendPostScripts(ksdata) + + # set ksdata.method based on anaconda.method if it isn't already set + if anaconda.methodstr and not ksdata.method.method: + if anaconda.methodstr.startswith("cdrom"): + ksdata.method.method = "cdrom" + elif anaconda.methodstr.startswith("nfs"): + ksdata.method.method = "nfs" + url = anaconda.methodstr.split(":", 1)[1] + (opts, server, path) = iutil.parseNfsUrl(url) + ksdata.method.server = server + ksdata.method.dir = path + ksdata.method.opts = opts + elif anaconda.methodstr.startswith("hd:"): + ksdata.method.method = "harddrive" + url = anaconda.methodstr.split(":", 1)[1] + url_parts = url.split(":") + device = url_parts[0] + path = "" + if len(url_parts) == 2: + path = url_parts[1] + elif len(url_parts) == 3: + fstype = url_parts[1] # XXX not used + path = url_parts[2] + + ksdata.method.partition = device + ksdata.method.dir = path + elif anaconda.methodstr.startswith("http") or \ + anaconda.methodstr.startswith("ftp"): + ksdata.method.method = "url" + ksdata.method.noverifyssl = flags.noverifyssl + ksdata.method.proxy = anaconda.proxy # FIXME: username/password + ksdata.method.url = anaconda.methodstr + + # setup keyboard layout from the command line option and let + # it override from kickstart if/when X is initialized + if opts.keymap: + if not ksdata.keyboard.keyboard: + ksdata.keyboard.keyboard = opts.keymap + anaconda.keyboard.set(opts.keymap) + anaconda.keyboard.activate() # now start the interface setupDisplay(anaconda, opts) - # setting the install steps requires interface to be running - if opts.ksfile: - kickstart.setSteps(anaconda) - else: - anaconda.instClass.setSteps(anaconda) - if anaconda.rescue: - anaconda.dispatch.request_steps("rescue") image_count = 0 for image in opts.images: @@ -914,31 +946,30 @@ if __name__ == "__main__": if opts.lang: # this is lame, but make things match what we expect (#443408) opts.lang = opts.lang.replace(".utf8", ".UTF-8") - anaconda.dispatch.skip_steps("language") anaconda.instLanguage.instLang = opts.lang anaconda.instLanguage.systemLang = opts.lang anaconda.timezone.setTimezoneInfo(anaconda.instLanguage.getDefaultTimeZone()) - if opts.keymap: - anaconda.dispatch.skip_steps("keyboard") - anaconda.keyboard.set(opts.keymap) - anaconda.keyboard.activate() + from pyanaconda.storage import storageInitialize + from pyanaconda.packaging import payloadInitialize + from pyanaconda.threads import initThreading, threadMgr, AnacondaThread - # set up the headless case - if anaconda.isHeadless: - anaconda.dispatch.skip_steps("keyboard") + initThreading() + threadMgr.add(AnacondaThread(name="AnaStorageThread", target=storageInitialize, args=(anaconda.storage, ksdata, anaconda.protected))) + threadMgr.add(AnacondaThread(name="AnaPayloadThread", target=payloadInitialize, args=(anaconda.storage, ksdata, anaconda.payload))) - atexit.register(exitHandler, anaconda) + atexit.register(exitHandler, ksdata.reboot, anaconda.storage) - try: - anaconda.dispatch.run() - except SystemExit as code: - exitHandler(anaconda, code) - except RuntimeError as errtxt: - if anaconda.displayMode == 'c': - print errtxt - while True: - time.sleep(10000) - raise + # setup ntp servers and start NTP daemon if not requested otherwise + if (not flags.imageInstall) and anaconda.ksdata.timezone.ntpservers: + ntp.save_servers_to_config(anaconda.ksdata.timezone.ntpservers) + + if not anaconda.ksdata.timezone.nontp: + iutil.start_service("chronyd") + + # FIXME: This will need to be made cleaner once this file starts to take + # shape with the new UI code. + anaconda._intf.setup(ksdata) + anaconda._intf.run() # vim:tw=78:ts=4:et:sw=4 |