From b59a40606974a82e1d99751fd68818c3b7b0fe0f Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 29 Apr 2021 14:22:38 +0200 Subject: Adding on_pacstrap hook for installation. As well as a plugins listing that plugins can hook in to in order to be called during specific on_ calls. --- archinstall/__init__.py | 2 +- archinstall/lib/installer.py | 7 +++++++ archinstall/lib/plugins.py | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 archinstall/lib/plugins.py diff --git a/archinstall/__init__.py b/archinstall/__init__.py index e2c7ea62..82bba81e 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -14,6 +14,7 @@ from .lib.packages import * from .lib.output import * from .lib.storage import * from .lib.hardware import * +from .lin.plugins import plugins __version__ = "2.2.0" @@ -32,7 +33,6 @@ for arg in sys.argv[1:]: else: positionals.append(arg) - # TODO: Learn the dark arts of argparse... # (I summon thee dark spawn of cPython) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a7b36481..51539d2c 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -10,6 +10,7 @@ from .systemd import Networkd from .output import log from .storage import storage from .hardware import * +from .plugins import plugins # Any package that the Installer() is responsible for (optional and the default ones) __packages__ = ["base", "base-devel", "linux-firmware", "linux", "linux-lts", "linux-zen", "linux-hardened"] @@ -126,6 +127,12 @@ class Installer(): def pacstrap(self, *packages, **kwargs): if type(packages[0]) in (list, tuple): packages = packages[0] + + for plugin in plugins.values(): + if hasattr(plugin, 'on_pacstrap'): + if (result := plugin.on_pacstrap(packages)): + packages = result + self.log(f'Installing packages: {packages}', level=logging.INFO) if (sync_mirrors := sys_command('/usr/bin/pacman -Syy')).exit_code == 0: diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py new file mode 100644 index 00000000..adf900b9 --- /dev/null +++ b/archinstall/lib/plugins.py @@ -0,0 +1 @@ +plugins = {} \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 25b699b44ea272e9bac7d75c7d86871e082122ae Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 30 Apr 2021 15:33:26 +0200 Subject: Automatic loading of plugins --- archinstall/lib/plugins.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index adf900b9..f744661a 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -1 +1,13 @@ -plugins = {} \ No newline at end of file +import pkgutil +import importlib +import imp # Deprecated + +plugins = {} + +for module_info in pkgutil.iter_modules(path=None, prefix=''): + if 'archinstall-' in module_info.name and module_info.ispkg: + try: + modulesource = importlib.import_module(module_info.name) + imp.reload(modulesource) + except Exception as e: + print('Could not load plugin {} {}'.format(modname, e)) \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 404197dc93c2efb24097772848af708d833bdd98 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 30 Apr 2021 16:45:42 +0200 Subject: Enabling --plugins filtering --- archinstall/__init__.py | 4 +++- archinstall/lib/plugins.py | 25 ++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 82bba81e..a1fa4216 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -14,7 +14,6 @@ from .lib.packages import * from .lib.output import * from .lib.storage import * from .lib.hardware import * -from .lin.plugins import plugins __version__ = "2.2.0" @@ -33,6 +32,9 @@ for arg in sys.argv[1:]: else: positionals.append(arg) +storage['arguments'] = arguments +from .lib.plugins import plugins + # TODO: Learn the dark arts of argparse... # (I summon thee dark spawn of cPython) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index f744661a..f7f8bc4e 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -1,13 +1,24 @@ import pkgutil import importlib import imp # Deprecated +from .storage import storage plugins = {} +PLUGIN_PREFIXES = 'archinstall-' -for module_info in pkgutil.iter_modules(path=None, prefix=''): - if 'archinstall-' in module_info.name and module_info.ispkg: - try: - modulesource = importlib.import_module(module_info.name) - imp.reload(modulesource) - except Exception as e: - print('Could not load plugin {} {}'.format(modname, e)) \ No newline at end of file +if (plugin_list := storage.get('plugins', None)): + if type(plugin_list) == str and plugin_list != '*': + plugin_list = plugin_list.split(',') + + for module_info in pkgutil.iter_modules(path=None, prefix=''): + if not module_info.ispkg: + continue + + # If --plugins=* and == 'archinstall-' + # of --plugins=name is + if (plugin_list == '*' and PLUGIN_PREFIXES in module_info.name) or (module_info.name in plugin_list): + try: + modulesource = importlib.import_module(module_info.name) + imp.reload(modulesource) + except Exception as e: + print('Could not load plugin {} {}'.format(modname, e)) \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 2ee88e0e3ab2aa2af836427f5d9e87059a6952c8 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 13:34:56 +0200 Subject: Switched plugin strategty. Now uses built-in entrypoints to source and load the plugins. This is the default method provided by Python, and is the cleanest so far I think. --- archinstall/lib/plugins.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index f7f8bc4e..d838da91 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -1,24 +1,10 @@ -import pkgutil -import importlib -import imp # Deprecated -from .storage import storage +from importlib import metadata plugins = {} -PLUGIN_PREFIXES = 'archinstall-' -if (plugin_list := storage.get('plugins', None)): - if type(plugin_list) == str and plugin_list != '*': - plugin_list = plugin_list.split(',') - - for module_info in pkgutil.iter_modules(path=None, prefix=''): - if not module_info.ispkg: - continue - - # If --plugins=* and == 'archinstall-' - # of --plugins=name is - if (plugin_list == '*' and PLUGIN_PREFIXES in module_info.name) or (module_info.name in plugin_list): - try: - modulesource = importlib.import_module(module_info.name) - imp.reload(modulesource) - except Exception as e: - print('Could not load plugin {} {}'.format(modname, e)) \ No newline at end of file +# 1: List archinstall.plugin definitions +# 2: Loade the plugin entry point +# 3: Initiate the plugin and store it as .name in plugins +for plugin_definition in metadata.entry_points()['archinstall.plugin']: + plugin_entrypoint = plugin_definition.load() + plugins[plugin_definition.name] = plugin_entrypoint() \ No newline at end of file -- cgit v1.2.3-54-g00ecf From bad4d8a38b5399b37335fc7971aec301928ba9e9 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 13:37:33 +0200 Subject: Added redundant argument creation. --- archinstall/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index fb7e0591..d002e79c 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -58,10 +58,9 @@ def initialize_arguments(): config["script"] = args.script return config -storage['arguments'] = arguments +arguments = initialize_arguments() from .lib.plugins import plugins -arguments = initialize_arguments() # TODO: Learn the dark arts of argparse... (I summon thee dark spawn of cPython) -- cgit v1.2.3-54-g00ecf From fcbb5490c05e1a103eea32d947b8af9acf0e758d Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 13:38:01 +0200 Subject: Removed empty whitespace --- archinstall/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index d002e79c..d7ecfad8 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -62,7 +62,6 @@ arguments = initialize_arguments() from .lib.plugins import plugins - # TODO: Learn the dark arts of argparse... (I summon thee dark spawn of cPython) -- cgit v1.2.3-54-g00ecf From 29dcd5f2d07ffef979e005669993c9d6461459fe Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 13:38:17 +0200 Subject: Pleasing the linter gods --- archinstall/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index d7ecfad8..82ac3d8f 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -58,6 +58,7 @@ def initialize_arguments(): config["script"] = args.script return config + arguments = initialize_arguments() from .lib.plugins import plugins -- cgit v1.2.3-54-g00ecf From 6f3a3584223841d9a8c18a0a475065946216a6a8 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 13:38:54 +0200 Subject: Added a comment --- archinstall/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 82ac3d8f..6bdc931c 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -60,7 +60,7 @@ def initialize_arguments(): arguments = initialize_arguments() -from .lib.plugins import plugins +from .lib.plugins import plugins # This initiates the plugin loading ceremony # TODO: Learn the dark arts of argparse... (I summon thee dark spawn of cPython) -- cgit v1.2.3-54-g00ecf From 14577415f38cd656b0c31821b55d60c57f5b642e Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 13:42:09 +0200 Subject: Spelling error --- archinstall/lib/plugins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index d838da91..2b71bbf8 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -3,7 +3,7 @@ from importlib import metadata plugins = {} # 1: List archinstall.plugin definitions -# 2: Loade the plugin entry point +# 2: Load the plugin entry point # 3: Initiate the plugin and store it as .name in plugins for plugin_definition in metadata.entry_points()['archinstall.plugin']: plugin_entrypoint = plugin_definition.load() -- cgit v1.2.3-54-g00ecf From 1fff9b44d13b8c6151bd7f19826418cfab425108 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 13:42:28 +0200 Subject: Spelling error --- archinstall/lib/plugins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index 2b71bbf8..7bb5147c 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -3,7 +3,7 @@ from importlib import metadata plugins = {} # 1: List archinstall.plugin definitions -# 2: Load the plugin entry point +# 2: Load the plugin entrypoint # 3: Initiate the plugin and store it as .name in plugins for plugin_definition in metadata.entry_points()['archinstall.plugin']: plugin_entrypoint = plugin_definition.load() -- cgit v1.2.3-54-g00ecf From c7426067dd828697fc4b7e4157e811ddd9c4eb36 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 13:56:57 +0200 Subject: Implemented load_plugin() which handles local or remote paths. Also added some error handling surrounding the loading of plugins. --- archinstall/lib/plugins.py | 52 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index 7bb5147c..9dfa786b 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -1,5 +1,14 @@ +import hashlib +import importlib +import logging +import os +import sys +import urllib.parse +import urllib.request from importlib import metadata +from .output import log + plugins = {} # 1: List archinstall.plugin definitions @@ -7,4 +16,45 @@ plugins = {} # 3: Initiate the plugin and store it as .name in plugins for plugin_definition in metadata.entry_points()['archinstall.plugin']: plugin_entrypoint = plugin_definition.load() - plugins[plugin_definition.name] = plugin_entrypoint() \ No newline at end of file + try: + plugins[plugin_definition.name] = plugin_entrypoint() + except Exception as err: + log(err, level=logging.ERROR) + log(f"The above error was detected when loading the plugin: {plugin_definition}", fg="red", level=logging.ERROR) + +def localize_path(profile_path :str) -> str: + if (url := urllib.parse.urlparse(profile_path)).scheme and url.scheme in ('https', 'http'): + converted_path = f"/tmp/{os.path.basename(profile_path).replace('.py', '')}_{hashlib.md5(os.urandom(12)).hexdigest()}.py" + + with open(converted_path, "w") as temp_file: + temp_file.write(urllib.request.urlopen(url.geturl()).read().decode('utf-8')) + + return converted_path + else: + return profile_path + +def import_via_path(path :str, namespace=None): # -> module (not sure how to write that in type definitions) + if not namespace: + namespace = os.path.basename(path) + + try: + spec = importlib.util.spec_from_file_location(namespace, path) + imported = importlib.util.module_from_spec(spec) + sys.modules[namespace] = imported + spec.loader.exec_module(sys.modules[namespace]) + except Exception as err: + log(err, level=logging.ERROR) + log(f"The above error was detected when loading the plugin: {path}", fg="red", level=logging.ERROR) + + return sys.modules[namespace] + +def load_plugin(path :str): # -> module (not sure how to write that in type definitions) + parsed_url = urllib.parse.urlparse(path) + + # The Profile was not a direct match on a remote URL + if not parsed_url.scheme: + # Path was not found in any known examples, check if it's an absolute path + if os.path.isfile(path): + return import_via_path(path) + elif parsed_url.scheme in ('https', 'http'): + return import_via_path(localize_path(path)) \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 250eb93f103acc6110782aad4f897edfc1781bd6 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 14:12:23 +0200 Subject: Added better error handling. --- archinstall/__init__.py | 2 +- archinstall/lib/plugins.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 6bdc931c..1f230902 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -60,7 +60,7 @@ def initialize_arguments(): arguments = initialize_arguments() -from .lib.plugins import plugins # This initiates the plugin loading ceremony +from .lib.plugins import plugins, load_plugin # This initiates the plugin loading ceremony # TODO: Learn the dark arts of argparse... (I summon thee dark spawn of cPython) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index 9dfa786b..8376f3d5 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -3,6 +3,7 @@ import importlib import logging import os import sys +import pathlib import urllib.parse import urllib.request from importlib import metadata @@ -37,17 +38,21 @@ def import_via_path(path :str, namespace=None): # -> module (not sure how to wri if not namespace: namespace = os.path.basename(path) + if namespace == '__init__.py': + path = pathlib.PurePath(path) + namespace = path.parent.name + try: spec = importlib.util.spec_from_file_location(namespace, path) imported = importlib.util.module_from_spec(spec) sys.modules[namespace] = imported spec.loader.exec_module(sys.modules[namespace]) + + return namespace except Exception as err: log(err, level=logging.ERROR) log(f"The above error was detected when loading the plugin: {path}", fg="red", level=logging.ERROR) - return sys.modules[namespace] - def load_plugin(path :str): # -> module (not sure how to write that in type definitions) parsed_url = urllib.parse.urlparse(path) @@ -55,6 +60,12 @@ def load_plugin(path :str): # -> module (not sure how to write that in type defi if not parsed_url.scheme: # Path was not found in any known examples, check if it's an absolute path if os.path.isfile(path): - return import_via_path(path) + namespace = import_via_path(path) elif parsed_url.scheme in ('https', 'http'): - return import_via_path(localize_path(path)) \ No newline at end of file + namespace = import_via_path(localize_path(path)) + + try: + plugins[namespace] = sys.modules[namespace].Plugin() + except Exception as err: + log(err, level=logging.ERROR) + log(f"The above error was detected when loading the plugin: {path}", fg="red", level=logging.ERROR) \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 2b5ad7e52ef69255918e396d599536b1907f6b46 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 14:13:45 +0200 Subject: Added a comment --- archinstall/lib/plugins.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index 8376f3d5..b7b6afbb 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -23,6 +23,8 @@ for plugin_definition in metadata.entry_points()['archinstall.plugin']: log(err, level=logging.ERROR) log(f"The above error was detected when loading the plugin: {plugin_definition}", fg="red", level=logging.ERROR) + +# The following functions and core are support structures for load_plugin() def localize_path(profile_path :str) -> str: if (url := urllib.parse.urlparse(profile_path)).scheme and url.scheme in ('https', 'http'): converted_path = f"/tmp/{os.path.basename(profile_path).replace('.py', '')}_{hashlib.md5(os.urandom(12)).hexdigest()}.py" @@ -34,6 +36,7 @@ def localize_path(profile_path :str) -> str: else: return profile_path + def import_via_path(path :str, namespace=None): # -> module (not sure how to write that in type definitions) if not namespace: namespace = os.path.basename(path) @@ -53,6 +56,7 @@ def import_via_path(path :str, namespace=None): # -> module (not sure how to wri log(err, level=logging.ERROR) log(f"The above error was detected when loading the plugin: {path}", fg="red", level=logging.ERROR) + def load_plugin(path :str): # -> module (not sure how to write that in type definitions) parsed_url = urllib.parse.urlparse(path) @@ -68,4 +72,4 @@ def load_plugin(path :str): # -> module (not sure how to write that in type defi plugins[namespace] = sys.modules[namespace].Plugin() except Exception as err: log(err, level=logging.ERROR) - log(f"The above error was detected when loading the plugin: {path}", fg="red", level=logging.ERROR) \ No newline at end of file + log(f"The above error was detected when initiating the plugin: {path}", fg="red", level=logging.ERROR) \ No newline at end of file -- cgit v1.2.3-54-g00ecf From e604f2c676471bde781cbb0a0586e73a52024e94 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 14:36:24 +0200 Subject: Added optional version handling. And improved error handling a bit. --- archinstall/__init__.py | 2 +- archinstall/lib/plugins.py | 34 +++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 1f230902..53d31af2 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -24,7 +24,7 @@ from .lib.user_interaction import * parser = ArgumentParser() __version__ = "2.2.0.RC1" - +storage['__version__'] = __version__ def initialize_arguments(): config = {} diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index b7b6afbb..bf4b7720 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -9,6 +9,7 @@ import urllib.request from importlib import metadata from .output import log +from .storage import storage plugins = {} @@ -56,6 +57,17 @@ def import_via_path(path :str, namespace=None): # -> module (not sure how to wri log(err, level=logging.ERROR) log(f"The above error was detected when loading the plugin: {path}", fg="red", level=logging.ERROR) + try: + del(sys.modules[namespace]) + except: + pass + +def find_nth(haystack, needle, n): + start = haystack.find(needle) + while start >= 0 and n > 1: + start = haystack.find(needle, start+len(needle)) + n -= 1 + return start def load_plugin(path :str): # -> module (not sure how to write that in type definitions) parsed_url = urllib.parse.urlparse(path) @@ -68,8 +80,20 @@ def load_plugin(path :str): # -> module (not sure how to write that in type defi elif parsed_url.scheme in ('https', 'http'): namespace = import_via_path(localize_path(path)) - try: - plugins[namespace] = sys.modules[namespace].Plugin() - except Exception as err: - log(err, level=logging.ERROR) - log(f"The above error was detected when initiating the plugin: {path}", fg="red", level=logging.ERROR) \ No newline at end of file + # Version dependency via __archinstall__version__ variable (if present) in the plugin + # Any errors in version inconsistency will be handled through normal error handling if not defined. + if namespace in sys.modules: + if hasattr(sys.modules[namespace], '__archinstall__version__'): + archinstall_major_and_minor_version = float(storage['__version__'][:find_nth(storage['__version__'], '.', 2)]) + + if sys.modules[namespace].__archinstall__version__ < archinstall_major_and_minor_version: + log(f"Plugin {sys.modules[namespace]} does not support the current Archinstall version.", fg="red", level=logging.ERROR) + + if hasattr(sys.modules[namespace], 'Plugin'): + try: + plugins[namespace] = sys.modules[namespace].Plugin() + except Exception as err: + log(err, level=logging.ERROR) + log(f"The above error was detected when initiating the plugin: {path}", fg="red", level=logging.ERROR) + else: + log(f"Plugin '{path}' is missing a valid entry-point or is corrupt.", fg="yellow", level=logging.WARNING) \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 1773efbe45a60af49394fbf274f584cb50a758ac Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 14:37:31 +0200 Subject: Pleasing the linter gods --- archinstall/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 53d31af2..5bcb7f7f 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -26,6 +26,7 @@ parser = ArgumentParser() __version__ = "2.2.0.RC1" storage['__version__'] = __version__ + def initialize_arguments(): config = {} parser.add_argument("--config", nargs="?", help="JSON configuration file or URL") -- cgit v1.2.3-54-g00ecf From 0d0dfc8ebec5ed957686a7c42095bcbcc8b2059d Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 14:40:21 +0200 Subject: Added/moved comments. --- archinstall/lib/plugins.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index bf4b7720..a61be30b 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -80,15 +80,17 @@ def load_plugin(path :str): # -> module (not sure how to write that in type defi elif parsed_url.scheme in ('https', 'http'): namespace = import_via_path(localize_path(path)) - # Version dependency via __archinstall__version__ variable (if present) in the plugin - # Any errors in version inconsistency will be handled through normal error handling if not defined. if namespace in sys.modules: + # Version dependency via __archinstall__version__ variable (if present) in the plugin + # Any errors in version inconsistency will be handled through normal error handling if not defined. if hasattr(sys.modules[namespace], '__archinstall__version__'): archinstall_major_and_minor_version = float(storage['__version__'][:find_nth(storage['__version__'], '.', 2)]) if sys.modules[namespace].__archinstall__version__ < archinstall_major_and_minor_version: log(f"Plugin {sys.modules[namespace]} does not support the current Archinstall version.", fg="red", level=logging.ERROR) + # Locate the plugin entry-point called Plugin() + # This in accordance with the entry_points() from setup.cfg above if hasattr(sys.modules[namespace], 'Plugin'): try: plugins[namespace] = sys.modules[namespace].Plugin() -- cgit v1.2.3-54-g00ecf From 7b1096bfa6a5d042b38341b68f857dbe4f150bb3 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 14:59:34 +0200 Subject: Added a number of on_ hooks for different stages of the installation. --- archinstall/lib/installer.py | 55 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index dff05b0a..c5e77b7e 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -150,6 +150,11 @@ class Installer: self.log(f'Could not sync mirrors: {sync_mirrors.exit_code}', level=logging.INFO) def set_mirrors(self, mirrors): + for plugin in plugins.values(): + if hasattr(plugin, 'on_mirrors'): + if result := plugin.on_mirrors(mirrors): + mirrors = result + return use_mirrors(mirrors, destination=f'{self.target}/etc/pacman.d/mirrorlist') def genfstab(self, flags='-pU'): @@ -161,6 +166,10 @@ class Installer: if not os.path.isfile(f'{self.target}/etc/fstab'): raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{fstab}') + for plugin in plugins.values(): + if hasattr(plugin, 'on_genfstab'): + plugin.on_genfstab(self) + return True def set_hostname(self, hostname: str, *args, **kwargs): @@ -184,6 +193,11 @@ class Installer: if not len(zone): return True # Redundant + for plugin in plugins.values(): + if hasattr(plugin, 'on_timezone'): + if result := plugin.on_timezone(zone): + zone = result + if (pathlib.Path("/usr") / "share" / "zoneinfo" / zone).exists(): (pathlib.Path(self.target) / "etc" / "localtime").unlink(missing_ok=True) SysCommand(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{zone} /etc/localtime') @@ -207,6 +221,10 @@ class Installer: if (output := self.arch_chroot(f'systemctl enable {service}')).exit_code != 0: raise ServiceException(f"Unable to start service {service}: {output}") + for plugin in plugins.values(): + if hasattr(plugin, 'on_service'): + plugin.on_service(service) + def run_command(self, cmd, *args, **kwargs): return SysCommand(f'/usr/bin/arch-chroot {self.target} {cmd}') @@ -236,6 +254,11 @@ class Installer: conf = Networkd(Match={"Name": nic}, Network=network) + for plugin in plugins.values(): + if hasattr(plugin, 'on_configure_nic'): + if (new_conf := plugin.on_configure_nic(nic, dhcp, ip, gateway, dns)): + conf = new_conf + with open(f"{self.target}/etc/systemd/network/10-{nic}.network", "a") as netconf: netconf.write(str(conf)) @@ -299,6 +322,12 @@ class Installer: return False def mkinitcpio(self, *flags): + for plugin in plugins.values(): + if hasattr(plugin, 'on_mkinitcpio'): + # Allow plugins to override the usage of mkinitcpio altogether. + if plugin.on_mkinitcpio(self): + return True + with open(f'{self.target}/etc/mkinitcpio.conf', 'w') as mkinit: mkinit.write(f"MODULES=({' '.join(self.MODULES)})\n") mkinit.write(f"BINARIES=({' '.join(self.BINARIES)})\n") @@ -373,9 +402,20 @@ class Installer: self.log(f"Running post-installation hook: {function}", level=logging.INFO) function(self) + for plugin in plugins.values(): + if hasattr(plugin, 'on_install'): + plugin.on_install(self) + return True def add_bootloader(self, bootloader='systemd-bootctl'): + for plugin in plugins.values(): + if hasattr(plugin, 'on_add_bootloader'): + # Allow plugins to override the boot-loader handling. + # This allows for bot configuring and installing bootloaders. + if plugin.on_add_bootloader(self): + return True + boot_partition = None root_partition = None for partition in self.partitions: @@ -494,8 +534,19 @@ class Installer: def user_create(self, user: str, password=None, groups=None, sudo=False): if groups is None: groups = [] - self.log(f'Creating user {user}', level=logging.INFO) - o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} useradd -m -G wheel {user}')) + + # This plugin hook allows for the plugin to handle the creation of the user. + # Password and Group management is still handled by user_create() + handled_by_plugin = False + for plugin in plugins.values(): + if hasattr(plugin, 'on_user_create'): + if result := plugin.on_user_create(user): + handled_by_plugin = result + + if not handled_by_plugin: + self.log(f'Creating user {user}', level=logging.INFO) + o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} useradd -m -G wheel {user}')) + if password: self.user_set_pw(user, password) -- cgit v1.2.3-54-g00ecf From 94bceb2199a16509c744a2f28dcfa19ab8cc5935 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 24 May 2021 15:29:59 +0200 Subject: Adding support for --plugin= --- archinstall/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 5bcb7f7f..6a070392 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -63,6 +63,8 @@ def initialize_arguments(): arguments = initialize_arguments() from .lib.plugins import plugins, load_plugin # This initiates the plugin loading ceremony +if arguments.get('plugin', None): + load_plugin(arguments['plugin']) # TODO: Learn the dark arts of argparse... (I summon thee dark spawn of cPython) -- cgit v1.2.3-54-g00ecf From 2aed8c6ad5a8ab31accb6d618bca4798591cf415 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Mon, 24 May 2021 19:23:08 +0530 Subject: removed builtins usage and added gfx_package key in config --- examples/guided.py | 7 +++++-- profiles/sway.py | 6 +++--- profiles/xorg.py | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index 73fded4e..1f67a460 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -5,7 +5,7 @@ import time import archinstall from archinstall.lib.general import run_custom_user_commands -from archinstall.lib.hardware import has_uefi +from archinstall.lib.hardware import has_uefi, AVAILABLE_GFX_DRIVERS from archinstall.lib.networking import check_mirror_reachable from archinstall.lib.profiles import Profile @@ -450,5 +450,8 @@ else: archinstall.arguments['mirror-region'] = {selected_region: archinstall.list_mirrors()[selected_region]} archinstall.arguments['sys-language'] = archinstall.arguments.get('sys-language', 'en_US') archinstall.arguments['sys-encoding'] = archinstall.arguments.get('sys-encoding', 'utf-8') - + if archinstall.arguments.get('gfx_driver', None) is not None: + archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) + + perform_installation_steps() diff --git a/profiles/sway.py b/profiles/sway.py index 9afc047d..b0ff8c19 100644 --- a/profiles/sway.py +++ b/profiles/sway.py @@ -25,7 +25,7 @@ def _prep_function(*args, **kwargs): other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ - __builtins__["_gfx_driver_packages"] = archinstall.select_driver() + archinstall.storage["gfx_driver_packages"] = archinstall.select_driver() return True @@ -34,7 +34,7 @@ def _prep_function(*args, **kwargs): # through importlib.util.spec_from_file_location("sway", "/somewhere/sway.py") # or through conventional import sway if __name__ == "sway": - if "nvidia" in _gfx_driver_packages: + if "nvidia" in archinstall.storage.get("gfx_driver_packages", None): choice = input("The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues. Continue anyways? [y/N] ") if choice.lower() in ("n", ""): raise archinstall.lib.exceptions.HardwareIncompatibilityError("Sway does not support the proprietary nvidia drivers.") @@ -43,4 +43,4 @@ if __name__ == "sway": archinstall.storage['installation_session'].add_additional_packages(__packages__) # Install the graphics driver packages - archinstall.storage['installation_session'].add_additional_packages(_gfx_driver_packages) + archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(archinstall.storage.get('gfx_driver_packages', None))}") diff --git a/profiles/xorg.py b/profiles/xorg.py index b8fb2cbb..9006a430 100644 --- a/profiles/xorg.py +++ b/profiles/xorg.py @@ -22,7 +22,7 @@ def _prep_function(*args, **kwargs): for more input before any other installer steps start. """ - __builtins__['_gfx_driver_packages'] = archinstall.select_driver() + archinstall.storage["gfx_driver_packages"] = archinstall.select_driver() # TODO: Add language section and/or merge it with the locale selected # earlier in for instance guided.py installer. @@ -35,13 +35,13 @@ def _prep_function(*args, **kwargs): # or through conventional import xorg if __name__ == 'xorg': try: - if "nvidia" in _gfx_driver_packages: + if "nvidia" in archinstall.storage.get("gfx_driver_packages", None): if "linux-zen" in archinstall.storage['installation_session'].base_packages or "linux-lts" in archinstall.storage['installation_session'].base_packages: archinstall.storage['installation_session'].add_additional_packages("dkms") # I've had kernel regen fail if it wasn't installed before nvidia-dkms archinstall.storage['installation_session'].add_additional_packages("xorg-server xorg-xinit nvidia-dkms") else: - archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") + archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(archinstall.storage.get('gfx_driver_packages', None))}") else: - archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") + archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(archinstall.storage.get('gfx_driver_packages', None))}") except: archinstall.storage['installation_session'].add_additional_packages("xorg-server xorg-xinit") # Prep didn't run, so there's no driver to install -- cgit v1.2.3-54-g00ecf From be6021b41faf7fae3663a30ace46a5186e2723bb Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 24 May 2021 14:00:57 -0400 Subject: The fixup vars commit made this optional param no longer correct --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9ca63fa..dc5fec01 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Prequisites: Assuming you are on a Arch Linux live-ISO and booted into EFI mode. - # archinstall --config [optional: --vars ''] + # archinstall --config # Help? -- cgit v1.2.3-54-g00ecf From 6cd9c86691c69062d237e4ed6f12128ae83ee91b Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 25 May 2021 12:45:08 +0200 Subject: Changed FreeNode -> LiberaChat for IRC --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc5fec01..c430ac0e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The installer also doubles as a python library to install Arch Linux and manage * archinstall [discord](https://discord.gg/cqXU88y) server * archinstall [matrix.org](https://app.element.io/#/room/#archinstall:matrix.org) channel -* archinstall [#archinstall@freenode (IRC)](irc://#archinstall@FreeNode) +* archinstall [#archinstall@irc.libera.chat](irc://#archinstall@irc.libera.chat:6697) * archinstall [documentation](https://python-archinstall.readthedocs.io/en/latest/index.html) # Installation & Usage -- cgit v1.2.3-54-g00ecf From 45902925079c84c8f49049c08c54e951d5a9f1aa Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 25 May 2021 18:43:35 +0200 Subject: Removed EFI warning from doc index https://archinstall.readthedocs.io/en/latest/ --- docs/index.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index a5d07901..0d80501b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -6,9 +6,6 @@ python-archinstall Documentation | | A demo can be viewed here: `https://www.youtube.com/watch?v=9Xt7X_Iqg6E `_ which uses the default guided installer. -.. warning:: - This installer currently requires that your machine has EFI-mode enabled. - Some of the features of Archinstall are: * **No external dependencies or installation requirements.** Runs without any external requirements or installation processes. -- cgit v1.2.3-54-g00ecf From 94b73b6067ebbb7c0cbca7eeed4fb1fe8e35bba6 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Wed, 26 May 2021 20:19:56 +0530 Subject: Added new keys in table --- docs/installing/guided.rst | 89 +++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/docs/installing/guided.rst b/docs/installing/guided.rst index e442d927..58e3cb6c 100644 --- a/docs/installing/guided.rst +++ b/docs/installing/guided.rst @@ -92,46 +92,55 @@ To run it, execute archinstall as a Python module: python -m archinstall --config -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| Key | Values/Description | Description | Required | -| | | | | -+======================+========================================================+============================================================================+===============================================+ -| audio | pipewire/pulseaudio | Audioserver to be installed | No | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| bootloader | systemd-bootctl/grub-install | Bootloader to be installed | Yes | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| custom-commands | [ , , ...] | Custom commands to be run post install | No | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| !encryption-password | any | Password to encrypt disk, not encrypted if password not provided | No | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| filesystem | ext4 / btrfs / fat32 etc. | Filesystem for root and home partitions | Yes | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| harddrive | { "path": } | Path of device to be used | Yes | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| hostname | any | Hostname of machine after installation | Yes | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| kernels | [ "kernel1", "kernel2"] | List of kernels to install eg: linux, linux-lts, linux-zen etc | Atleast 1 | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| keyboard-language | 2 letter code for your keyboard language | eg: us, de etc | Yes | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| mirror-region | {"": { "Mirror Name": True/False}, ..} | List of regions and mirrors to use | Yes | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| nic | nic to use, Use value NetworkManager for installing it | | Yes | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| packages | [ "package1", "package2", ..] | List of packages to install post-installation | No | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| profile | Name of profile to install | profiles are present in profiles/, use the name of a profile to install it | No | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| !root-password | any | The root account password | No | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| services | [ "service1", "service2", ..] | Services to enable post-installation | No | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| superusers | { "": { "!password": ""}, ..} | List of superuser credentials, see config for reference | Yes, if root account password is not provided | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| timezone | Timezone to configure in installation | Timezone eg: UTC, Asia/Kolkata etc. | Yes | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ -| users | { "": { "!password": ""}, ..} | List of regular user credentials, see config for reference | Yes, can be {} | -+----------------------+--------------------------------------------------------+----------------------------------------------------------------------------+-----------------------------------------------+ ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| Key | Values/Description | Description | Required | +| | | | | ++======================+======================================================================================================================================+======================================================================================+===============================================+ +| audio | pipewire/pulseaudio | Audioserver to be installed | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| bootloader | systemd-bootctl/grub-install | Bootloader to be installed | Yes | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| custom-commands | [ , , ...] | Custom commands to be run post install | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| !encryption-password | any | Password to encrypt disk, not encrypted if password not provided | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| filesystem | ext4 / btrfs / fat32 etc. | Filesystem for root and home partitions | Yes | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| gfx_driver | "VMware / VirtualBox (open-source)" or "Nvidia" or "Intel (open-source)" or "AMD / ATI (open-source)" or "All open-source (default)" | Graphics Drivers to install | No | +| | | | | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| harddrive | { "path": } | Path of device to be used | Yes | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| hostname | any | Hostname of machine after installation | Yes | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| kernels | [ "kernel1", "kernel2"] | List of kernels to install eg: linux, linux-lts, linux-zen etc | Atleast 1 | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| keyboard-language | 2 letter code for your keyboard language | eg: us, de etc | Yes | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| mirror-region | {"": { "Mirror Name": True/False}, ..} | List of regions and mirrors to use | Yes | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| nic | { NetworkManager: , nic: } | | Yes | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| ntp | | Set to true to set-up ntp post install | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| packages | [ "package1", "package2", ..] | List of packages to install post-installation | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| profile | Name of profile to install | profiles are present in profiles/, use the name of a profile to install it | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| !root-password | any | The root account password | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| services | [ "service1", "service2", ..] | Services to enable post-installation | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| sys-encoding | "utf-8" | Set to change system encoding post-install, ignored if --advanced flag is not passed | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| sys-language | "en_US" | Set to change system language post-install, ignored if --advanced flag is not passed | No | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| superusers | { "": { "!password": ""}, ..} | List of superuser credentials, see config for reference | Yes, if root account password is not provided | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| timezone | Timezone to configure in installation | Timezone eg: UTC, Asia/Kolkata etc. | Yes | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ +| users | { "": { "!password": ""}, ..} | List of regular user credentials, see config for reference | Yes, can be {} | ++----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ Description individual steps ============================ -- cgit v1.2.3-54-g00ecf From 6e7cb20348a3ad08cddb153bb1831bb70bad4c9e Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Wed, 26 May 2021 20:27:50 +0530 Subject: grammar fixes and json update --- docs/installing/guided.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/installing/guided.rst b/docs/installing/guided.rst index 58e3cb6c..03225adb 100644 --- a/docs/installing/guided.rst +++ b/docs/installing/guided.rst @@ -39,7 +39,7 @@ And to run it, execute archinstall as a Python module: | The ``--script guided`` argument is optional as it's the default behavior. | But this will start the process of guiding you through a installation of a quite minimal Arch Linux experience. -Installing directly from a config file +Installing directly from a configuration file -------------------------------------- .. note:: @@ -58,6 +58,7 @@ Installing directly from a config file ], "!encryption-password": "supersecret", "filesystem": "btrfs", + "gfx_driver": "VMware / VirtualBox (open-source)", "harddrive": { "path": "/dev/nvme0n1" }, @@ -66,14 +67,11 @@ Installing directly from a config file "linux" ], "keyboard-language": "us", - "mirror-region": { - "Worldwide": { - "https://mirror.rackspace.com/archlinux/$repo/os/$arch": true - } - }, + "mirror-region": "Worldwide", "nic": { "NetworkManager": true }, + "ntp": true, "packages": ["docker", "git", "wget", "zsh"], "profile": "gnome", "services": ["docker"], @@ -82,6 +80,8 @@ Installing directly from a config file "!password": "devel" } }, + "sys-encoding": "utf-8", + "sys-language": "en_US", "timezone": "US/Eastern", "users": {} } @@ -125,7 +125,7 @@ To run it, execute archinstall as a Python module: +----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ | packages | [ "package1", "package2", ..] | List of packages to install post-installation | No | +----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ -| profile | Name of profile to install | profiles are present in profiles/, use the name of a profile to install it | No | +| profile | Name of the profile to install | Profiles are present in profiles/, use the name of a profile to install it | No | +----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ | !root-password | any | The root account password | No | +----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ @@ -135,11 +135,11 @@ To run it, execute archinstall as a Python module: +----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ | sys-language | "en_US" | Set to change system language post-install, ignored if --advanced flag is not passed | No | +----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ -| superusers | { "": { "!password": ""}, ..} | List of superuser credentials, see config for reference | Yes, if root account password is not provided | +| superusers | { "": { "!password": ""}, ..} | List of superuser credentials, see configuration for reference | Yes, if root account password is not provided | +----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ | timezone | Timezone to configure in installation | Timezone eg: UTC, Asia/Kolkata etc. | Yes | +----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ -| users | { "": { "!password": ""}, ..} | List of regular user credentials, see config for reference | Yes, can be {} | +| users | { "": { "!password": ""}, ..} | List of regular user credentials, see configuration for reference | Yes, can be {} | +----------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ Description individual steps -- cgit v1.2.3-54-g00ecf From c3b703bc2ac51c4666ee6aed3586d28fd9ecd1af Mon Sep 17 00:00:00 2001 From: nullrequest <30698906+advaithm@users.noreply.github.com> Date: Thu, 27 May 2021 09:34:55 +0530 Subject: Make it more clear what the desktop profile does --- archinstall/lib/user_interaction.py | 1 + 1 file changed, 1 insertion(+) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 0a4cd0f9..817ae548 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -579,6 +579,7 @@ def select_profile(): print(' -- The above list is a set of pre-programmed profiles. --') print(' -- They might make it easier to install things like desktop environments. --') + print(' -- The desktop profile contains a list of profiles for DEs/WMs, e.g sway,kde plasma and gnome --') print(' -- (Leave blank and hit enter to skip this step and continue) --') selected_profile = generic_select(actual_profiles_raw, 'Enter a pre-programmed profile name if you want to install one: ', options_output=False) -- cgit v1.2.3-54-g00ecf From 544eccaadab0bd59ead6504484efbf10038c2c4d Mon Sep 17 00:00:00 2001 From: nullrequest <30698906+advaithm@users.noreply.github.com> Date: Thu, 27 May 2021 10:13:23 +0530 Subject: made it more clear using Redecorating's suggestion in the discord --- archinstall/lib/user_interaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 817ae548..4e54a065 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -579,7 +579,7 @@ def select_profile(): print(' -- The above list is a set of pre-programmed profiles. --') print(' -- They might make it easier to install things like desktop environments. --') - print(' -- The desktop profile contains a list of profiles for DEs/WMs, e.g sway,kde plasma and gnome --') + print(' -- The desktop profile will let you select a DE/WM profile, e.g sway,kde plasma and gnome --') print(' -- (Leave blank and hit enter to skip this step and continue) --') selected_profile = generic_select(actual_profiles_raw, 'Enter a pre-programmed profile name if you want to install one: ', options_output=False) -- cgit v1.2.3-54-g00ecf From 712d29962711cafe17d41cbf24555884fb206a0b Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 27 May 2021 05:34:28 -0400 Subject: Change ordering of example profiles --- archinstall/lib/user_interaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 4e54a065..79919658 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -579,7 +579,7 @@ def select_profile(): print(' -- The above list is a set of pre-programmed profiles. --') print(' -- They might make it easier to install things like desktop environments. --') - print(' -- The desktop profile will let you select a DE/WM profile, e.g sway,kde plasma and gnome --') + print(' -- The desktop profile will let you select a DE/WM profile, e.g gnome, kde, sway --') print(' -- (Leave blank and hit enter to skip this step and continue) --') selected_profile = generic_select(actual_profiles_raw, 'Enter a pre-programmed profile name if you want to install one: ', options_output=False) -- cgit v1.2.3-54-g00ecf From 26a33000d8bbd99fd4c9c0b9f5103fd012f8769a Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 27 May 2021 07:55:22 -0400 Subject: Add descriptions for top-level profiles --- examples/guided.py | 2 -- profiles/desktop.py | 2 ++ profiles/minimal.py | 2 ++ profiles/server.py | 2 ++ profiles/xorg.py | 2 ++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index 1f67a460..a43fc9b1 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -61,7 +61,6 @@ def ask_user_questions(): if not archinstall.arguments.get('sys-encoding', None): archinstall.arguments['sys-encoding'] = 'utf-8' - # Ask which harddrive/block-device we will install to if archinstall.arguments.get('harddrive', None): archinstall.arguments['harddrive'] = archinstall.BlockDevice(archinstall.arguments['harddrive']) @@ -453,5 +452,4 @@ else: if archinstall.arguments.get('gfx_driver', None) is not None: archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) - perform_installation_steps() diff --git a/profiles/desktop.py b/profiles/desktop.py index 631c7f76..73df9256 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -4,6 +4,8 @@ import archinstall is_top_level_profile = True +__description__ = 'Provides a selection of desktop environments and tiling window managers, e.g. gnome, kde, sway' + # New way of defining packages for a profile, which is iterable and can be used out side # of the profile to get a list of "what packages will be installed". __packages__ = [ diff --git a/profiles/minimal.py b/profiles/minimal.py index 13cfd05a..c7df517c 100644 --- a/profiles/minimal.py +++ b/profiles/minimal.py @@ -2,6 +2,8 @@ is_top_level_profile = True +__description__ = 'A very basic installation that allows you to customize Arch Linux as you see fit.' + def _prep_function(*args, **kwargs): """ diff --git a/profiles/server.py b/profiles/server.py index 704c8efe..79aa9481 100644 --- a/profiles/server.py +++ b/profiles/server.py @@ -6,6 +6,8 @@ import archinstall is_top_level_profile = True +__description__ = 'Provides a selection of various server packages to install and enable, e.g. httpd, nginx, mariadb' + available_servers = [ "cockpit", "docker", diff --git a/profiles/xorg.py b/profiles/xorg.py index 9006a430..ce13664d 100644 --- a/profiles/xorg.py +++ b/profiles/xorg.py @@ -4,6 +4,8 @@ import archinstall is_top_level_profile = True +__description__ = 'Installs a minimal system as well as xorg and graphics drivers.' + __packages__ = [ 'dkms', 'xorg-server', -- cgit v1.2.3-54-g00ecf From fd4b2c97fb6f4953b0ecc7f43096b49979c038d1 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Thu, 27 May 2021 21:29:14 +0530 Subject: Update custom-command-sample.json --- examples/custom-command-sample.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/custom-command-sample.json b/examples/custom-command-sample.json index 5e7a70e3..f38bcca1 100644 --- a/examples/custom-command-sample.json +++ b/examples/custom-command-sample.json @@ -8,6 +8,7 @@ ], "!encryption-password": "supersecret", "filesystem": "btrfs", + "gfx_driver": "VMware / VirtualBox (open-source)", "harddrive": { "path": "/dev/nvme0n1" }, @@ -16,14 +17,11 @@ "linux" ], "keyboard-language": "us", - "mirror-region": { - "Worldwide": { - "https://mirror.rackspace.com/archlinux/$repo/os/$arch": true - } - }, + "mirror-region": "Worldwide", "nic": { "NetworkManager": true }, + "ntp": true, "packages": ["docker", "git", "wget", "zsh"], "profile": "gnome", "services": ["docker"], @@ -32,6 +30,8 @@ "!password": "devel" } }, + "sys-encoding": "utf-8", + "sys-language": "en_US", "timezone": "US/Eastern", "users": {} } -- cgit v1.2.3-54-g00ecf From 8ddb9153c7c9d0282e1fb3c9692ea0f29a4a74f6 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Thu, 27 May 2021 14:15:27 -0400 Subject: Fix is_vm detection on real hardware --- archinstall/lib/hardware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index 7c164096..6a3b166d 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -110,7 +110,7 @@ def cpu_vendor() -> Optional[str]: def is_vm() -> bool: try: # systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine - if b"".join(SysCommand("systemd-detect-virt")).lower() != b"none": + if b"none" not in b"".join(SysCommand("systemd-detect-virt")).lower(): return True except: pass -- cgit v1.2.3-54-g00ecf From 5b1f30383b3cdb046dcdaaac14c3e6ffbd8e1231 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 27 May 2021 14:42:24 -0400 Subject: Update version for 2.2.0 final --- archinstall/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index b914c7ec..89792477 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -23,7 +23,7 @@ from .lib.user_interaction import * parser = ArgumentParser() -__version__ = "2.2.0.RC1" +__version__ = "2.2.0" def initialize_arguments(): -- cgit v1.2.3-54-g00ecf From eb8f45952531394875e5911b89ae013fe61f9171 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Thu, 27 May 2021 22:24:09 -0400 Subject: Write user configuration JSON to a file in logs directory --- examples/guided.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/guided.py b/examples/guided.py index a43fc9b1..bad9b625 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -258,7 +258,10 @@ def perform_installation_steps(): print() print('This is your chosen configuration:') archinstall.log("-- Guided template chosen (with below config) --", level=logging.DEBUG) - archinstall.log(json.dumps(archinstall.arguments, indent=4, sort_keys=True, cls=archinstall.JSON), level=logging.INFO) + user_configuration = json.dumps(archinstall.arguments, indent=4, sort_keys=True, cls=archinstall.JSON) + archinstall.log(user_configuration, level=logging.INFO) + with open("/var/log/archinstall/user_configuration.json") as config_file: + config_file.write(user_configuration) print() if not archinstall.arguments.get('silent'): -- cgit v1.2.3-54-g00ecf From 04e58f98fac6a3834d3ce60f3a13f0bb980b165e Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 27 May 2021 22:50:38 -0400 Subject: Needed to set file mode to write. --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/guided.py b/examples/guided.py index bad9b625..320bcfd8 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -260,7 +260,7 @@ def perform_installation_steps(): archinstall.log("-- Guided template chosen (with below config) --", level=logging.DEBUG) user_configuration = json.dumps(archinstall.arguments, indent=4, sort_keys=True, cls=archinstall.JSON) archinstall.log(user_configuration, level=logging.INFO) - with open("/var/log/archinstall/user_configuration.json") as config_file: + with open("/var/log/archinstall/user_configuration.json", "w") as config_file: config_file.write(user_configuration) print() -- cgit v1.2.3-54-g00ecf From c3c55f59928a6b07739114aa4e25713051bbbcca Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Fri, 28 May 2021 08:44:28 +0530 Subject: added support for setting mirror-region to a dict or a string in config --- examples/guided.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index 320bcfd8..b26887a5 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -448,8 +448,11 @@ else: else: archinstall.arguments['profile'] = None if archinstall.arguments.get('mirror-region', None) is not None: - selected_region = archinstall.arguments.get('mirror-region', None) - archinstall.arguments['mirror-region'] = {selected_region: archinstall.list_mirrors()[selected_region]} + if type(archinstall.arguments.get('mirror-region', None)) is dict: + archinstall.arguments['mirror-region'] = archinstall.arguments.get('mirror-region', None) + else: + selected_region = archinstall.arguments.get('mirror-region', None) + archinstall.arguments['mirror-region'] = {selected_region: archinstall.list_mirrors()[selected_region]} archinstall.arguments['sys-language'] = archinstall.arguments.get('sys-language', 'en_US') archinstall.arguments['sys-encoding'] = archinstall.arguments.get('sys-encoding', 'utf-8') if archinstall.arguments.get('gfx_driver', None) is not None: -- cgit v1.2.3-54-g00ecf From 3aee3611c4081272c622a86f09bbd1c8c382b098 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Fri, 28 May 2021 08:50:27 +0530 Subject: added support for setting profile to a dict or a string in config --- examples/guided.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/guided.py b/examples/guided.py index b26887a5..42429370 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -444,7 +444,10 @@ else: archinstall.arguments['harddrive'].keep_partitions = False # Temporary workaround to make Desktop Environments work if archinstall.arguments.get('profile', None) is not None: - archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)) + if type(archinstall.arguments.get('profile', None)) is dict: + archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)['path']) + else: + archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)) else: archinstall.arguments['profile'] = None if archinstall.arguments.get('mirror-region', None) is not None: -- cgit v1.2.3-54-g00ecf From a89f87c14595849e0959e816c23931961cb70617 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 28 May 2021 09:03:10 +0200 Subject: Update __version__ to become a dev-version again To avoid accidental pypi snafu's --- archinstall/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 89792477..948dc070 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -23,7 +23,7 @@ from .lib.user_interaction import * parser = ArgumentParser() -__version__ = "2.2.0" +__version__ = "2.3.0.dev0" def initialize_arguments(): -- cgit v1.2.3-54-g00ecf