]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
steps: Use the new Transaction class to install packages
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 Mar 2025 18:06:40 +0000 (18:06 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 Mar 2025 18:06:40 +0000 (18:06 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/step.py

index a98ad8ace2898ffafbe80f7ea4b8535139c407b5..bfc2aab102d8ca4f9de2ec683d8cb0a89cb194da 100644 (file)
@@ -75,40 +75,36 @@ class Step(object):
                if not title:
                        title = _("Installing Packages")
 
-               # Set up Pakfire
-               with self.tui.progress(title, _("Installing packages..."), max_value=100) as t:
-                       # Create a new Pakfire instance
-                       p = self.bricklayer.setup_pakfire()
+               # Create a new Pakfire instance
+               p = self.bricklayer.setup_pakfire()
+
+               # Create a new transaction
+               t = pakfire.Transaction(p)
+
+               # Install all packages
+               for package in packages:
+                       t.install(package)
 
+               # Solve the transaction
+               with self.tui.progress(title, _("Solving dependencies...")):
                        try:
-                               # Install packages
-                               p.install(packages, status_callback=t.status)
+                               t.solve()
 
                        # Abort on any dependencies problems
                        except pakfire.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))
-
+                               # Show an error with the error
                                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),
+                                       _("Problems have occured during resolving package dependencies"
+                                               ":\n\n%s") % problems,
                                        width=78,
                                )
 
+               # Run the transaction
+               t.run()
+
 
 class InteractiveStep(Step):
        """