def on_grub2_edit_button_clicked(self, widget, data=None): partition = os.path.join("/dev", self.cfg.cur_boot_partition) if slt.isMounted(partition): mp = slt.getMountPoint(partition) doumount = False else: mp = slt.mountDevice(partition) doumount = True grub2cfg = os.path.join(mp, "etc/default/grub") if os.path.exists(grub2cfg): launched = False for editor in self._editors: try: cmd = editor.split(" ") + [grub2cfg] slt.execCall(cmd, shell=True, env=None) launched = True break except: pass if not launched: self._bootsetup.error_dialog( _( "Sorry, BootSetup is unable to find a suitable text editor in your system. You will not be able to manually modify the Grub2 default configuration.\n" ) ) if doumount: slt.umountDevice(mp)
def _mountBootPartition(self, bootPartition): """ Return the mount point """ self.__debug("bootPartition = " + bootPartition) if slt.isMounted(bootPartition): self.__debug("bootPartition already mounted") return slt.getMountPoint(bootPartition) else: self.__debug("bootPartition not mounted") return slt.mountDevice(bootPartition)
def _mountBootPartition(self): """ Return the mount point """ self.__debug("bootPartition = " + self._bootPartition) if slt.isMounted(self._bootPartition): self.__debug("bootPartition already mounted") mp = slt.getMountPoint(self._bootPartition) else: self.__debug("bootPartition not mounted") mp = slt.mountDevice(self._bootPartition) if mp: self._mountBootInPartition(mp) return mp
def _updateGrub2EditButton(self, doTest=True): if doTest: partition = os.path.join("/dev", self.cfg.cur_boot_partition) if slt.isMounted(partition): mp = slt.getMountPoint(partition) doumount = False else: mp = slt.mountDevice(partition) doumount = True self._grub2_conf = os.path.exists(os.path.join(mp, "etc/default/grub")) if doumount: slt.umountDevice(mp) else: self._grub2_conf = False self._grub2BtnEdit.sensitive = self._grub2_conf self._updateScreen()
def update_buttons(self): install_ok = False multiple = False grub2_edit_ok = False if ( self.cfg.cur_mbr_device and os.path.exists("/dev/{0}".format(self.cfg.cur_mbr_device)) and slt.getDiskInfo(self.cfg.cur_mbr_device) ): if self.cfg.cur_bootloader == "lilo" and not self._editing: if len(self.BootPartitionListStore) > 1: multiple = True for bp in self.BootPartitionListStore: if bp[4] == "gtk-yes": install_ok = True elif self.cfg.cur_bootloader == "grub2": if ( self.cfg.cur_boot_partition and os.path.exists("/dev/{0}".format(self.cfg.cur_boot_partition)) and slt.getPartitionInfo(self.cfg.cur_boot_partition) ): install_ok = True if install_ok: partition = os.path.join("/dev", self.cfg.cur_boot_partition) if slt.isMounted(partition): mp = slt.getMountPoint(partition) doumount = False else: mp = slt.mountDevice(partition) doumount = True grub2_edit_ok = os.path.exists(os.path.join(mp, "etc/default/grub")) if doumount: slt.umountDevice(mp) self.RadioLilo.set_sensitive(not self._editing) self.RadioGrub2.set_sensitive(not self._editing) self.ComboBoxMbr.set_sensitive(not self._editing) self.BootPartitionTreeview.set_sensitive(not self._custom_lilo) self.UpButton.set_sensitive(not self._editing and multiple) self.DownButton.set_sensitive(not self._editing and multiple) self.LiloUndoButton.set_sensitive(not self._editing and self._custom_lilo) self.LiloEditButton.set_sensitive(not self._editing and install_ok) self.Grub2EditButton.set_sensitive(grub2_edit_ok) self.ExecuteButton.set_sensitive(not self._editing and install_ok)
def _mountPartitions(self, mountPointList): """ Fill a list of mount points for each partition """ if self._partitions: partitionsToMount = [p for p in self._partitions if p[2] == "linux"] self.__debug("mount partitions: " + unicode(partitionsToMount)) for p in partitionsToMount: dev = os.path.join("/dev", p[0]) self.__debug("mount partition " + dev) if slt.isMounted(dev): mp = slt.getMountPoint(dev) else: mp = slt.mountDevice(dev) self.__debug("mount partition " + dev + " => " + unicode(mp)) if mp: mountPointList[p[0]] = mp self._mountBootInPartition(mp) else: raise Exception("Cannot mount {d}".format(d=dev))
def _editGrub2Conf(self, button): partition = os.path.join("/dev", self.cfg.cur_boot_partition) if slt.isMounted(partition): mp = slt.getMountPoint(partition) doumount = False else: mp = slt.mountDevice(partition) doumount = True grub2cfg = os.path.join(mp, "etc/default/grub") launched = False for editor in self._editors: try: slt.execCall([editor, grub2cfg], shell=True, env=None) launched = True break except: pass if not launched: self._errorDialog(_("Sorry, BootSetup is unable to find a suitable text editor in your system. You will not be able to manually modify the Grub2 default configuration.\n")) if doumount: slt.umountDevice(mp)