]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
backend: Create the Pakfire context only once
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 Mar 2025 16:45:31 +0000 (16:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 Mar 2025 16:45:31 +0000 (16:45 +0000)
It would be enough to initialize this only once

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/__init__.py

index 1c2d2a028983234548ede421d944037a8398b21d..cca3c9a7e14022d52df475055bc206e1d7118197 100644 (file)
@@ -101,6 +101,9 @@ class Bricklayer(object):
                # Initialise the text user interface
                self.tui = tui.Tui(self)
 
+               # Setup the Pakfire context
+               self.ctx = self.setup_context()
+
                # Create root directory
                self.root = tempfile.mkdtemp(prefix="bricklayer-", suffix="-root")
 
@@ -324,9 +327,9 @@ class Bricklayer(object):
                        # Perform umount
                        self.command(["umount", target], error_ok=True)
 
-       def setup_pakfire(self, **kwargs):
+       def setup_context(self):
                """
-                       Calls Pakfire and has it load its configuration
+                       Sets up the Pakfire context
                """
                logger = log.getChild("pakfire")
 
@@ -336,9 +339,15 @@ class Bricklayer(object):
                # Configure the logger
                ctx.set_logger(logger)
 
+               return ctx
+
+       def setup_pakfire(self, **kwargs):
+               """
+                       Calls Pakfire and has it load its configuration
+               """
                # Create a new pakfire instance
                return pakfire.Pakfire(
-                       ctx    = ctx,
+                       ctx    = self.ctx,
                        path   = self.root,
                        arch   = self.arch,
                        config = self.pakfire_conf,