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.py | 151 ---------------------------------------------------- 1 file changed, 151 deletions(-) delete mode 100644 examples/only_hd.py (limited to 'examples/only_hd.py') diff --git a/examples/only_hd.py b/examples/only_hd.py deleted file mode 100644 index e3d18f0a..00000000 --- a/examples/only_hd.py +++ /dev/null @@ -1,151 +0,0 @@ - -import logging -import os -import pathlib - -import archinstall -from archinstall import ConfigurationOutput - - -class OnlyHDMenu(archinstall.GlobalMenu): - def _setup_selection_menu_options(self): - super()._setup_selection_menu_options() - options_list = [] - mandatory_list = [] - options_list = ['harddrives', 'disk_layouts', 'disk_encryption','swap'] - mandatory_list = ['harddrives'] - options_list.extend(['save_config','install','abort']) - - for entry in self._menu_options: - if entry in options_list: - # for not lineal executions, only self.option(entry).set_enabled and set_mandatory are necessary - if entry in mandatory_list: - self.enable(entry,mandatory=True) - else: - self.enable(entry) - else: - self.option(entry).set_enabled(False) - self._update_install_text() - - def mandatory_lacking(self) -> [int, list]: - mandatory_fields = [] - mandatory_waiting = 0 - for field in self._menu_options: - option = self._menu_options[field] - if option.is_mandatory(): - if not option.has_selection(): - mandatory_waiting += 1 - mandatory_fields += [field,] - return mandatory_fields, mandatory_waiting - - def _missing_configs(self): - """ overloaded method """ - def check(s): - return self.option(s).has_selection() - - missing, missing_cnt = self.mandatory_lacking() - if check('harddrives'): - if not self.option('harddrives').is_empty() and not check('disk_layouts'): - missing_cnt += 1 - missing += ['disk_layout'] - return missing - -def ask_user_questions(): - """ - First, we'll ask the user for a bunch of user input. - Not until we're satisfied with what we want to install - will we continue with the actual installation steps. - """ - with OnlyHDMenu(data_store=archinstall.arguments) as menu: - # We select the execution language separated - menu.exec_option('archinstall-language') - menu.option('archinstall-language').set_enabled(False) - menu.run() - -def perform_disk_operations(): - """ - 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('harddrives', None): - print(f" ! Formatting {archinstall.arguments['harddrives']} in ", end='') - archinstall.do_countdown() - """ - Setup the blockdevice, filesystem (and optionally encryption). - Once that's done, we'll hand over to perform_installation() - """ - mode = archinstall.GPT - if archinstall.has_uefi() is False: - mode = archinstall.MBR - - for drive in archinstall.arguments.get('harddrives', []): - if archinstall.arguments.get('disk_layouts', {}).get(drive.path): - with archinstall.Filesystem(drive, mode) as fs: - fs.load_layout(archinstall.arguments['disk_layouts'][drive.path]) - -def perform_installation(mountpoint): - """ - Performs the installation steps on a block device. - Only requirement is that the block devices are - formatted and setup prior to entering this function. - """ - with archinstall.Installer(mountpoint, kernels=None) 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_layouts'): - installation.mount_ordered_layout(archinstall.arguments['disk_layouts']) - - # Placing /boot check during installation because this will catch both re-use and wipe scenarios. - for partition in installation.partitions: - if partition.mountpoint == installation.target + '/boot': - if partition.size <= 0.25: # in GB - raise archinstall.DiskError(f"The selected /boot partition in use is not large enough to properly install a boot loader. Please resize it to at least 256MB and re-run the installation.") - # to generate a fstab directory holder. Avoids an error on exit and at the same time checks the procedure - target = pathlib.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: {archinstall.disk_layouts()}", level=logging.DEBUG) - -def log_execution_environment(): - # Log various information about hardware before starting the installation. This might assist in troubleshooting - archinstall.log(f"Hardware model detected: {archinstall.sys_vendor()} {archinstall.product_name()}; UEFI mode: {archinstall.has_uefi()}", level=logging.DEBUG) - archinstall.log(f"Processor model detected: {archinstall.cpu_model()}", level=logging.DEBUG) - archinstall.log(f"Memory statistics: {archinstall.mem_available()} available out of {archinstall.mem_total()} total installed", level=logging.DEBUG) - archinstall.log(f"Virtualization detected: {archinstall.virtualization()}; is VM: {archinstall.is_vm()}", level=logging.DEBUG) - archinstall.log(f"Graphics devices detected: {archinstall.graphics_devices().keys()}", level=logging.DEBUG) - - # For support reasons, we'll log the disk layout pre installation to match against post-installation layout - archinstall.log(f"Disk states before installing: {archinstall.disk_layouts()}", level=logging.DEBUG) - - -if archinstall.arguments.get('help'): - print("See `man archinstall` for help.") - exit(0) -if os.getuid() != 0: - print("Archinstall requires root privileges to run. See --help for more.") - exit(1) - -log_execution_environment() - -if not archinstall.check_mirror_reachable(): - log_file = os.path.join(archinstall.storage.get('LOG_PATH', None), archinstall.storage.get('LOG_FILE', None)) - archinstall.log(f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'.", level=logging.INFO, fg="red") - exit(1) - -if not archinstall.arguments.get('silent'): - ask_user_questions() - -config_output = ConfigurationOutput(archinstall.arguments) -if not archinstall.arguments.get('silent'): - config_output.show() -config_output.save() - -if archinstall.arguments.get('dry_run'): - exit(0) -if not archinstall.arguments.get('silent'): - input('Press Enter to continue.') - -perform_disk_operations() -perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt')) -- cgit v1.2.3-70-g09d2