libalpm
Arch Linux Package Manager Library
|
Functions to manipulate libalpm transactions More...
Enumerations | |
enum | alpm_transflag_t { ALPM_TRANS_FLAG_NODEPS = 1 , ALPM_TRANS_FLAG_NOSAVE = (1 << 2) , ALPM_TRANS_FLAG_NODEPVERSION = (1 << 3) , ALPM_TRANS_FLAG_CASCADE = (1 << 4) , ALPM_TRANS_FLAG_RECURSE = (1 << 5) , ALPM_TRANS_FLAG_DBONLY = (1 << 6) , ALPM_TRANS_FLAG_NOHOOKS = (1 << 7) , ALPM_TRANS_FLAG_ALLDEPS = (1 << 8) , ALPM_TRANS_FLAG_DOWNLOADONLY = (1 << 9) , ALPM_TRANS_FLAG_NOSCRIPTLET = (1 << 10) , ALPM_TRANS_FLAG_NOCONFLICTS = (1 << 11) , ALPM_TRANS_FLAG_NEEDED = (1 << 13) , ALPM_TRANS_FLAG_ALLEXPLICIT = (1 << 14) , ALPM_TRANS_FLAG_UNNEEDED = (1 << 15) , ALPM_TRANS_FLAG_RECURSEALL = (1 << 16) , ALPM_TRANS_FLAG_NOLOCK = (1 << 17) } |
Transaction flags. More... | |
Functions | |
int | alpm_trans_get_flags (alpm_handle_t *handle) |
Returns the bitfield of flags for the current transaction. | |
alpm_list_t * | alpm_trans_get_add (alpm_handle_t *handle) |
Returns a list of packages added by the transaction. | |
alpm_list_t * | alpm_trans_get_remove (alpm_handle_t *handle) |
Returns the list of packages removed by the transaction. | |
int | alpm_trans_init (alpm_handle_t *handle, int flags) |
Initialize the transaction. | |
int | alpm_trans_prepare (alpm_handle_t *handle, alpm_list_t **data) |
Prepare a transaction. | |
int | alpm_trans_commit (alpm_handle_t *handle, alpm_list_t **data) |
Commit a transaction. | |
int | alpm_trans_interrupt (alpm_handle_t *handle) |
Interrupt a transaction. | |
int | alpm_trans_release (alpm_handle_t *handle) |
Release a transaction. | |
Add/Remove packages | |
These functions remove/add packages to the transactions | |
int | alpm_sync_sysupgrade (alpm_handle_t *handle, int enable_downgrade) |
Search for packages to upgrade and add them to the transaction. | |
int | alpm_add_pkg (alpm_handle_t *handle, alpm_pkg_t *pkg) |
Add a package to the transaction. | |
int | alpm_remove_pkg (alpm_handle_t *handle, alpm_pkg_t *pkg) |
Add a package removal to the transaction. | |
Functions to manipulate libalpm transactions
Transactions are the way to add/remove packages to/from the system. Only one transaction can exist at a time.
The basic workflow of a transaction is to:
A transaction can be released at any time. A transaction does not have to be committed.
enum alpm_transflag_t |
Transaction flags.
int alpm_add_pkg | ( | alpm_handle_t * | handle, |
alpm_pkg_t * | pkg ) |
Add a package to the transaction.
If the package was loaded by alpm_pkg_load(), it will be freed upon alpm_trans_release invocation.
handle | the context handle |
pkg | the package to add |
References _, alpm_trans_t::add, ALPM_ERR_TRANS_DUP_TARGET, ALPM_ERR_TRANS_NOT_INITIALIZED, ALPM_ERR_TRANS_NULL, ALPM_ERR_WRONG_ARGS, alpm_list_add(), ALPM_LOG_DEBUG, ALPM_LOG_WARNING, alpm_pkg_find(), ALPM_PKG_FROM_LOCALDB, ALPM_PKG_REASON_EXPLICIT, ALPM_TRANS_FLAG_DOWNLOADONLY, ALPM_TRANS_FLAG_NEEDED, ASSERT, CHECK_HANDLE, alpm_trans_t::flags, RET_ERR, alpm_trans_t::state, and STATE_INITIALIZED.
int alpm_remove_pkg | ( | alpm_handle_t * | handle, |
alpm_pkg_t * | pkg ) |
Add a package removal to the transaction.
handle | the context handle |
pkg | the package to uninstall |
References ALPM_ERR_TRANS_NOT_INITIALIZED, ALPM_ERR_TRANS_NULL, ALPM_ERR_WRONG_ARGS, alpm_list_add(), ALPM_LOG_DEBUG, alpm_pkg_find(), ALPM_PKG_FROM_LOCALDB, ASSERT, CHECK_HANDLE, alpm_trans_t::remove, RET_ERR, alpm_trans_t::state, and STATE_INITIALIZED.
int alpm_sync_sysupgrade | ( | alpm_handle_t * | handle, |
int | enable_downgrade ) |
Search for packages to upgrade and add them to the transaction.
handle | the context handle |
enable_downgrade | allow downgrading of packages if the remote version is lower |
References alpm_trans_t::add, ALPM_DB_USAGE_UPGRADE, ALPM_ERR_TRANS_NOT_INITIALIZED, ALPM_ERR_TRANS_NULL, alpm_list_add(), alpm_list_join(), ALPM_LOG_DEBUG, alpm_pkg_find(), ASSERT, CHECK_HANDLE, check_literal(), check_replacers(), alpm_list_t::data, alpm_list_t::next, alpm_trans_t::remove, RET_ERR, alpm_trans_t::state, and STATE_INITIALIZED.
int alpm_trans_commit | ( | alpm_handle_t * | handle, |
alpm_list_t ** | data ) |
Commit a transaction.
handle | the context handle |
data | the address of an alpm_list where detailed description of an error can be dumped (i.e. list of conflicting files) |
References alpm_trans_t::add, ALPM_CALLER_PREFIX, ALPM_ERR_TRANS_HOOK_FAILED, ALPM_ERR_TRANS_NOT_LOCKED, ALPM_ERR_TRANS_NOT_PREPARED, ALPM_ERR_TRANS_NULL, ALPM_EVENT_TRANSACTION_DONE, ALPM_EVENT_TRANSACTION_START, ALPM_HOOK_POST_TRANSACTION, ALPM_HOOK_PRE_TRANSACTION, alpm_logaction(), ALPM_TRANS_FLAG_DOWNLOADONLY, ALPM_TRANS_FLAG_NOHOOKS, ALPM_TRANS_FLAG_NOLOCK, ASSERT, CHECK_HANDLE, EVENT, alpm_trans_t::flags, alpm_trans_t::remove, RET_ERR, alpm_trans_t::state, STATE_COMMITED, STATE_COMMITING, STATE_INTERRUPTED, and STATE_PREPARED.
alpm_list_t * alpm_trans_get_add | ( | alpm_handle_t * | handle | ) |
Returns a list of packages added by the transaction.
handle | the context handle |
References ALPM_ERR_TRANS_NULL, ASSERT, CHECK_HANDLE, and RET_ERR.
int alpm_trans_get_flags | ( | alpm_handle_t * | handle | ) |
Returns the bitfield of flags for the current transaction.
handle | the context handle |
References ALPM_ERR_TRANS_NULL, ASSERT, CHECK_HANDLE, and RET_ERR.
alpm_list_t * alpm_trans_get_remove | ( | alpm_handle_t * | handle | ) |
Returns the list of packages removed by the transaction.
handle | the context handle |
References ALPM_ERR_TRANS_NULL, ASSERT, CHECK_HANDLE, and RET_ERR.
int alpm_trans_init | ( | alpm_handle_t * | handle, |
int | flags ) |
Initialize the transaction.
handle | the context handle |
flags | flags of the transaction (like nodeps, etc; see alpm_transflag_t) |
References ALPM_ERR_HANDLE_LOCK, ALPM_ERR_MEMORY, ALPM_ERR_TRANS_NOT_NULL, ALPM_TRANS_FLAG_NOLOCK, ASSERT, CALLOC, CHECK_HANDLE, alpm_trans_t::flags, RET_ERR, alpm_trans_t::state, and STATE_INITIALIZED.
int alpm_trans_interrupt | ( | alpm_handle_t * | handle | ) |
Interrupt a transaction.
handle | the context handle |
References ALPM_ERR_TRANS_NULL, ALPM_ERR_TRANS_TYPE, ASSERT, CHECK_HANDLE, RET_ERR_ASYNC_SAFE, alpm_trans_t::state, STATE_COMMITING, and STATE_INTERRUPTED.
int alpm_trans_prepare | ( | alpm_handle_t * | handle, |
alpm_list_t ** | data ) |
Prepare a transaction.
handle | the context handle |
data | the address of an alpm_list where a list of alpm_depmissing_t objects is dumped (conflicting packages) |
References alpm_trans_t::add, ALPM_ERR_PKG_INVALID_ARCH, ALPM_ERR_TRANS_NOT_INITIALIZED, ALPM_ERR_TRANS_NULL, ALPM_ERR_WRONG_ARGS, alpm_list_free(), ALPM_LOG_DEBUG, ALPM_TRANS_FLAG_NODEPS, ASSERT, check_arch(), CHECK_HANDLE, alpm_trans_t::flags, alpm_trans_t::remove, RET_ERR, alpm_trans_t::state, STATE_INITIALIZED, and STATE_PREPARED.
int alpm_trans_release | ( | alpm_handle_t * | handle | ) |
Release a transaction.
handle | the context handle |
References ALPM_ERR_TRANS_NULL, ALPM_TRANS_FLAG_NOLOCK, ASSERT, CHECK_HANDLE, alpm_trans_t::flags, RET_ERR, alpm_trans_t::state, and STATE_IDLE.