index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Aggam Rahamim <agamclass@gmail.com> | 2021-04-25 14:56:03 +0300 |
---|---|---|
committer | Aggam Rahamim <agamclass@gmail.com> | 2021-04-25 14:56:03 +0300 |
commit | e25018131756757999bbe8ba8e54ec3ae8224c7d (patch) | |
tree | 828fb3ad3882d4dfac3e522c52a16369c6042990 /archinstall/lib/profiles.py | |
parent | 5c9859d316b8064949370c03745cfd99e0d67670 (diff) | |
parent | 4db40c06eb37390eaa19b6d8b0afa7b21c5e65b3 (diff) |
-rw-r--r-- | archinstall/lib/profiles.py | 46 |
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 21ec5f6f..c5f63e72 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -177,7 +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,7 +193,6 @@ class Profile(Script): with self.load_instructions(namespace=f"{self.namespace}.py") as imported: if hasattr(imported, '_post_install'): return True - """ def is_top_level_profile(self): with open(self.path, 'r') as source: @@ -224,6 +223,49 @@ class Profile(Script): return None + def has_post_install(self): + with open(self.path, 'r') as source: + source_data = source.read() + + # Some crude safety checks, make sure the imported profile has + # a __name__ check and if so, check if it's got a _prep_function() + # we can call to ask for more user input. + # + # 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 '_post_install' in source_data: + with self.load_instructions(namespace=f"{self.namespace}.py") as imported: + if hasattr(imported, '_post_install'): + return True + + def is_top_level_profile(self): + with open(self.path, 'r') as source: + source_data = source.read() + 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)})' |