alpm_api_databases(3)

NAME
alpm_api_databases - Database Functions

Functions to query and manipulate the database of libalpm.

  Typedefs
typedef enum _alpm_db_usage_ alpm_db_usage_t

  Enumerations
enum _alpm_db_usage_ { ALPM_DB_USAGE_SYNC = 1, ALPM_DB_USAGE_SEARCH = (1 << 1), ALPM_DB_USAGE_INSTALL = (1 << 2), ALPM_DB_USAGE_UPGRADE = (1 << 3), ALPM_DB_USAGE_ALL = (1 << 4) - 1 }

  Functions
alpm_db_t * alpm_get_localdb (alpm_handle_t *handle)
Get the database of locally installed packages.
alpm_list_t * alpm_get_syncdbs (alpm_handle_t *handle)
Get the list of sync databases.
alpm_db_t * alpm_register_syncdb (alpm_handle_t *handle, const char *treename, alpm_siglevel_t level)
Register a sync database of packages.
int alpm_unregister_all_syncdbs (alpm_handle_t *handle)
Unregister all package databases.
int alpm_db_unregister (alpm_db_t *db)
Unregister a package database.
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 force, 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_get_group (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_usage (alpm_db_t *db, alpm_db_usage_t usage)
Sets the usage of a database.
int alpm_db_get_usage (alpm_db_t *db, alpm_db_usage_t *usage)
Gets the usage of a database.

  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.

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:
    db database pointer
    url url of the server

Returns:
    0 on success, -1 on error (pm_errno is set accordingly)

References alpm_list_add().

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

Get a group entry from a package database.

Parameters:
    db pointer to the package database to get the group from
    name of the group

Returns:
    the groups entry on success, NULL on error

Referenced by alpm_find_group_pkgs().

  alpm_list_t* alpm_db_get_groupcache (alpm_db_t * db)

Get the group cache of a package database.

Parameters:
    db pointer to the package database to get the group from

Returns:
    the list of groups on success, NULL on error

  const char* alpm_db_get_name (const alpm_db_t * db)

Get the name of a package database.

Parameters:
    db pointer to the package database

Returns:
    the name of the package database, NULL on error

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

Get a package entry from a package database.

Parameters:
    db pointer to the package database to get the package from
    name of the package

Returns:
    the package entry on success, NULL on error

Referenced by alpm_find_group_pkgs().

  alpm_list_t* alpm_db_get_pkgcache (alpm_db_t * db)

Get the package cache of a package database.

Parameters:
    db pointer to the package database to get the package from

Returns:
    the list of packages on success, NULL on error

Referenced by alpm_checkconflicts(), and alpm_dep_free().

  alpm_list_t* alpm_db_get_servers (const alpm_db_t * db)

Get the serverlist of a database.

  alpm_siglevel_t alpm_db_get_siglevel (alpm_db_t * db)

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:
    db pointer to the package database

Returns:
    the signature verification level

Referenced by alpm_db_update(), and alpm_pkg_download_size().

  int alpm_db_get_usage (alpm_db_t * db, alpm_db_usage_t * usage)

Gets the usage of a database.

Parameters:
    db pointer to the package database to get the status of
    usage pointer to an alpm_db_usage_t to store db's status

Returns:
    0 on success, or -1 on error

Gets the usage of a database.

References alpm_list_add(), alpm_list_copy(), alpm_list_find_ptr(), alpm_list_free(), alpm_list_free_inner(), alpm_pkg_get_desc(), alpm_pkg_get_groups(), alpm_pkg_get_provides(), __alpm_list_t::data, __alpm_pkghash_t::list, _alpm_group_t::name, __alpm_list_t::next, and _alpm_group_t::packages.

  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.

Parameters:
    db pointer to the package database

Returns:
    0 if valid, -1 if invalid (pm_errno is set accordingly)

  int alpm_db_remove_server (alpm_db_t * db, const char * url)

Remove a download server from a database.

Parameters:
    db database pointer
    url url of the server

Returns:
    0 on success, 1 on server not present, -1 on error (pm_errno is set accordingly)

References alpm_list_remove_str().

  alpm_list_t* alpm_db_search (alpm_db_t * db, const alpm_list_t * needles)

Searches a database with regular expressions.

Parameters:
    db pointer to the package database to search in
    needles a list of regular expressions to search for

Returns:
    the list of packages matching all regular expressions on success, NULL on error

Searches a database with regular expressions.

  int alpm_db_set_servers (alpm_db_t * db, alpm_list_t * servers)

Set the serverlist of a database.

  int alpm_db_set_usage (alpm_db_t * db, alpm_db_usage_t usage)

Sets the usage of a database.

Parameters:
    db pointer to the package database to set the status for
    usage a bitmask of alpm_db_usage_t values

Returns:
    0 on success, or -1 on error

Sets the usage of a database.

  int alpm_db_unregister (alpm_db_t * db)

Unregister a package database.

Parameters:
    db pointer to the package database to unregister

Returns:
    0 on success, -1 on error (pm_errno is set accordingly)

References alpm_list_remove().

  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:

1 alpm_list_t *syncs = alpm_get_syncdbs();
2 for(i = syncs; i; i = alpm_list_next(i)) {
3     alpm_db_t *db = alpm_list_getdata(i);
4     result = alpm_db_update(0, db);
5
6     if(result < 0) {
7         printf("Unable to update database: %s, alpm_strerrorlast());
8     } else if(result == 1) {
9         printf("Database already up to date);
10     } else {
11         printf("Database updated);
12     }
13 }

Note:
    After a successful update, the package cache will be invalidated

Parameters:
    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

Returns:
    0 on success, -1 on error (pm_errno is set accordingly), 1 if up to to date

References alpm_db_get_siglevel(), alpm_list_add(), alpm_list_count(), alpm_list_msort(), alpm_strerror(), __alpm_list_t::data, default_pkg_ops, __alpm_pkghash_t::list, and __alpm_list_t::next.

  alpm_db_t* alpm_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.

Returns:
    a reference to the local database

  alpm_list_t* alpm_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.

Parameters:
    handle the context handle

Returns:
    a reference to an internal list of alpm_db_t structures

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

Register a sync database of packages.

Parameters:
    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

Returns:
    an alpm_db_t* on success (the value), NULL on error

References __alpm_list_t::data, and __alpm_list_t::next.

  int alpm_unregister_all_syncdbs (alpm_handle_t * handle)

Unregister all package databases.

Parameters:
    handle the context handle

Returns:
    0 on success, -1 on error (pm_errno is set accordingly)

References __alpm_list_t::data, and __alpm_list_t::next.

Referenced by alpm_release().

Author

Generated automatically by Doxygen for libalpm from the source code.