Commits

M0E-lnx  committed fa718e1

Automatic fs selection for / and swap mountpoints in advanced mode

  • Participants
  • Parent commits d1de08f

Comments (0)

Files changed (2)

File vinstall/backend/bootloader.py

 class LiloTestCase(FakeDeviceTestCase):
 
     def test_lilo(self):
+        import os
+        if not os.path.exists('/bin/lilo'):
+            print "LiLO not found.  Skipping test"
+            return True
         lilo = Lilo(self.path)
         for ops in OperatingSystem.all(include_running_os=True):
             lilo.add_os(ops)

File vinstall/ui/gtk.py

     """
     DNF = "Do not format"
     DNU = "Not use"
+    ROOT_FS = "ext3" # FIXME:  This should be defined somewhere else.
 
     def __init__(self, mountpoints):
 
     def show_partitions(self):
         for p in self.mountpoints.partitions:
             self.store.append([p, self.DNU, self.DNF])
+    
+    def warn(self, title="", message=""):
+        dia = gtk.MessageDialog(type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK)
+        dia.set_property('title', title)
+        dia.set_markup(message)
+        if dia.run():
+            dia.destroy()
+    def error(self, title="", message=""):
+        dia = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
+        dia.set_property('title', title)
+        dia.set_markup(message)
+        if dia.run():
+            dia.destroy()
 
     def on_click(self, treeview, event):
         """Answer to click on treeview
                 treeview.set_cursor(path, col, 0)
                 index = treeview.get_columns().index(col)
                 if index in (0, 1):
+                    # Mountpoint column clicked
                     self.show_mountpoints_menu(path[0], event)
                 elif index == 2:
+                    # Format column clicked
                     self.show_filesystem_menu(path[0], event)
+                    self.warn("Test2")
                 else:
                     pass
             return True
+    
+    def verify_mountpoint_selection(self, menu, row, event):
+        """Processed after the mountpoint has been selected.
+        Provides methods select a default fs for /"""
+        mpoint = menu.get_active().get_label()
+        partition = self.store[row][0]
+        if mpoint is "/":
+            # Check if the partition selected for / is big enough
+            ## /dev/sda1 (9.7 GB ext4)
+            psize = partition.split("(")[1].split()[0]
+            ppath = partition.split()[0]
+            if int(float(psize)) > 4:
+                # Add a default filesystem for /
+                self.filesystem_selected(row, partition, self.ROOT_FS) 
+            else:
+                msg = """%s is not big enough to be your / partition."""% ppath
+                self.error('Insuficient space', msg)
+                self.mountpoint_selected(row, partition, self.DNU)
+        elif "swap" in mpoint:
+            # automatically select 'swap' as the format for swap partitions
+            self.filesystem_selected(row, partition, "swap")
+        else:
+            self.filesystem_selected(row, partition, self.DNF)
 
     def show_mountpoints_menu(self, row, event):
         """Show mountpoints menu
                     row, partition, i)
             item.show()
             menu.append(item)
+        menu.connect("selection-done", self.verify_mountpoint_selection, row, event)
         menu.show()
         menu.popup(None, None, None, event.button, event.time)
+        
 
     def show_filesystem_menu(self, row, event):
         """Show a menu with filesystem options