Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorDylan Taylor <dylan@dylanmtaylor.com>2021-04-07 09:12:33 -0400
committerDylan Taylor <dylan@dylanmtaylor.com>2021-04-08 09:51:11 -0400
commit4059d62e55042583860d78a91d2f83aec71f5cfb (patch)
tree1356fe335e352c7268310dca64411f6e94082fbb /archinstall
parentea81759e40bf0a54c30dbf90453e2d4c036f01aa (diff)
Add filtration on top level profile
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/profiles.py30
1 files changed, 30 insertions, 0 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)})'