Commits

M0E-lnx  committed 74d7871

Fixed partitioning to avoid empty space at end of drive. Display partition size on mountpoint selection

  • Participants
  • Parent commits 58e8cb2

Comments (0)

Files changed (3)

File vinstall/backend/media.py

             filesystem = self.query_filesystem()
         else:
             filesystem = "Not formated"
-        return '%s (%s)' % (self.device_path, filesystem)
+        return '%s (%s %s)' % (self.device_path, self.size("GB"), filesystem)
 
     def __repr__(self):
         return '<Partition object: %s>' % self.device_path
         """Returns True if the media is mounted, False otherwise."""
 
         return is_mounted(self.device_path)
+    
+    def size(self, unit="GB"):
+        """Return the partition size in the specified unit.  Defaults to GB"""
+        su = round(self._parted_partition.getLength(unit), 1)
+        return "%s %s"% (su, unit)
+
 
     def query_filesystem(self):
         """Retrieve the current filesystem type from the system."""
-
-        process = subprocess.Popen(['blkid', self.device_path],
-                stdout=subprocess.PIPE)
-        data = process.stdout.read()
-        process.stdout.close()
-        try:
-            return re.search(r'TYPE="(\w+)"', data).group(1)
-        except AttributeError:
-            #blkid returned nothing
-            return None
+        pfs = self._parted_partition.fileSystem.type
+        if "swap" in pfs:
+            pfs = "swap"
+        return pfs
 
     def format(self, filesystem):
         """Create a filesystem in this partition.
         for part in partitions:
             if part.type in (parted.PARTITION_NORMAL,
                              parted.PARTITION_LOGICAL,):
-                yield cls(part.path)
+                p = cls(part.path)
+                p._parted_partition = part # We could use this for other operations.
+                yield p
 
 
 class Disk(object):
 
     def __str__(self):
 
-        return "%s - %s GB (%s)" % (self.model(),  self.size(), self.path())
+        return "%s - %s GB (%s)" % (self.model(), round(self.size(), 2), self.path())
 
     def model(self):
         """Return the string describing the device model"""
         """ Returns disk size, by default in GB, unit can be GB or MB
 
         """
-        return self._device.getSize(unit)
+        return self._device.getLength(unit)
+        #return self._device.getSize(unit)
 
     def path(self):
         """Return the node path for this device"""

File vinstall/controller/automatic.py

         else:
             swap_size = int(available_ram / 2)
 
-        disk_size = disk.size(unit="MB")
+        disk_size = int(disk.size(unit="MB"))
         partitioner = partitioning.DiskPartitioner(disk)
         if not disk.has_partition_table:
             partitioner.create_partition_table()
                 mountpoint = "none", filesystem="swap")
         for entry in (root_entry, swap_entry):
             fstab_obj.add_entry(entry)
+        # Additional entries needed
+        proc = fstab.FstabEntry(device="proc",
+            mountpoint = "/proc",
+            filesystem = "proc",
+            options = "defaults 0 0")
+        devpts = fstab.FstabEntry(device="none",
+            mountpoint = "/dev/pts",
+            filesystem = "devpts",
+            options = "gid=5,mode=666  0 0"
+            )
+        shm = fstab.FstabEntry(device = "tmpfs",
+            mountpoint = "/dev/shm",
+            filesystem = "tmpfs",
+            options = "defaults 0 0"
+            )
+        sysfs = fstab.FstabEntry(device = "sysfs",
+            mountpoint = "/sys",
+            filesystem = "sysfs",
+            options = "defaults 0 0"
+            )
+        for item in (proc, devpts, shm, sysfs):
+            fstab_obj.add_entry(item)
 
     def setup_services(self):
         """Setup default system services

File vinstall/controller/usersetup.py

                     mountpoint=mount,
                     filesystem=fs)
             fstab_obj.add_entry(entry)
+        # Additional entries needed
+        proc = fstab.FstabEntry(device="proc",
+            mountpoint = "/proc",
+            filesystem = "proc",
+            options = "defaults 0 0")
+        devpts = fstab.FstabEntry(device="none",
+            mountpoint = "/dev/pts",
+            filesystem = "devpts",
+            options = "gid=5,mode=666  0 0"
+            )
+        shm = fstab.FstabEntry(device = "tmpfs",
+            mountpoint = "/dev/shm",
+            filesystem = "tmpfs",
+            options = "defaults 0 0"
+            )
+        sysfs = fstab.FstabEntry(device = "sysfs",
+            mountpoint = "/sys",
+            filesystem = "sysfs",
+            options = "defaults 0 0"
+            )
+        for item in (proc, devpts, shm, sysfs):
+            fstab_obj.add_entry(item)
+            
 
     def setup_services(self):
         """Setup default system services