def _install_linux_partitions(self, msg, step, steps, weights): if self._cfg.is_test: for p in self._cfg.linux_partitions: if self._installation == 'cancelled': return step d = p[0] self._update_progressbar(msg + "\n - {0}".format(d), step, steps) w = weights[d] sleep(w) step += w return step else: rootmp = sltl.getMountPoint("/dev/{0}".format(self._cfg.main_partition)) for p in self._cfg.linux_partitions: if self._installation == 'cancelled': return step d = p[0] self._update_progressbar(msg + "\n - {0}".format(d), step, steps) full_dev = "/dev/{0}".format(d) fs = p[1] mp = p[2] sltl.umountDevice(full_dev, deleteMountPoint = False) if fs != 'none': label = sltl.getFsLabel(d) if not label: label = os.path.basename(p[2]) if len(label) > 12: label = None # for not having problems sltl.makeFs(d, fs, label = label, force = True) sltl.mountDevice(full_dev, mountPoint = "{root}/{mp}".format(root = rootmp, mp = mp)) step += weights[d] return step
def _install_main_partition(self): if self._cfg.is_test: sleep(1) else: d = "/dev/{0}".format(self._cfg.main_partition) sltl.umountDevice(d, deleteMountPoint = False) if self._cfg.main_format != 'none': label = sltl.getFsLabel(d) if not label: label = 'Salix' sltl.makeFs(self._cfg.main_partition, self._cfg.main_format, label = label, force = True) sltl.mountDevice(d, fsType = self._cfg.main_format)
def _mountBootPartition(self, bootPartition): """ Return the mount point """ self.__debug("bootPartition = " + bootPartition) if sltl.isMounted(bootPartition): self.__debug("bootPartition already mounted") return sltl.getMountPoint(bootPartition) else: self.__debug("bootPartition not mounted") return sltl.mountDevice(bootPartition)
def _mountBootPartition(self): """ Return the mount point """ self.__debug("bootPartition = " + self._bootPartition) if sltl.isMounted(self._bootPartition): self.__debug("bootPartition already mounted") mp = sltl.getMountPoint(self._bootPartition) else: self.__debug("bootPartition not mounted") mp = sltl.mountDevice(self._bootPartition) if mp: self._mountBootInPartition(mp) return mp
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) = sltl.execGetOutput('set -- $(grep /boot {fstab}) && echo "$1,$3"'.format(fstab = fstab), shell = True)[0].split(',') if bootDev and not os.path.ismount(bootdir): mp = sltl.mountDevice(bootDev, fsType = bootType, mountPoint = bootdir) if mp: self._bootsMounted.append(mp) self.__debug("/boot mounted in " + mp) except: pass
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 sltl.isMounted(dev): mp = sltl.getMountPoint(dev) else: mp = sltl.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))