libalpm
Arch Linux Package Manager Library
Functions
Database Functions
Public API

Functions to query and manipulate the database of libalpm. More...

Collaboration diagram for Database Functions:

Functions

alpm_db_talpm_option_get_localdb (alpm_handle_t *handle)
 Get the database of locally installed packages.
alpm_list_talpm_option_get_syncdbs (alpm_handle_t *handle)
 Get the list of sync databases.
alpm_db_talpm_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_talpm_db_get_pkg (alpm_db_t *db, const char *name)
 Get a package entry from a package database.
alpm_list_talpm_db_get_pkgcache (alpm_db_t *db)
 Get the package cache of a package database.
alpm_group_talpm_db_readgroup (alpm_db_t *db, const char *name)
 Get a group entry from a package database.
alpm_list_talpm_db_get_groupcache (alpm_db_t *db)
 Get the group cache of a package database.
alpm_list_talpm_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_talpm_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.

Detailed Description

Functions to query and manipulate the database of libalpm.


Function Documentation

int alpm_db_add_server ( alpm_db_t db,
const char *  url 
)

Add a download server to a database.

Parameters:
dbdatabase pointer
urlurl of the server
Returns:
0 on success, -1 on error (pm_errno is set accordingly)

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.

Here is the call graph for this function:

Get the group cache of a package database.

Parameters:
dbpointer to the package database to get the group from
Returns:
the list of groups on success, NULL on error

Definition at line 275 of file db.c.

References _alpm_db_get_groupcache(), ASSERT, __alpm_db_t::handle, and __alpm_handle_t::pm_errno.

Here is the call graph for this function:

const char* alpm_db_get_name ( const alpm_db_t db)

Get the name of a package database.

Parameters:
dbpointer to the package database
Returns:
the name of the package database, NULL on error

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().

Here is the caller graph for this function:

alpm_pkg_t* alpm_db_get_pkg ( alpm_db_t db,
const char *  name 
)

Get a package entry from a package database.

Parameters:
dbpointer to the package database to get the package from
nameof the package
Returns:
the package entry on success, NULL on error

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().

Here is the call graph for this function:

Here is the caller graph for this function:

Get the package cache of a package database.

Parameters:
dbpointer to the package database to get the package from
Returns:
the list of packages on success, NULL on error

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
dbpointer to the package database
Returns:
the signature verification level

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().

Here is the caller graph for this function:

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.

Parameters:
dbpointer to the package database
Returns:
0 if valid, -1 if invalid (pm_errno is set accordingly)

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().

Here is the caller graph for this function:

alpm_group_t* alpm_db_readgroup ( alpm_db_t db,
const char *  name 
)

Get a group entry from a package database.

Parameters:
dbpointer to the package database to get the group from
nameof the group
Returns:
the groups entry on success, NULL on error

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().

Here is the call graph for this function:

Here is the caller graph for this function:

alpm_db_t* alpm_db_register_sync ( alpm_handle_t handle,
const char *  treename,
alpm_siglevel_t  level 
)

Register a sync database of packages.

Parameters:
handlethe context handle
treenamethe name of the sync repository
levelwhat level of signature checking to perform on the database; note that this must be a '.sig' file type verification
Returns:
an alpm_db_t* on success (the value), NULL on error

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.

Here is the call graph for this function:

int alpm_db_remove_server ( alpm_db_t db,
const char *  url 
)

Remove a download server from a database.

Parameters:
dbdatabase pointer
urlurl of the server
Returns:
0 on success, 1 on server not present, -1 on error (pm_errno is set accordingly)

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.

Here is the call graph for this function:

alpm_list_t* alpm_db_search ( alpm_db_t db,
const alpm_list_t needles 
)

Searches a database with regular expressions.

Parameters:
dbpointer to the package database to search in
needlesa list of regular expressions to search for
Returns:
the list of packages matching all regular expressions on success, NULL on error

Definition at line 284 of file db.c.

References _alpm_db_search(), ASSERT, __alpm_db_t::handle, and __alpm_handle_t::pm_errno.

Here is the call graph for this function:

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.

Parameters:
handlethe context handle
pkgthe package to update
reasonthe new install reason
Returns:
0 on success, -1 on error (pm_errno is set accordingly)

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Unregister a package database.

Parameters:
dbpointer to the package database to unregister
Returns:
0 on success, -1 on error (pm_errno is set accordingly)

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.

Here is the call graph for this function:

Unregister all package databases.

Parameters:
handlethe context handle
Returns:
0 on success, -1 on error (pm_errno is set accordingly)

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().

Here is the caller graph for this function:

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");
     }
 }
Note:
After a successful update, the package cache will be invalidated
Parameters:
forceif true, then forces the update, otherwise update only in case the database isn't up to date
dbpointer to the package database to update
Returns:
0 on success, -1 on error (pm_errno is set accordingly), 1 if up to to date

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.

Here is the call graph for this function:

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.

Returns:
a reference to the local database

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().

Here is the caller graph for this function:

Get the list of sync databases.

Returns a list of alpm_db_t structures, one for each registered sync database.

Parameters:
handlethe context handle
Returns:
a reference to an internal list of alpm_db_t structures

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().

Here is the caller graph for this function: