コード例 #1
0
ファイル: autopart.py プロジェクト: BackupTheBerlios/larch
    def init(self):
        if not self.initialize:
            return
        # Info on drive
        di = DiskInfo(self.device)
        c2G = float(di.cyl2B()) / 10**9
        self.disksize = di.drvcyls * c2G
        if self.keep1:
            p = di.parts[0]
            self.p1size = (p[2]-p[1]+1)*c2G
        else:
            self.p1size = 0.0
        ui.command("autopart:disk.x__text", self.device)
        ui.command("autopart:disksize.x__text", "%4.0f GB" % self.disksize)
        ui.command("autopart:reserved.x__text", "%4.0f GB" % self.p1size)
        # Set up unallocated space display
        self.unallocated = 0.0
        self.swapsize = 1.0
        self.swapsize_old = 1.0
        self.maxunallocated = self.disksize - self.p1size - self.systemsize - 15.0
        # Also use this as criterion for possibility of user data partition
        self.datapart = self.maxunallocated > 0.0
        ui.command("autopart:free.enable", self.datapart)
        ui.command("autopart:free_l.enable", self.datapart)
        ui.command("autopart:home.enable", self.datapart)
        if self.datapart:
            ui.command("autopart:free.x__max", self.maxunallocated)
            ui.command("autopart:free.x__value", 0.0)
            self.datasize = self.maxunallocated + 5.0
            self.datasize_old = self.datasize
            if self.datasize > 20.0:
                ui.command("autopart:home.opton", True)
                ui.command("autopart:homesize.x__max", self.datasize)
                ui.command("autopart:homesize.x__value", self.datasize)
            else:
                self.datasize = 0.0
                ui.command("autopart:home.opton", False)
        else:
            self.datasize = 0.0
        # Set up swap partition display
        ui.command("autopart:swap.opton", True)
        self.recalculate()

        self.swapcheck = False
        ui.command("autopart:swapcheck.set", False)
        self.homedata = False
        ui.command("autopart:homedata.set", False)
コード例 #2
0
ファイル: manupart.py プロジェクト: BackupTheBerlios/larch
    def diskpartition(self):
        # Info on drive
        di = DiskInfo(self.device)
        c2G = float(di.cyl2B()) / 10**9
        self.disksize = di.drvcyls * c2G
        ui.command("manupart:disk.x__text", self.device)
        ui.command("manupart:disksize.x__text", "%4.0f GB" % self.disksize)
        drive_info = self.driveinfo(di)
        if drive_info:
            self.extpa, self.prim, self.logi, self.free = drive_info
        else:
            ui.sendsignal("$$$goback$$$")
            return

        self.parts = self.prim + self.logi + self.free
        self.parts.sort()


        self.formatinfo = {}
        self.mountinfo = {}
#TODO: The question is - how to keep a fairly persistent record of
# formatting and mount-point wishes which is not restricted to just
# one device (or should it be restricted to one device?)


        parts = []
        for ps, pe, pn, pt in self.parts:
            size = "%5.1f" % ((pe - ps + 1) * c2G)
            if pn == 0:
                parts.append((_("Free"), size, "", "", "", ""))
            else:
                d = self.device + str(pn)
                fst = PartInfo(d).getfstype()
                fmt = self.formatinfo.get(d, "")
                mp = self.mountinfo.get(d, "")
                parts.append((str(pn), size, pt, fst, fmt, mp))

        ui.command("manu:part-list.set", parts)
        ui.command("manu:part-list.compact")
コード例 #3
0
ファイル: disks.py プロジェクト: BackupTheBerlios/larch
    def select_device(self, index=-1):
        if index < 0:
            return
        self.device_index = index
        self.device = self.devices[index][1]
        di = DiskInfo(self.device)
        # Convert size from cyls to GB
        c2G = float(di.cyl2B()) / 10**9
        parts = di.parts
        pinfo = []
        for p in parts:
            size = "%-7.2f" % ((p[2]-p[1]+1)*c2G)
            pinfo.append((p[0], size, p[4]))
        ui.command("disks:device-partitions.set", pinfo)
        ui.command("disks:device-partitions.compact")

        # Test whether 1st partition is NTFS
        self.ntfs1 = backend.get_partfstype(self.device + "1") == "ntfs"
        ui.command("disks:ntfs-shrink.enable", self.ntfs1)

        # If device has mounted partition(s), it is not autopartitionable
        # Might be useful for testing: noauto = False
        noauto = (self.devices[index][0] == '-')

        size = self.devices[index][2]
        if size.endswith("GB"):
            if float(size[:-2]) < 10.0:
                noauto = True
        else:
            noauto = True
        ui.command("disks:auto.enable", not noauto)
        if not self.method:
            ui.command("disks:%s.set" % ("manual" if noauto else "auto"),
                    True)
        elif (self.method == "auto") and noauto:
            method = ui.command("disks:manual.set", True)
        self.setkeep1(self.ntfs1 and
                (self.method == "auto") and not noauto)
コード例 #4
0
ファイル: manupart.py プロジェクト: BackupTheBerlios/larch
    def partition(self, doit):
        if not doit:
            return
        # I'll make the sequence: root, then swap then home(/DATA).
        # But swap and/or home may be absent.
        # root and swap are created as primary partitions, home(/DATA)
        # as logical (to ensure that ny unallocated space may also be used).

        # The actual partitioning is done, but the formatting is
        # handled - given the appropriate information - by the
        # installation stage. If a swap partition is created that will,
        # however, be formatted.

        startpart = 2 if self.keep1 else 1
        # Remove all existing partitions from startpart
        ui.progressPopup.start()
        ui.progressPopup.add(_("Removing all partitions on %s,\n"
                "   starting from number %d") % (self.device, startpart))
        if not backend.rmparts(self.device, startpart):
            return

        diskinfo = DiskInfo(self.device)
        # Check that the free space corresponds to what is expected.
        # Convert GB to cylinders for (self.disksize - self.p1size)
        allfreecyls = diskinfo.get_freecyls()
        bytespercyl = diskinfo.cyl2B()
        deviation = abs(self.disksize - self.p1size -
                (allfreecyls * bytespercyl / 10**9))
        if deviation > 1:
            fatal_error("BUG in autopart: free space deviation = %5.1f"
                    % deviation)

        # Allocate number of cylinders for the largest partition last,
        # just in case it gets tight ...
        newparts = []
        maxp = None
        maxs = 0
        boots = 0.2
        if self.larchboot:
            boots += self.live_gb * 1.5
        for m, s, t in (
                ("/boot", boots, "primary"),
                ("swap", self.swapsize, "primary"),
                ("/", self.rootsize, "logical"),
                ("/home/DATA" if self.homedata else "/home", self.datasize,
                        "logical"),
                ("", self.unallocated, None)):
            if s > 0.1:
                # Convert GB to cylinders
                entry = [t, int((s * 10**9 / bytespercyl) + 0.5), m]
                newparts.append(entry)
                if s > maxs:
                    maxs = s
                    maxp = entry
        sum = 0
        for ps in newparts:
            if ps != maxp:
                sum += ps[1]
        maxp[1] = allfreecyls - sum

        # Create the partitions
        iparts = []
        for t, s, m in newparts:
            if not t:
                continue
            swap = (m=="swap")
            ui.progressPopup.add(_("Creating %s partition for %s")
                    % (t, m))
            part = backend.newpart(self.device, t.startswith("p"), s, swap)
            if not part:
                iparts = None
                break
            if swap and not backend.mkswap(part, self.swapcheck):
                iparts = None
                break
            else:
                # [mount-point, device, size, format]
                iparts.append([m, part, "" if swap
                        else "ext2" if m == "/boot"
                        else "ext4"])
                ui.progressPopup.add("   ---> " + part)
        ui.progressPopup.end()

        # Go to installation stage
        if iparts:
            ui.sendsignal("&install!", iparts)