def prepare(self): """For preparation there is a special C function, which we use to get the needed targets into the transaction """ if p.alpm_sync_sysupgrade(self.session.config.allow_downgrade) == -1: self.handle_error(p.get_errno()) super(SysUpgradeTransaction, self).prepare()
def add_target(self, target): if "/" in target: pos = target.find("/") ret = p.alpm_sync_dbtarget(target[:pos], target[pos+1:]) else: ret = p.alpm_sync_target(target) if ret == -1: self.handle_error(p.get_errno())
def commit(self): """Commit this transaction and let libalpm apply the changes to the filesystem and the databases """ if len(self.targets["add"]) + len(self.targets["remove"]) == 0: raise NothingToBeDoneError("Nothing to be done...") if p.alpm_trans_commit(self.__backend_data) == -1: self.handle_error(p.get_errno()) self.events.DoneTransactionCommit()
def prepare(self): """After setting the targets, the transaction is ready to be prepared. Use helper functions in C (pyalpmm_raw/helper.i) to construct a alpm_list_t in C space on which the transaction can work on. """ self.__backend_data = p.get_list_buffer_ptr() if p.alpm_trans_prepare(self.__backend_data) == -1: self.handle_error(p.get_errno()) self.targets = self.get_targets() if len(self.targets["remove"]) + len(self.targets["add"]) == 0: raise NothingToBeDoneError("Nothing to be done...") self.events.DoneTransactionPrepare()
def aquire(self): """Aquire a transaction from libalpm by setting all necassary callback functions and values, then call alpm_trans_init() and pray """ if self.session.config.rights != "root": raise TransactionError( "You must be root to initialize a transaction") # set callbacks for download and totaldownload p.alpm_option_set_dlcb(self.__callback_download_progress) p.alpm_option_set_totaldlcb(self.__callback_download_total_progress) # this one to set alernative downloader #p.alpm_cb_fetch(const char *url, const char *localpath, int force) # init transaction, including the rest of the callbacks if p.alpm_trans_init( self.session.config.transaction_flags, self.__callback_event, self.__callback_conv, self.__callback_progress ) == -1: if p.get_errno() == p.PM_ERR_HANDLE_LOCK: raise TransactionError("The local database is locked") raise TransactionError("Could not initialize the transaction") # list of packages and groups self.pkg_search_list = self.session.db_man.get_packages() self.grp_search_list = self.session.db_man.get_groups() self.events.DoneTransactionInit() # if targets were directly passed at __init__ set them and .prepare() if self.targets: self.set_targets(self.targets) self.prepare()
def add_target(self, target): ret = p.alpm_add_target(target) if ret == -1: self.handle_error(p.get_errno())