Beispiel #1
0
 def checkEmpty(self, mp):
     if self.xcall("check-mount %s" % mp):
         return popupWarning(_("The partition mounted at %s is not"
                 " empty. This could have bad consequences if you"
                 " attempt to install to it. Please reconsider.\n\n"
                 " Do you still want to install to it?") % mp)
     return True
Beispiel #2
0
    def forward(self):
        if self.skip:
            return 0

        # Carry out the requested operation!
        devpart="%s%d" % (self.device, self.partitionnum)
        if self.ntfs.deletestate:
            install.rmpart(self.device, self.partitionnum)
            self.partlist.remove(devpart)
            self.diskChanged(self.device)

        elif self.ntfs.shrinkstate and popupWarning(
                _("You are about to shrink %s."
                " Make sure you have backed up"
                " any important data.\n\n"
                "Continue?") % devpart):
            newsize = int(self.ntfs.size * 1e9 / self.secsize)  # sectors
            message = install.doNTFSshrink(self.device, self.partitionnum,
                    newsize, self.pstart, self.dinfo)
            if message:
                # resize failed
                popupMessage(_("Sorry, resizing failed. Here is the"
                        " error report:\n\n") + message)
            self.diskChanged(self.device)

        if (devpart == self.partlist[-1]):
            # Last NTFS partition
            return 0

        self.reinit()
        # Don't go to next stage
        return -1
Beispiel #3
0
 def listDevices(self):
     """Return a list of device descriptions.
     Each device description is a list of strings:
         [device (/dev/sda, etc.),
          size (including unit),
          device type/name]
     """
     devices = []
     op = self.xcall("get-devices")
     for line in op.splitlines():
         # In virtualbox with a fresh virtual disk, we can get this:
         # "Error: /dev/sda: unrecognised disk label:"
         em = line.split(":")
         if (em[0].strip() == "Error" and (em[2].strip() ==
                 "unrecognised disk label")):
             dev = em[1].strip()
             if popupWarning(_("Error scanning devices:\n %s\n"
                     "Your disk (%s) seems to be empty and unformatted. "
                     "Shall I prepare it for use (create an msdos "
                     "partition table on it)?")
                     % (line, dev)):
                 op = self.xcall("make-parttable %s" % dev)
                 if op:
                     popupError(_("Couldn't create partition table:\n %s"))
                 else:
                     return self.listDevices()
             return []
         devices.append(line.rstrip(';').split(':'))
     return devices
Beispiel #4
0
    def forward(self):
        if not popupWarning(_("You are about to perform a destructive"
                " operation on the data on your disk drive (%s):\n"
                "    Repartitioning (removing old and creating new"
                " partitions)\n\n"
                "This is a risky business, so don't proceed if"
                " you have not backed up your important data.\n\n"
                "Continue?") % self.device):
            return -1

        # I'll make the sequence: root, then swap then home.
        # But swap and/or home may be absent.
        # Start partitioning from partition with index self.startpart,
        # default value (no NTFS partitions) = 1.
        # The first sector to use is self.startsector
        # default value (no NTFS partitions) = 0.

        # The actual partitioning should be done, but the formatting can
        # be handled - given the appropriate information - by the
        # installation stage.

        # Remove all existing partitions from self.startpart
        install.rmparts(self.device, self.startpart)

        secspercyl = self.dinfo[2]
        startcyl = (self.startsector + secspercyl - 1) / secspercyl
        endcyl = self.dinfo[1]
        # Note that the ending cylinder referred to in the commands
        # will not be included in the partition, it is available to
        # be the start of the next one.

        # Get partition sizes in cylinder units
        ncyls = endcyl - startcyl
        cylsizeB = secspercyl * self.dinfo[3]
        swapC = int(self.swapsizeG * 1e9 / cylsizeB + 0.5)
        homeC = int(self.homesizeG * 1e9 / cylsizeB + 0.5)
        rootC = ncyls - swapC - homeC

        startcyl = self.newpart(startcyl, endcyl, rootC,
                (swapC == 0) and (homeC == 0))
        # See partition formatting and fstab setting up for the
        # meaning of the flags
        config = "/:%s%d:%s:%s:%s" % (self.device, self.startpart,
                install.DEFAULTFS, install.FORMATFLAGS, install.MOUNTFLAGS)
        self.startpart += 1
        if (swapC > 0):
            format = "cformat" if self.getCheck(self.swapfc) else "format"
            startcyl = self.newpart(startcyl, endcyl, swapC,
                    (homeC == 0), True)
            install.set_config("swaps", "%s%d:%s:include" %
                    (self.device, self.startpart, format))
            self.startpart += 1

        if (homeC > 0):
            startcyl = self.newpart(startcyl, endcyl, homeC, True)
            config += "\n/home:%s%d:%s:%s:%s" % (self.device, self.startpart,
                    install.DEFAULTFS, install.FORMATFLAGS, install.MOUNTFLAGS)

        install.set_config("partitions", config)
        return 0