feat: verbose installation logs, improved auto-partitioning logic, and UI tweaks
This commit is contained in:
@@ -55,12 +55,12 @@ def get_total_memory() -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def calculate_auto_partitions(disk_device):
|
||||
def calculate_auto_partitions(disk_device):
|
||||
"""
|
||||
Generates an automatic partition layout.
|
||||
- 2GB EFI
|
||||
- RAM + 2GB Swap
|
||||
- Rest Root (ext4)
|
||||
- 2GB EFI (or 1GB if disk < required)
|
||||
- Root (Rest)
|
||||
- RAM + 2GB Swap (at end) (or 0 if disk < required)
|
||||
"""
|
||||
disk_size = 0
|
||||
try:
|
||||
@@ -87,16 +87,24 @@ def calculate_auto_partitions(disk_device):
|
||||
return []
|
||||
|
||||
ram_size = get_total_memory()
|
||||
disk_mb = disk_size / (1024*1024)
|
||||
|
||||
# Sizes in bytes
|
||||
# Defaults
|
||||
efi_size = 2 * 1024 * 1024 * 1024
|
||||
swap_size = ram_size + (2 * 1024 * 1024 * 1024)
|
||||
min_root_size = 10 * 1024 * 1024 * 1024 # 10GB
|
||||
|
||||
# Check if disk is large enough
|
||||
min_root = 10 * 1024 * 1024 * 1024 # minimum 10GB for root
|
||||
if disk_size < (efi_size + swap_size + min_root):
|
||||
print("Disk too small for automatic partitioning scheme.")
|
||||
return []
|
||||
total_required = efi_size + swap_size + min_root_size
|
||||
|
||||
use_swap = True
|
||||
|
||||
if disk_size < total_required:
|
||||
efi_size = 1 * 1024 * 1024 * 1024
|
||||
use_swap = False
|
||||
swap_size = 0
|
||||
if disk_size < (efi_size + min_root_size):
|
||||
print("Disk too small for automatic partitioning scheme.")
|
||||
return []
|
||||
|
||||
root_size = disk_size - efi_size - swap_size
|
||||
|
||||
@@ -110,15 +118,6 @@ def calculate_auto_partitions(disk_device):
|
||||
"bytes": efi_size,
|
||||
"style_class": "part-efi",
|
||||
},
|
||||
{
|
||||
"type": "partition",
|
||||
"name": "Swap",
|
||||
"filesystem": "swap",
|
||||
"mount_point": "[SWAP]",
|
||||
"size": f"{swap_size / (1024**3):.1f} GB",
|
||||
"bytes": swap_size,
|
||||
"style_class": "part-swap",
|
||||
},
|
||||
{
|
||||
"type": "partition",
|
||||
"name": "Root",
|
||||
@@ -127,8 +126,19 @@ def calculate_auto_partitions(disk_device):
|
||||
"size": f"{root_size / (1024**3):.1f} GB",
|
||||
"bytes": root_size,
|
||||
"style_class": "part-root",
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
if use_swap:
|
||||
partitions.append({
|
||||
"type": "partition",
|
||||
"name": "Swap",
|
||||
"filesystem": "swap",
|
||||
"mount_point": "[SWAP]",
|
||||
"size": f"{swap_size / (1024**3):.1f} GB",
|
||||
"bytes": swap_size,
|
||||
"style_class": "part-swap",
|
||||
})
|
||||
|
||||
return partitions
|
||||
|
||||
@@ -525,6 +535,7 @@ class PartitioningPage(Adw.Bin):
|
||||
# Size entry
|
||||
size_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
|
||||
size_entry = Gtk.Entry(text=str(int(data["bytes"] / (1024*1024))))
|
||||
size_entry.set_width_chars(15)
|
||||
size_box.append(size_entry)
|
||||
size_box.append(Gtk.Label(label="MB"))
|
||||
box.append(Gtk.Label(label="Size:"))
|
||||
|
||||
Reference in New Issue
Block a user