Added a 'use /mnt' option to the formatted #124. This has not yet been tested, but the logic should work according to the new API layout for Installation().

This commit is contained in:
Anton Hvornum 2021-04-09 15:27:22 +02:00
parent 740eccb213
commit f298b9e393
No known key found for this signature in database
GPG Key ID: F1234C5BA67C59DF
2 changed files with 54 additions and 48 deletions

View File

@ -179,6 +179,7 @@ def ask_to_configure_network():
def ask_for_disk_layout(): def ask_for_disk_layout():
options = { options = {
'keep-existing' : 'Keep existing partition layout and select which ones to use where.', 'keep-existing' : 'Keep existing partition layout and select which ones to use where.',
'use-mnt' : 'Use whatever is mounted under /mnt and don\'t format anything',
'format-all' : 'Format entire drive and setup a basic partition scheme.', 'format-all' : 'Format entire drive and setup a basic partition scheme.',
'abort' : 'Abort the installation.' 'abort' : 'Abort the installation.'
} }

View File

@ -53,6 +53,9 @@ def ask_user_questions():
if (option := archinstall.ask_for_disk_layout()) == 'abort': if (option := archinstall.ask_for_disk_layout()) == 'abort':
archinstall.log(f"Safely aborting the installation. No changes to the disk or system has been made.") archinstall.log(f"Safely aborting the installation. No changes to the disk or system has been made.")
exit(1) exit(1)
elif option == 'use-mnt':
archinstall.arguments['harddrive'] = None
archinstall.arguments['target-mount'] = '/mnt'
elif option == 'keep-existing': elif option == 'keep-existing':
archinstall.arguments['harddrive'].keep_partitions = True archinstall.arguments['harddrive'].keep_partitions = True
@ -197,6 +200,7 @@ def perform_installation_steps():
We mention the drive one last time, and count from 5 to 0. We mention the drive one last time, and count from 5 to 0.
""" """
if archinstall.arguments.get('harddrive', None):
print(f" ! Formatting {archinstall.arguments['harddrive']} in ", end='') print(f" ! Formatting {archinstall.arguments['harddrive']} in ", end='')
archinstall.do_countdown() archinstall.do_countdown()
@ -228,31 +232,31 @@ def perform_installation_steps():
else: else:
archinstall.log(f"Did not format {partition} because .safe_to_format() returned False or .allow_formatting was False.", level=archinstall.LOG_LEVELS.Debug) archinstall.log(f"Did not format {partition} because .safe_to_format() returned False or .allow_formatting was False.", level=archinstall.LOG_LEVELS.Debug)
fs.find_partition('/boot').format('vfat')
if archinstall.arguments.get('!encryption-password', None): if archinstall.arguments.get('!encryption-password', None):
# First encrypt and unlock, then format the desired partition inside the encrypted part. # First encrypt and unlock, then format the desired partition inside the encrypted part.
# archinstall.luks2() encrypts the partition when entering the with context manager, and # archinstall.luks2() encrypts the partition when entering the with context manager, and
# unlocks the drive so that it can be used as a normal block-device within archinstall. # unlocks the drive so that it can be used as a normal block-device within archinstall.
with archinstall.luks2(fs.find_partition('/'), 'luksloop', archinstall.arguments.get('!encryption-password', None)) as unlocked_device: with archinstall.luks2(fs.find_partition('/'), 'luksloop', archinstall.arguments.get('!encryption-password', None)) as unlocked_device:
unlocked_device.format(fs.find_partition('/').filesystem) unlocked_device.format(fs.find_partition('/').filesystem)
unlocked_device.mount('/mnt')
perform_installation(device=unlocked_device,
boot_partition=fs.find_partition('/boot'),
language=archinstall.arguments['keyboard-language'],
mirrors=archinstall.arguments['mirror-region'])
else: else:
perform_installation(device=fs.find_partition('/'), fs.find_partition('/').format(fs.find_partition('/').filesystem)
boot_partition=fs.find_partition('/boot'), fs.find_partition('/').mount('/mnt')
language=archinstall.arguments['keyboard-language'],
mirrors=archinstall.arguments['mirror-region']) fs.find_partition('/boot').mount('/mnt/boot')
perform_installation('/mnt')
def perform_installation(device, boot_partition, language, mirrors): def perform_installation(mountpoint):
""" """
Performs the installation steps on a block device. Performs the installation steps on a block device.
Only requirement is that the block devices are Only requirement is that the block devices are
formatted and setup prior to entering this function. formatted and setup prior to entering this function.
""" """
with archinstall.Installer(device, boot_partition=boot_partition, hostname=archinstall.arguments.get('hostname', 'Archinstall')) as installation: with archinstall.Installer(mountpoint) as installation:
## if len(mirrors): ## if len(mirrors):
# Certain services might be running that affects the system during installation. # Certain services might be running that affects the system during installation.
# Currently, only one such service is "reflector.service" which updates /etc/pacman.d/mirrorlist # Currently, only one such service is "reflector.service" which updates /etc/pacman.d/mirrorlist
@ -261,10 +265,11 @@ def perform_installation(device, boot_partition, language, mirrors):
while 'dead' not in (status := archinstall.service_state('reflector')): while 'dead' not in (status := archinstall.service_state('reflector')):
time.sleep(1) time.sleep(1)
archinstall.use_mirrors(mirrors) # Set the mirrors for the live medium archinstall.use_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors for the live medium
if installation.minimal_installation(): if installation.minimal_installation():
installation.set_mirrors(mirrors) # Set the mirrors in the installation medium installation.set_hostname(archinstall.arguments['hostname'])
installation.set_keyboard_language(language) installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium
installation.set_keyboard_language(archinstall.arguments['keyboard-language'])
installation.add_bootloader() installation.add_bootloader()
# If user selected to copy the current ISO network configuration # If user selected to copy the current ISO network configuration