From 00b0ae7ba439a5a420095175b3bedd52c569db51 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Wed, 19 Apr 2023 20:55:42 +1000 Subject: PyParted and a large rewrite of the underlying partitioning (#1604) * Invert mypy files * Add optional pre-commit hooks * New profile structure * Serialize profiles * Use profile instead of classmethod * Custom profile setup * Separator between back * Support profile import via url * Move profiles module * Refactor files * Remove symlink * Add user to docker group * Update schema description * Handle list services * mypy fixes * mypy fixes * Rename profilesv2 to profiles * flake8 * mypy again * Support selecting DM * Fix mypy * Cleanup * Update greeter setting * Update schema * Revert toml changes * Poc external dependencies * Dependency support * New encryption menu * flake8 * Mypy and flake8 * Unify lsblk command * Update bootloader configuration * Git hooks * Fix import * Pyparted * Remove custom font setting * flake8 * Remove default preview * Manual partitioning menu * Update structure * Disk configuration * Update filesystem * luks2 encryption * Everything works until installation * Btrfsutil * Btrfs handling * Update btrfs * Save encryption config * Fix pipewire issue * Update mypy version * Update all pre-commit * Update package versions * Revert audio/pipewire * Merge master PRs * Add master changes * Merge master changes * Small renaming * Pull master changes * Reset disk enc after disk config change * Generate locals * Update naming * Fix imports * Fix broken sync * Fix pre selection on table menu * Profile menu * Update profile * Fix post_install * Added python-pyparted to PKGBUILD, this requires [testing] to be enabled in order to run makepkg. Package still works via python -m build etc. * Swaped around some setuptools logic in pyproject Since we define `package-data` and `packages` there should be no need for: ``` [tool.setuptools.packages.find] where = ["archinstall", "archinstall.*"] ``` * Removed pyproject collisions. Duplicate definitions. * Made sure pyproject.toml includes languages * Add example and update README * Fix pyproject issues * Generate locale * Refactor imports * Simplify imports * Add profile description and package examples * Align code * Fix mypy * Simplify imports * Fix saving config * Fix wrong luks merge * Refactor installation * Fix cdrom device loading * Fix wrongly merged code * Fix imports and greeter * Don't terminate on partprobe error * Use specific path on partprobe from luks * Update archinstall/lib/disk/device_model.py Co-authored-by: codefiles <11915375+codefiles@users.noreply.github.com> * Update archinstall/lib/disk/device_model.py Co-authored-by: codefiles <11915375+codefiles@users.noreply.github.com> * Update github workflow to test archinstall installation * Update sway merge * Generate locales * Update workflow --------- Co-authored-by: Daniel Girtler Co-authored-by: Anton Hvornum Co-authored-by: Anton Hvornum Co-authored-by: codefiles <11915375+codefiles@users.noreply.github.com> --- examples/only_hd_installation.py | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 examples/only_hd_installation.py (limited to 'examples/only_hd_installation.py') diff --git a/examples/only_hd_installation.py b/examples/only_hd_installation.py new file mode 100644 index 00000000..2fc74bf0 --- /dev/null +++ b/examples/only_hd_installation.py @@ -0,0 +1,63 @@ +import logging +from pathlib import Path + +import archinstall +from archinstall import Installer +from archinstall.lib import disk + + +def ask_user_questions(): + global_menu = archinstall.GlobalMenu(data_store=archinstall.arguments) + + global_menu.enable('archinstall-language') + + global_menu.enable('disk_config', mandatory=True) + global_menu.enable('disk_encryption') + global_menu.enable('swap') + + global_menu.enable('save_config') + global_menu.enable('install') + global_menu.enable('abort') + + global_menu.run() + + +def perform_installation(mountpoint: Path): + """ + Performs the installation steps on a block device. + Only requirement is that the block devices are + formatted and setup prior to entering this function. + """ + disk_config: disk.DiskLayoutConfiguration = archinstall.arguments['disk_config'] + disk_encryption: disk.DiskEncryption = archinstall.arguments.get('disk_encryption', None) + + with Installer( + mountpoint, + disk_config, + disk_encryption=disk_encryption, + kernels=archinstall.arguments.get('kernels', ['linux']) + ) as installation: + # Mount all the drives to the desired mountpoint + # This *can* be done outside of the installation, but the installer can deal with it. + if archinstall.arguments.get('disk_config'): + installation.mount_ordered_layout() + + # to generate a fstab directory holder. Avoids an error on exit and at the same time checks the procedure + target = Path(f"{mountpoint}/etc/fstab") + if not target.parent.exists(): + target.parent.mkdir(parents=True) + + # For support reasons, we'll log the disk layout post installation (crash or no crash) + archinstall.log(f"Disk states after installing: {disk.disk_layouts()}", level=logging.DEBUG) + + +ask_user_questions() + +fs_handler = disk.FilesystemHandler( + archinstall.arguments['disk_config'], + archinstall.arguments.get('disk_encryption', None) +) + +fs_handler.perform_filesystem_operations() + +perform_installation(archinstall.storage.get('MOUNT_POINT', Path('/mnt'))) -- cgit v1.2.3-54-g00ecf