Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archinstall/lib/profiles.py30
-rw-r--r--examples/guided.py4
2 files changed, 33 insertions, 1 deletions
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index b56304c5..1948a819 100644
--- a/archinstall/lib/profiles.py
+++ b/archinstall/lib/profiles.py
@@ -177,6 +177,7 @@ class Profile(Script):
if hasattr(imported, '_prep_function'):
return True
return False
+
def has_post_install(self):
with open(self.path, 'r') as source:
source_data = source.read()
@@ -193,6 +194,35 @@ class Profile(Script):
if hasattr(imported, '_post_install'):
return True
+ def is_top_level_profile(self):
+ with open(self.path, 'r') as source:
+ source_data = source.read()
+
+ # TODO: I imagine that there is probably a better way to write this.
+ return 'top_level_profile = True' in source_data
+
+ @property
+ def packages(self) -> list:
+ """
+ Returns a list of packages baked into the profile definition.
+ If no package definition has been done, .packages() will return None.
+ """
+ with open(self.path, 'r') as source:
+ source_data = source.read()
+
+ # Some crude safety checks, make sure the imported profile has
+ # a __name__ check before importing.
+ #
+ # If the requirements are met, import with .py in the namespace to not
+ # trigger a traditional:
+ # if __name__ == 'moduleName'
+ if '__name__' in source_data and '__packages__' in source_data:
+ with self.load_instructions(namespace=f"{self.namespace}.py") as imported:
+ if hasattr(imported, '__packages__'):
+ return imported.__packages__
+ return None
+
+
class Application(Profile):
def __repr__(self, *args, **kwargs):
return f'Application({os.path.basename(self.profile)})'
diff --git a/examples/guided.py b/examples/guided.py
index ed838a29..a28aa50e 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,5 +1,7 @@
import getpass, time, json, sys, signal, os
import archinstall
+from archinstall.lib.hardware import hasUEFI
+from archinstall.lib.profiles import Profile
"""
This signal-handler chain (and global variable)
@@ -166,7 +168,7 @@ def ask_user_questions():
# Ask for archinstall-specific profiles (such as desktop environments etc)
if not archinstall.arguments.get('profile', None):
- archinstall.arguments['profile'] = archinstall.select_profile(archinstall.list_profiles())
+ archinstall.arguments['profile'] = archinstall.select_profile(filter(lambda profile: (Profile(None, profile).is_top_level_profile()), archinstall.list_profiles()))
else:
archinstall.arguments['profile'] = archinstall.list_profiles()[archinstall.arguments['profile']]