def __init__(self,
                 anaconda,
                 extraModules,
                 floppyDevice,
                 methodstr,
                 displayMode,
                 backend=None):
        self.displayMode = displayMode

        self.instLanguage = language.Language(self.displayMode)
        self.keyboard = keyboard.Keyboard()
        self.backend = backend
        self.anaconda = anaconda

        self.mouse = None
        self.monitor = None
        self.videocard = None
        self.xsetup = None
        self.isHeadless = 0
        self.extraModules = extraModules
        self.floppyDevice = floppyDevice
        self.fsset = fsset.FileSystemSet(anaconda)
        self.excludeDocs = 0

        if flags.cmdline.has_key("excludedocs"):
            self.excludeDocs = 1

        self.methodstr = methodstr
        self.reset()
Exemple #2
0
def hostActionWriteFstab(_context):
    allRequests = partition.allUserPartitionRequests()
    allRequests.sort(sortByMountPoint=True)

    myFsset = fsset.FileSystemSet()
    for request in allRequests:
        # skip vmfs partitions since they can't be mounted
        if (not isinstance(request.fsType, fsset.swapFileSystem)
                and not request.mountPoint):
            continue

        uuid = request.fsType.getUuid(request.consoleDevicePath)
        if uuid:
            spec = "UUID=%s" % uuid
        else:
            spec = request.consoleDevicePath

        if isinstance(request.fsType, fsset.swapFileSystem):
            mountPoint = "swap"
        else:
            mountPoint = request.mountPoint
        entry = fsset.FileSystemSetEntry(spec,
                                         mountPoint,
                                         request.fsType,
                                         format=False)
        myFsset.addEntry(entry)

    # Make sure all the mount points exist.
    for entry in myFsset:
        path = os.path.join(consts.HOST_ROOT, entry.mountPoint.lstrip('/'))
        if not os.path.exists(path):
            os.makedirs(path)

    # panic when the filesystem with the logs goes read-only
    myFsset.sort(sortByMountPoint=True)
    myFsset.reverse()

    for entry in myFsset:
        if entry.mountPoint in ['/var/log', '/var', '/']:
            assert 'errors=' not in entry.options

            if not entry.options:
                entry.options = 'errors=panic'
                break
            else:
                entry.options += ',errors=panic'
                break

    # re-sort by mount point
    myFsset.sort(sortByMountPoint=True)

    util.writeConfFile(consts.HOST_ROOT + 'etc/fstab', str(myFsset))
Exemple #3
0
    def __init__(self, extraModules, floppyDevice, configFileData, methodstr):
        self.instLanguage = language.InstallTimeLanguage()
        self.keyboard = keyboard.Keyboard()
        self.tmpData = configFileData

        self.configFileData = None
        self.mouse = None
        self.monitor = None
        self.videocard = None
        self.xsetup = None
        self.isHeadless = 0
        self.extraModules = extraModules
        self.floppyDevice = floppyDevice
        self.fsset = fsset.FileSystemSet()

        # FIXME: this is a major hack to get the comps package installed
        self.compspkg = None

        self.methodstr = methodstr
        self.reset()
Exemple #4
0
def runRescue(anaconda):
    for file in [
            "services", "protocols", "group", "joe", "man.config",
            "nsswitch.conf", "selinux", "mke2fs.conf"
    ]:
        try:
            os.symlink('/mnt/runtime/etc/' + file, '/etc/' + file)
        except:
            pass

    # see if they would like networking enabled
    if not methodUsesNetworking(anaconda.id.methodstr):
        screen = SnackScreen()

        while 1:
            rc = ButtonChoiceWindow(
                screen, _("Setup Networking"),
                _("Do you want to start the network interfaces on "
                  "this system?"), [_("Yes"), _("No")])

            if rc != string.lower(_("No")):
                anaconda.intf = RescueInterface(screen)

                # need to call sequence of screens, have to look in text.py
                #
                # this code is based on main loop in text.py, and if it
                # or the network step in dispatch.py change significantly
                # then this will certainly break
                #
                pyfile = "network_text"
                classNames = ("NetworkDeviceWindow", "NetworkGlobalWindow")

                lastrc = INSTALL_OK
                step = 0
                anaconda.dir = 1

                while 1:
                    s = "from %s import %s; nextWindow = %s" % \
                 (pyfile, classNames[step], classNames[step])
                    exec s

                    win = nextWindow()

                    rc = win(screen, anaconda, showonboot=0)

                    if rc == INSTALL_NOOP:
                        rc = lastrc

                    if rc == INSTALL_BACK:
                        step = step - 1
                        anaconda.dir = -1
                    elif rc == INSTALL_OK:
                        step = step + 1
                        anaconda.dir = 1

                    lastrc = rc

                    if step == -1:
                        ButtonChoiceWindow(screen,
                                           _("Cancelled"),
                                           _("I can't go to the previous step "
                                             "from here. You will have to try "
                                             "again."),
                                           buttons=[_("OK")])
                        anaconda.dir = 1
                        step = 0
                    elif step >= len(classNames):
                        break

                startNetworking(anaconda.id.network, anaconda.intf, anaconda)
                break
            else:
                break

        screen.finish()

    # Early shell access with no disk access attempts
    if not anaconda.rescue_mount:
        runShell()
        sys.exit(0)

    # need loopback devices too
    for lpminor in range(8):
        dev = "loop%s" % (lpminor, )
        isys.makeDevInode(dev, "/dev/" + dev)

    screen = SnackScreen()
    anaconda.intf = RescueInterface(screen)
    anaconda.setMethod()

    # prompt to see if we should try and find root filesystem and mount
    # everything in /etc/fstab on that root
    rc = ButtonChoiceWindow(
        screen, _("Rescue"),
        _("The rescue environment will now attempt to find your "
          "Linux installation and mount it under the directory "
          "%s.  You can then make any changes required to your "
          "system.  If you want to proceed with this step choose "
          "'Continue'.  You can also choose to mount your file systems "
          "read-only instead of read-write by choosing 'Read-Only'."
          "\n\n"
          "If for some reason this process fails you can choose 'Skip' "
          "and this step will be skipped and you will go directly to a "
          "command shell.\n\n") % (anaconda.rootPath, ),
        [_("Continue"), _("Read-Only"),
         _("Skip")])

    if rc == string.lower(_("Skip")):
        runShell(screen)
        sys.exit(0)
    elif rc == string.lower(_("Read-Only")):
        readOnly = 1
    else:
        readOnly = 0

    disks = upgrade.findExistingRoots(anaconda, upgradeany=1)

    if not disks:
        root = None
    elif len(disks) == 1:
        root = disks[0]
    else:
        height = min(len(disks), 12)
        if height == 12:
            scroll = 1
        else:
            scroll = 0

        partList = []
        for (drive, fs, relstr, label) in disks:
            if label:
                partList.append("%s (%s)" % (drive, label))
            else:
                partList.append(drive)

        (button, choice) = \
            ListboxChoiceWindow(screen, _("System to Rescue"),
           _("What partition holds the root partition "
             "of your installation?"), partList,
           [ _("OK"), _("Exit") ], width = 30,
           scroll = scroll, height = height,
           help = "multipleroot")

        if button == string.lower(_("Exit")):
            root = None
        else:
            root = disks[choice]

    rootmounted = 0

    if root:
        try:
            fs = fsset.FileSystemSet(anaconda)

            # only pass first two parts of tuple for root, since third
            # element is a comment we dont want
            rc = upgrade.mountRootPartition(anaconda,
                                            root[:2],
                                            fs,
                                            allowDirty=1,
                                            warnDirty=1,
                                            readOnly=readOnly)

            if rc == -1:
                ButtonChoiceWindow(
                    screen,
                    _("Rescue"),
                    _("Your system had dirty file systems which you chose not "
                      "to mount.  Press return to get a shell from which "
                      "you can fsck and mount your partitions.  The system "
                      "will reboot automatically when you exit from the "
                      "shell."), [_("OK")],
                    width=50)
                rootmounted = 0
            else:
                ButtonChoiceWindow(
                    screen, _("Rescue"),
                    _("Your system has been mounted under %s.\n\n"
                      "Press <return> to get a shell. If you would like to "
                      "make your system the root environment, run the command:\n\n"
                      "\tchroot %s\n\nThe system will reboot "
                      "automatically when you exit from the shell.") %
                    (anaconda.rootPath, anaconda.rootPath), [_("OK")])
                rootmounted = 1

                # now turn on swap
                if not readOnly:
                    try:
                        fs.turnOnSwap("/")
                    except:
                        log.error("Error enabling swap")

                # now that dev is udev, bind mount the installer dev there
                isys.mount("/dev",
                           "%s/dev" % (anaconda.rootPath, ),
                           bindMount=1)

                # and /dev/pts
                isys.mount("/dev/pts",
                           "%s/dev/pts" % (anaconda.rootPath, ),
                           bindMount=1)

                # and /selinux too
                if flags.selinux and os.path.isdir("%s/selinux" %
                                                   (anaconda.rootPath, )):
                    try:
                        isys.mount("/selinux",
                                   "%s/selinux" % (anaconda.rootPath, ),
                                   "selinuxfs")
                    except Exception, e:
                        log.error("error mounting selinuxfs: %s" % (e, ))

        # set a library path to use mounted fs
                os.environ[
                    "LD_LIBRARY_PATH"] = "/lib:/usr/lib:/usr/X11R6/lib:/lib:/mnt/usr/lib:/mnt/sysimage/lib:/mnt/sysimage/usr/lib:/mnt/sysimage/usr/X11R6/lib"

                # get man pages to work
                os.environ[
                    "MANPATH"] = "/mnt/sysimage/usr/share/man:/mnt/sysimage/usr/local/share/man:/usr/share/man:/usr/local/share/man"

                # find groff data dir
                try:
                    glst = os.listdir("/mnt/sysimage/usr/share/groff")

                    # find a directory which is a numeral, its where
                    # data files are
                    gversion = None
                    for gdir in glst:
                        try:
                            isone = 1
                            for idx in range(0, len(gdir)):
                                if string.find(string.digits + '.',
                                               gdir[idx]) == -1:
                                    isone = 0
                                    break
                            if isone:
                                gversion = gdir
                                break

                        except:
                            gversion = None
                            continue

                except:
                    gversion = None

                if gversion is not None:
                    gpath = "/mnt/sysimage/usr/share/groff/" + gversion
                    os.environ["GROFF_FONT_PATH"] = gpath + '/font'
                    os.environ[
                        "GROFF_TMAC_PATH"] = "%s:/mnt/sysimage/usr/share/groff/site-tmac" % (
                            gpath + '/tmac', )

        # do we have bash?
                try:
                    if os.access("/usr/bin/bash", os.R_OK):
                        os.symlink("/usr/bin/bash", "/bin/bash")
                except:
                    pass

        except:
            # This looks horrible, but all it does is catch every exception,
            # and reraise those in the tuple check. This lets programming
            # errors raise exceptions, while any runtime error will
            # still result in a shell.
            (exc, val) = sys.exc_info()[0:2]
            log.error(val)
            if exc in (IndexError, ValueError, SyntaxError):
                raise exc, val, sys.exc_info()[2]

            ButtonChoiceWindow(
                screen, _("Rescue"),
                _("An error occurred trying to mount some or all of your "
                  "system. Some of it may be mounted under %s.\n\n"
                  "Press <return> to get a shell. The system will reboot "
                  "automatically when you exit from the shell.") %
                (anaconda.rootPath, ), [_("OK")])
    else:
        ButtonChoiceWindow(screen,
                           _("Rescue Mode"),
                           _("You don't have any Linux partitions. Press "
                             "return to get a shell. The system will reboot "
                             "automatically when you exit from the shell."),
                           [_("OK")],
                           width=50)

    msgStr = ""

    if rootmounted and not readOnly:
        makeMtab(anaconda.rootPath, fs)
        try:
            makeResolvConf(anaconda.rootPath)
        except Exception, e:
            log.error("error making a resolv.conf: %s" % (e, ))
        msgStr = _("Your system is mounted under the %s directory.") % (
            anaconda.rootPath, )