]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
packages: Use Pakfire callbacks to show progress
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Dec 2021 13:29:10 +0000 (13:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Dec 2021 13:29:10 +0000 (13:29 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/__init__.py
src/python/step.py

index 7a7e32da25b2de457d337b8a1bcba4d1119b00e6..96658ee03b5bbb9a314579df6aefcfc8df5dba80 100644 (file)
@@ -237,12 +237,12 @@ class Bricklayer(object):
 
                return output
 
-       def setup_pakfire(self):
+       def setup_pakfire(self, **kwargs):
                """
                        Calls Pakfire and has it load its configuration
                """
                return pakfire.Pakfire(self.root, arch=self.arch,
-                       conf="/etc/pakfire/distros/ipfire3.conf")
+                       conf="/etc/pakfire/distros/ipfire3.conf", **kwargs)
 
        def _select_bootloaders(self):
                """
index ed0ecc498d55a5044fac920113b4801fb4685564..7612f3214e95fbf431d20df2759214d6fe865820 100644 (file)
@@ -70,54 +70,41 @@ class Step(object):
 
                # Set up Pakfire
                with self.tui.progress(
-                       _("Setting Up Pakfire"),
-                       _("Pakfire is being set up..."),
-               ):
-                       p = self.bricklayer.setup_pakfire()
-
-               with p as p:
-                       # Resolve package dependencies
-                       with self.tui.progress(
-                               _("Resolving Dependencies"),
-                               _("Resolving package dependencies..."),
-                       ):
-                               try:
-                                       transaction = p.install(packages)
-
-                               # Abort on any dependencies problems
-                               except pakfire.errors.DependencyError as e:
-                                       problems = e.args[0]
-
-                                       # Format problem descriptions
-                                       text = []
-                                       for problem in problems:
-                                               lines = [
-                                                       "* %s" % problem
-                                               ]
-                                               for solution in problem.solutions:
-                                                       lines.append("  --> %s" % solution)
-
-                                               text.append("\n".join(lines))
-
-                                       self.tui.error(
-                                               _("Dependency Problem"),
-                                               _(
-                                                       "A problem has occured during resolving package dependencies:\n\n%s",
-                                                       "Problems have occured during resolving package dependencies:\n\n%s",
-                                                       len(problems),
-                                               ) % "\n\n".join(text),
-                                               width=78,
-                                       )
-
-                       # Log the transaction
-                       log.info("%s" % transaction.dump())
-
-                       # Run the transaction
-                       with self.tui.progress(
-                               _("Installing Packages"),
-                               _("Installing packages..."),
-                       ):
-                               transaction.run()
+                       _("Installing Packages"),
+                       _("Installing packages..."),
+                       max_value=100,
+               ) as t:
+                       # Create a new Pakfire instance
+                       p = self.bricklayer.setup_pakfire(**t.callbacks)
+
+                       try:
+                               # Install packages
+                               p.install(packages)
+
+                       # Abort on any dependencies problems
+                       except pakfire.errors.DependencyError as e:
+                               problems = e.args[0]
+
+                               # Format problem descriptions
+                               text = []
+                               for problem in problems:
+                                       lines = [
+                                               "* %s" % problem
+                                       ]
+                                       for solution in problem.solutions:
+                                               lines.append("  --> %s" % solution)
+
+                                       text.append("\n".join(lines))
+
+                               self.tui.error(
+                                       _("Dependency Problem"),
+                                       _(
+                                               "A problem has occured during resolving package dependencies:\n\n%s",
+                                               "Problems have occured during resolving package dependencies:\n\n%s",
+                                               len(problems),
+                                       ) % "\n\n".join(text),
+                                       width=78,
+                               )
 
 
 class InteractiveStep(Step):