Пример #1
0
 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
Пример #2
0
  def _getLinuxLiloSections(self, device, fs, mp, label):
    """
    Returns a list of string sections, one for each kernel+initrd
    """
    sections = []
    self.__debug("Section 'linux' for " + device + "/" + fs + ", mounted on " + mp + " with label: " + label)
    kernelList = sorted(glob.glob("{mp}/boot/vmlinuz*".format(mp=mp)))
    initrdList = sorted(glob.glob("{mp}/boot/initr*".format(mp=mp)))
    for l in (kernelList, initrdList):
      for el in l:
        if os.path.isdir(el) or os.path.islink(el):
          l.remove(el)
    self.__debug("kernelList: " + unicode(kernelList))
    self.__debug("initrdList: " + unicode(initrdList))
    uuid = slt.execGetOutput(['/sbin/blkid', '-s', 'UUID', '-o', 'value', device], shell=False)
    if uuid:
      rootDevice = "/dev/disk/by-uuid/{uuid}".format(uuid=uuid[0])
    else:
      rootDevice = device
    self.__debug("rootDevice = " + rootDevice)
    for (k, i, l) in self._getKernelInitrdCouples(kernelList, initrdList, label):
      self.__debug("kernel, initrd, label found: " + unicode(k) + "," + unicode(i) + "," + unicode(l))
      section = None
      if i:
        section = """# {label} Linux section
  image = {image}
  initrd = {initrd}
  root = {root}
""".format(image=k, initrd=i, root=rootDevice, label=l)
      else:
        section = """# {label} Linux section
  image = {image}
  root = {root}
""".format(image=k, root=rootDevice, label=l)
      if fs == 'ext4':
        section += '  append = "{append} "\n'.format(append='rootfstype=ext4')
      section += "  read-only\n  label = {label}\n".format(label=l)
      sections.append(section)
    return sections
Пример #3
0
 def _getFrameBufferConf(self):
   """
   Return the frame buffer configuration for this hardware.
   Format: (fb, label)
   """
   try:
     fbGeometry = slt.execGetOutput("/usr/sbin/fbset | grep -w geometry")
   except CalledProcessError:
     self.__debug("Impossible to determine frame buffer mode, default to text.")
     fbGeometry = None
   mode = None
   label = None
   if fbGeometry:
     vesaModes = [
         (320, 200, 4, None),
         (640, 400, 4, None),
         (640, 480, 4, None),
         (800, 500, 4, None),
         (800, 600, 4, 770),
         (1024, 640, 4, None),
         (896, 672, 4, None),
         (1152, 720, 4, None),
         (1024, 768, 4, 772),
         (1440, 900, 4, None),
         (1280, 1024, 4, 774),
         (1400, 1050, 4, None),
         (1600, 1200, 4, None),
         (1920, 1200, 4, None),
         (320, 200, 8, None),
         (640, 400, 8, 768),
         (640, 480, 8, 769),
         (800, 500, 8, 879),
         (800, 600, 8, 771),
         (1024, 640, 8, 874),
         (896, 672, 8, 815),
         (1152, 720, 8, 869),
         (1024, 768, 8, 773),
         (1440, 900, 8, 864),
         (1280, 1024, 8, 775),
         (1400, 1050, 8, 835),
         (1600, 1200, 8, 796),
         (1920, 1200, 8, 893),
         (320, 200, 15, 781),
         (640, 400, 15, 801),
         (640, 480, 15, 784),
         (800, 500, 15, 880),
         (800, 600, 15, 787),
         (1024, 640, 15, 875),
         (896, 672, 15, 816),
         (1152, 720, 15, 870),
         (1024, 768, 15, 790),
         (1440, 900, 15, 865),
         (1280, 1024, 15, 793),
         (1400, 1050, 15, None),
         (1600, 1200, 15, 797),
         (1920, 1200, 15, None),
         (320, 200, 16, 782),
         (640, 400, 16, 802),
         (640, 480, 16, 785),
         (800, 500, 16, 881),
         (800, 600, 16, 788),
         (1024, 640, 16, 876),
         (896, 672, 16, 817),
         (1152, 720, 16, 871),
         (1024, 768, 16, 791),
         (1440, 900, 16, 866),
         (1280, 1024, 16, 794),
         (1400, 1050, 16, 837),
         (1600, 1200, 16, 798),
         (1920, 1200, 16, None),
         (320, 200, 24, 783),
         (640, 400, 24, 803),
         (640, 480, 24, 786),
         (800, 500, 24, 882),
         (800, 600, 24, 789),
         (1024, 640, 24, 877),
         (896, 672, 24, 818),
         (1152, 720, 24, 872),
         (1024, 768, 24, 792),
         (1440, 900, 24, 867),
         (1280, 1024, 24, 795),
         (1400, 1050, 24, 838),
         (1600, 1200, 24, 799),
         (1920, 1200, 24, None),
         (320, 200, 32, None),
         (640, 400, 32, 804),
         (640, 480, 32, 809),
         (800, 500, 32, 883),
         (800, 600, 32, 814),
         (1024, 640, 32, 878),
         (896, 672, 32, 819),
         (1152, 720, 32, 873),
         (1024, 768, 32, 824),
         (1440, 900, 32, 868),
         (1280, 1024, 32, 829),
         (1400, 1050, 32, None),
         (1600, 1200, 32, 834),
         (1920, 1200, 32, None),
       ]
     values = fbGeometry[0].strip().split(' ')
     self.__debug("FB Values: " + unicode(values))
     xRes = int(values[1])
     yRes = int(values[2])
     deep = int(values[-1])
     xMax = None
     yMax = None
     dMax = None
     # order the vesa modes by vertical size desc, horizontal size desc, color depth desc.
     for vesaMode in sorted(vesaModes, key=itemgetter(1, 0, 2), reverse=True):
       (x, y, d, m) = vesaMode
       if m:
         self.__debug("trying {0} for y, {1} for x and {2} for d".format(y, x, d))
         if y <= yRes and x <= xRes and d <= deep:
           xMax = x
           yMax = y
           dMax = d
           mode = m
           break
     if mode:
       self.__debug("Max mode found: {x}×{y}×{d}".format(x=xMax, y=yMax, d=dMax))
       label = "{x}x{y}x{d}".format(x=xMax, y=yMax, d=dMax)
   if not mode:
     mode = 'normal'
     label = 'text'
   return (mode, label)