Moved the globalization of 'installation' variable. Since Profile() might be created before the installation instance, we need to move the global variable declaration after installation has begun and there's an installation instance.

This commit is contained in:
Anton Hvornum 2021-03-21 15:25:24 +01:00
parent 6081733422
commit 93faf07b69
No known key found for this signature in database
GPG Key ID: F1234C5BA67C59DF
2 changed files with 9 additions and 1 deletions

View File

@ -381,6 +381,15 @@ class Installer():
return self.pacstrap(*packages)
def install_profile(self, profile):
# TODO: Replace this with a import archinstall.session instead in the profiles.
# The tricky thing with doing the import archinstall.session instead is that
# profiles might be run from a different chroot, and there's no way we can
# guarantee file-path safety when accessing the installer object that way.
# Doing the __builtins__ replacement, ensures that the global vriable "installation"
# is always kept up to date. It's considered a nasty hack - but it's a safe way
# of ensuring 100% accuracy of archinstall session variables.
__builtins__['installation'] = self.installer
if type(profile) == str:
profile = Profile(self, profile)

View File

@ -142,7 +142,6 @@ class Script():
if not self.namespace in sys.modules or self.spec is None:
self.load_instructions()
__builtins__['installation'] = self.installer # TODO: Replace this with a import archinstall.session instead
self.spec.loader.exec_module(sys.modules[self.namespace])
return sys.modules[self.namespace]