コード例 #1
0
    def getScreen(self, anaconda):
        self.dispatch = anaconda.dispatch
        self.bl = anaconda.id.bootloader
        self.intf = anaconda.intf

        self.driveorder = self.bl.drivelist
        if len(self.driveorder) == 0:
            partitioned = anaconda.id.storage.partitioned
            disks = anaconda.id.storage.disks
            self.driveorder = [d.name for d in disks if d in partitioned]

        if self.bl.getPassword():
            self.usePass = 1
            self.password = self.bl.getPassword()
        else:
            self.usePass = 0
            self.password = None

        thebox = gtk.VBox (False, 12)
        thebox.set_border_width(18)

        # make sure we get a valid device to say we're installing to
        if self.bl.getDevice() is not None:
            self.bldev = self.bl.getDevice()
        else:
            # we don't know what it is yet... if mbr is possible, we want
            # it, else we want the boot dev
            choices = anaconda.platform.bootloaderChoices(self.bl)
            if choices.has_key('mbr'):
                self.bldev = choices['mbr'][0]
            else:
                self.bldev = choices['boot'][0]

        hb = gtk.HBox(False, 12)
        self.grubCB = gtk.CheckButton(_("_Install boot loader on /dev/%s.") %
                                      (self.bldev,))
        self.grubCB.set_active(not self.dispatch.stepInSkipList("instbootloader"))
        self.grubCB.connect("toggled", self.bootloaderChanged)
        hb.pack_start(self.grubCB, False)

        # no "Change device" button on EFI systems, since there should only
        # be one EFI System Partition available/usable
        self.deviceButton = None
        if not iutil.isEfi():
            self.deviceButton = gtk.Button(_("_Change device"))
            self.deviceButton.connect("clicked", self._deviceChange, anaconda)
            hb.pack_start(self.deviceButton, False)

        thebox.pack_start(hb, False)

        # control whether or not there's a boot loader password and what it is
        self.blpass = BootloaderPasswordWidget(anaconda, self.parent)
        thebox.pack_start(self.blpass.getWidget(), False)

        # configure the systems available to boot from the boot loader
        self.oslist = OSBootWidget(anaconda, self.parent)
        thebox.pack_end(self.oslist.getWidget(), True)

        self.bootloaderChanged()
        return thebox
コード例 #2
0
ファイル: platform.py プロジェクト: mattias-ohlsson/anaconda
def getPlatform(anaconda):
    """Check the architecture of the system and return an instance of a
       Platform subclass to match.  If the architecture could not be determined,
       raise an exception."""
    if iutil.isPPC():
        ppcMachine = iutil.getPPCMachine()

        if (ppcMachine == "PMac" and iutil.getPPCMacGen() == "NewWorld"):
            return NewWorldPPC(anaconda)
        elif ppcMachine in ["iSeries", "pSeries"]:
            return IPSeriesPPC(anaconda)
        elif ppcMachine == "PS3":
            return PS3(anaconda)
        else:
            raise SystemError, "Unsupported PPC machine type"
    elif iutil.isS390():
        return S390(anaconda)
    elif iutil.isSparc():
        return Sparc(anaconda)
    elif iutil.isEfi():
        if iutil.isMactel():
            return MacEFI(anaconda)
        else:
            return EFI(anaconda)
    elif iutil.isX86():
        return X86(anaconda)
    elif iutil.isARM():
        return ARM(anaconda)
    else:
        raise SystemError, "Could not determine system architecture."
コード例 #3
0
ファイル: x86.py プロジェクト: icomfort/anaconda
    def writeGrub(self,
                  instRoot,
                  bl,
                  kernelList,
                  chainList,
                  defaultDev,
                  upgrade=False):

        rootDev = self.storage.rootDevice
        grubTarget = bl.getDevice()

        try:
            bootDev = self.storage.mountpoints["/boot"]
            grubPath = "/grub"
            cfPath = "/"
        except KeyError:
            bootDev = rootDev
            grubPath = "/boot/grub"
            cfPath = "/boot/"

        if not upgrade and not iutil.isEfi():
            self.writeGrubConf(instRoot, bootDev, rootDev, defaultDev,
                               kernelList, chainList, grubTarget, grubPath,
                               cfPath)

        # keep track of which devices are used for the device.map
        usedDevs = set()
        usedDevs.update(self.getPhysicalDevices(grubTarget))
        usedDevs.update(self.getPhysicalDevices(bootDev.name))
        usedDevs.update(
            [dev for (label, longlabel, dev) in chainList if longlabel])

        if not upgrade:
            self.writeDeviceMap(instRoot, usedDevs, upgrade)
            self.writeSysconfig(instRoot, grubTarget, upgrade)

        ret = self.installGrub(instRoot, bootDev, grubTarget, grubPath, cfPath)
        if iutil.isEfi():
            self.writeGrubConf(instRoot, bootDev, rootDev, defaultDev,
                               kernelList, chainList, grubTarget, grubPath,
                               cfPath)
        return ret
コード例 #4
0
ファイル: x86.py プロジェクト: 274914765/python
    def writeGrub(self, instRoot, bl, kernelList, chainList,
            defaultDev, upgrade=False):

        rootDev = self.storage.rootDevice
        grubTarget = bl.getDevice()

        try:
            bootDev = self.storage.mountpoints["/boot"]
            grubPath = "/grub"
            cfPath = "/"
        except KeyError:
            bootDev = rootDev
            grubPath = "/boot/grub"
            cfPath = "/boot/"

        if not upgrade and not iutil.isEfi():
            self.writeGrubConf(instRoot, bootDev, rootDev, defaultDev,
                               kernelList, chainList, grubTarget, grubPath,
                               cfPath)

        # keep track of which devices are used for the device.map
        usedDevs = set()
        usedDevs.update(self.getPhysicalDevices(grubTarget))
        usedDevs.update(self.getPhysicalDevices(bootDev.name))
        usedDevs.update([dev for (label, longlabel, dev) in chainList if longlabel])

        if not upgrade:
            self.writeDeviceMap(instRoot, usedDevs, upgrade)
            self.writeSysconfig(instRoot, grubTarget, upgrade)

        ret = self.installGrub(instRoot, bootDev, grubTarget, grubPath, cfPath)
        if iutil.isEfi():
            self.writeGrubConf(instRoot, bootDev, rootDev, defaultDev,
                               kernelList, chainList, grubTarget, grubPath,
                               cfPath)
        return ret
コード例 #5
0
ファイル: x86.py プロジェクト: 274914765/python
    def installGrub(self, instRoot, bootDev, grubTarget, grubPath, cfPath):
        if iutil.isEfi():
            return efiBootloaderInfo.installGrub(self, instRoot, bootDev, grubTarget,
                                                 grubPath, cfPath)

        args = "--stage2=/boot/grub/stage2 "

        stage1Devs = self.getPhysicalDevices(grubTarget)
        bootDevs = self.getPhysicalDevices(bootDev.name)

        installs = [(None,
                     self.grubbyPartitionName(stage1Devs[0]),
                     self.grubbyPartitionName(bootDevs[0]))]

        if bootDev.type == "mdarray":

            matches = self.matchingBootTargets(stage1Devs, bootDevs)

            # If the stage1 target disk contains member of boot raid array (mbr
            # case) or stage1 target partition is member of boot raid array
            # (partition case)
            if matches:
                # 1) install stage1 on target disk/partiton
                stage1Dev, mdMemberBootPart = matches[0]
                installs = [(None,
                             self.grubbyPartitionName(stage1Dev),
                             self.grubbyPartitionName(mdMemberBootPart))]
                firstMdMemberDiskGrubbyName = self.grubbyDiskName(getDiskPart(mdMemberBootPart, self.storage)[0])

                # 2) and install stage1 on other members' disks/partitions too
                # NOTES:
                # - the goal is to be able to boot after a members' disk removal
                # - so we have to use grub device names as if after removal
                #   (i.e. the same disk name (e.g. (hd0)) for both member disks)
                # - if member partitions have different numbers only removal of
                #   specific one of members will work because stage2 containing
                #   reference to config file is shared and therefore can contain
                #   only one value

                # if target is mbr, we want to install also to mbr of other
                # members, so extend the matching list
                matches = self.addMemberMbrs(matches, bootDevs)
                for stage1Target, mdMemberBootPart in matches[1:]:
                    # prepare special device mapping corresponding to member removal
                    mdMemberBootDisk = getDiskPart(mdMemberBootPart, self.storage)[0]
                    # It can happen due to ks --driveorder option, but is it ok?
                    if not mdMemberBootDisk in self.drivelist:
                        continue
                    mdRaidDeviceRemap = (firstMdMemberDiskGrubbyName,
                                         mdMemberBootDisk)

                    stage1TargetGrubbyName = self.grubbyPartitionName(stage1Target)
                    rootPartGrubbyName = self.grubbyPartitionName(mdMemberBootPart)

                    # now replace grub disk name part according to special device
                    # mapping
                    old = self.grubbyDiskName(mdMemberBootDisk).strip('() ')
                    new = firstMdMemberDiskGrubbyName.strip('() ')
                    rootPartGrubbyName = rootPartGrubbyName.replace(old, new)
                    stage1TargetGrubbyName = stage1TargetGrubbyName.replace(old, new)

                    installs.append((mdRaidDeviceRemap,
                                     stage1TargetGrubbyName,
                                     rootPartGrubbyName))

                # This is needed for case when /boot member partitions have
                # different numbers. Shared stage2 can contain only one reference
                # to grub.conf file, so let's ensure that it is reference to partition
                # on disk which we will boot from - that is, install grub to
                # this disk as last so that its reference is not overwritten.
                installs.reverse()

        cmds = []
        for mdRaidDeviceRemap, stage1Target, rootPart in installs:
            if mdRaidDeviceRemap:
                cmd = "device (%s) /dev/%s\n" % tuple(mdRaidDeviceRemap)
            else:
                cmd = ''
            cmd += "root %s\n" % (rootPart,)
            cmd += "install %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \
                (args, grubPath, stage1Target, grubPath, rootPart, grubPath)
            cmds.append(cmd)
        return self.runGrubInstall(instRoot, bootDev.name, cmds, cfPath)
コード例 #6
0
    def setSteps(self, anaconda):
        dispatch = anaconda.dispatch
	dispatch.setStepList(
                 "kernelvm_top",
                 "installTinyCoreNag",
		 "language",
		 "keyboard",
                 "filtertype",
                 "filter",
                 "storageinit",
                 "findrootparts",
                 "cleardiskssel",
                 "parttype",
                 "autopartitionexecute",
                 "partition",
		 "storagedone",
		 "bootloadersetup",                 
		 "bootloader",
		 "network",
		 "timezone",
		 "accounts",
                 "reposetup",
                 "basepkgsel",
		 "tasksel",                                  
		 "postselection",
                 "reipl",
		 "install",
		 "enablefilesystems",
                 "setuptime",
                 "preinstallconfig",
		 "installpackages",
                 "postinstallconfig",
		 "writeconfig",
                 "firstboot",
		 "instbootloader",
                 "dopostaction",
                 "postscripts",
		 "writeksconfig",
                 "methodcomplete",
                 "copylogs",
                 "setfilecon",
		 "complete"
		)

	if not isBeta:
	    dispatch.skipStep("betanag", permanent=1)

        if iutil.isEfi() or not iutil.isX86():
            dispatch.skipStep("bootloader", permanent=1)

        # allow backends to disable interactive package selection
        if not anaconda.backend.supportsPackageSelection:
            dispatch.skipStep("tasksel", skip = 1, permanent=1)
            dispatch.skipStep("group-selection", skip = 1, permanent=1)

        # allow install classes to turn off the upgrade 
        if not self.showUpgrade or not anaconda.backend.supportsUpgrades:
            dispatch.skipStep("findrootparts", skip = 1)

        # 'noupgrade' can be used on the command line to force not looking
        # for partitions to upgrade.  useful in some cases...
        if flags.cmdline.has_key("noupgrade"):
            dispatch.skipStep("findrootparts", skip = 1)

        # upgrade will also always force looking for an upgrade. 
        if flags.cmdline.has_key("upgrade"):
            dispatch.skipStep("findrootparts", skip = 0)

        # allow interface backends to skip certain steps.
        anaconda.intf.setSteps(anaconda)
コード例 #7
0
    def getScreen(self, anaconda):
        self.dispatch = anaconda.dispatch
        self.bl = anaconda.id.bootloader
        self.intf = anaconda.intf

        self.driveorder = self.bl.drivelist
        if len(self.driveorder) == 0:
            partitioned = anaconda.id.storage.partitioned
            disks = anaconda.id.storage.disks
            self.driveorder = [d.name for d in disks if d in partitioned]

        if self.bl.getPassword():
            self.usePass = 1
            self.password = self.bl.getPassword()
        else:
            self.usePass = 0
            self.password = None

        thebox = gtk.VBox(False, 12)
        thebox.set_border_width(18)

        # make sure we get a valid device to say we're installing to
        if self.bl.getDevice() is not None:
            self.bldev = self.bl.getDevice()
        else:
            # we don't know what it is yet... if mbr is possible, we want
            # it, else we want the boot dev
            choices = anaconda.platform.bootloaderChoices(self.bl)
            if choices.has_key('mbr'):
                self.bldev = choices['mbr'][0]
            else:
                self.bldev = choices['boot'][0]

        hb = gtk.HBox(False, 12)
        self.grubCB = gtk.CheckButton(
            _("_Install boot loader on /dev/%s.") % (self.bldev, ))
        self.grubCB.set_active(
            not self.dispatch.stepInSkipList("instbootloader"))
        self.grubCB.connect("toggled", self.bootloaderChanged)
        hb.pack_start(self.grubCB, False)

        # no "Change device" button on EFI systems, since there should only
        # be one EFI System Partition available/usable
        self.deviceButton = None
        if not iutil.isEfi():
            self.deviceButton = gtk.Button(_("_Change device"))
            self.deviceButton.connect("clicked", self._deviceChange, anaconda)
            hb.pack_start(self.deviceButton, False)

        thebox.pack_start(hb, False)

        # control whether or not there's a boot loader password and what it is
        self.blpass = BootloaderPasswordWidget(anaconda, self.parent)
        thebox.pack_start(self.blpass.getWidget(), False)

        # configure the systems available to boot from the boot loader
        self.oslist = OSBootWidget(anaconda, self.parent)
        thebox.pack_end(self.oslist.getWidget(), True)

        self.bootloaderChanged()
        return thebox
コード例 #8
0
def mountptchangeCB(widget, fstypecombo):
    if iutil.isEfi() and widget.get_children()[0].get_text() == "/boot/efi":
        fstypecombo.set_active_text(getFormat("efi").name)
    if widget.get_children()[0].get_text() == "/boot":
        fstypecombo.set_active_text(get_default_filesystem_type(boot=True))
コード例 #9
0
def getBootloaderTypeAndBoot(instRoot, storage):
    haveGrubConf = 1
    haveLiloConf = 1
    haveYabootConf = 1
    haveSiloConf = 1
    haveZiplConf = 1

    bootDev = None

    # make sure they have the config file, otherwise we definitely can't
    # use that bootloader
    if not os.access(instRoot + grubConfigFile, os.R_OK):
        haveGrubConf = 0
    if not os.access(instRoot + liloConfigFile, os.R_OK):
        haveLiloConf = 0
    if not os.access(instRoot + yabootConfigFile, os.R_OK):
        haveYabootConf = 0
    if not os.access(instRoot + siloConfigFile, os.R_OK):
        haveSiloConf = 0
    if not os.access(instRoot + ziplConfigFile, os.R_OK):
        haveZiplConf = 0

    if haveGrubConf:
        bootDev = None
        for (fn, stanza) in [("/etc/sysconfig/grub", "boot="),
                             (grubConfigFile, "#boot=")]:
            try:
                f = open(instRoot + fn, "r")
            except:
                continue

            # the following bits of code are straight from checkbootloader.py
            lines = f.readlines()
            f.close()
            for line in lines:
                if line.startswith(stanza):
                    bootDev = getBootDevString(line)
                    break
            if bootDev is not None:
                break

        if iutil.isEfi():
            return ("GRUB", bootDev)

        if bootDev is not None:
            block = getBootBlock(bootDev, instRoot, storage)
            # XXX I don't like this, but it's what the maintainer suggested :(
            if string.find(block, "GRUB") >= 0:
                return ("GRUB", bootDev)

    if haveLiloConf:
        f = open(instRoot + liloConfigFile, "r")
        lines = f.readlines()
        for line in lines:
            if line[0:5] == "boot=":
                bootDev = getBootDevString(line)
                break

        block = getBootBlock(bootDev, instRoot, storage)
        # this at least is well-defined
        if block[6:10] == "LILO":
            return ("LILO", bootDev)

    if haveYabootConf:
        f = open(instRoot + yabootConfigFile, "r")
        lines = f.readlines()
        for line in lines:
            if line[0:5] == "boot=":
                bootDev = getBootDevList(line)

        if bootDev:
            return ("YABOOT", bootDev)

    if haveSiloConf:
        bootDev = None
        # We've never done the /etc/sysconfig/silo thing, but maybe
        # we should start...
        for (fn, stanza) in [("/etc/sysconfig/silo", "boot="),
                             (grubConfigFile, "#boot=")]:
            try:
                f = open(instRoot + fn, "r")
            except:
                continue

            lines = f.readlines()
            f.close()
            for line in lines:
                if line.startswith(stanza):
                    bootDev = getBootDevString(line)
                    break
            if bootDev is not None:
                break

        if bootDev is not None:
            # XXX SILO sucks just like grub.
            if getDiskPart(bootDev, storage)[1] != 3:
                block = getBootBlock(bootDev, instRoot, storage, 1)
                if block[24:28] == "SILO":
                    return ("SILO", bootDev)

    if haveZiplConf:
        bootDev = None
        f = open(instRoot + ziplConfigFile, "r")
        lines = f.readlines()
        for line in lines:
            if line[0:7] == "target=":
                bootDev = getBootDevList(line)

        if bootDev:
            return ("ZIPL", bootDev)

    return (None, None)
コード例 #10
0
def bootloaderSetupChoices(anaconda):
    if anaconda.dir == DISPATCH_BACK:
        rc = anaconda.intf.messageWindow(_("Warning"),
                _("Filesystems have already been activated.  You "
                  "cannot go back past this point.\n\nWould you like to "
                  "continue with the installation?"),
                type="custom", custom_icon=["error","error"],
                custom_buttons=[_("_Exit installer"), _("_Continue")])

        if rc == 0:
            sys.exit(0)
        return DISPATCH_FORWARD

    if anaconda.ksdata and anaconda.ksdata.bootloader.driveorder:
        anaconda.bootloader.updateDriveList(anaconda.ksdata.bootloader.driveorder)
    else:
        #We want the selected bootloader drive to be preferred
        pref = anaconda.bootloader.drivelist[:1]
        anaconda.bootloader.updateDriveList(pref)

    if iutil.isEfi() and not anaconda.bootloader.device:
        bootPart = None
        partitions = anaconda.storage.partitions
        for part in partitions:
            if part.partedPartition.active and isEfiSystemPartition(part.partedPartition):
                bootPart = part.name
                break
        if bootPart:
            anaconda.bootloader.setDevice(bootPart)

# iSeries bootloader on upgrades
    if iutil.getPPCMachine() == "iSeries" and not anaconda.bootloader.device:
        bootPart = None
        partitions = anaconda.storage.partitions
        for part in partitions:
            if part.partedPartition.active and \
               part.partedPartition.getFlag(parted.PARTITION_PREP):
                bootPart = part.name
                break
        if bootPart:
            anaconda.bootloader.setDevice(bootPart)

    choices = anaconda.platform.bootloaderChoices(anaconda.bootloader)
    if not choices and iutil.getPPCMachine() != "iSeries":
	anaconda.dispatch.skipStep("instbootloader")
    else:
	anaconda.dispatch.skipStep("instbootloader", skip = 0)

    # FIXME: ...
    anaconda.bootloader.images.setup(anaconda.storage)

    if anaconda.bootloader.defaultDevice != None and choices:
        keys = choices.keys()
        # there are only two possible things that can be in the keys
        # mbr and boot.  boot is ALWAYS present.  so if the dev isn't
        # listed, it was mbr and we should nicely fall back to boot
        if anaconda.bootloader.defaultDevice not in keys:
            log.warning("MBR not suitable as boot device; installing to partition")
            anaconda.bootloader.defaultDevice = "boot"
        anaconda.bootloader.setDevice(choices[anaconda.bootloader.defaultDevice][0])
    elif choices and iutil.isMactel() and choices.has_key("boot"): # haccckkkk
        anaconda.bootloader.setDevice(choices["boot"][0])        
    elif choices and choices.has_key("mbr"):
        anaconda.bootloader.setDevice(choices["mbr"][0])
    elif choices and choices.has_key("boot"):
        anaconda.bootloader.setDevice(choices["boot"][0])
コード例 #11
0
ファイル: checkbootloader.py プロジェクト: 274914765/python
def getBootloaderTypeAndBoot(instRoot, storage):
    haveGrubConf = 1
    haveLiloConf = 1
    haveYabootConf = 1
    haveSiloConf = 1
    haveZiplConf = 1
    
    bootDev = None
    
    # make sure they have the config file, otherwise we definitely can't
    # use that bootloader
    if not os.access(instRoot + grubConfigFile, os.R_OK):
        haveGrubConf = 0
    if not os.access(instRoot + liloConfigFile, os.R_OK):
        haveLiloConf = 0
    if not os.access(instRoot + yabootConfigFile, os.R_OK):
        haveYabootConf = 0
    if not os.access(instRoot + siloConfigFile, os.R_OK):
        haveSiloConf = 0
    if not os.access(instRoot + ziplConfigFile, os.R_OK):
        haveZiplConf = 0

    if haveGrubConf:
        bootDev = None
        for (fn, stanza) in [ ("/etc/sysconfig/grub", "boot="),
                              (grubConfigFile, "#boot=") ]:
            try:
                f = open(instRoot + fn, "r")
            except:
                continue
        
            # the following bits of code are straight from checkbootloader.py
            lines = f.readlines()
            f.close()
            for line in lines:
                if line.startswith(stanza):
                    bootDev = getBootDevString(line)
                    break
            if bootDev is not None:
                break

        if iutil.isEfi():
            return ("GRUB", bootDev)

        if bootDev is not None:
            block = getBootBlock(bootDev, instRoot, storage)
            # XXX I don't like this, but it's what the maintainer suggested :(
            if string.find(block, "GRUB") >= 0:
                return ("GRUB", bootDev)

    if haveLiloConf:
        f = open(instRoot + liloConfigFile, "r")
        lines = f.readlines()
        for line in lines:
            if line[0:5] == "boot=":
                bootDev = getBootDevString(line)
                break

        block = getBootBlock(bootDev, instRoot, storage)
        # this at least is well-defined
        if block[6:10] == "LILO":
            return ("LILO", bootDev)

    if haveYabootConf:
        f = open(instRoot + yabootConfigFile, "r")
        lines = f.readlines()
        for line in lines:
            if line[0:5] == "boot=":
                bootDev = getBootDevList(line)

        if bootDev:
                return ("YABOOT", bootDev)

    if haveSiloConf:
        bootDev = None
        # We've never done the /etc/sysconfig/silo thing, but maybe 
        # we should start...
        for (fn, stanza) in [ ("/etc/sysconfig/silo", "boot="),
                              (grubConfigFile, "#boot=") ]:
            try:
                f = open(instRoot + fn, "r")
            except:
                continue

            lines = f.readlines()
            f.close()
            for line in lines:
                if line.startswith(stanza):
                    bootDev = getBootDevString(line)
                    break
            if bootDev is not None:
                break

        if bootDev is not None:
            # XXX SILO sucks just like grub.
            if getDiskPart(bootDev, storage)[1] != 3:
                block = getBootBlock(bootDev, instRoot, storage, 1)
                if block[24:28] == "SILO":
                    return ("SILO", bootDev)

    if haveZiplConf:
        bootDev = None
        f = open(instRoot + ziplConfigFile, "r")
        lines = f.readlines()
        for line in lines:
            if line[0:7] == "target=":
                bootDev = getBootDevList(line)

        if bootDev:
            return ("ZIPL", bootDev)

    return (None, None)
コード例 #12
0
    def getScreen(self, anaconda):
        self.dispatch = anaconda.dispatch
        self.bl = anaconda.id.bootloader
        self.intf = anaconda.intf

        self.driveorder = self.bl.drivelist
        if len(self.driveorder) == 0:
            partitioned = anaconda.id.storage.partitioned
            disks = anaconda.id.storage.disks
            self.driveorder = [d.name for d in disks if d in partitioned]

        if self.bl.getPassword():
            self.usePass = 1
            self.password = self.bl.getPassword()
        else:
            self.usePass = 0
            self.password = None

        isBlack = False
        '''
        f = open("/root/isotype")
        lines = f.readlines()
        f.close()
    
        for x in lines:
            if x.find("vServer") != -1 or x.find("vCenter") != -1:
                isBlack = True
                break
        '''
        import fvi
        x = fvi.get_iso_type()
        if x.find("vServer") != -1 or x.find("vCenter") != -1:
            isBlack = True
                
        if isBlack:
            bgcolor = "#333333"
            fontcolor = "#e6e6e6"
        else:
            bgcolor = "#cccccc"
            fontcolor = "#333333"
            
        eboximage = gtk.EventBox()
        eboximage.set_app_paintable(True) 
        eboximage.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse(bgcolor))
        eboximage.set_size_request(1024,100)
        
        fixed = gtk.Fixed()
        i = gtk.Image()
        path = "/usr/share/anaconda/pixmaps/icon11_boot.png"
        i.set_from_file(path)
        i.show()
        fixed.put(i,45,15)
        label1 = gtk.Label()
        lstr = "<span font_desc=' 16' weight='bold' foreground='"+fontcolor+"'><b>引导程序:</b></span>"
        label1.set_markup(lstr)
        fixed.put(label1,160,23)
        label2 = gtk.Label()
        label2.set_markup("<span font_desc=' 11.5' weight='bold' foreground='"+fontcolor+"'><b>选择引导程序安装位置</b></span>")
        fixed.put(label2,160,58)
        eboximage.add(fixed) 
        eboximage.show_all()

        thebox = gtk.VBox(False,0)
        thebox.pack_start(eboximage,False,False,0)
        
        ###########################################################
        
        # make sure we get a valid device to say we're installing to
        if self.bl.getDevice() is not None:
            self.bldev = self.bl.getDevice()
        else:
            # we don't know what it is yet... if mbr is possible, we want
            # it, else we want the boot dev
            choices = anaconda.platform.bootloaderChoices(self.bl)
            if choices.has_key('mbr'):
                self.bldev = choices['mbr'][0]
            else:
                self.bldev = choices['boot'][0]
        ###########################################################
        boxall = gtk.VBox(False,0)
        
        hb = gtk.HBox(False, 12)
        """self.grubCB = gtk.CheckButton(_("_Install boot loader on /dev/%s.") %
                                      (self.bldev,))"""
        self.grubCB = gtk.CheckButton((u"在/dev/%s 中安装引导装载程序") %
                                      (self.bldev,))
        l = self.grubCB.get_children()[0]
        lstr = "<span  foreground='#333333'><b>"+l.get_text()+"</b></span>"
        l.set_markup(lstr)
            
        self.grubCB.set_active(not self.dispatch.stepInSkipList("instbootloader"))
        self.grubCB.connect("toggled", self.bootloaderChanged)
        hb.pack_start(self.grubCB, False)

        # no "Change device" button on EFI systems, since there should only
        # be one EFI System Partition available/usable
        self.deviceButton = None
        if not iutil.isEfi():
            self.deviceButton = gtk.Button(_(u"更换设备"))
            
            l = self.deviceButton.get_children()[0]
            lstr = "<span  foreground='#333333'><b>"+l.get_text()+"</b></span>"
            l.set_markup(lstr)
            
            self.deviceButton.connect("clicked", self._deviceChange, anaconda)
            hb.pack_start(self.deviceButton, False,False,32)

        boxall.pack_start(hb,False,False,0)
        #################################################################
        
        # control whether or not there's a boot loader password and what it is
        self.blpass = BootloaderPasswordWidget(anaconda, self.parent)
        boxall.pack_start(self.blpass.getWidget(),False,False,5)
        
        ###################################################################
        # configure the systems available to boot from the boot loader
        self.oslist = OSBootWidget(anaconda, self.parent)
        boxall.pack_start(self.oslist.getWidget(),True,True,10)
        
        fix = gtk.Fixed()
        fix.put(boxall,35,35)
        thebox.pack_start(fix,True,True,20)
        ######################################################################
        
        self.bootloaderChanged()
        """return thebox"""
        ####################################################################
        ebox = gtk.EventBox()
        ebox.add(thebox)
        ebox.set_app_paintable(True)
        ebox.set_border_width(0)
        ebox.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse("#e6e6e6"))
        return ebox
コード例 #13
0
def mountptchangeCB(widget, fstypecombo):
    if iutil.isEfi() and widget.get_children()[0].get_text() == "/boot/efi":
        fstypecombo.set_active_text(getFormat("efi").name)
コード例 #14
0
    label = gtk.Label(text)
    label.set_alignment(0.0, 0.5)
    label.set_property("use-underline", True)

    return label


defaultMountPoints = [
    '/', '/boot', '/home', '/tmp', '/usr', '/var', '/usr/local', '/opt'
]

if iutil.isS390():
    # Many s390 have 2G DASDs, we recomment putting /usr/share on its own DASD
    defaultMountPoints.insert(5, '/usr/share')

if iutil.isEfi():
    defaultMountPoints.insert(2, '/boot/efi')


def createMountPointCombo(request, excludeMountPoints=[]):
    mountCombo = gtk.combo_box_entry_new_text()

    mntptlist = []
    label = getattr(request.format, "label", None)
    if request.exists and label and label.startswith("/"):
        mntptlist.append(label)
        idx = 0

    for p in defaultMountPoints:
        if p in excludeMountPoints:
            continue
コード例 #15
0
def mountptchangeCB(widget, fstypecombo):
    if iutil.isEfi() and widget.get_children()[0].get_text() == "/boot/efi":
        fstypecombo.set_active_text(getFormat("efi").name)
コード例 #16
0
def createAlignedLabel(text):
    label = gtk.Label(text)
    label.set_alignment(0.0, 0.5)
    label.set_property("use-underline", True)

    return label

defaultMountPoints = ['/', '/boot', '/home', '/tmp', '/usr',
                      '/var', '/usr/local', '/opt']

if iutil.isS390():
    # Many s390 have 2G DASDs, we recomment putting /usr/share on its own DASD
    defaultMountPoints.insert(5, '/usr/share')

if iutil.isEfi():
    defaultMountPoints.insert(2, '/boot/efi')

def createMountPointCombo(request, excludeMountPoints=[]):
    mountCombo = gtk.combo_box_entry_new_text()

    mntptlist = []
    label = getattr(request.format, "label", None)
    if request.exists and label and label.startswith("/"):
        mntptlist.append(label)
        idx = 0

    for p in defaultMountPoints:
        if p in excludeMountPoints:
            continue
コード例 #17
0
ファイル: x86.py プロジェクト: 274914765/python
    def writeGrubConf(self, instRoot, bootDev, rootDev, defaultDev, kernelList,
                      chainList, grubTarget, grubPath, cfPath):

        bootDevs = self.getPhysicalDevices(bootDev.name)

        # XXX old config file should be read here for upgrade

        cf = "%s%s" % (instRoot, self.configfile)
        self.perms = 0600
        if os.access (cf, os.R_OK):
            self.perms = os.stat(cf)[0] & 0777
            os.rename(cf, cf + '.rpmsave')

        f = open(cf, "w+")

        f.write("# grub.conf generated by anaconda\n")
        f.write("#\n")
        f.write("# Note that you do not have to rerun grub "
                "after making changes to this file\n")

        if grubPath == "/grub":
            f.write("# NOTICE:  You have a /boot partition.  This means "
                    "that\n")
            f.write("#          all kernel and initrd paths are relative "
                    "to /boot/, eg.\n")
        else:
            f.write("# NOTICE:  You do not have a /boot partition.  "
                    "This means that\n")
            f.write("#          all kernel and initrd paths are relative "
                    "to /, eg.\n")

        f.write('#          root %s\n' % self.grubbyPartitionName(bootDevs[0]))
        f.write("#          kernel %svmlinuz-version ro root=%s\n" % (cfPath, rootDev.path))
        f.write("#          initrd %sinitrd-[generic-]version.img\n" % (cfPath))
        f.write("#boot=/dev/%s\n" % (grubTarget))

        if iutil.isEfi():
            from product import productName
            # Map the target device to the full EFI path
            if self.getEfiProductPath(productName):
                (n, pn) = getDiskPart(bootDevs[0], self.storage)
                f.write("device (%s) %s\n" % (self.grubbyDiskName(n), self.getEfiProductPath(productName)))

        # get the default image to boot... we have to walk and find it
        # since grub indexes by where it is in the config file
        if defaultDev.name == rootDev.name:
            default = 0
        else:
            # if the default isn't linux, it's the first thing in the
            # chain list
            default = len(kernelList)


        f.write('default=%s\n' % (default))
        f.write('timeout=%d\n' % (self.timeout or 0))

        if self.serial == 1:
            # grub the 0-based number of the serial console device
            unit = self.serialDevice[-1]
            
            # and we want to set the speed too
            speedend = 0
            for char in self.serialOptions:
                if char not in string.digits:
                    break
                speedend = speedend + 1
            if speedend != 0:
                speed = self.serialOptions[:speedend]
            else:
                # reasonable default
                speed = "9600"
                
            f.write("serial --unit=%s --speed=%s\n" %(unit, speed))
            f.write("terminal --timeout=%s serial console\n" % (self.timeout or 5))
        else:
            # we only want splashimage if they're not using a serial console
            if os.access("%s/boot/grub/splash.xpm.gz" %(instRoot,), os.R_OK):
                f.write('splashimage=%s%sgrub/splash.xpm.gz\n'
                        % (self.grubbyPartitionName(bootDevs[0]), cfPath))
                f.write("hiddenmenu\n")

            
        if self.password:
            f.write('password --encrypted %s\n' %(self.password))
        
        for (label, longlabel, version) in kernelList:
            kernelTag = "-" + version
            kernelFile = "%svmlinuz%s" % (cfPath, kernelTag)

            initrd = self.makeInitrd(kernelTag, instRoot)

            f.write('title %s (%s)\n' % (longlabel, version))
            f.write('\troot %s\n' % self.grubbyPartitionName(bootDevs[0]))

            realroot = " root=%s" % rootDev.fstabSpec

            if version.endswith("xen0") or (version.endswith("xen") and not os.path.exists("/proc/xen")):
                # hypervisor case
                sermap = { "ttyS0": "com1", "ttyS1": "com2",
                           "ttyS2": "com3", "ttyS3": "com4" }
                if self.serial and sermap.has_key(self.serialDevice) and \
                       self.serialOptions:
                    hvs = "%s=%s" %(sermap[self.serialDevice],
                                    self.serialOptions)
                else:
                    hvs = ""
                if version.endswith("xen0"):
                    hvFile = "%sxen.gz-%s %s" %(cfPath,
                                                version.replace("xen0", ""),
                                                hvs)
                else:
                    hvFile = "%sxen.gz-%s %s" %(cfPath,
                                                version.replace("xen", ""),
                                                hvs)
                f.write('\tkernel %s\n' %(hvFile,))
                f.write('\tmodule %s ro%s' %(kernelFile, realroot))
                if self.args.get():
                    f.write(' %s' % self.args.get())
                f.write('\n')

                if initrd:
                    f.write('\tmodule %s%s\n' % (cfPath, initrd))
            else: # normal kernel
                if self.trusted_boot:
                    f.write('\tkernel %stboot.gz logging=vga,serial,memory\n' % (cfPath))
                    f.write('\tmodule %s ro%s intel_iommu=on amd_iommu=on' % (kernelFile, realroot))
                    if self.args.get():
                        f.write(' %s' % self.args.get())
                    f.write('\n')

                    if initrd:
                        f.write('\tmodule %s%s\n' % (cfPath, initrd))
                else:
                    f.write('\tkernel %s ro%s' % (kernelFile, realroot))
                    if self.args.get():
                        f.write(' %s' % self.args.get())
                    f.write('\n')

                    if initrd:
                        f.write('\tinitrd %s%s\n' % (cfPath, initrd))

        for (label, longlabel, device) in chainList:
            if ((not longlabel) or (longlabel == "")):
                continue
            f.write('title %s\n' % (longlabel))
            f.write('\trootnoverify %s\n' % self.grubbyPartitionName(device))
#            f.write('\tmakeactive\n')
            f.write('\tchainloader +1')
            f.write('\n')

        f.close()

        if not "/efi/" in cf:
            os.chmod(cf, self.perms)

        try:
            # make symlink for menu.lst (default config file name)
            menulst = "%s%s/menu.lst" % (instRoot, self.configdir)
            if os.access (menulst, os.R_OK):
                os.rename(menulst, menulst + ".rpmsave")
            os.symlink("./grub.conf", menulst)
        except:
            pass

        try:
            # make symlink for /etc/grub.conf (config files belong in /etc)
            etcgrub = "%s%s" % (instRoot, "/etc/grub.conf")
            if os.access (etcgrub, os.R_OK):
                os.rename(etcgrub, etcgrub + ".rpmsave")
            os.symlink(".." + self.configfile, etcgrub)
        except:
            pass
コード例 #18
0
ファイル: x86.py プロジェクト: icomfort/anaconda
    def installGrub(self, instRoot, bootDev, grubTarget, grubPath, cfPath):
        if iutil.isEfi():
            return efiBootloaderInfo.installGrub(self, instRoot, bootDev,
                                                 grubTarget, grubPath, cfPath)

        args = "--stage2=/boot/grub/stage2 "

        stage1Devs = self.getPhysicalDevices(grubTarget)
        bootDevs = self.getPhysicalDevices(bootDev.name)

        installs = [(None, self.grubbyPartitionName(stage1Devs[0]),
                     self.grubbyPartitionName(bootDevs[0]))]

        if bootDev.type == "mdarray":

            matches = self.matchingBootTargets(stage1Devs, bootDevs)

            # If the stage1 target disk contains member of boot raid array (mbr
            # case) or stage1 target partition is member of boot raid array
            # (partition case)
            if matches:
                # 1) install stage1 on target disk/partiton
                stage1Dev, mdMemberBootPart = matches[0]
                installs = [(None, self.grubbyPartitionName(stage1Dev),
                             self.grubbyPartitionName(mdMemberBootPart))]
                firstMdMemberDiskGrubbyName = self.grubbyDiskName(
                    getDiskPart(mdMemberBootPart, self.storage)[0])

                # 2) and install stage1 on other members' disks/partitions too
                # NOTES:
                # - the goal is to be able to boot after a members' disk removal
                # - so we have to use grub device names as if after removal
                #   (i.e. the same disk name (e.g. (hd0)) for both member disks)
                # - if member partitions have different numbers only removal of
                #   specific one of members will work because stage2 containing
                #   reference to config file is shared and therefore can contain
                #   only one value

                # if target is mbr, we want to install also to mbr of other
                # members, so extend the matching list
                matches = self.addMemberMbrs(matches, bootDevs)
                for stage1Target, mdMemberBootPart in matches[1:]:
                    # prepare special device mapping corresponding to member removal
                    mdMemberBootDisk = getDiskPart(mdMemberBootPart,
                                                   self.storage)[0]
                    # It can happen due to ks --driveorder option, but is it ok?
                    if not mdMemberBootDisk in self.drivelist:
                        continue
                    mdRaidDeviceRemap = (firstMdMemberDiskGrubbyName,
                                         mdMemberBootDisk)

                    stage1TargetGrubbyName = self.grubbyPartitionName(
                        stage1Target)
                    rootPartGrubbyName = self.grubbyPartitionName(
                        mdMemberBootPart)

                    # now replace grub disk name part according to special device
                    # mapping
                    old = self.grubbyDiskName(mdMemberBootDisk).strip('() ')
                    new = firstMdMemberDiskGrubbyName.strip('() ')
                    rootPartGrubbyName = rootPartGrubbyName.replace(old, new)
                    stage1TargetGrubbyName = stage1TargetGrubbyName.replace(
                        old, new)

                    installs.append((mdRaidDeviceRemap, stage1TargetGrubbyName,
                                     rootPartGrubbyName))

                # This is needed for case when /boot member partitions have
                # different numbers. Shared stage2 can contain only one reference
                # to grub.conf file, so let's ensure that it is reference to partition
                # on disk which we will boot from - that is, install grub to
                # this disk as last so that its reference is not overwritten.
                installs.reverse()

        cmds = []
        for mdRaidDeviceRemap, stage1Target, rootPart in installs:
            if mdRaidDeviceRemap:
                cmd = "device (%s) /dev/%s\n" % tuple(mdRaidDeviceRemap)
            else:
                cmd = ''
            cmd += "root %s\n" % (rootPart, )
            cmd += "install %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \
                (args, grubPath, stage1Target, grubPath, rootPart, grubPath)
            cmds.append(cmd)
        return self.runGrubInstall(instRoot, bootDev.name, cmds, cfPath)
コード例 #19
0
class Platform(object):
    """Platform

       A class containing platform-specific information and methods for use
       during installation.  The intent is to eventually encapsulate all the
       architecture quirks in one place to avoid lots of platform checks
       throughout anaconda."""
    _bootFSTypes = ["ext3"]
    _disklabel_types = ["msdos"]
    _isEfi = iutil.isEfi()
    _minimumSector = 0
    _packages = []
    _supportsLvmBoot = False
    _supportsMdRaidBoot = False
    _minBootPartSize = 50
    _maxBootPartSize = 0

    def __init__(self, anaconda):
        """Creates a new Platform object.  This is basically an abstract class.
           You should instead use one of the platform-specific classes as
           returned by getPlatform below.  Not all subclasses need to provide
           all the methods in this class."""
        self.anaconda = anaconda

    def _mntDict(self):
        """Return a dictionary mapping mount points to devices."""
        ret = {}
        for device in [
                d for d in self.anaconda.id.storage.devices
                if d.format.mountable
        ]:
            ret[device.format.mountpoint] = device

        return ret

    def bootDevice(self):
        """Return the device where /boot is mounted."""
        if self.__class__ is Platform:
            raise NotImplementedError(
                "bootDevice not implemented for this platform")

        mntDict = self._mntDict()
        return mntDict.get("/boot", mntDict.get("/"))

    @property
    def defaultBootFSType(self):
        """Return the default filesystem type for the boot partition."""
        return self._bootFSTypes[0]

    @property
    def bootFSTypes(self):
        """Return a list of all valid filesystem types for the boot partition."""
        return self._bootFSTypes

    def bootloaderChoices(self, bl):
        """Return the default list of places to install the bootloader.
           This is returned as a dictionary of locations to (device, identifier)
           tuples.  If there is no boot device, an empty dictionary is
           returned."""
        if self.__class__ is Platform:
            raise NotImplementedError(
                "bootloaderChoices not implemented for this platform")

        bootDev = self.bootDevice()
        ret = {}

        if not bootDev:
            return ret

        if bootDev.type == "mdarray":
            ret["boot"] = (bootDev.name, N_("RAID Device"))
            ret["mbr"] = (bl.drivelist[0], N_("Master Boot Record (MBR)"))
        else:
            ret["boot"] = (bootDev.name, N_("First sector of boot partition"))
            ret["mbr"] = (bl.drivelist[0], N_("Master Boot Record (MBR)"))

        return ret

    def checkBootRequest(self, req):
        """Perform an architecture-specific check on the boot device.  Not all
           platforms may need to do any checks.  Returns a list of errors if
           there is a problem, or [] otherwise."""
        errors = []

        if not req:
            return [_("You have not created a bootable partition.")]

        # most arches can't have boot on a logical volume
        if req.type == "lvmlv" and not self.supportsLvmBoot:
            errors.append(
                _("Bootable partitions cannot be on a logical volume."))

        # most arches can't have boot on RAID
        if req.type == "mdarray":
            if not self.supportsMdRaidBoot:
                errors.append(
                    _("Bootable partitions cannot be on a RAID device."))
            elif req.level != 1:
                errors.append(
                    _("Bootable partitions can only be on RAID1 devices."))

        # Make sure /boot is on a supported FS type.  This prevents crazy
        # things like boot on vfat.
        if not req.format.bootable or \
           (getattr(req.format, "mountpoint", None) == "/boot" and
            req.format.type not in self.bootFSTypes):
            errors.append(
                _("Bootable partitions cannot be on an %s filesystem.") %
                req.format.type)

        if req.type == "luks/dm-crypt":
            # Handle encrypted boot on a partition.
            errors.append(
                _("Bootable partitions cannot be on an encrypted block device")
            )
        else:
            # Handle encrypted boot on more complicated devices.
            for dev in filter(lambda d: d.type == "luks/dm-crypt",
                              self.anaconda.id.storage.devices):
                if req in self.anaconda.id.storage.deviceDeps(dev):
                    errors.append(
                        _("Bootable partitions cannot be on an encrypted block device"
                          ))

        return errors

    @property
    def diskLabelTypes(self):
        """A list of valid disklabel types for this architecture."""
        return self._disklabel_types

    @property
    def defaultDiskLabelType(self):
        """The default disklabel type for this architecture."""
        return self.diskLabelTypes[0]

    def requiredDiskLabelType(self, device_type):
        return None

    def bestDiskLabelType(self, device):
        """The best disklabel type for the specified device."""
        # if there's a required type for this device type, use that
        labelType = self.requiredDiskLabelType(device.partedDevice.type)
        log.debug("required disklabel type for %s (%s) is %s" %
                  (device.name, device.partedDevice.type, labelType))
        if not labelType:
            # otherwise, use the first supported type for this platform
            # that is large enough to address the whole device
            labelType = self.defaultDiskLabelType
            log.debug("default disklabel type for %s is %s" %
                      (device.name, labelType))
            for lt in self.diskLabelTypes:
                l = parted.freshDisk(device=device.partedDevice, ty=lt)
                if l.maxPartitionStartSector > device.partedDevice.length:
                    labelType = lt
                    log.debug("selecting %s disklabel for %s based on size" %
                              (labelType, device.name))
                    break

        return labelType

    @property
    def isEfi(self):
        return self._isEfi

    @property
    def minimumSector(self, disk):
        """Return the minimum starting sector for the provided disk."""
        return self._minimumSector

    @property
    def packages(self):
        if flags.cmdline.get('fips', None) == '1':
            return self._packages + ['dracut-fips']
        return self._packages

    def setDefaultPartitioning(self):
        """Return the default platform-specific partitioning information."""
        return [
            PartSpec(mountpoint="/boot",
                     fstype=self.defaultBootFSType,
                     size=500,
                     weight=self.weight(mountpoint="/boot"))
        ]

    @property
    def supportsLvmBoot(self):
        """Does the platform support /boot on LVM logical volume?"""
        return self._supportsLvmBoot

    @property
    def supportsMdRaidBoot(self):
        """Does the platform support /boot on MD RAID?"""
        return self._supportsMdRaidBoot

    @property
    def minBootPartSize(self):
        return self._minBootPartSize

    @property
    def maxBootPartSize(self):
        return self._maxBootPartSize

    def validBootPartSize(self, size):
        """ Is the given size (in MB) acceptable for a boot device? """
        if not isinstance(size, int) and not isinstance(size, float):
            return False

        return ((not self.minBootPartSize or size >= self.minBootPartSize)
                and (not self.maxBootPartSize or size <= self.maxBootPartSize))

    def weight(self, fstype=None, mountpoint=None):
        """ Given an fstype (as a string) or a mountpoint, return an integer
            for the base sorting weight.  This is used to modify the sort
            algorithm for partition requests, mainly to make sure bootable
            partitions and /boot are placed where they need to be."""
        if mountpoint and mountpoint == "/boot":
            return 2000
        else:
            return 0
コード例 #20
0
ファイル: x86.py プロジェクト: icomfort/anaconda
    def writeGrubConf(self, instRoot, bootDev, rootDev, defaultDev, kernelList,
                      chainList, grubTarget, grubPath, cfPath):

        bootDevs = self.getPhysicalDevices(bootDev.name)

        # XXX old config file should be read here for upgrade

        cf = "%s%s" % (instRoot, self.configfile)
        self.perms = 0600
        if os.access(cf, os.R_OK):
            self.perms = os.stat(cf)[0] & 0777
            os.rename(cf, cf + '.rpmsave')

        f = open(cf, "w+")

        f.write("# grub.conf generated by anaconda\n")
        f.write("#\n")
        f.write("# Note that you do not have to rerun grub "
                "after making changes to this file\n")

        if grubPath == "/grub":
            f.write("# NOTICE:  You have a /boot partition.  This means "
                    "that\n")
            f.write("#          all kernel and initrd paths are relative "
                    "to /boot/, eg.\n")
        else:
            f.write("# NOTICE:  You do not have a /boot partition.  "
                    "This means that\n")
            f.write("#          all kernel and initrd paths are relative "
                    "to /, eg.\n")

        f.write('#          root %s\n' % self.grubbyPartitionName(bootDevs[0]))
        f.write("#          kernel %svmlinuz-version ro root=%s\n" %
                (cfPath, rootDev.path))
        f.write("#          initrd %sinitrd-[generic-]version.img\n" %
                (cfPath))
        f.write("#boot=/dev/%s\n" % (grubTarget))

        if iutil.isEfi():
            from product import productName
            # Map the target device to the full EFI path
            if self.getEfiProductPath(productName):
                (n, pn) = getDiskPart(bootDevs[0], self.storage)
                f.write("device (%s) %s\n" %
                        (self.grubbyDiskName(n),
                         self.getEfiProductPath(productName)))

        # get the default image to boot... we have to walk and find it
        # since grub indexes by where it is in the config file
        if defaultDev.name == rootDev.name:
            default = 0
        else:
            # if the default isn't linux, it's the first thing in the
            # chain list
            default = len(kernelList)

        f.write('default=%s\n' % (default))
        f.write('timeout=%d\n' % (self.timeout or 0))

        if self.serial == 1:
            # grub the 0-based number of the serial console device
            unit = self.serialDevice[-1]

            # and we want to set the speed too
            speedend = 0
            for char in self.serialOptions:
                if char not in string.digits:
                    break
                speedend = speedend + 1
            if speedend != 0:
                speed = self.serialOptions[:speedend]
            else:
                # reasonable default
                speed = "9600"

            f.write("serial --unit=%s --speed=%s\n" % (unit, speed))
            f.write("terminal --timeout=%s serial console\n" %
                    (self.timeout or 5))
        else:
            # we only want splashimage if they're not using a serial console
            if os.access("%s/boot/grub/splash.xpm.gz" % (instRoot, ), os.R_OK):
                f.write('splashimage=%s%sgrub/splash.xpm.gz\n' %
                        (self.grubbyPartitionName(bootDevs[0]), cfPath))
                f.write("hiddenmenu\n")

        if self.password:
            f.write('password --encrypted %s\n' % (self.password))

        for (label, longlabel, version) in kernelList:
            kernelTag = "-" + version
            kernelFile = "%svmlinuz%s" % (cfPath, kernelTag)

            initrd = self.makeInitrd(kernelTag, instRoot)

            f.write('title %s (%s)\n' % (longlabel, version))
            f.write('\troot %s\n' % self.grubbyPartitionName(bootDevs[0]))

            realroot = " root=%s" % rootDev.fstabSpec

            if version.endswith("xen0") or (version.endswith("xen") and
                                            not os.path.exists("/proc/xen")):
                # hypervisor case
                sermap = {
                    "ttyS0": "com1",
                    "ttyS1": "com2",
                    "ttyS2": "com3",
                    "ttyS3": "com4"
                }
                if self.serial and sermap.has_key(self.serialDevice) and \
                       self.serialOptions:
                    hvs = "%s=%s" % (sermap[self.serialDevice],
                                     self.serialOptions)
                else:
                    hvs = ""
                if version.endswith("xen0"):
                    hvFile = "%sxen.gz-%s %s" % (
                        cfPath, version.replace("xen0", ""), hvs)
                else:
                    hvFile = "%sxen.gz-%s %s" % (
                        cfPath, version.replace("xen", ""), hvs)
                f.write('\tkernel %s\n' % (hvFile, ))
                f.write('\tmodule %s ro%s' % (kernelFile, realroot))
                if self.args.get():
                    f.write(' %s' % self.args.get())
                f.write('\n')

                if initrd:
                    f.write('\tmodule %s%s\n' % (cfPath, initrd))
            else:  # normal kernel
                f.write('\tkernel %s ro%s' % (kernelFile, realroot))
                if self.args.get():
                    f.write(' %s' % self.args.get())
                f.write('\n')

                if initrd:
                    f.write('\tinitrd %s%s\n' % (cfPath, initrd))

        for (label, longlabel, device) in chainList:
            if ((not longlabel) or (longlabel == "")):
                continue
            f.write('title %s\n' % (longlabel))
            f.write('\trootnoverify %s\n' % self.grubbyPartitionName(device))
            #            f.write('\tmakeactive\n')
            f.write('\tchainloader +1')
            f.write('\n')

        f.close()

        if not "/efi/" in cf:
            os.chmod(cf, self.perms)

        try:
            # make symlink for menu.lst (default config file name)
            menulst = "%s%s/menu.lst" % (instRoot, self.configdir)
            if os.access(menulst, os.R_OK):
                os.rename(menulst, menulst + ".rpmsave")
            os.symlink("./grub.conf", menulst)
        except:
            pass

        try:
            # make symlink for /etc/grub.conf (config files belong in /etc)
            etcgrub = "%s%s" % (instRoot, "/etc/grub.conf")
            if os.access(etcgrub, os.R_OK):
                os.rename(etcgrub, etcgrub + ".rpmsave")
            os.symlink(".." + self.configfile, etcgrub)
        except:
            pass
コード例 #21
0
    def setSteps(self, anaconda):
        dispatch = anaconda.dispatch
	dispatch.schedule_steps(
		 "language",
		 "keyboard",
                 "filtertype",
                 "filter",
                 "storageinit",
                 "findrootparts",
		 "betanag",
                 "cleardiskssel",
                 "parttype",
                 "autopartitionexecute",
		 "storagedone",
		 "bootloader",
		 "network",
		 "timezone",
		 "accounts",
                 "reposetup",
                 "basepkgsel",
		 "tasksel",
		 "postselection",
                 "reipl",
		 "install",
		 "enablefilesystems",
                 "setuptime",
                 "preinstallconfig",
		 "installpackages",
                 "postinstallconfig",
		 "writeconfig",
                 "firstboot",
		 "instbootloader",
                 "dopostaction",
                 "postscripts",
		 "writeksconfig",
                 "methodcomplete",
                 "copylogs",
                 "setfilecon",
		 "complete"
		)

	if isFinal:
	    dispatch.skip_steps("betanag")

        if iutil.isEfi() or not iutil.isX86():
            dispatch.skip_steps("bootloader")

        # allow backends to disable interactive package selection
        if not anaconda.backend.supportsPackageSelection:
            dispatch.skip_steps("tasksel")
            dispatch.skip_steps("group-selection")

        # allow install classes to turn off the upgrade
        if not self.showUpgrade or not anaconda.backend.supportsUpgrades:
            dispatch.skip_steps("findrootparts")

        # 'noupgrade' can be used on the command line to force not looking
        # for partitions to upgrade.  useful in some cases...
        if flags.cmdline.has_key("noupgrade"):
            dispatch.skip_steps("findrootparts")

        # upgrade will also always force looking for an upgrade.
        if flags.cmdline.has_key("upgrade"):
            dispatch.request_steps("findrootparts")

        # allow interface backends to skip certain steps.
        map(lambda s: dispatch.skip_steps(s), anaconda.intf.unsupported_steps())
コード例 #22
0
def mountptchangeCB(widget, fstypecombo):
    if iutil.isEfi() and widget.get_children()[0].get_text() == "/boot/efi":
        fstypecombo.set_active_text(getFormat("efi").name)
    if widget.get_children()[0].get_text() == "/boot":
        fstypecombo.set_active_text(get_default_filesystem_type(boot=True))