New features
==========
* `BlockDevice()` now has four new functions as well as "improved" cache *(still some improvements to be done)*:
- `BlockDevice().partition_table_type` which returns `GPT` or `MBR` depending on which is used
- `.has_partitions()` which returns the number of partitions
- `.has_mount_point(path)`, returns `True` if any of the block device partitions have been mounted to the given `path`
- `.flush_cache()` which clears the internal partition cache and forces a refresh of the current partitions *(mainly useful for internal use when formatting etc)*
* `BlockDevice()` are now iterable and will iterate over the partitions *(`for partition in BlockDevice("/dev/sda"):`)*.
* `BlockDevice()` will now auto fill information about itself if no information is given during initialization.
* Throughout the [guided.py](https://github.com/Torxed/archinstall/blob/master/examples/guided.py) installation, arguments are now supported from the command-line in to the script via `--argument=value`. This helps testing and enables scripts to utilize archinstall example installations *(minimal and others will get an overhaul soon too)*.
* `Partition()` has a lot of new additions, mainly safety features and a bit of re-work to support more complex partition layouts
- `.target_mountpoint` which sets the desired mount point once the partition is formatted and complete
- `.allow_formatting` *(Bool)* dictates if the archinstall formatter is allowed to touch the partition or not. By default all partitions are set to `False` which ensures that for instance Windows partitions is left untouched. This protection can be overridden by `BlockDevice().keep_partitions = False` which tells archinstall that it's ok to wipe all partitions no matter what individual partitions dictates.
- `Partition()` now auto-mounts if `mountpoint` is given, which is not to say the same as `target_mountpoint` which is post-formatting.
- `Partition()` will now correctly identify itself as encrypted by checking its file system during initialization, which will trigger additional user input / library actions depending on certain conditions.
- `Partition()` is now sortable among other partitions *(and strings)*, based on the full path name of itself.
- `.detect_inner_filesystem()` a helper function that will attempt to detect any inner file systems automatically by decrypting the partition using any supplied password.
- `.has_content()` will mount the partition to a temporary location and check if there's any content inside that temporary mount location. Useful to check if `/boot` has content for instance.
- `.safe_to_format()` will return a *bool* depending on some criteria. If `.allow_formatting` is `False` for instance, then `.safe_to_format()` will also return `False`.
- `.encrypt(*args, **kwargs)` is a helper/wrapper around setting up and calling `luks2().encrypt(*args, **kwargs)`.
- `.format()` has some new safety checks/features implemented to avoid accidental formatting.
- `.unmount()` *(`.umount` is an alias)* will attempt to unmount the partition.
- `.filesystem_supported()` is a new helper function that will format the partitions selected file system against `/dev/null` to determine if the format is supported, or if the selected file format isn't supported by archinstall.
* `Filesystem()` has been re-worked quite a bit to incorporate some new partition flexability. It now supports existing partition schemes by simply honoring what flags are set in `Partition()`. But some new features, logic and flags are:
- Will now check `self.blockdevice.keep_partitions`, and if `False` will initiate a new disk label wiping any existing partitions.
- `.find_partition(mountpoint)` will iterate the partitions for the selected drive and find any partition with the given mount point and return that partition.
- `.use_entire_disk()` have been re-worked completely to accommodate a new way of formatting. This function instead of actually formatting, will simply create a file system definition, and mark the partitions as ready to be formatted and set the protective flags accordingly. And if encryption is specified, will mark the correct partitions as encrypted triggering further actions later on in the library calls.
* `disk.py` also has `get_mount_info(path)` to get information based on a mount-point
* `disk.py` also has `get_filesystem_type(path)` which will return a single string representing the file system on that path
* `archinstall.exceptions.SysCallError` now has a property that can be fetched during a `try/catch`, which is `err.exit_code` which might be useful to debug/set actions depending on a syscall that exits as non-zero.
* `JSON_Encoder` now properly creates a copy of dictionaries rather than replacing keys in the existing dictionary *(the old behavior would overwrite keys and values, causing confusion with the benefit of being more memory conservative)*
* `luks2()` now has some additional parameters, `key_file` and `auto_unmount`. The key-file is just to avoid hard-coded locations for key-file lookups. And `auto_unmount` will automatically close the encrypted partition once the `__exit__` function is called.
- `.mapdev` is also a new property which holds the location of the luks mapper device created during `cryptsetup open`.
- If the partition is being used when we try to call `.encrypt()`, `luks2()` will now attempt to close the device as well as unmount the location where it's mounted and then re-run the `.encrypt()` call.
- Any partition within the encryption will inherit safety-flags once the partition is unlocked. This means if the encrypted partition `/dev/sda2` is selected for formatting, then so will `/dev/sda2 -> /dev/mapper/luksdev` as an example.
- `.format()` is a helper function that will attempt to run `cryptsetup -q -v luksErase` on the encrypted partition.
* `log()` will now default to `LOG_LEVELS.Info` if nothing else is specified.
* `Profile()` will now remember the initilization-namespace given, and `.load_instructions()` can overwrite the namespace during loading of instructions to circumvent potential `if __name__ == "filename"` logics. But once `Profile().install()` is called, the original namespace is restored in favor or triggering those `if __name__ == "filename"` again.
* `Profile()` also has a new helper function called `.has_prep_function()`, which will return `True` if thereis a `def _prep_function()` defined in the profile - but `if __name__ == 'moduleName'` also has to be defined for this helper function to return `True`. This to avoid *"stray code"* to be executed when we try to call `profile._prep_function()` in isolation.
* `Application()` now also resets the namespace prior to executing `.install()`.
* `lib/user_interactions.py` have gotten quite a few new helper functions:
- `get_terminal_height()` and `get_terminal_width()` which returns what it sounds like, the size of the current terminal in terms of character columns and character lines.
- `get_longest_option()` which returns the longest length of any given option within a list.
- `get_password()` which is a helper function to get a password with verification from the user 106
- `print_large_list()` which enables columinzation of largers sets of options courtesy of ninchester and fixes 81.
- `ask_for_superuser_account()` which asks for a single super-user account and has a `force=True` option to enable sticky-asking.
- `ask_for_additional_users()` now asks to create additional users and have the ability to ask and determinate and distinguish between normal users and superusers.
- `ask_for_a_timezone()` can ask and verify selected time zones.
- `ask_to_configure_network()` Now contains questions and options surrounding network configuration. This supports the option to copy existing configurations as well as configuring a specific interface for DHCP or static IP configuration.
- `ask_for_disk_layout()` will ask if the user wants to abort, keep an existing partition layout of wipe the entire drive
- `ask_for_main_filesystem_format()` will ask which file system to use for the root partition `/`, asking from a hard coded set of file systems.
* [examples/guided.py](https://github.com/Torxed/archinstall/blob/master/examples/guided.py) has been re-written more or less entirely. Most of the logic is the same and in the same order. The key differences being that the example now has the steps in functions and they are in order of execution. It also supports arguments via `archinstall.arguments` which translates `python guided.py --argument=value` into `archinstall.arguments['argument']`. It also has a completely re-written partitioning logic to support more flexible partitions.
* The profile `awesome` has been slimmed down further.
Bugs and fixes
===========
* `set_timezone` now properly removes any existing timezone that might be default in the installation 64.
* `set_locale()` no longer adds encoding in the `locale` string, since that's another parameter to [set_locale()](https://github.com/Torxed/archinstall/blob/e0611c276c82b54649b062f7980de7bcf20b5a01/archinstall/lib/installer.py#L161)
* Although not as clean as I would want it, this first generation fix enables encrypted partitions using file formats [other than btrfs](https://github.com/Torxed/archinstall/compare/v2.1.1...v2.1.2#diff-283d51110d004467e254215ad93e4dfcf0188beb22d9f878bb7088c12076dd2eR301-R308) by setting up `mkinitcpio.conf` *"properly"*. In the future, I wish to not overwrite the config as it might interfere with future default Arch Linux changes. But for now this should work.
* `add_bootloader` no longer defaults to a configuration file called `arch.conf`, which worked great in older versions of archinstall where flexability wasn't *really* that important. But since we now support multiple partiton layouts and multi-boot, this had to change 51.
* `Profile()` have been improved and re-worked a bit. Profiles installation function `.install()` no longer set the super-global variable `installation`, instead, `installation.install_profile(profile)` is now responsible for setting this variable. Since we need to install profiles through a installer instance, this makes more sense and also ensures that empty profile instances such as `Profile(None, "awesome")` which has `None` as the installation instance, can still be used for sanity checks - but not installations. This overall logic might be re-worked in the future, but **the global variable `installation` won't be accessible until `.install_profile()` is called** *(perhaps we move this to the `__init__()` function of `Installation()` in the future)*.
This version closes the following issues:
* 64
* 81
* 101
* 51
* 106
* 46
Honorable mentions:
* General improvements to language in user input questions.
* Improved build instructions under the Github wiki
* `lib/disk.py` has some preparations added for `MBR` disk setups which is a work in progress in PR 113
* Trying to use `pathlib.Path()` in as many places as possible