Making sure the drive paths are in the JSON structure, and not the class object, as it won't work seamlessly to access for instance storage['disk_layouts'][ClassInstance()] if it's not the identical mem copy of the object we're accessing, so strings are better for storage/comparisons.
This commit is contained in:
parent
70af00f33d
commit
9e67ce3f05
|
|
@ -114,13 +114,13 @@ def suggest_single_disk_layout(block_device):
|
||||||
MIN_SIZE_TO_ALLOW_HOME_PART = 40 # Gb
|
MIN_SIZE_TO_ALLOW_HOME_PART = 40 # Gb
|
||||||
|
|
||||||
layout = {
|
layout = {
|
||||||
block_device : {
|
block_device.path : {
|
||||||
"wipe" : True,
|
"wipe" : True,
|
||||||
"partitions" : []
|
"partitions" : []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layout[block_device]['partitions'].append({
|
layout[block_device.path]['partitions'].append({
|
||||||
# Boot
|
# Boot
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"start" : "1MiB",
|
"start" : "1MiB",
|
||||||
|
|
@ -133,7 +133,7 @@ def suggest_single_disk_layout(block_device):
|
||||||
"format" : "fat32"
|
"format" : "fat32"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
layout[block_device]['partitions'].append({
|
layout[block_device.path]['partitions'].append({
|
||||||
# Root
|
# Root
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"start" : "513MiB",
|
"start" : "513MiB",
|
||||||
|
|
@ -147,7 +147,7 @@ def suggest_single_disk_layout(block_device):
|
||||||
})
|
})
|
||||||
|
|
||||||
if block_device.size >= MIN_SIZE_TO_ALLOW_HOME_PART:
|
if block_device.size >= MIN_SIZE_TO_ALLOW_HOME_PART:
|
||||||
layout[block_device]['partitions'].append({
|
layout[block_device.path]['partitions'].append({
|
||||||
# Home
|
# Home
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"encrypted" : False,
|
"encrypted" : False,
|
||||||
|
|
@ -175,17 +175,17 @@ def suggest_multi_disk_layout(block_devices):
|
||||||
log(f"Suggesting multi-disk-layout using {len(block_devices)} disks, where {root_device} will be /root and {home_device} will be /home", level=logging.DEBUG)
|
log(f"Suggesting multi-disk-layout using {len(block_devices)} disks, where {root_device} will be /root and {home_device} will be /home", level=logging.DEBUG)
|
||||||
|
|
||||||
layout = {
|
layout = {
|
||||||
root_device : {
|
root_device.path : {
|
||||||
"wipe" : True,
|
"wipe" : True,
|
||||||
"partitions" : []
|
"partitions" : []
|
||||||
},
|
},
|
||||||
home_device : {
|
home_device.path : {
|
||||||
"wipe" : True,
|
"wipe" : True,
|
||||||
"partitions" : []
|
"partitions" : []
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
layout[root_device]['partitions'].append({
|
layout[root_device.path]['partitions'].append({
|
||||||
# Boot
|
# Boot
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"start" : "1MiB",
|
"start" : "1MiB",
|
||||||
|
|
@ -198,7 +198,7 @@ def suggest_multi_disk_layout(block_devices):
|
||||||
"format" : "fat32"
|
"format" : "fat32"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
layout[root_device]['partitions'].append({
|
layout[root_device.path]['partitions'].append({
|
||||||
# Root
|
# Root
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"start" : "513MiB",
|
"start" : "513MiB",
|
||||||
|
|
@ -211,7 +211,7 @@ def suggest_multi_disk_layout(block_devices):
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
layout[home_device]['partitions'].append({
|
layout[home_device.path]['partitions'].append({
|
||||||
# Home
|
# Home
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"encrypted" : False,
|
"encrypted" : False,
|
||||||
|
|
|
||||||
|
|
@ -751,7 +751,7 @@ def select_individual_blockdevice_usage(block_devices :list):
|
||||||
for device in block_devices:
|
for device in block_devices:
|
||||||
layout = manage_new_and_existing_partitions(device)
|
layout = manage_new_and_existing_partitions(device)
|
||||||
|
|
||||||
result[device] = layout
|
result[device.path] = layout
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,16 +58,14 @@ def load_config():
|
||||||
if (dl_path := pathlib.Path(archinstall.arguments['disk_layouts'])).exists() and str(dl_path).endswith('.json'):
|
if (dl_path := pathlib.Path(archinstall.arguments['disk_layouts'])).exists() and str(dl_path).endswith('.json'):
|
||||||
try:
|
try:
|
||||||
with open(dl_path) as fh:
|
with open(dl_path) as fh:
|
||||||
archinstall.arguments['disk_layouts'] = json.load(fh)
|
archinstall.storage['disk_layouts'] = json.load(fh)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(f"--disk_layouts does not contain a valid JSON format: {e}")
|
raise ValueError(f"--disk_layouts does not contain a valid JSON format: {e}")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
archinstall.arguments['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts'])
|
archinstall.storage['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts'])
|
||||||
except:
|
except:
|
||||||
raise ValueError("--disk_layouts=<json> needs either a JSON file or a JSON string given with a valid disk layout.")
|
raise ValueError("--disk_layouts=<json> needs either a JSON file or a JSON string given with a valid disk layout.")
|
||||||
archinstall.storage['disk_layouts'] = {archinstall.BlockDevice(disk) : struct for disk, struct in archinstall.arguments['disk_layouts'].items()}
|
|
||||||
|
|
||||||
|
|
||||||
def ask_user_questions():
|
def ask_user_questions():
|
||||||
"""
|
"""
|
||||||
|
|
@ -111,15 +109,12 @@ def ask_user_questions():
|
||||||
|
|
||||||
# Ask which harddrives/block-devices we will install to
|
# Ask which harddrives/block-devices we will install to
|
||||||
# and convert them into archinstall.BlockDevice() objects.
|
# and convert them into archinstall.BlockDevice() objects.
|
||||||
if archinstall.arguments.get('harddrives', None):
|
if archinstall.arguments.get('harddrives', None) is None:
|
||||||
if type(archinstall.arguments['harddrives']) is str:
|
|
||||||
archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives'].split(',')]
|
|
||||||
else:
|
|
||||||
archinstall.arguments['harddrives'] = archinstall.generic_multi_select(archinstall.all_disks(),
|
archinstall.arguments['harddrives'] = archinstall.generic_multi_select(archinstall.all_disks(),
|
||||||
text="Select one or more harddrives to use and configure (leave blank to skip this step): ",
|
text="Select one or more harddrives to use and configure (leave blank to skip this step): ",
|
||||||
allow_empty=True)
|
allow_empty=True)
|
||||||
|
|
||||||
if archinstall.arguments.get('harddrives', None):
|
if archinstall.arguments.get('harddrives', None) is not None and archinstall.storage.get('disk_layouts', None) is None:
|
||||||
archinstall.storage['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives'])
|
archinstall.storage['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives'])
|
||||||
|
|
||||||
# Get disk encryption password (or skip if blank)
|
# Get disk encryption password (or skip if blank)
|
||||||
|
|
@ -256,8 +251,7 @@ def perform_filesystem_operations():
|
||||||
|
|
||||||
for drive in archinstall.arguments['harddrives']:
|
for drive in archinstall.arguments['harddrives']:
|
||||||
with archinstall.Filesystem(drive, mode) as fs:
|
with archinstall.Filesystem(drive, mode) as fs:
|
||||||
fs.load_layout(archinstall.storage['disk_layouts'][drive])
|
fs.load_layout(archinstall.storage['disk_layouts'][drive.path])
|
||||||
|
|
||||||
|
|
||||||
def perform_installation(mountpoint):
|
def perform_installation(mountpoint):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue