From 4a5d38ff8a6615e837a5795abb1096a7360cfdc1 Mon Sep 17 00:00:00 2001 From: benni347 <64905406+benni347@users.noreply.github.com> Date: Sun, 2 Oct 2022 22:10:04 +0200 Subject: Fixed spelling mistakes (#1496) * Fixed spelling mistakes * Fixed the spelling of JSON so it comforms to the offical spelling of it. --- archinstall/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'archinstall') diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 44852d4c..108e51b2 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -156,18 +156,18 @@ def get_arguments() -> Dict[str, Any]: Is done on following steps: 0) we create a dict to store the arguments and their values 1) preprocess. - We take those arguments which use Json files, and read them into the argument dict. So each first level entry becomes a argument un it's own right + We take those arguments which use JSON files, and read them into the argument dict. So each first level entry becomes a argument on it's own right 2) Load. - We convert the predefined argument list directly into the dict vía the vars() función. Non specified arguments are loaded with value None or false if they are booleans (action="store_true"). + We convert the predefined argument list directly into the dict via the vars() function. Non specified arguments are loaded with value None or false if they are booleans (action="store_true"). The name is chosen according to argparse conventions. See above (the first text is used as argument name, but underscore substitutes dash) We then load all the undefined arguments. In this case the names are taken as written. - Important. This way explicit command line arguments take precedence over configuración files. + Important. This way explicit command line arguments take precedence over configuration files. 3) Amend Change whatever is needed on the configuration dictionary (it could be done in post_process_arguments but this ougth to be left to changes anywhere else in the code, not in the arguments dictionary """ config = {} args, unknowns = parser.parse_known_args() - # preprocess the json files. + # preprocess the JSON files. # TODO Expand the url access to the other JSON file arguments ? if args.config is not None: if not json_stream_to_structure('--config', args.config, config): -- cgit v1.2.3-70-g09d2 From cfea7b2f7bc71262fdf80a54d3e0133fa0f75dee Mon Sep 17 00:00:00 2001 From: Nicolas MF <52258510+nicolasmf@users.noreply.github.com> Date: Mon, 3 Oct 2022 16:07:30 +0200 Subject: Fixed typo (#1500) --- archinstall/locales/fr/LC_MESSAGES/base.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall') diff --git a/archinstall/locales/fr/LC_MESSAGES/base.po b/archinstall/locales/fr/LC_MESSAGES/base.po index f85c9e25..e58592bf 100644 --- a/archinstall/locales/fr/LC_MESSAGES/base.po +++ b/archinstall/locales/fr/LC_MESSAGES/base.po @@ -259,7 +259,7 @@ msgid "Disk layout" msgstr "Disposition du disque" msgid "Encryption password" -msgstr "Mot de passe de cryptage" +msgstr "Mot de passe de chiffrement" msgid "Swap" msgstr "Swap" @@ -367,7 +367,7 @@ msgid "Enter a password: " msgstr "Entrer un mot de passe : " msgid "Enter a encryption password for {}" -msgstr "Entrer un mot de passe de cryptage pour {}" +msgstr "Entrer un mot de passe de chiffrement pour {}" msgid "Enter disk encryption password (leave blank for no encryption): " msgstr "Entrer le mot de passe de chiffrement du disque (laisser vide pour aucun chiffrement) : " -- cgit v1.2.3-70-g09d2 From fcb53e4d56b9f0ec78825f27a5224425245455c8 Mon Sep 17 00:00:00 2001 From: Oskar Date: Mon, 3 Oct 2022 16:22:37 +0200 Subject: Fix Polish translation (#1492) * Fix Polish language name * Fix message "Should this user be a superuser (sudoer)?" --- archinstall/locales/README.md | 2 +- archinstall/locales/languages.json | 2 +- archinstall/locales/pl/LC_MESSAGES/base.mo | Bin 23368 -> 23373 bytes archinstall/locales/pl/LC_MESSAGES/base.po | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) (limited to 'archinstall') diff --git a/archinstall/locales/README.md b/archinstall/locales/README.md index 37dc32e3..cd7d794a 100644 --- a/archinstall/locales/README.md +++ b/archinstall/locales/README.md @@ -54,5 +54,5 @@ To display the language inside Archinstall in your own tongue, please edit the f add a `translated_lang` entry to the respective language, e.g. ``` - {"abbr": "pl", "lang": "Polish", "translated_lang": "Polskie"} + {"abbr": "pl", "lang": "Polish", "translated_lang": "Polski"} ``` diff --git a/archinstall/locales/languages.json b/archinstall/locales/languages.json index 7bee29db..43391d5e 100644 --- a/archinstall/locales/languages.json +++ b/archinstall/locales/languages.json @@ -126,7 +126,7 @@ {"abbr": "os", "lang": "Ossetian"}, {"abbr": "pa", "lang": "Panjabi"}, {"abbr": "pi", "lang": "Pali"}, - {"abbr": "pl", "lang": "Polish", "translated_lang": "Polskie"}, + {"abbr": "pl", "lang": "Polish", "translated_lang": "Polski"}, {"abbr": "pt", "lang": "Portuguese", "translated_lang": "Português"}, {"abbr": "pt_BR", "lang": "Brazilian Portuguese", "translated_lang": "Portugues do Brasil"}, {"abbr": "ps", "lang": "Pushto"}, diff --git a/archinstall/locales/pl/LC_MESSAGES/base.mo b/archinstall/locales/pl/LC_MESSAGES/base.mo index 05fbedaf..e9051d78 100644 Binary files a/archinstall/locales/pl/LC_MESSAGES/base.mo and b/archinstall/locales/pl/LC_MESSAGES/base.mo differ diff --git a/archinstall/locales/pl/LC_MESSAGES/base.po b/archinstall/locales/pl/LC_MESSAGES/base.po index 9b12b024..d1c50634 100644 --- a/archinstall/locales/pl/LC_MESSAGES/base.po +++ b/archinstall/locales/pl/LC_MESSAGES/base.po @@ -32,7 +32,7 @@ msgid "Any additional users to install (leave blank for no users): " msgstr "Ewentualni użytkownicy do instalacji (pozostaw puste jeśli nie chcesz tworzyć użytkowników): " msgid "Should this user be a superuser (sudoer)?" -msgstr "Czy użytkownik powinien superużytkownikiem (sudoer)?" +msgstr "Czy użytkownik powinien być superużytkownikiem (sudoer)?" msgid "Select a timezone" msgstr "Wybierz strefę czasową" -- cgit v1.2.3-70-g09d2 From c7275e7e100e415ae7685b0aea88597a8cf81f18 Mon Sep 17 00:00:00 2001 From: Giovanni <82442402+gdonisi@users.noreply.github.com> Date: Mon, 3 Oct 2022 16:25:05 +0200 Subject: Update Italian translation (#1490) --- archinstall/locales/it/LC_MESSAGES/base.mo | Bin 23841 -> 27015 bytes archinstall/locales/it/LC_MESSAGES/base.po | 67 +++++++++++++++-------------- 2 files changed, 34 insertions(+), 33 deletions(-) (limited to 'archinstall') diff --git a/archinstall/locales/it/LC_MESSAGES/base.mo b/archinstall/locales/it/LC_MESSAGES/base.mo index c6d984c3..e1dccd81 100644 Binary files a/archinstall/locales/it/LC_MESSAGES/base.mo and b/archinstall/locales/it/LC_MESSAGES/base.mo differ diff --git a/archinstall/locales/it/LC_MESSAGES/base.po b/archinstall/locales/it/LC_MESSAGES/base.po index 905ad7cf..d122b87f 100644 --- a/archinstall/locales/it/LC_MESSAGES/base.po +++ b/archinstall/locales/it/LC_MESSAGES/base.po @@ -9,7 +9,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.0.1\n" +"X-Generator: Poedit 3.1.1\n" msgid "[!] A log file has been created here: {} {}" msgstr "[!] Un file di log è stato creato qui: {} {}" @@ -659,7 +659,6 @@ msgstr "Un'installazione molto semplice che ti consente di personalizzare Arch L msgid "Provides a selection of various server packages to install and enable, e.g. httpd, nginx, mariadb" msgstr "Fornisce una selezione di vari pacchetti server da installare e abilitare, per esempio httpd, nginx, mariadb" -#, fuzzy msgid "Choose which servers to install, if none then a minimal installation will be done" msgstr "Scegli quali server installare, se nessuno verrà eseguita un'installazione minima" @@ -752,56 +751,47 @@ msgstr "Spazio libero" msgid "Bus-type" msgstr "Tipo di bus" -#, fuzzy msgid "Either root-password or at least 1 user with sudo privileges must be specified" -msgstr "È necessario specificare la password di root o almeno 1 superuser" +msgstr "È necessario specificare la password di root o almeno 1 utente con privilegi sudo" -#, fuzzy msgid "Enter username (leave blank to skip): " -msgstr "Inserisci un nome utente per creare un utente aggiuntivo (lascia vuoto per saltare): " +msgstr "Inserisci il nome utente (lascia vuoto per saltare): " msgid "The username you entered is invalid. Try again" -msgstr "" +msgstr "Il nome utente inserito non è valido. Riprova" -#, fuzzy msgid "Should \"{}\" be a superuser (sudo)?" -msgstr "{} dovrebbe essere un superutente? (sudoer)" +msgstr "\"{}\" dovrebbe essere un superutente? (sudo)" -#, fuzzy msgid "Select which partitions to encrypt:" -msgstr "" -"{}\n" -"\n" -"Seleziona quale partizione contrassegnare come crittografata" +msgstr "Seleziona le partizioni da crittografare:" msgid "very weak" -msgstr "" +msgstr "molto debole" msgid "weak" -msgstr "" +msgstr "debole" msgid "moderate" -msgstr "" +msgstr "discreto" msgid "strong" -msgstr "" +msgstr "forte" -#, fuzzy msgid "Add subvolume" -msgstr " Sottovolume :{:16}" +msgstr "Aggiungi sottovolume" msgid "Edit subvolume" -msgstr "" +msgstr "Modifica sottovolume" -#, fuzzy msgid "Delete subvolume" -msgstr "Elimina utente" +msgstr "Elimina sottovolume" msgid "Configured {} interfaces" -msgstr "" +msgstr "Configurate {} interfacce" msgid "This option enables the number of parallel downloads that can occur during installation" -msgstr "" +msgstr "Questa opzione consente di impostare il numero di download paralleli che possono avvenire durante l'installazione" #, python-brace-format msgid "" @@ -809,29 +799,40 @@ msgid "" " (Enter a value between 1 to {max_downloads})\n" "Note:" msgstr "" +"Inserisci il numero di download paralleli da abilitare.\n" +" (Inserisci un valore compreso tra 1 e {max_downloads})\n" +"Nota:" msgid " - Maximum value : {max_downloads} ( Allows {max_downloads} parallel downloads, allows {max_downloads+1} downloads at a time )" -msgstr "" +msgstr " - Valore massimo : {max_downloads} ( Consente {max_downloads} download parallelo, consente {max_downloads+1} download alla volta )" msgid " - Minimum value : 1 ( Allows 1 parallel download, allows 2 downloads at a time )" -msgstr "" +msgstr " - Valore minimo : 1 ( Consente 1 download parallelo, consente 2 download alla volta )" msgid " - Disable/Default : 0 ( Disables parallel downloading, allows only 1 download at a time )" -msgstr "" +msgstr " - Disabilita/Predefinito : 0 ( Disabilita il download parallelo, consente solo 1 download alla volta )" #, python-brace-format msgid "Invalid input! Try again with a valid input [1 to {max_downloads}, or 0 to disable]" -msgstr "" +msgstr "Input non valido! Riprova con un input valido [da 1 a {max_downloads}, o 0 per disabilitare]." msgid "Parallel Downloads" -msgstr "" +msgstr "Download paralleli" -#, fuzzy msgid "ESC to skip" msgstr "Usa ESC per saltare" msgid "CTRL+C to reset" -msgstr "" +msgstr "CTRL+C per resettare" msgid "TAB to select" -msgstr "" +msgstr "TAB per selezionare" + +msgid "[Default value: 0] > " +msgstr "[Valore predefinito: 0] > " + +msgid "To be able to use this translation, please install a font manually that supports the language." +msgstr "Per poter utilizzare questa traduzione, installa manualmente un font che supporti la lingua." + +msgid "The font should be stored as {}" +msgstr "Il carattere dovrebbe essere memorizzato come {}" -- cgit v1.2.3-70-g09d2 From 5959cde5cb43c166d44af49864ab50d5584ecf45 Mon Sep 17 00:00:00 2001 From: "K.B.Dharun Krishna" Date: Mon, 3 Oct 2022 19:55:37 +0530 Subject: Update ta locale (#1486) Signed-off-by: K.B.Dharun Krishna Signed-off-by: K.B.Dharun Krishna --- archinstall/locales/ta/LC_MESSAGES/base.mo | Bin 47919 -> 48222 bytes archinstall/locales/ta/LC_MESSAGES/base.po | 9 ++++----- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'archinstall') diff --git a/archinstall/locales/ta/LC_MESSAGES/base.mo b/archinstall/locales/ta/LC_MESSAGES/base.mo index 2129b1fb..20b8a7f5 100644 Binary files a/archinstall/locales/ta/LC_MESSAGES/base.mo and b/archinstall/locales/ta/LC_MESSAGES/base.mo differ diff --git a/archinstall/locales/ta/LC_MESSAGES/base.po b/archinstall/locales/ta/LC_MESSAGES/base.po index fa32830b..3ea3dd19 100644 --- a/archinstall/locales/ta/LC_MESSAGES/base.po +++ b/archinstall/locales/ta/LC_MESSAGES/base.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: \n" "PO-Revision-Date: \n" -"Last-Translator: \n" +"Last-Translator: K.B.Dharun Krishna \n" "Language-Team: \n" "Language: ta\n" "MIME-Version: 1.0\n" @@ -819,12 +819,11 @@ msgstr "தவறான உள்ளீடு! சரியான உள்ள msgid "Parallel Downloads" msgstr "இணையான பதிவிறக்கங்கள்" -#, fuzzy msgid "ESC to skip" -msgstr "தவிர்க்க ESC ஐப் பயன்படுத்தவும்" +msgstr "தவிர்க்க ESC" msgid "CTRL+C to reset" -msgstr "" +msgstr "மீட்டமைக்க CTRL+C" msgid "TAB to select" -msgstr "" +msgstr "தேர்ந்தெடுக்க TAB" -- cgit v1.2.3-70-g09d2 From 40e4046633d857929b8fd1bfa121b38937add81c Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Tue, 4 Oct 2022 01:37:57 +1100 Subject: Exclude archiso devices from selectable blockdevices (#1481) * Exclude liveusb from disk selection * Exclude arch iso from being an option * Update * Update * Update * Mypy Co-authored-by: Daniel Girtler --- .github/workflows/mypy.yaml | 2 +- archinstall/lib/disk/diskinfo.py | 40 +++++++++++++++++++++++++ archinstall/lib/disk/helpers.py | 27 +++++++++++++---- archinstall/lib/menu/global_menu.py | 2 +- archinstall/lib/user_interaction/system_conf.py | 7 +---- 5 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 archinstall/lib/disk/diskinfo.py (limited to 'archinstall') diff --git a/.github/workflows/mypy.yaml b/.github/workflows/mypy.yaml index 160faa53..6a4a9860 100644 --- a/.github/workflows/mypy.yaml +++ b/.github/workflows/mypy.yaml @@ -15,4 +15,4 @@ jobs: # one day this will be enabled # run: mypy --strict --module archinstall || exit 0 - name: run mypy - run: mypy --follow-imports=silent archinstall/lib/menu/selection_menu.py archinstall/lib/menu/global_menu.py archinstall/lib/models/network_configuration.py archinstall/lib/menu/list_manager.py archinstall/lib/user_interaction/network_conf.py archinstall/lib/models/users.py archinstall/lib/disk/blockdevice.py archinstall/lib/user_interaction/subvolume_config.py archinstall/lib/disk/btrfs/btrfs_helpers.py archinstall/lib/translationhandler.py + run: mypy --follow-imports=silent archinstall/lib/menu/selection_menu.py archinstall/lib/menu/global_menu.py archinstall/lib/models/network_configuration.py archinstall/lib/menu/list_manager.py archinstall/lib/user_interaction/network_conf.py archinstall/lib/models/users.py archinstall/lib/disk/blockdevice.py archinstall/lib/user_interaction/subvolume_config.py archinstall/lib/disk/btrfs/btrfs_helpers.py archinstall/lib/translationhandler.py archinstall/lib/disk/diskinfo.py diff --git a/archinstall/lib/disk/diskinfo.py b/archinstall/lib/disk/diskinfo.py new file mode 100644 index 00000000..b56ba282 --- /dev/null +++ b/archinstall/lib/disk/diskinfo.py @@ -0,0 +1,40 @@ +import dataclasses +import json +from dataclasses import dataclass, field +from typing import Optional, List + +from ..general import SysCommand +from ..exceptions import DiskError + +@dataclass +class LsblkInfo: + size: int = 0 + log_sec: int = 0 + pttype: Optional[str] = None + rota: bool = False + tran: Optional[str] = None + ptuuid: Optional[str] = None + partuuid: Optional[str] = None + uuid: Optional[str] = None + fstype: Optional[str] = None + type: Optional[str] = None + mountpoints: List[str] = field(default_factory=list) + + +def get_lsblk_info(dev_path: str) -> LsblkInfo: + fields = [f.name for f in dataclasses.fields(LsblkInfo)] + lsblk_fields = ','.join([f.upper().replace('_', '-') for f in fields]) + + output = SysCommand(f'lsblk --json -b -o+{lsblk_fields} {dev_path}').decode('UTF-8') + + if output: + block_devices = json.loads(output) + info = block_devices['blockdevices'][0] + lsblk_info = LsblkInfo() + + for f in fields: + setattr(lsblk_info, f, info[f.replace('_', '-')]) + + return lsblk_info + + raise DiskError(f'Failed to read disk "{dev_path}" with lsblk') diff --git a/archinstall/lib/disk/helpers.py b/archinstall/lib/disk/helpers.py index f19125f4..256f7abb 100644 --- a/archinstall/lib/disk/helpers.py +++ b/archinstall/lib/disk/helpers.py @@ -6,13 +6,12 @@ import pathlib import re import time import glob + from typing import Union, List, Iterator, Dict, Optional, Any, TYPE_CHECKING # https://stackoverflow.com/a/39757388/929999 +from .diskinfo import get_lsblk_info from ..models.subvolume import Subvolume -if TYPE_CHECKING: - from .partition import Partition - from .blockdevice import BlockDevice from .dmcryptdev import DMCryptDev from .mapperdev import MapperDev @@ -21,6 +20,10 @@ from ..general import SysCommand from ..output import log from ..storage import storage +if TYPE_CHECKING: + from .partition import Partition + + ROOT_DIR_PATTERN = re.compile('^.*?/devices') GIGA = 2 ** 30 @@ -204,11 +207,18 @@ def get_blockdevice_uevent(dev_name :str) -> Dict[str, Any]: } } + def all_disks() -> List[BlockDevice]: log(f"[Deprecated] archinstall.all_disks() is deprecated. Use archinstall.all_blockdevices() with the appropriate filters instead.", level=logging.WARNING, fg="yellow") return all_blockdevices(partitions=False, mappers=False) -def all_blockdevices(mappers=False, partitions=False, error=False) -> Dict[str, Any]: + +def all_blockdevices( + mappers: bool = False, + partitions: bool = False, + error: bool = False, + exclude_iso_dev: bool = True +) -> Dict[str, Any]: """ Returns BlockDevice() and Partition() objects for all available devices. """ @@ -227,6 +237,13 @@ def all_blockdevices(mappers=False, partitions=False, error=False) -> Dict[str, continue try: + if exclude_iso_dev: + # exclude all devices associated with the iso boot locations + iso_devs = ['/run/archiso/airootfs', '/run/archiso/bootmnt'] + lsblk_info = get_lsblk_info(device_path) + if any([dev in lsblk_info.mountpoints for dev in iso_devs]): + continue + information = blkid(f'blkid -p -o export {device_path}') except SysCallError as ex: if ex.exit_code in (512, 2): @@ -416,7 +433,7 @@ def get_partitions_in_use(mountpoint :str) -> Dict[str, Any]: # Since all_blockdevices() returns PosixPath objects, we need to convert # findmnt paths to pathlib.Path() first: mountpoint = pathlib.Path(mountpoint) - + if mountpoint in block_devices_mountpoints: if mountpoint not in mounts: mounts[mountpoint] = block_devices_mountpoints[mountpoint] diff --git a/archinstall/lib/menu/global_menu.py b/archinstall/lib/menu/global_menu.py index d1bec189..444ba7ee 100644 --- a/archinstall/lib/menu/global_menu.py +++ b/archinstall/lib/menu/global_menu.py @@ -341,7 +341,7 @@ class GlobalMenu(GeneralMenu): return ntp - def _select_harddrives(self, old_harddrives : list) -> List: + def _select_harddrives(self, old_harddrives: List[str] = []) -> List: harddrives = select_harddrives(old_harddrives) if harddrives is not None: diff --git a/archinstall/lib/user_interaction/system_conf.py b/archinstall/lib/user_interaction/system_conf.py index 0416e91f..8b574b2c 100644 --- a/archinstall/lib/user_interaction/system_conf.py +++ b/archinstall/lib/user_interaction/system_conf.py @@ -52,11 +52,6 @@ def select_harddrives(preset: List[str] = []) -> List[str]: hard_drives = all_blockdevices(partitions=False).values() options = {f'{option}': option for option in hard_drives} - if preset: - preset_disks = {f'{option}': option for option in preset} - else: - preset_disks = {} - title = str(_('Select one or more hard drives to use and configure\n')) title += str(_('Any modifications to the existing setting will reset the disk layout!')) @@ -65,7 +60,7 @@ def select_harddrives(preset: List[str] = []) -> List[str]: selected_harddrive = Menu( title, list(options.keys()), - preset_values=list(preset_disks.keys()), + preset_values=preset, multi=True, raise_error_on_interrupt=True, raise_error_warning_msg=warning -- cgit v1.2.3-70-g09d2 From 977976f88e761ced7d5bc9f39b32e2296ee91806 Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Mon, 3 Oct 2022 10:42:10 -0400 Subject: Add hostname and locales as parameters to `minimal_installation()` (#1458) --- README.md | 3 +-- archinstall/lib/installer.py | 8 +++++--- examples/guided.py | 6 +++--- examples/swiss.py | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) (limited to 'archinstall') diff --git a/README.md b/README.md index 72197ada..6bddfa24 100644 --- a/README.md +++ b/README.md @@ -122,8 +122,7 @@ with archinstall.luks2(root, 'luksloop', disk_password) as unlocked_root: boot.mount('/mnt/boot') with archinstall.Installer('/mnt') as installation: - if installation.minimal_installation(): - installation.set_hostname('minimal-arch') + if installation.minimal_installation(hostname='minimal-arch'): installation.add_bootloader() installation.add_additional_packages(['nano', 'wget', 'git']) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 1270959e..49ce4d7f 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -662,7 +662,9 @@ class Installer: return SysCommand(f'/usr/bin/arch-chroot {self.target} mkinitcpio {" ".join(flags)}').exit_code == 0 - def minimal_installation(self, testing=False, multilib=False) -> bool: + def minimal_installation( + self, testing: bool = False, multilib: bool = False, + hostname: str = 'archinstall', locales: List[str] = ['en_US.UTF-8 UTF-8']) -> bool: # Add necessary packages if encrypting the drive # (encrypted partitions default to btrfs for now, so we need btrfs-progs) # TODO: Perhaps this should be living in the function which dictates @@ -750,8 +752,8 @@ class Installer: # os.remove(f'{self.target}/etc/localtime') # sys_command(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime') # sys_command('/usr/bin/arch-chroot /mnt hwclock --hctosys --localtime') - self.set_hostname('archinstall') - self.set_locale('en_US') + self.set_hostname(hostname) + self.set_locale(*locales[0].split()) # TODO: Use python functions for this SysCommand(f'/usr/bin/arch-chroot {self.target} chmod 700 /root') diff --git a/examples/guided.py b/examples/guided.py index 6f289caa..ad178207 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -192,9 +192,9 @@ def perform_installation(mountpoint): enable_testing = False enable_multilib = False - if installation.minimal_installation(testing=enable_testing, multilib=enable_multilib): - installation.set_locale(archinstall.arguments['sys-language'], archinstall.arguments['sys-encoding'].upper()) - installation.set_hostname(archinstall.arguments['hostname']) + if installation.minimal_installation( + testing=enable_testing, multilib=enable_multilib, hostname=archinstall.arguments['hostname'], + locales=[f"{archinstall.arguments['sys-language']} {archinstall.arguments['sys-encoding'].upper()}"]): if archinstall.arguments.get('mirror-region') is not None: if archinstall.arguments.get("mirrors", None) is not None: installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium diff --git a/examples/swiss.py b/examples/swiss.py index da45cd18..419bd859 100644 --- a/examples/swiss.py +++ b/examples/swiss.py @@ -402,9 +402,9 @@ def os_setup(installation): # Set mirrors used by pacstrap (outside of installation) if archinstall.arguments.get('mirror-region', None): archinstall.use_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors for the live medium - if installation.minimal_installation(): - installation.set_locale(archinstall.arguments['sys-language'], archinstall.arguments['sys-encoding'].upper()) - installation.set_hostname(archinstall.arguments['hostname']) + if installation.minimal_installation( + hostname=archinstall.arguments['hostname'], + locales=[f"{archinstall.arguments['sys-language']} {archinstall.arguments['sys-encoding'].upper()}"]): if archinstall.arguments['mirror-region'].get("mirrors", None) is not None: installation.set_mirrors( archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium -- cgit v1.2.3-70-g09d2 From 5c8eb7144d9583a8a117a4e892b1e78be1324a28 Mon Sep 17 00:00:00 2001 From: Jucgshu Date: Thu, 6 Oct 2022 18:59:28 +0200 Subject: Fix typo (#1501) * Fix typo * Fix typo --- README.md | 2 +- archinstall/locales/languages.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall') diff --git a/README.md b/README.md index 6bddfa24..78787dec 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Current translations are listed below and vary in the amount of translations per English Deutsch Español -Française +Français Indonesia Italiano Nederlands diff --git a/archinstall/locales/languages.json b/archinstall/locales/languages.json index 43391d5e..2a7fab2e 100644 --- a/archinstall/locales/languages.json +++ b/archinstall/locales/languages.json @@ -43,7 +43,7 @@ {"abbr": "fa", "lang": "Persian"}, {"abbr": "fj", "lang": "Fijian"}, {"abbr": "fi", "lang": "Finnish"}, - {"abbr": "fr", "lang": "French", "translated_lang": "Française"}, + {"abbr": "fr", "lang": "French", "translated_lang": "Français"}, {"abbr": "fy", "lang": "Western Frisian"}, {"abbr": "ff", "lang": "Fulah"}, {"abbr": "gd", "lang": "Scottish Gaelic"}, -- cgit v1.2.3-70-g09d2 From eec45643e950a5b982e1478ef57497491ec37f73 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 12 Oct 2022 14:17:14 +0200 Subject: Updating Partition() information after mount and unmount. (#1508) * Updating Partition() information after mount and unmount. * Cleaned up raw_parted() to gracefully output relevant partition error information. * Adding timestmap to cmd_history.txt as it's impossible to debug properly otherwise * Adding more verbose debugging information * Reinstating the lsblk retry code for PARTUUID and UUID on Partition()'s information * Added error handling for JSON parsing --- .gitignore | 3 +- archinstall/lib/disk/blockdevice.py | 4 +++ archinstall/lib/disk/filesystem.py | 15 ++++++--- archinstall/lib/disk/partition.py | 63 ++++++++++++++++++++++++++++++------- archinstall/lib/general.py | 2 +- 5 files changed, 70 insertions(+), 17 deletions(-) (limited to 'archinstall') diff --git a/.gitignore b/.gitignore index 24b1b697..40e00e87 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,5 @@ venv .DS_Store **/cmd_history.txt **/*.*~ -/*.sig \ No newline at end of file +/*.sig +/*.json \ No newline at end of file diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py index 736bacbc..cd0e14a6 100644 --- a/archinstall/lib/disk/blockdevice.py +++ b/archinstall/lib/disk/blockdevice.py @@ -274,12 +274,16 @@ class BlockDevice: if not uuid and not partuuid: raise ValueError(f"BlockDevice.get_partition() requires either a UUID or a PARTUUID for lookups.") + log(f"Retrieving partition PARTUUID={partuuid} or UUID={uuid}", level=logging.INFO, fg="teal") + for count in range(storage.get('DISK_RETRY_ATTEMPTS', 5)): for partition_index, partition in self.partitions.items(): try: if uuid and partition.uuid and partition.uuid.lower() == uuid.lower(): + log(f"Matched UUID={uuid} against {partition.uuid}", level=logging.INFO, fg="teal") return partition elif partuuid and partition.part_uuid and partition.part_uuid.lower() == partuuid.lower(): + log(f"Matched PARTUUID={partuuid} against {partition.part_uuid}", level=logging.INFO, fg="teal") return partition except DiskError as error: # Most likely a blockdevice that doesn't support or use UUID's diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py index 5d5952a0..c8eaf0be 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -189,10 +189,13 @@ class Filesystem: return True def raw_parted(self, string: str) -> SysCommand: - if (cmd_handle := SysCommand(f'/usr/bin/parted -s {string}')).exit_code != 0: - log(f"Parted ended with a bad exit code: {cmd_handle}", level=logging.ERROR, fg="red") - time.sleep(0.5) - return cmd_handle + try: + cmd_handle = SysCommand(f'/usr/bin/parted -s {string}') + time.sleep(0.5) + return cmd_handle + except SysCallError as error: + log(f"Parted ended with a bad exit code: {error.exit_code} ({error})", level=logging.ERROR, fg="red") + return error def parted(self, string: str) -> bool: """ @@ -258,6 +261,9 @@ class Filesystem: new_partition_uuids = [partition.part_uuid for partition in self.blockdevice.partitions.values()] new_partuuid_set = (set(previous_partuuids) ^ set(new_partition_uuids)) + log(f'Old partition set: {previous_partuuids}', level=logging.INFO, fg="teal") + log(f'New partition set: {new_partition_uuids}', level=logging.INFO, fg="teal") + if len(new_partuuid_set) and (new_partuuid := new_partuuid_set.pop()): try: return self.blockdevice.get_partition(partuuid=new_partuuid) @@ -282,6 +288,7 @@ class Filesystem: log(f"Could not find the new PARTUUID after adding the partition.", level=logging.ERROR, fg="red") log(f"Previous partitions: {previous_partuuids}", level=logging.ERROR, fg="red") log(f"New partitions: {total_partitions}", level=logging.ERROR, fg="red") + raise DiskError(f"Could not add partition using: {parted_string}") def set_name(self, partition: int, name: str) -> bool: diff --git a/archinstall/lib/disk/partition.py b/archinstall/lib/disk/partition.py index 56a7d436..04d33453 100644 --- a/archinstall/lib/disk/partition.py +++ b/archinstall/lib/disk/partition.py @@ -5,7 +5,7 @@ import json import os import hashlib import typing -from dataclasses import dataclass +from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Dict, Any, List, Union, Iterator @@ -18,19 +18,51 @@ from ..general import SysCommand from .btrfs.btrfs_helpers import subvolume_info_from_path from .btrfs.btrfssubvolumeinfo import BtrfsSubvolumeInfo - @dataclass class PartitionInfo: - pttype: str - partuuid: str - uuid: str - start: Optional[int] - end: Optional[int] + partition_object: 'Partition' + device_path: str # This would be /dev/sda1 for instance bootable: bool size: float sector_size: int - filesystem_type: str - mountpoints: List[Path] + start: Optional[int] + end: Optional[int] + pttype: Optional[str] + filesystem_type: Optional[str] + partuuid: Optional[str] + uuid: Optional[str] + mountpoints: List[Path] = field(default_factory=list) + + def __post_init__(self): + if not all([self.partuuid, self.uuid]): + for i in range(storage['DISK_RETRY_ATTEMPTS']): + lsblk_info = SysCommand(f"lsblk --json -b -o+LOG-SEC,SIZE,PTTYPE,PARTUUID,UUID,FSTYPE {self.device_path}").decode('UTF-8') + try: + lsblk_info = json.loads(lsblk_info) + except json.decoder.JSONDecodeError: + log(f"Could not decode JSON: {lsblk_info}", fg="red", level=logging.ERROR) + raise DiskError(f'Failed to retrieve information for "{self.device_path}" with lsblk') + + if not (device := lsblk_info.get('blockdevices', [None])[0]): + raise DiskError(f'Failed to retrieve information for "{self.device_path}" with lsblk') + + self.partuuid = device.get('partuuid') + self.uuid = device.get('uuid') + + # Lets build a list of requirements that we would like + # to retry and build (stuff that can take time between partprobes) + requirements = [] + requirements.append(self.partuuid) + + # Unformatted partitions won't have a UUID + if lsblk_info.get('fstype') is not None: + requirements.append(self.uuid) + + if all(requirements): + break + + self.partition_object.partprobe() + time.sleep(max(0.1, storage['DISK_TIMEOUTS'] * i)) def get_first_mountpoint(self) -> Optional[Path]: if len(self.mountpoints) > 0: @@ -154,8 +186,11 @@ class Partition: output = error.worker.decode('UTF-8') if output: - lsblk_info = json.loads(output) - return lsblk_info + try: + lsblk_info = json.loads(output) + return lsblk_info + except json.decoder.JSONDecodeError: + log(f"Could not decode JSON: {output}", fg="red", level=logging.ERROR) raise DiskError(f'Failed to read disk "{self.device_path}" with lsblk') @@ -185,6 +220,8 @@ class Partition: bootable = sfdisk_info.get('bootable', False) or sfdisk_info.get('type', '') == 'C12A7328-F81F-11D2-BA4B-00A0C93EC93B' return PartitionInfo( + partition_object=self, + device_path=self._path, pttype=device['pttype'], partuuid=device['partuuid'], uuid=device['uuid'], @@ -568,6 +605,8 @@ class Partition: except SysCallError as err: raise err + # Update the partition info since the mount info has changed after this call. + self._partition_info = self._fetch_information() return True return False @@ -582,6 +621,8 @@ class Partition: if exit_code and 0 < exit_code < 8000: raise SysCallError(f"Could not unmount {self._path} properly: {worker}", exit_code=exit_code) + # Update the partition info since the mount info has changed after this call. + self._partition_info = self._fetch_information() return True def filesystem_supported(self) -> bool: diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index d76b7036..8c7aed91 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -379,7 +379,7 @@ class SysCommandWorker: try: with history_logfile.open("a") as cmd_log: - cmd_log.write(f"{self.cmd}\n") + cmd_log.write(f"{time.time()} {self.cmd}\n") if change_perm: os.chmod(str(history_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) -- cgit v1.2.3-70-g09d2 From db32bc4dda8d4632d6816ac09407327c97a64518 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 12 Oct 2022 15:07:11 +0200 Subject: Muted a log output --- archinstall/lib/disk/blockdevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall') diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py index cd0e14a6..b7f92a57 100644 --- a/archinstall/lib/disk/blockdevice.py +++ b/archinstall/lib/disk/blockdevice.py @@ -274,7 +274,7 @@ class BlockDevice: if not uuid and not partuuid: raise ValueError(f"BlockDevice.get_partition() requires either a UUID or a PARTUUID for lookups.") - log(f"Retrieving partition PARTUUID={partuuid} or UUID={uuid}", level=logging.INFO, fg="teal") + log(f"Retrieving partition PARTUUID={partuuid} or UUID={uuid}", level=logging.DEBUG, fg="gray") for count in range(storage.get('DISK_RETRY_ATTEMPTS', 5)): for partition_index, partition in self.partitions.items(): -- cgit v1.2.3-70-g09d2 From 14be423a6cf3ae6f9ac25c4da138911efc59f7fd Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 12 Oct 2022 15:07:44 +0200 Subject: Muted a log output --- archinstall/lib/disk/blockdevice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall') diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py index b7f92a57..178b786a 100644 --- a/archinstall/lib/disk/blockdevice.py +++ b/archinstall/lib/disk/blockdevice.py @@ -280,10 +280,10 @@ class BlockDevice: for partition_index, partition in self.partitions.items(): try: if uuid and partition.uuid and partition.uuid.lower() == uuid.lower(): - log(f"Matched UUID={uuid} against {partition.uuid}", level=logging.INFO, fg="teal") + log(f"Matched UUID={uuid} against {partition.uuid}", level=logging.DEBUG, fg="gray") return partition elif partuuid and partition.part_uuid and partition.part_uuid.lower() == partuuid.lower(): - log(f"Matched PARTUUID={partuuid} against {partition.part_uuid}", level=logging.INFO, fg="teal") + log(f"Matched PARTUUID={partuuid} against {partition.part_uuid}", level=logging.DEBUG, fg="gray") return partition except DiskError as error: # Most likely a blockdevice that doesn't support or use UUID's -- cgit v1.2.3-70-g09d2 From 4addd2d7cbc015ec19c155d1d4a4bb997c05db00 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 12 Oct 2022 15:08:48 +0200 Subject: Removed debug output --- archinstall/lib/disk/filesystem.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'archinstall') diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py index c8eaf0be..af5879aa 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -261,9 +261,6 @@ class Filesystem: new_partition_uuids = [partition.part_uuid for partition in self.blockdevice.partitions.values()] new_partuuid_set = (set(previous_partuuids) ^ set(new_partition_uuids)) - log(f'Old partition set: {previous_partuuids}', level=logging.INFO, fg="teal") - log(f'New partition set: {new_partition_uuids}', level=logging.INFO, fg="teal") - if len(new_partuuid_set) and (new_partuuid := new_partuuid_set.pop()): try: return self.blockdevice.get_partition(partuuid=new_partuuid) -- cgit v1.2.3-70-g09d2 From 16ca69540cc1ac8a28b7007aefe628cf24d2c395 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 12 Oct 2022 20:28:55 +0200 Subject: Version bump v2.5.2 (forgot before tagging the release) --- archinstall/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall') diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 108e51b2..c6135e74 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -51,7 +51,7 @@ from .lib.hsm import ( ) parser = ArgumentParser() -__version__ = "2.5.1" +__version__ = "2.5.2" storage['__version__'] = __version__ # add the custome _ as a builtin, it can now be used anywhere in the -- cgit v1.2.3-70-g09d2