From: Michael Tremer Date: Wed, 7 Dec 2016 22:10:44 +0000 (+0100) Subject: Move update() to PakfireContext X-Git-Tag: 0.9.28~1285^2~1374 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a0b428f870f90c16bb237dc1e1b780240b841c8c;p=pakfire.git Move update() to PakfireContext Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/base.py b/src/pakfire/base.py index 9ad9148b3..0af0142da 100644 --- a/src/pakfire/base.py +++ b/src/pakfire/base.py @@ -106,64 +106,6 @@ class Pakfire(object): if not ret: raise NotAnIPFireSystemError("You can run pakfire only on an IPFire system") - def update(self, pkgs=None, check=False, excludes=None, interactive=True, logger=None, sync=False, **kwargs): - """ - check indicates, if the method should return after calculation - of the transaction. - """ - if logger is None: - logger = logging.getLogger("pakfire") - - # If there are given any packets on the command line, we will - # only update them. Otherwise, we update the whole system. - updateall = True - if pkgs: - updateall = False - - request = self.pool.create_request(update=pkgs, updateall=updateall) - - # Exclude packages that should not be updated. - for exclude in excludes or []: - logger.info(_("Excluding %s.") % exclude) - - exclude = self.pool.create_relation(exclude) - request.lock(exclude) - - # Update or downgrade to the latest version of all packages - # in the enabled repositories. - if sync: - kwargs.update({ - "allow_downgrade" : True, - "allow_uninstall" : True, - }) - - solver = self.pool.solve(request, logger=logger, **kwargs) - - if not solver.status: - logger.info(_("Nothing to do")) - - # If we are running in check mode, we return a non-zero value to - # indicate, that there are no updates. - if check: - return 1 - else: - return - - # Create the transaction. - t = transaction.Transaction.from_solver(self, solver) - t.dump(logger=logger) - - # Just exit here, because we won't do the transaction in this mode. - if check: - return - - # Ask the user if the transaction is okay. - if interactive and not t.cli_yesno(): - return - - # Run the transaction. - t.run(logger=logger) - def downgrade(self, pkgs, logger=None, **kwargs): assert pkgs @@ -545,6 +487,64 @@ class PakfireContext(object): t.run(logger=logger) + def update(self, pkgs=None, check=False, excludes=None, interactive=True, logger=None, sync=False, **kwargs): + """ + check indicates, if the method should return after calculation + of the transaction. + """ + if logger is None: + logger = logging.getLogger("pakfire") + + # If there are given any packets on the command line, we will + # only update them. Otherwise, we update the whole system. + updateall = True + if pkgs: + updateall = False + + request = self.pakfire.pool.create_request(update=pkgs, updateall=updateall) + + # Exclude packages that should not be updated. + for exclude in excludes or []: + logger.info(_("Excluding %s.") % exclude) + + exclude = self.pakfire.pool.create_relation(exclude) + request.lock(exclude) + + # Update or downgrade to the latest version of all packages + # in the enabled repositories. + if sync: + kwargs.update({ + "allow_downgrade" : True, + "allow_uninstall" : True, + }) + + solver = self.pakfire.pool.solve(request, logger=logger, **kwargs) + + if not solver.status: + logger.info(_("Nothing to do")) + + # If we are running in check mode, we return a non-zero value to + # indicate, that there are no updates. + if check: + return 1 + else: + return + + # Create the transaction. + t = transaction.Transaction.from_solver(self.pakfire, solver) + t.dump(logger=logger) + + # Just exit here, because we won't do the transaction in this mode. + if check: + return + + # Ask the user if the transaction is okay. + if interactive and not t.cli_yesno(): + return + + # Run the transaction. + t.run(logger=logger) + class PakfireBuilder(Pakfire): mode = "builder"