Ejemplo n.º 1
0
    def commit(self):
        import yali.gui.context as ctx

        attempt = 1
        maxTries = 5
        keepTrying = True

        while keepTrying and (attempt <= maxTries):
            try:
                self._disk.commit()
                keepTrying = False
                sysutils.run("sync")
            except Exception, msg:
                attempt += 1
Ejemplo n.º 2
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("dosfslabel")
     cmd = "%s %s %s" % (cmd_path, partition.getPath(), label)
     if not sysutils.run(cmd):
         return False
     return label
Ejemplo n.º 3
0
 def format(self, partition):
     self.preFormat(partition)
     cmd_path = requires("mkfs.vfat")
     cmd = "%s %s" %(cmd_path,partition.getPath())
     res = sysutils.run(cmd)
     if not res:
         raise YaliException, "vfat format failed: %s" % partition.getPath()
Ejemplo n.º 4
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("xfs_admin")
     cmd = "%s -L %s %s" % (cmd_path, label, partition.getPath())
     if not sysutils.run(cmd):
         return False
     return label
Ejemplo n.º 5
0
 def format(self, partition):
     self.preFormat(partition)
     cmd_path = requires("mkfs.xfs")
     cmd = "%s -f %s" %(cmd_path, partition.getPath())
     res = sysutils.run(cmd)
     if not res:
         raise YaliException, "%s format failed: %s" % (self.name(), partition.getPath())
Ejemplo n.º 6
0
 def getLabel(self, partition):
     """ Read file system label and return """
     cmd_path = requires("e2label")
     cmd = "%s %s" % (cmd_path, partition.getPath())
     label = sysutils.run(cmd, capture=True)
     if not label:
         return False
     return label.strip()
Ejemplo n.º 7
0
 def tune2fs(self, partition):
     """ Runs tune2fs for given partition """
     cmd_path = requires("tune2fs")
     # Disable mount count and use 6 month interval to fsck'ing disks at boot
     cmd = "%s -c 0 -i 6m %s" % (cmd_path, partition.getPath())
     res = sysutils.run(cmd)
     if not res:
         raise YaliException, "tune2fs tuning failed: %s" % partition.getPath()
Ejemplo n.º 8
0
 def setLabel(self, partition, label):
     # FIXME It formats the device twice for setting label
     # Find a better way for it...
     label = self.availableLabel(label)
     cmd_path = requires("mkfs.btrfs")
     cmd = "%s -L %s %s" % (cmd_path, label, partition.getPath())
     if not sysutils.run(cmd):
         return False
     return label
Ejemplo n.º 9
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("e2label")
     cmd = "%s %s %s" % (cmd_path, partition.getPath(), label)
     if not sysutils.run(cmd):
         return False
     # Check label consistency
     if not self.getLabel(partition) == label:
         return False
     return label
Ejemplo n.º 10
0
    def execute(self):
        ctx.mainScreen.disableNext()

        ctx.debugger.log("Show reboot dialog.")
        InfoDialog(_("Press <b>Restart</b> to restart your system."), _("Restart"))

        ctx.yali.info.updateAndShow(_('<b>Please wait while restarting...</b>'))

        # remove cd...
        if not ctx.yali.install_type == YALI_FIRSTBOOT:
            ctx.debugger.log("Trying to eject the CD.")
            sysutils.ejectCdrom()

        ctx.debugger.log("Yali, reboot calling..")

        ctx.mainScreen.processEvents()
        sysutils.run("sync")
        time.sleep(4)
        sysutils.reboot()
Ejemplo n.º 11
0
    def setLabel(self, partition, label):
        label = self.availableLabel(label)
        cmd_path = requires("mkswap")
        cmd = "%s -v1 -L %s %s" % (cmd_path, label, partition.getPath())
        if not sysutils.run(cmd):
            return False

        # Swap on
        sysutils.swapOn(partition.getPath())

        return label
Ejemplo n.º 12
0
    def resize(self, size_mb, partition):
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize

        if not self.preResize(partition):
            raise FSCheckError, _("Running fsck failed or fsck does not exist on your system. Resizing is not possible for this partition.")

        cmd_path = requires("btrfsctl")
        cmd = "%s -r %dm -A %s" % (cmd_path, size_mb, partition.getPath())
        if not sysutils.run(cmd):
            raise FSError, _("Failed resizing %s.") % partition.getPath()

        return True
Ejemplo n.º 13
0
    def resize(self, size_mb, partition):
        """ Resize given partition as given size """
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize
        cmd_path = requires("resize2fs")

        # Check before resize
        self.preResize(partition)

        res = sysutils.run("resize2fs",[partition.getPath(), "%sM" %(size_mb)])
        if not res:
            raise FSError, "Resize failed on %s" % (partition.getPath())
        return True
Ejemplo n.º 14
0
    def resize(self, size_mb, partition):
        minsize = self.minResizeMB(partition)
        if size_mb < minsize:
            size_mb = minsize

        if not self.resizeSilent(size_mb, partition) or not self.preResize(partition):
            raise FSCheckError, _("It seems that the NTFS filesystem on %s is not properly closed.\n"
                                  "You will have to connect the drive back to the other operating \n"
                                  "system, safely remove the hardware and then shutdown the system \n"
                                  "cleanly. You can also use the 'force' option of ntfs-3g on your \n"
                                  "own responsibility.") % partition.getPath()

        cmd_path = requires("ntfsresize")
        cmd = "%s -P -f -s %dM %s" % (cmd_path, size_mb, partition.getPath())

        if not sysutils.run(cmd):
            raise FSError, _("Failed resizing %s.") % partition.getPath()

        return True
Ejemplo n.º 15
0
    def format(self, partition):
        """ Format the given partition """
        self.preFormat(partition)

        cmd_path = requires("mkfs.%s" % self.name())

        # bug 5616: ~100MB reserved-blocks-percentage
        reserved_percentage = int(math.ceil(100.0 * 100.0 / partition.getMB()))

        # Use hashed b-trees to speed up lookups in large directories
        cmd = "%s -O dir_index -q -j -m %d %s" % (cmd_path,
                                                  reserved_percentage,
                                                  partition.getPath())

        res = sysutils.run(cmd)
        if not res:
            raise YaliException, "%s format failed: %s" % (self.name(), partition.getPath())

        # for Disabling Lengthy Boot-Time Checks
        self.tune2fs(partition)
Ejemplo n.º 16
0
def setOrderedDiskList():
    devices = detectAll()
    devices.sort()

    import yali.gui.context as ctx

    # Check EDD Module
    if not os.path.exists("/sys/firmware/edd"):
        cmd_path = sysutils.find_executable("modprobe")
        cmd = "%s %s" % (cmd_path, "edd")
        res = sysutils.run(cmd)
        if not res:
            ctx.installData.orderedDiskList = devices
            ctx.debugger.log("ERROR : Inserting EDD Module failed !")
            return

    edd = EDD()
    sortedList = []
    edd_list = edd.list_edd_signatures()
    mbr_list = edd.list_mbr_signatures()
    edd_keys = edd_list.keys()
    edd_keys.sort()
    for bios_num in edd_keys:
        edd_sig = edd_list[bios_num]
        if mbr_list.has_key(edd_sig):
            sortedList.append(mbr_list[edd_sig])

    if len(devices) > 1:
        a = ctx.installData.orderedDiskList = sortedList
        b = devices
        # check consistency of diskList
        if not len(filter(None, map(lambda x: x in a,b))) == len(b):
            ctx.installData.orderedDiskList = devices
            ctx.isEddFailed = True
    else:
        ctx.installData.orderedDiskList = devices
Ejemplo n.º 17
0
 def resizeSilent(self, size_mb, partition):
     # don't do anything, just check
     cmd_path = requires("ntfsresize")
     cmd = "%s -P -n -ff -s %dM %s" % (cmd_path, size_mb, partition.getPath())
     return sysutils.run(cmd)
Ejemplo n.º 18
0
 def preResize(self, partition):
     """ Routine operations before resizing """
     cmd_path = requires("ntfsresize")
     cmd = "%s -P -c %s" % (cmd_path, partition.getPath())
     return sysutils.run(cmd)