From: Michael Tremer Date: Fri, 14 Mar 2025 16:45:31 +0000 (+0000) Subject: backend: Create the Pakfire context only once X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e22ebc3a766d51ea5a727524f7fc23f4a9b3bd75;p=people%2Fms%2Fbricklayer.git backend: Create the Pakfire context only once It would be enough to initialize this only once Signed-off-by: Michael Tremer --- diff --git a/src/python/__init__.py b/src/python/__init__.py index 1c2d2a0..cca3c9a 100644 --- a/src/python/__init__.py +++ b/src/python/__init__.py @@ -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,