示例#1
0
 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)
示例#2
0
文件: grub2.py 项目: jrd/bootsetup
 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)
示例#3
0
文件: lilo.py 项目: jrd/bootsetup
 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
示例#4
0
文件: lilo.py 项目: jrd/bootsetup
 def _mountBootInPartition(self, mountPoint):
   # assume that if the mount_point is /, any /boot directory is already accessible/mounted
   fstab = os.path.join(mountPoint, 'etc/fstab')
   bootdir = os.path.join(mountPoint, 'boot')
   if mountPoint != '/' and os.path.exists(fstab) and os.path.exists(bootdir):
     self.__debug("mp != / and etc/fstab + boot exists, will try to mount /boot by reading fstab")
     try:
       self.__debug('set -- $(grep /boot {fstab}) && echo "$1,$3"'.format(fstab=fstab))
       (bootDev, bootType) = slt.execGetOutput('set -- $(grep /boot {fstab}) && echo "$1,$3"'.format(fstab=fstab), shell=True)[0].split(',')
       if bootDev and not os.path.ismount(bootdir):
         mp = slt.mountDevice(bootDev, fsType=bootType, mountPoint=bootdir)
         if mp:
           self._bootsMounted.append(mp)
           self.__debug("/boot mounted in " + mp)
     except:
       pass
示例#5
0
 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()
示例#6
0
 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)
示例#7
0
文件: lilo.py 项目: jrd/bootsetup
 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))
示例#8
0
 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)