Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/profiles
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2022-05-09 20:02:48 +1000
committerGitHub <noreply@github.com>2022-05-09 12:02:48 +0200
commit0fa52a5424e28ed62ef84bdc92868bbfc434e015 (patch)
tree4b88e7799319aa9489f7e16beedf5517b6feba34 /profiles
parent20ffebac50478554a7582de5e5c1d8b4504ea8be (diff)
Introduce ctrl+c and other bug fixes (#1152)
* Intergrate ctrl+c * stash * Update * Fix profile reset * flake8 Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
Diffstat (limited to 'profiles')
-rw-r--r--profiles/desktop.py25
-rw-r--r--profiles/i3.py13
-rw-r--r--profiles/minimal.py2
-rw-r--r--profiles/server.py17
-rw-r--r--profiles/sway.py5
5 files changed, 45 insertions, 17 deletions
diff --git a/profiles/desktop.py b/profiles/desktop.py
index eaece9f5..e94d3505 100644
--- a/profiles/desktop.py
+++ b/profiles/desktop.py
@@ -1,6 +1,12 @@
# A desktop environment selector.
+from typing import Any, TYPE_CHECKING
+
import archinstall
-from archinstall import log
+from archinstall import log, Menu
+from archinstall.lib.menu.menu import MenuSelectionType
+
+if TYPE_CHECKING:
+ _: Any
is_top_level_profile = True
@@ -46,23 +52,26 @@ def _prep_function(*args, **kwargs) -> bool:
other code in this stage. So it's a safe way to ask the user
for more input before any other installer steps start.
"""
- desktop = archinstall.Menu(str(_('Select your desired desktop environment')), __supported__).run()
+ choice = Menu(str(_('Select your desired desktop environment')), __supported__).run()
+
+ if choice.type_ != MenuSelectionType.Selection:
+ return False
- if desktop:
+ if choice.value:
# Temporarily store the selected desktop profile
# in a session-safe location, since this module will get reloaded
# the next time it gets executed.
if not archinstall.storage.get('_desktop_profile', None):
- archinstall.storage['_desktop_profile'] = desktop
+ archinstall.storage['_desktop_profile'] = choice.value
if not archinstall.arguments.get('desktop-environment', None):
- archinstall.arguments['desktop-environment'] = desktop
- profile = archinstall.Profile(None, desktop)
+ archinstall.arguments['desktop-environment'] = choice.value
+ profile = archinstall.Profile(None, choice.value)
# Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered.
- with profile.load_instructions(namespace=f"{desktop}.py") as imported:
+ with profile.load_instructions(namespace=f"{choice.value}.py") as imported:
if hasattr(imported, '_prep_function'):
return imported._prep_function()
else:
- log(f"Deprecated (??): {desktop} profile has no _prep_function() anymore")
+ log(f"Deprecated (??): {choice.value} profile has no _prep_function() anymore")
exit(1)
return False
diff --git a/profiles/i3.py b/profiles/i3.py
index 3283848e..37029a02 100644
--- a/profiles/i3.py
+++ b/profiles/i3.py
@@ -1,6 +1,8 @@
# Common package for i3, lets user select which i3 configuration they want.
import archinstall
+from archinstall import Menu
+from archinstall.lib.menu.menu import MenuSelectionType
is_top_level_profile = False
@@ -27,13 +29,16 @@ def _prep_function(*args, **kwargs):
supported_configurations = ['i3-wm', 'i3-gaps']
- desktop = archinstall.Menu('Select your desired configuration', supported_configurations).run()
+ choice = Menu('Select your desired configuration', supported_configurations).run()
- if desktop:
+ if choice.type_ != MenuSelectionType.Selection:
+ return False
+
+ if choice.value:
# Temporarily store the selected desktop profile
# in a session-safe location, since this module will get reloaded
# the next time it gets executed.
- archinstall.storage['_i3_configuration'] = desktop
+ archinstall.storage['_i3_configuration'] = choice.value
# i3 requires a functioning Xorg installation.
profile = archinstall.Profile(None, 'xorg')
@@ -43,6 +48,8 @@ def _prep_function(*args, **kwargs):
else:
print('Deprecated (??): xorg profile has no _prep_function() anymore')
+ return False
+
if __name__ == 'i3':
"""
diff --git a/profiles/minimal.py b/profiles/minimal.py
index 3b161511..a412aa81 100644
--- a/profiles/minimal.py
+++ b/profiles/minimal.py
@@ -1,4 +1,5 @@
# Used to do a minimal install
+import archinstall
is_top_level_profile = True
@@ -12,6 +13,7 @@ def _prep_function(*args, **kwargs):
we don't need to do anything special here, but it
needs to exist and return True.
"""
+ archinstall.storage['profile_minimal'] = True
return True # Do nothing and just return True
diff --git a/profiles/server.py b/profiles/server.py
index 91ac7cf2..21681c2f 100644
--- a/profiles/server.py
+++ b/profiles/server.py
@@ -1,8 +1,14 @@
# Used to select various server application profiles on top of a minimal installation.
import logging
+from typing import Any, TYPE_CHECKING
import archinstall
+from archinstall import Menu
+from archinstall.lib.menu.menu import MenuSelectionType
+
+if TYPE_CHECKING:
+ _: Any
is_top_level_profile = True
@@ -26,15 +32,18 @@ def _prep_function(*args, **kwargs):
Magic function called by the importing installer
before continuing any further.
"""
- servers = archinstall.Menu(str(_(
+ choice = Menu(str(_(
'Choose which servers to install, if none then a minimal installation wil be done')),
available_servers,
- preset_values=archinstall.storage.get('_selected_servers', []),
+ preset_values=kwargs['servers'],
multi=True
).run()
- if servers:
- archinstall.storage['_selected_servers'] = servers
+ if choice.type_ != MenuSelectionType.Selection:
+ return False
+
+ if choice.value:
+ archinstall.storage['_selected_servers'] = choice.value
return True
return False
diff --git a/profiles/sway.py b/profiles/sway.py
index 0819db95..b7266da3 100644
--- a/profiles/sway.py
+++ b/profiles/sway.py
@@ -23,8 +23,9 @@ def _check_driver() -> bool:
if packages and "nvidia" in packages:
prompt = 'The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues, are you okay with that?'
- choice = Menu(prompt, Menu.yes_no(), default_option=Menu.no()).run()
- if choice == Menu.no():
+ choice = Menu(prompt, Menu.yes_no(), default_option=Menu.no(), skip=False).run()
+
+ if choice.value == Menu.no():
return False
return True