/** Release a transaction. */ int SYMEXPORT alpm_trans_release(alpm_handle_t *handle) { alpm_trans_t *trans; /* Sanity checks */ CHECK_HANDLE(handle, return -1); trans = handle->trans; ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1)); ASSERT(trans->state != STATE_IDLE, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1)); int nolock_flag = trans->flags & ALPM_TRANS_FLAG_NOLOCK; _alpm_trans_free(trans); handle->trans = NULL; /* unlock db */ if(!nolock_flag) { if(_alpm_handle_unlock(handle)) { _alpm_log(handle, ALPM_LOG_WARNING, _("could not remove lock file %s\n"), alpm_option_get_lockfile(handle)); alpm_logaction(handle, "warning: could not remove lock file %s\n", alpm_option_get_lockfile(handle)); } } return 0; }
/** Release a transaction. * @return 0 on success, -1 on error (pm_errno is set accordingly) */ int SYMEXPORT alpm_trans_release() { pmtrans_t *trans; ALPM_LOG_FUNC; /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); trans = handle->trans; ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans->state != STATE_IDLE, RET_ERR(PM_ERR_TRANS_NULL, -1)); _alpm_trans_free(trans); handle->trans = NULL; /* unlock db */ if(handle->lckfd != -1) { while(close(handle->lckfd) == -1 && errno == EINTR); handle->lckfd = -1; } if(_alpm_lckrm()) { _alpm_log(PM_LOG_WARNING, _("could not remove lock file %s\n"), alpm_option_get_lockfile()); alpm_logaction("warning: could not remove lock file %s\n", alpm_option_get_lockfile()); } return(0); }
static void trans_init_error(alpm_handle_t *handle) { alpm_errno_t err = alpm_errno(handle); printf("failed to init transaction (%s)\n", alpm_strerror(err)); if(err == ALPM_ERR_HANDLE_LOCK) { const char *lockfile = alpm_option_get_lockfile(handle); printf("could not lock database: %s\n", strerror(errno)); if(access(lockfile, F_OK) == 0) { fprintf(stderr, " if you're sure a package manager is not already\n" " running, you can remove %s\n", lockfile); } } }
gboolean pacman_transaction_start (guint32 flags, GError **error) { g_return_val_if_fail (pacman_manager != NULL, FALSE); if (pacman_manager_get_transaction (pacman_manager) != NULL) { PacmanError code = PACMAN_ERROR_TRANSACTION_ALREADY_INITIALIZED; g_set_error (error, PACMAN_ERROR, code, _("Could not initialize transaction: %s"), alpm_strerror (code)); return FALSE; } if (alpm_trans_init (flags, pacman_transaction_event_cb, pacman_transaction_question_cb, pacman_transaction_progress_cb) < 0) { if (pm_errno == PACMAN_ERROR_ALREADY_RUNNING) { g_message (_("If you are certain no other package manager is running, you can remove %s\n"), alpm_option_get_lockfile ()); } g_set_error (error, PACMAN_ERROR, pm_errno, _("Could not initialize transaction: %s"), alpm_strerrorlast ()); return FALSE; } alpm_option_set_dlcb (pacman_transaction_download_cb); alpm_option_set_totaldlcb (pacman_transaction_total_download_cb); return TRUE; }