libalpm
Arch Linux Package Manager Library
|
Functions to query and manipulate the database of libalpm. More...
Functions | |
alpm_db_t * | alpm_option_get_localdb (alpm_handle_t *handle) |
Get the database of locally installed packages. | |
alpm_list_t * | alpm_option_get_syncdbs (alpm_handle_t *handle) |
Get the list of sync databases. | |
alpm_db_t * | alpm_db_register_sync (alpm_handle_t *handle, const char *treename, alpm_siglevel_t level) |
Register a sync database of packages. | |
int | alpm_db_unregister (alpm_db_t *db) |
Unregister a package database. | |
int | alpm_db_unregister_all (alpm_handle_t *handle) |
Unregister all package databases. | |
const char * | alpm_db_get_name (const alpm_db_t *db) |
Get the name of a package database. | |
alpm_siglevel_t | alpm_db_get_siglevel (alpm_db_t *db) |
Get the signature verification level for a database. | |
int | alpm_db_get_valid (alpm_db_t *db) |
Check the validity of a database. | |
int | alpm_db_update (int level, alpm_db_t *db) |
Update a package database. | |
alpm_pkg_t * | alpm_db_get_pkg (alpm_db_t *db, const char *name) |
Get a package entry from a package database. | |
alpm_list_t * | alpm_db_get_pkgcache (alpm_db_t *db) |
Get the package cache of a package database. | |
alpm_group_t * | alpm_db_readgroup (alpm_db_t *db, const char *name) |
Get a group entry from a package database. | |
alpm_list_t * | alpm_db_get_groupcache (alpm_db_t *db) |
Get the group cache of a package database. | |
alpm_list_t * | alpm_db_search (alpm_db_t *db, const alpm_list_t *needles) |
Searches a database with regular expressions. | |
int | alpm_db_set_pkgreason (alpm_handle_t *handle, alpm_pkg_t *pkg, alpm_pkgreason_t reason) |
Set install reason for a package in db. | |
Accessors to the list of servers for a database. | |
alpm_list_t * | alpm_db_get_servers (const alpm_db_t *db) |
Get the serverlist of a database. | |
int | alpm_db_set_servers (alpm_db_t *db, alpm_list_t *servers) |
Set the serverlist of a database. | |
int | alpm_db_add_server (alpm_db_t *db, const char *url) |
Add a download server to a database. | |
int | alpm_db_remove_server (alpm_db_t *db, const char *url) |
Remove a download server from a database. |
Functions to query and manipulate the database of libalpm.
int alpm_db_add_server | ( | alpm_db_t * | db, |
const char * | url | ||
) |
Add a download server to a database.
db | database pointer |
url | url of the server |
Definition at line 162 of file db.c.
References _alpm_log(), ALPM_ERR_WRONG_ARGS, alpm_list_add(), ALPM_LOG_DEBUG, ASSERT, __alpm_db_t::handle, __alpm_handle_t::pm_errno, RET_ERR, __alpm_db_t::servers, and __alpm_db_t::treename.
alpm_list_t* alpm_db_get_groupcache | ( | alpm_db_t * | db | ) |
Get the group cache of a package database.
db | pointer to the package database to get the group from |
Definition at line 275 of file db.c.
References _alpm_db_get_groupcache(), ASSERT, __alpm_db_t::handle, and __alpm_handle_t::pm_errno.
const char* alpm_db_get_name | ( | const alpm_db_t * | db | ) |
Get the name of a package database.
db | pointer to the package database |
Definition at line 214 of file db.c.
References ASSERT, and __alpm_db_t::treename.
Referenced by check_syncdbs(), dump_pkg_full(), print_packages(), and select_display().
alpm_pkg_t* alpm_db_get_pkg | ( | alpm_db_t * | db, |
const char * | name | ||
) |
Get a package entry from a package database.
db | pointer to the package database to get the package from |
name | of the package |
Definition at line 240 of file db.c.
References _alpm_db_get_pkgfromcache(), ALPM_ERR_PKG_NOT_FOUND, ALPM_ERR_WRONG_ARGS, ASSERT, __alpm_db_t::handle, __alpm_handle_t::pm_errno, and RET_ERR.
Referenced by display_targets(), pacman_database(), and pacman_query().
alpm_list_t* alpm_db_get_pkgcache | ( | alpm_db_t * | db | ) |
Get the package cache of a package database.
db | pointer to the package database to get the package from |
Definition at line 256 of file db.c.
References _alpm_db_get_pkgcache(), ASSERT, __alpm_db_t::handle, and __alpm_handle_t::pm_errno.
Referenced by pacman_deptest(), and pacman_query().
alpm_list_t* alpm_db_get_servers | ( | const alpm_db_t * | db | ) |
Get the serverlist of a database.
Definition at line 129 of file db.c.
References ASSERT, and __alpm_db_t::servers.
Get the signature verification level for a database.
Will return the default verification level if this database is set up with ALPM_SIG_USE_DEFAULT.
db | pointer to the package database |
Definition at line 221 of file db.c.
References ALPM_SIG_USE_DEFAULT, ASSERT, __alpm_db_t::handle, __alpm_db_t::siglevel, and __alpm_handle_t::siglevel.
Referenced by alpm_db_update().
int alpm_db_get_valid | ( | alpm_db_t * | db | ) |
Check the validity of a database.
This is most useful for sync databases and verifying signature status. If invalid, the handle error code will be set accordingly.
db | pointer to the package database |
Definition at line 232 of file db.c.
References ASSERT, __alpm_db_t::handle, __alpm_db_t::ops, __alpm_handle_t::pm_errno, and db_operations::validate.
Referenced by check_syncdbs().
alpm_group_t* alpm_db_readgroup | ( | alpm_db_t * | db, |
const char * | name | ||
) |
Get a group entry from a package database.
db | pointer to the package database to get the group from |
name | of the group |
Definition at line 264 of file db.c.
References _alpm_db_get_groupfromcache(), ALPM_ERR_WRONG_ARGS, ASSERT, __alpm_db_t::handle, __alpm_handle_t::pm_errno, and RET_ERR.
Referenced by alpm_find_group_pkgs().
alpm_db_t* alpm_db_register_sync | ( | alpm_handle_t * | handle, |
const char * | treename, | ||
alpm_siglevel_t | level | ||
) |
Register a sync database of packages.
handle | the context handle |
treename | the name of the sync repository |
level | what level of signature checking to perform on the database; note that this must be a '.sig' file type verification |
Definition at line 46 of file db.c.
References _alpm_db_register_sync(), ALPM_ERR_TRANS_NOT_NULL, ALPM_ERR_WRONG_ARGS, ASSERT, CHECK_HANDLE, RET_ERR, and __alpm_handle_t::trans.
int alpm_db_remove_server | ( | alpm_db_t * | db, |
const char * | url | ||
) |
Remove a download server from a database.
db | database pointer |
url | url of the server |
Definition at line 188 of file db.c.
References _alpm_log(), ALPM_ERR_WRONG_ARGS, alpm_list_remove_str(), ALPM_LOG_DEBUG, ASSERT, __alpm_db_t::handle, __alpm_handle_t::pm_errno, RET_ERR, __alpm_db_t::servers, and __alpm_db_t::treename.
alpm_list_t* alpm_db_search | ( | alpm_db_t * | db, |
const alpm_list_t * | needles | ||
) |
Searches a database with regular expressions.
db | pointer to the package database to search in |
needles | a list of regular expressions to search for |
Definition at line 284 of file db.c.
References _alpm_db_search(), ASSERT, __alpm_db_t::handle, and __alpm_handle_t::pm_errno.
int alpm_db_set_pkgreason | ( | alpm_handle_t * | handle, |
alpm_pkg_t * | pkg, | ||
alpm_pkgreason_t | reason | ||
) |
Set install reason for a package in db.
handle | the context handle |
pkg | the package to update |
reason | the new install reason |
Definition at line 293 of file db.c.
References _alpm_local_db_write(), _alpm_log(), ALPM_ERR_DB_WRITE, ALPM_ERR_WRONG_ARGS, ALPM_LOG_DEBUG, alpm_pkg_get_reason(), ASSERT, CHECK_HANDLE, __alpm_pkg_t::db, __alpm_handle_t::db_local, INFRQ_DESC, __alpm_pkg_t::name, __alpm_pkg_t::origin, __alpm_pkg_t::origin_data, PKG_FROM_LOCALDB, __alpm_pkg_t::reason, and RET_ERR.
Referenced by pacman_database().
int alpm_db_set_servers | ( | alpm_db_t * | db, |
alpm_list_t * | servers | ||
) |
Set the serverlist of a database.
Definition at line 136 of file db.c.
References ASSERT, FREELIST, and __alpm_db_t::servers.
int alpm_db_unregister | ( | alpm_db_t * | db | ) |
Unregister a package database.
db | pointer to the package database to unregister |
Definition at line 92 of file db.c.
References _alpm_db_cmp(), ALPM_ERR_DB_NOT_FOUND, ALPM_ERR_TRANS_NOT_NULL, alpm_list_remove(), ASSERT, __alpm_handle_t::db_local, __alpm_handle_t::dbs_sync, handle, __alpm_db_t::handle, __alpm_db_t::ops, __alpm_handle_t::pm_errno, RET_ERR, __alpm_handle_t::trans, and db_operations::unregister.
int alpm_db_unregister_all | ( | alpm_handle_t * | handle | ) |
Unregister all package databases.
handle | the context handle |
Definition at line 71 of file db.c.
References ALPM_ERR_TRANS_NOT_NULL, ASSERT, CHECK_HANDLE, __alpm_list_t::data, __alpm_handle_t::dbs_sync, FREELIST, __alpm_list_t::next, __alpm_db_t::ops, RET_ERR, __alpm_handle_t::trans, and db_operations::unregister.
Referenced by alpm_release().
int alpm_db_update | ( | int | force, |
alpm_db_t * | db | ||
) |
Update a package database.
An update of the package database db will be attempted. Unless force is true, the update will only be performed if the remote database was modified since the last update.
This operation requires a database lock, and will return an applicable error if the lock could not be obtained.
Example:
alpm_list_t *syncs = alpm_option_get_syncdbs(); for(i = syncs; i; i = alpm_list_next(i)) { alpm_db_t *db = alpm_list_getdata(i); result = alpm_db_update(0, db); if(result < 0) { printf("Unable to update database: %s\n", alpm_strerrorlast()); } else if(result == 1) { printf("Database already up to date\n"); } else { printf("Database updated\n"); } }
force | if true, then forces the update, otherwise update only in case the database isn't up to date |
db | pointer to the package database to update |
Definition at line 169 of file be_sync.c.
References _, _alpm_db_free_pkgcache(), _alpm_db_path(), _alpm_dload_payload_reset(), _alpm_download(), _alpm_handle_lock(), _alpm_handle_unlock(), _alpm_log(), _alpm_sigpath(), alpm_db_get_siglevel(), ALPM_ERR_HANDLE_LOCK, ALPM_ERR_MEMORY, ALPM_ERR_SERVER_NONE, ALPM_ERR_WRONG_ARGS, ALPM_LOG_DEBUG, ALPM_LOG_WARNING, ALPM_SIG_DATABASE_OPTIONAL, alpm_strerror(), ASSERT, __alpm_list_t::data, __alpm_handle_t::db_local, DB_STATUS_EXISTS, DB_STATUS_INVALID, DB_STATUS_MISSING, DB_STATUS_VALID, dload_payload::errors_ok, dload_payload::fileurl, dload_payload::force, dload_payload::handle, handle, __alpm_db_t::handle, __alpm_handle_t::lockfile, MALLOC, dload_payload::max_size, __alpm_list_t::next, __alpm_handle_t::pm_errno, RET_ERR, __alpm_db_t::servers, __alpm_db_t::status, __alpm_db_t::treename, and dload_payload::unlink_on_fail.
alpm_db_t* alpm_option_get_localdb | ( | alpm_handle_t * | handle | ) |
Get the database of locally installed packages.
The returned pointer points to an internal structure of libalpm which should only be manipulated through libalpm functions.
Definition at line 267 of file handle.c.
References CHECK_HANDLE, and __alpm_handle_t::db_local.
Referenced by display_targets(), main(), pacman_database(), pacman_deptest(), and pacman_query().
alpm_list_t* alpm_option_get_syncdbs | ( | alpm_handle_t * | handle | ) |
Get the list of sync databases.
Returns a list of alpm_db_t structures, one for each registered sync database.
handle | the context handle |
Definition at line 273 of file handle.c.
References CHECK_HANDLE, and __alpm_handle_t::dbs_sync.
Referenced by check_syncdbs(), main(), and pacman_sync().