def getScreen(self, anaconda): self.dispatch = anaconda.dispatch self.bl = anaconda.id.bootloader (self.type, self.bootDev) = \ checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath) self.update_radio = gtk.RadioButton(None, _("_Update boot loader configuration")) updatestr = _("This will update your current boot loader.") if self.type is not None and self.bootDev is not None: current = _("The installer has detected the %s boot loader " "currently installed on %s.") % (self.type, self.bootDev) self.update_label = gtk.Label("%s %s" % (updatestr, _("This is the recommended option."))) self.update_radio.set_active(False) update = 1 else: current = _("The installer is unable to detect the boot loader " "currently in use on your system.") self.update_label = gtk.Label("%s" % (updatestr,)) self.update_radio.set_sensitive(False) self.update_label.set_sensitive(False) update = 0 self.newbl_radio = gtk.RadioButton(self.update_radio, _("_Create new boot loader " "configuration")) self.newbl_label = gtk.Label(_("This will let you create a " "new boot loader configuration. If " "you wish to switch boot loaders, you " "should choose this.")) self.newbl_radio.set_active(False) self.nobl_radio = gtk.RadioButton(self.update_radio, _("_Skip boot loader updating")) self.nobl_label = gtk.Label(_("This will make no changes to boot " "loader configuration. If you are " "using a third party boot loader, you " "should choose this.")) self.nobl_radio.set_active(False) for label in [self.update_label, self.nobl_label, self.newbl_label]: label.set_alignment(0.8, 0) label.set_size_request(275, -1) label.set_line_wrap(True) str = _("What would you like to do?") # if they have one, the default is to update, otherwise the # default is to not touch anything if update == 1: default = self.update_radio else: default = self.nobl_radio if not self.dispatch.stepInSkipList("bootloader"): self.newbl_radio.set_active(True) elif self.dispatch.stepInSkipList("instbootloader"): self.nobl_radio.set_active(True) else: default.set_active(True) box = gtk.VBox(False, 5) label = gtk.Label(current) label.set_line_wrap(True) label.set_alignment(0.5, 0.0) label.set_size_request(300, -1) label2 = gtk.Label(str) label2.set_line_wrap(True) label2.set_alignment(0.5, 0.0) label2.set_size_request(300, -1) box.pack_start(label, False) box.pack_start(label2, False, padding = 10) box.pack_start(self.update_radio, False) box.pack_start(self.update_label, False) box.pack_start(self.nobl_radio, False) box.pack_start(self.nobl_label, False) box.pack_start(self.newbl_radio, False) box.pack_start(self.newbl_label, False) a = gtk.Alignment(0.2, 0.1) a.add(box) return a
def writeBootloader(intf, instRoot, fsset, bl, langs, comps): def dosync(): isys.sync() isys.sync() isys.sync() justConfigFile = not flags.setupFilesystems if bl.defaultDevice == -1: return # now make the upgrade stuff work for kickstart too. ick. if bl.kickstart == 1 and bl.doUpgradeOnly == 1: import checkbootloader (bootType, theDev) = checkbootloader.getBootloaderTypeAndBoot(instRoot) bl.doUpgradeonly = 1 if bootType == "GRUB": bl.useGrubVal = 1 bl.setDevice(theDev) elif bootType == "LILO": bl.useGrubVal = 0 bl.setDevice(theDev) else: bl.doUpgradeOnly = 0 w = intf.waitWindow(_("Bootloader"), _("Installing bootloader...")) kernelList = [] otherList = [] rootDev = fsset.getEntryByMountPoint('/').device.getDevice() defaultDev = bl.images.getDefault() kernelLabel = None kernelLongLabel = None for (dev, (label, longlabel, type)) in bl.images.getImages().items(): if dev == rootDev: kernelLabel = label kernelLongLabel = longlabel elif dev == defaultDev: otherList = [(label, longlabel, dev)] + otherList else: otherList.append((label, longlabel, dev)) if kernelLabel is None: log("unable to find default image, bailing") return plainLabelUsed = 0 for (version, nick) in comps.kernelVersionList(): if plainLabelUsed: kernelList.append(("%s-%s" %(kernelLabel, nick), "%s-%s" %(kernelLongLabel, nick), version)) else: kernelList.append((kernelLabel, kernelLongLabel, version)) plainLabelUsed = 1 # FIXME: blah, exec-shield breaks grub. turn it off for now if os.access("/proc/sys/kernel/exec-shield", os.W_OK): f = open("/proc/sys/kernel/exec-shield", "w") f.write("0") f.close() dosync() try: bl.write(instRoot, fsset, bl, langs, kernelList, otherList, defaultDev, justConfigFile, intf) w.pop() except BootyNoKernelWarning: w.pop() if intf: intf.messageWindow(_("Warning"), _("No kernel packages were installed on your " "system. Your boot loader configuration " "will not be changed.")) dosync()
def getScreen(self, dispatch, bl): self.dispatch = dispatch self.bl = bl self.intf = dispatch.intf (self.type, self.bootDev) = \ checkbootloader.getBootloaderTypeAndBoot(dispatch.instPath) self.update_radio = gtk.RadioButton( None, _("_Update boot loader configuration")) updatestr = _("This will update your current boot loader.") if self.type is not None and self.bootDev is not None: current = _( "The installer has detected the %s boot loader " "currently installed on %s.") % (self.type, self.bootDev) self.update_label = gtk.Label( "%s %s" % (updatestr, _("This is the recommended option."))) self.update_radio.set_active(gtk.FALSE) update = 1 else: current = _("The installer is unable to detect the boot loader " "currently in use on your system.") self.update_label = gtk.Label("%s" % (updatestr, )) self.update_radio.set_sensitive(gtk.FALSE) self.update_label.set_sensitive(gtk.FALSE) update = 0 self.newbl_radio = gtk.RadioButton( self.update_radio, _("_Create new boot loader " "configuration")) self.newbl_label = gtk.Label( _("This will let you create a " "new boot loader configuration. If " "you wish to switch boot loaders, you " "should choose this.")) self.newbl_radio.set_active(gtk.FALSE) self.nobl_radio = gtk.RadioButton(self.update_radio, _("_Skip boot loader updating")) self.nobl_label = gtk.Label( _("This will make no changes to boot " "loader configuration. If you are " "using a third party boot loader, you " "should choose this.")) self.nobl_radio.set_active(gtk.FALSE) for label in [self.update_label, self.nobl_label, self.newbl_label]: label.set_alignment(0.8, 0) label.set_size_request(275, -1) label.set_line_wrap(gtk.TRUE) str = _("What would you like to do?") # if they have one, the default is to update, otherwise the # default is to not touch anything if update == 1: default = self.update_radio else: default = self.nobl_radio if not dispatch.stepInSkipList("bootloader"): self.newbl_radio.set_active(gtk.TRUE) elif dispatch.stepInSkipList("instbootloader"): self.nobl_radio.set_active(gtk.TRUE) else: default.set_active(gtk.TRUE) box = gtk.VBox(gtk.FALSE, 5) label = gtk.Label(current) label.set_line_wrap(gtk.TRUE) label.set_alignment(0.5, 0.0) label.set_size_request(300, -1) label2 = gtk.Label(str) label2.set_line_wrap(gtk.TRUE) label2.set_alignment(0.5, 0.0) label2.set_size_request(300, -1) box.pack_start(label, gtk.FALSE) box.pack_start(label2, gtk.FALSE, padding=10) box.pack_start(self.update_radio, gtk.FALSE) box.pack_start(self.update_label, gtk.FALSE) box.pack_start(self.nobl_radio, gtk.FALSE) box.pack_start(self.nobl_label, gtk.FALSE) box.pack_start(self.newbl_radio, gtk.FALSE) box.pack_start(self.newbl_label, gtk.FALSE) a = gtk.Alignment(0.2, 0.1) a.add(box) return a
def writeBootloader(anaconda): def dosync(): isys.sync() isys.sync() isys.sync() justConfigFile = not flags.setupFilesystems if anaconda.id.bootloader.defaultDevice == -1: return # now make the upgrade stuff work for kickstart too. ick. if anaconda.isKickstart and anaconda.id.bootloader.doUpgradeOnly: import checkbootloader (bootType, theDev) = checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath) anaconda.id.bootloader.doUpgradeonly = 1 if bootType == "GRUB": anaconda.id.bootloader.useGrubVal = 1 anaconda.id.bootloader.setDevice(theDev) else: anaconda.id.bootloader.doUpgradeOnly = 0 # We don't need to let the user know if we're just doing the bootloader. if not justConfigFile: w = anaconda.intf.waitWindow(_("Bootloader"), _("Installing bootloader...")) kernelList = [] otherList = [] root = anaconda.id.fsset.getEntryByMountPoint('/') if root: rootDev = root.device.getDevice() else: rootDev = None kernelLabel = None kernelLongLabel = None def rectifyLuksName(anaconda, name): if name is not None and name.startswith('mapper/luks-'): try: newname = anaconda.id.partitions.encryptedDevices.get(name[12:]) if newname is None: for luksdev in anaconda.id.partitions.encryptedDevices.values(): if os.path.basename(luksdev.getDevice(encrypted=1)) == name[12:]: newname = luksdev break name = newname.getDevice() except: pass return name defaultDev = anaconda.id.bootloader.images.getDefault() defaultDev = rectifyLuksName(anaconda, defaultDev) for (dev, (label, longlabel, type)) in anaconda.id.bootloader.images.getImages().items(): dev = rectifyLuksName(anaconda, dev) if (dev == rootDev) or (rootDev is None and kernelLabel is None): kernelLabel = label kernelLongLabel = longlabel elif dev == defaultDev: otherList = [(label, longlabel, dev)] + otherList else: otherList.append((label, longlabel, dev)) if kernelLabel is None and not flags.livecd: # FIXME log.error("unable to find default image, bailing") if not justConfigFile: w.pop() return plainLabelUsed = 0 defkern = "kernel" backendKernelList = anaconda.backend.kernelVersionList() if iutil.inXen(): kernel_rank = {'xenU':1, 'xen':2} # sort based on this ranking backendKernelList.sort(key=lambda (v,a,n): kernel_rank.get(n,9)) for (version, arch, nick) in backendKernelList: if plainLabelUsed: kernelList.append(("%s-%s" %(kernelLabel, nick), "%s-%s" %(kernelLongLabel, nick), version)) else: kernelList.append((kernelLabel, kernelLongLabel, version)) if nick in ("hypervisor", "guest"): # XXX: *sigh* inconsistent defkern = "kernel-xen-%s" %(nick,) elif nick != "base": defkern = "kernel-%s" %(nick,) plainLabelUsed = 1 f = open(anaconda.rootPath + "/etc/sysconfig/kernel", "w+") f.write("# UPDATEDEFAULT specifies if new-kernel-pkg should make\n" "# new kernels the default\n") # only update the default if we're setting the default to linux (#156678) if rootDev == defaultDev: f.write("UPDATEDEFAULT=yes\n") else: f.write("UPDATEDEFAULT=no\n") f.write("\n") f.write("# DEFAULTKERNEL specifies the default kernel package type\n") f.write("DEFAULTKERNEL=%s\n" %(defkern,)) f.close() dosync() try: anaconda.id.bootloader.write(anaconda.rootPath, anaconda.id.fsset, anaconda.id.bootloader, anaconda.id.instLanguage, kernelList, otherList, defaultDev, justConfigFile, anaconda.intf) if not justConfigFile: w.pop() except bootloaderInfo.BootyNoKernelWarning: if not justConfigFile: w.pop() if anaconda.intf: anaconda.intf.messageWindow(_("Warning"), _("No kernel packages were installed on your " "system. Your boot loader configuration " "will not be changed.")) dosync()
def __call__(self, screen, anaconda): self.dispatch = anaconda.dispatch self.bl = anaconda.id.bootloader (self.type, self.bootDev) = \ checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath) blradio = RadioGroup() (update, newbl, nobl) = (0, 0, 0) if not self.dispatch.stepInSkipList("bootloader"): newbl = 1 elif self.dispatch.stepInSkipList("instbootloader"): nobl = 1 else: if self.type is not None and self.bootDev is not None: update = 1 else: nobl = 1 if self.type is not None and self.bootDev is not None: t = TextboxReflowed(53, _("The installer has detected the %s boot " "loader currently installed on %s.") % (self.type, self.bootDev)) self.update_radio = blradio.add(_("Update boot loader configuration"), "update", update) else: t = TextboxReflowed(53, _("The installer is unable to detect the boot loader " "currently in use on your system.")) self.update_radio = blradio.add(_("Update boot loader configuration"), "update", update) self.update_radio.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_SET) self.nobl_radio = blradio.add(_("Skip boot loader updating"), "nobl", nobl) self.newbl_radio = blradio.add(_("Create new boot loader " "configuration"), "newbl", newbl) buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON]) grid = GridFormHelp(screen, _("Upgrade Boot Loader Configuration"), "bl-upgrade", 1, 5) grid.add(t, 0, 0, (0,0,0,1)) grid.add(self.update_radio, 0, 1, (0,0,0,0)) grid.add(self.nobl_radio, 0, 2, (0,0,0,0)) grid.add(self.newbl_radio, 0, 3, (0,0,0,1)) grid.add(buttons, 0, 4, growx = 1) while 1: result = grid.run() button = buttons.buttonPressed(result) if button == TEXT_BACK_CHECK: screen.popWindow() return INSTALL_BACK if blradio.getSelection() == "nobl": self.dispatch.skipStep("bootloadersetup", skip = 1) self.dispatch.skipStep("bootloader", skip = 1) self.dispatch.skipStep("bootloaderadvanced", skip = 1) self.dispatch.skipStep("instbootloader", skip = 1) elif blradio.getSelection() == "newbl": self.dispatch.skipStep("bootloadersetup", skip = 0) self.dispatch.skipStep("bootloader", skip = 0) self.dispatch.skipStep("bootloaderadvanced", skip = 0) self.dispatch.skipStep("instbootloader", skip = 0) self.bl.doUpgradeOnly = 0 else: self.dispatch.skipStep("bootloadersetup", skip = 0) self.dispatch.skipStep("bootloader", skip = 1) self.dispatch.skipStep("bootloaderadvanced", skip = 1) self.dispatch.skipStep("instbootloader", skip = 0) self.bl.doUpgradeOnly = 1 if self.type == "GRUB": self.bl.useGrubVal = 1 else: self.bl.useGrubVal = 0 self.bl.setDevice(self.bootDev) screen.popWindow() return INSTALL_OK
def writeBootloader(anaconda): def dosync(): isys.sync() isys.sync() isys.sync() justConfigFile = not flags.setupFilesystems if anaconda.id.bootloader.defaultDevice == -1: return # now make the upgrade stuff work for kickstart too. ick. if anaconda.isKickstart and anaconda.id.bootloader.doUpgradeOnly: import checkbootloader (bootType, theDev) = checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath) anaconda.id.bootloader.doUpgradeonly = 1 if bootType == "GRUB": anaconda.id.bootloader.useGrubVal = 1 anaconda.id.bootloader.setDevice(theDev) else: anaconda.id.bootloader.doUpgradeOnly = 0 # We don't need to let the user know if we're just doing the bootloader. if not justConfigFile: w = anaconda.intf.waitWindow(_("Bootloader"), _("Installing bootloader...")) kernelList = [] otherList = [] root = anaconda.id.fsset.getEntryByMountPoint('/') if root: rootDev = root.device.getDevice() else: rootDev = None kernelLabel = None kernelLongLabel = None def rectifyLuksName(anaconda, name): if name is not None and name.startswith('mapper/luks-'): try: newname = anaconda.id.partitions.encryptedDevices.get( name[12:]) if newname is None: for luksdev in anaconda.id.partitions.encryptedDevices.values( ): if os.path.basename( luksdev.getDevice(encrypted=1)) == name[12:]: newname = luksdev break name = newname.getDevice() except: pass return name defaultDev = anaconda.id.bootloader.images.getDefault() defaultDev = rectifyLuksName(anaconda, defaultDev) for (dev, (label, longlabel, type)) in anaconda.id.bootloader.images.getImages().items(): dev = rectifyLuksName(anaconda, dev) if (dev == rootDev) or (rootDev is None and kernelLabel is None): kernelLabel = label kernelLongLabel = longlabel elif dev == defaultDev: otherList = [(label, longlabel, dev)] + otherList else: otherList.append((label, longlabel, dev)) if kernelLabel is None and not flags.livecd: # FIXME log.error("unable to find default image, bailing") if not justConfigFile: w.pop() return plainLabelUsed = 0 defkern = "kernel" backendKernelList = anaconda.backend.kernelVersionList() if iutil.inXen(): kernel_rank = {'xenU': 1, 'xen': 2} # sort based on this ranking backendKernelList.sort(key=lambda (v, a, n): kernel_rank.get(n, 9)) for (version, arch, nick) in backendKernelList: if plainLabelUsed: kernelList.append(("%s-%s" % (kernelLabel, nick), "%s-%s" % (kernelLongLabel, nick), version)) else: kernelList.append((kernelLabel, kernelLongLabel, version)) if nick in ("hypervisor", "guest"): # XXX: *sigh* inconsistent defkern = "kernel-xen-%s" % (nick, ) elif nick != "base": defkern = "kernel-%s" % (nick, ) plainLabelUsed = 1 f = open(anaconda.rootPath + "/etc/sysconfig/kernel", "w+") f.write("# UPDATEDEFAULT specifies if new-kernel-pkg should make\n" "# new kernels the default\n") # only update the default if we're setting the default to linux (#156678) if rootDev == defaultDev: f.write("UPDATEDEFAULT=yes\n") else: f.write("UPDATEDEFAULT=no\n") f.write("\n") f.write("# DEFAULTKERNEL specifies the default kernel package type\n") f.write("DEFAULTKERNEL=%s\n" % (defkern, )) f.close() dosync() try: anaconda.id.bootloader.write(anaconda.rootPath, anaconda.id.fsset, anaconda.id.bootloader, anaconda.id.instLanguage, kernelList, otherList, defaultDev, justConfigFile, anaconda.intf) if not justConfigFile: w.pop() except bootloaderInfo.BootyNoKernelWarning: if not justConfigFile: w.pop() if anaconda.intf: anaconda.intf.messageWindow( _("Warning"), _("No kernel packages were installed on your " "system. Your boot loader configuration " "will not be changed.")) dosync()
def __call__(self, screen, anaconda): self.dispatch = anaconda.dispatch self.bl = anaconda.id.bootloader (self.type, self.bootDev) = \ checkbootloader.getBootloaderTypeAndBoot(anaconda.rootPath) blradio = RadioGroup() (update, newbl, nobl) = (0, 0, 0) if not self.dispatch.stepInSkipList("bootloader"): newbl = 1 elif self.dispatch.stepInSkipList("instbootloader"): nobl = 1 else: if self.type is not None and self.bootDev is not None: update = 1 else: nobl = 1 if self.type is not None and self.bootDev is not None: t = TextboxReflowed( 53, _("The installer has detected the %s boot " "loader currently installed on %s.") % (self.type, self.bootDev)) self.update_radio = blradio.add( _("Update boot loader configuration"), "update", update) else: t = TextboxReflowed( 53, _("The installer is unable to detect the boot loader " "currently in use on your system.")) self.update_radio = blradio.add( _("Update boot loader configuration"), "update", update) self.update_radio.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_SET) self.nobl_radio = blradio.add(_("Skip boot loader updating"), "nobl", nobl) self.newbl_radio = blradio.add( _("Create new boot loader " "configuration"), "newbl", newbl) buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON]) grid = GridFormHelp(screen, _("Upgrade Boot Loader Configuration"), "bl-upgrade", 1, 5) grid.add(t, 0, 0, (0, 0, 0, 1)) grid.add(self.update_radio, 0, 1, (0, 0, 0, 0)) grid.add(self.nobl_radio, 0, 2, (0, 0, 0, 0)) grid.add(self.newbl_radio, 0, 3, (0, 0, 0, 1)) grid.add(buttons, 0, 4, growx=1) while 1: result = grid.run() button = buttons.buttonPressed(result) if button == TEXT_BACK_CHECK: screen.popWindow() return INSTALL_BACK if blradio.getSelection() == "nobl": self.dispatch.skipStep("bootloadersetup", skip=1) self.dispatch.skipStep("bootloader", skip=1) self.dispatch.skipStep("bootloaderadvanced", skip=1) self.dispatch.skipStep("instbootloader", skip=1) elif blradio.getSelection() == "newbl": self.dispatch.skipStep("bootloadersetup", skip=0) self.dispatch.skipStep("bootloader", skip=0) self.dispatch.skipStep("bootloaderadvanced", skip=0) self.dispatch.skipStep("instbootloader", skip=0) self.bl.doUpgradeOnly = 0 else: self.dispatch.skipStep("bootloadersetup", skip=0) self.dispatch.skipStep("bootloader", skip=1) self.dispatch.skipStep("bootloaderadvanced", skip=1) self.dispatch.skipStep("instbootloader", skip=0) self.bl.doUpgradeOnly = 1 if self.type == "GRUB": self.bl.useGrubVal = 1 else: self.bl.useGrubVal = 0 self.bl.setDevice(self.bootDev) screen.popWindow() return INSTALL_OK