From: Michael Tremer Date: Fri, 14 Mar 2025 18:06:40 +0000 (+0000) Subject: steps: Use the new Transaction class to install packages X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e1d7778beb476f75343d79590ebe226ad66a968b;p=people%2Fms%2Fbricklayer.git steps: Use the new Transaction class to install packages Signed-off-by: Michael Tremer --- diff --git a/src/python/step.py b/src/python/step.py index a98ad8a..bfc2aab 100644 --- a/src/python/step.py +++ b/src/python/step.py @@ -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): """