Beispiel #1
0
def perform_installation_steps():
	print()
	print('This is your chosen configuration:')
	archinstall.log("-- Guided template chosen (with below config) --", level=archinstall.LOG_LEVELS.Debug)
	archinstall.log(json.dumps(archinstall.arguments, indent=4, sort_keys=True, cls=archinstall.JSON), level=archinstall.LOG_LEVELS.Info)
	print()

	input('Press Enter to continue.')

	"""
		Issue a final warning before we continue with something un-revertable.
		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='')
		archinstall.do_countdown()

		"""
			Setup the blockdevice, filesystem (and optionally encryption).
			Once that's done, we'll hand over to perform_installation()
		"""
		with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs:
			# Wipe the entire drive if the disk flag `keep_partitions`is False.
			if archinstall.arguments['harddrive'].keep_partitions is False:
				fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get('filesystem', 'btrfs'))
			
			# Check if encryption is desired and mark the root partition as encrypted.
			if archinstall.arguments.get('!encryption-password', None):
				root_partition = fs.find_partition('/')
				root_partition.encrypted = True
					
			# After the disk is ready, iterate the partitions and check
			# which ones are safe to format, and format those.
			for partition in archinstall.arguments['harddrive']:
				if partition.safe_to_format():
					# Partition might be marked as encrypted due to the filesystem type crypt_LUKS
					# But we might have omitted the encryption password question to skip encryption.
					# In which case partition.encrypted will be true, but passwd will be false.
					if partition.encrypted and (passwd := archinstall.arguments.get('!encryption-password', None)):
						partition.encrypt(password=passwd)
					else:
						partition.format()
				else:
					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):
				# 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
				# 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:
					unlocked_device.format(fs.find_partition('/').filesystem)
					unlocked_device.mount('/mnt')
			else:
				fs.find_partition('/').format(fs.find_partition('/').filesystem)
				fs.find_partition('/').mount('/mnt')

			fs.find_partition('/boot').mount('/mnt/boot')
Beispiel #2
0
                                archinstall.GPT) as fs:
        # We use the entire disk instead of setting up partitions on your own
        if archinstall.arguments['harddrive'].keep_partitions is False:
            fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get(
                'filesystem', 'btrfs'))

        boot = fs.find_partition('/boot')
        root = fs.find_partition('/')

        boot.format('vfat')

        # We encrypt the root partition if we got a password to do so with,
        # Otherwise we just skip straight to formatting and installation
        if archinstall.arguments.get('!encryption-password', None):
            root.encrypted = True
            root.encrypt(password=archinstall.arguments.get(
                '!encryption-password', None))

            with archinstall.luks2(
                    root, 'luksloop',
                    archinstall.arguments.get('!encryption-password',
                                              None)) as unlocked_root:
                unlocked_root.format(root.filesystem)
                unlocked_root.mount('/mnt')
        else:
            root.format(root.filesystem)
            root.mount('/mnt')

        boot.mount('/mnt/boot')

install_on('/mnt')
Beispiel #3
0
def perform_installation_steps():
    global SIG_TRIGGER

    print()
    print('This is your chosen configuration:')
    archinstall.log("-- Guided template chosen (with below config) --",
                    level=archinstall.LOG_LEVELS.Debug)
    archinstall.log(json.dumps(archinstall.arguments,
                               indent=4,
                               sort_keys=True,
                               cls=archinstall.JSON),
                    level=archinstall.LOG_LEVELS.Info)
    print()

    input('Press Enter to continue.')
    """
		Issue a final warning before we continue with something un-revertable.
		We mention the drive one last time, and count from 5 to 0.
	"""

    print(f" ! Formatting {archinstall.arguments['harddrive']} in ", end='')

    for i in range(5, 0, -1):
        print(f"{i}", end='')

        for x in range(4):
            sys.stdout.flush()
            time.sleep(0.25)
            print(".", end='')

        if SIG_TRIGGER:
            abort = input('\nDo you really want to abort (y/n)? ')
            if abort.strip() != 'n':
                exit(0)

            if SIG_TRIGGER is False:
                sys.stdin.read()
            SIG_TRIGGER = False
            signal.signal(signal.SIGINT, sig_handler)

    # Put back the default/original signal handler now that we're done catching
    # and interrupting SIGINT with "Do you really want to abort".
    print()
    signal.signal(signal.SIGINT, original_sigint_handler)
    """
		Setup the blockdevice, filesystem (and optionally encryption).
		Once that's done, we'll hand over to perform_installation()
	"""
    with archinstall.Filesystem(archinstall.arguments['harddrive'],
                                archinstall.GPT) as fs:
        # Wipe the entire drive if the disk flag `keep_partitions`is False.
        if archinstall.arguments['harddrive'].keep_partitions is False:
            fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get(
                'filesystem', 'btrfs'))

        # Check if encryption is desired and mark the root partition as encrypted.
        if archinstall.arguments.get('!encryption-password', None):
            root_partition = fs.find_partition('/')
            root_partition.encrypted = True

        # After the disk is ready, iterate the partitions and check
        # which ones are safe to format, and format those.
        for partition in archinstall.arguments['harddrive']:
            if partition.safe_to_format():
                # Partition might be marked as encrypted due to the filesystem type crypt_LUKS
                # But we might have omitted the encryption password question to skip encryption.
                # In which case partition.encrypted will be true, but passwd will be false.
                if partition.encrypted and (passwd :=
                                            archinstall.arguments.get(
                                                '!encryption-password', None)):
                    partition.encrypt(password=passwd)
                else:
                    partition.format()
            else:
                archinstall.log(
                    f"Did not format {partition} because .safe_to_format() returned False or .allow_formatting was False.",
                    level=archinstall.LOG_LEVELS.Debug)

        if archinstall.arguments.get('!encryption-password', None):
            # 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
            # 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:
                unlocked_device.format(fs.find_partition('/').filesystem)

                perform_installation(
                    device=unlocked_device,
                    boot_partition=fs.find_partition('/boot'),
                    language=archinstall.arguments['keyboard-language'],
                    mirrors=archinstall.arguments['mirror-region'])
        else:
            perform_installation(
                device=fs.find_partition('/'),
                boot_partition=fs.find_partition('/boot'),
                language=archinstall.arguments['keyboard-language'],
                mirrors=archinstall.arguments['mirror-region'])
archinstall.sys_command(
    f'cryptsetup close /dev/mapper/luksloop', suppress_errors=True)

# Select a harddrive and a disk password
harddrive = archinstall.all_disks()['/dev/sda']
disk_password = '******'

with archinstall.Filesystem(harddrive, archinstall.GPT) as fs:
    # Use the entire disk instead of setting up partitions on your own
    fs.use_entire_disk('luks2')

    if harddrive.partition[1].size == '512M':
        raise OSError('Trying to encrypt the boot partition for petes sake..')
    harddrive.partition[0].format('fat32')

    with archinstall.luks2(harddrive.partition[1], 'luksloop', disk_password) as unlocked_device:
        unlocked_device.format('btrfs')

        with archinstall.Installer(
            unlocked_device,
            boot_partition=harddrive.partition[0],
            hostname="testmachine"
        ) as installation:
            if installation.minimal_installation():
                installation.add_bootloader()

                installation.add_additional_packages(['nano', 'wget', 'git'])
                installation.install_profile('awesome')

                installation.user_create('anton', 'test')
                installation.user_set_pw('root', 'toor')
Beispiel #5
0
        if not harddrive.keep_partitions:
            fs.use_entire_disk(root_filesystem_type='ext4')
            boot = fs.find_partition('/boot')
            root = fs.find_partition('/')

        root.allow_formatting = True
        if not input("keep_boot?: "):
            boot.allow_formatting = True
            boot.format('vfat')

        for mp in extra_partitions:
            mp['part'].mount('/mnt' + mp)
        # We encrypt the root partition if we got a password to do so with,
        # Otherwise we just skip straight to formatting and installation
        if len(disk_password) > 0:
            print("encrypting")
            root.encrypted = True
            root.encrypt(password=disk_password)

            with archinstall.luks2(root, 'luksloop',
                                   disk_password) as unlocked_root:
                unlocked_root.format(root.filesystem)
                unlocked_root.mount('/mnt')
        else:
            root.format(root.filesystem)
            root.mount('/mnt')

        boot.mount('/mnt/boot')

install_on('/mnt')