libalpm_databases(3)
π libalpm_databases π
okay so bestie, welcome to the libalpm_databases(3) page β this is the Library Functions Manual entry for the Database part of libalpm, and it's literally just β¨ functions to query and manipulate the database of libalpm β¨. Buckle up, it's giving reference material but make it cute.
β¨ NAME β¨
libalpm_databases β Database
- Functions to query and manipulate the database of libalpm. π«Ά
πΈ SYNOPSIS πΈ
π Typedefs π
typedef struct _alpm_db_t alpm_db_tβ a database. yes queen, that's the whole vibe.
π Enumerations π
enum alpm_db_usage_t { 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 }β the usage level of a database. noted, bestie.
π Functions π
alpm_db_t * alpm_get_localdb (alpm_handle_t *handle)β get the database of locally installed packages. your own little stash πalpm_list_t * alpm_get_syncdbs (alpm_handle_t *handle)β get the list of sync databases. the remote girlies β¨alpm_db_t * alpm_register_syncdb (alpm_handle_t *handle, const char *treename, int level)β register a sync database of packages. sign her up πint alpm_unregister_all_syncdbs (alpm_handle_t *handle)β unregister all package databases. bye bye to all of them at once πint alpm_db_unregister (alpm_db_t *db)β unregister a package database. just the one, bestie.alpm_handle_t * alpm_db_get_handle (alpm_db_t *db)β get the handle of a package database. who's her handler πconst char * alpm_db_get_name (const alpm_db_t *db)β get the name of a package database. what's her name π¦int alpm_db_get_siglevel (alpm_db_t *db)β get the signature verification level for a database. trust issues, but make it cryptographic π₯int alpm_db_get_valid (alpm_db_t *db)β check the validity of a database. vibe check fr frint alpm_db_update (alpm_handle_t *handle, alpm_list_t *dbs, int force)β update package databases. refresh queen πalpm_pkg_t * alpm_db_get_pkg (alpm_db_t *db, const char *name)β get a package entry from a package database. pulling one girl out of the crowd β¨alpm_list_t * alpm_db_get_pkgcache (alpm_db_t *db)β get the package cache of a package database. the whole friend group πΈalpm_group_t * alpm_db_get_group (alpm_db_t *db, const char *name)β get a group entry from a package database. squad goals π«Άalpm_list_t * alpm_db_get_groupcache (alpm_db_t *db)β get the group cache of a package database. all the squads πint alpm_db_search (alpm_db_t *db, const alpm_list_t *needles, alpm_list_t **ret)β searches a database with regular expressions. detective mode π
π Server accessors π
alpm_list_t * alpm_db_get_servers (const alpm_db_t *db)β get the list of servers assigned to this db. her contacts π±int alpm_db_set_servers (alpm_db_t *db, alpm_list_t *servers)β sets the list of servers for the database to use. assigning her whole roster πint alpm_db_add_server (alpm_db_t *db, const char *url)β add a download server to a database. plus one to the group chat βint alpm_db_remove_server (alpm_db_t *db, const char *url)β remove a download server from a database. and she's out πalpm_list_t * alpm_db_get_cache_servers (const alpm_db_t *db)β get the list of cache servers assigned to this db. the backup besties πint alpm_db_set_cache_servers (alpm_db_t *db, alpm_list_t *servers)β sets the list of cache servers for the database to use. setting the whole backup roster β¨int alpm_db_add_cache_server (alpm_db_t *db, const char *url)β add a download cache server to a database. plus one, but for cache πint alpm_db_remove_cache_server (alpm_db_t *db, const char *url)β remove a download cache server from a database. removing from the cache roster π
π§ Usage accessors π§
int alpm_db_set_usage (alpm_db_t *db, int usage)β sets the usage of a database. what is she for, bestieint alpm_db_get_usage (alpm_db_t *db, int *usage)β gets the usage of a database. okay so what is she for π
π¦ Detailed Description π¦
Functions to query and manipulate the database of libalpm. periodt. π
π Typedef Documentation π
typedef struct _alpm_db_t alpm_db_t
A database. and like, a database is a container that stores metadata about packages. that's it, that's the girl. π
A database can be located on the local filesystem or on a remote server. both are valid, both are iconic.
To use a database, it must first be registered via alpm_register_syncdb. If the database is already present in dbpath then it will be usable. Otherwise, the database needs to be downloaded using alpm_db_update. And yes bestie β even if the source of the database is the local filesystem. no shortcuts, sorry π
After this, the database can be used to query packages and groups. Any packages or groups from the database will continue to be owned by the database and do not need to be freed by the user. They will be freed when the database is unregistered. so like, do NOT go freeing them yourself, that's her business not yours π
Databases are automatically unregistered when the alpm_handle_t is released. no cleanup needed, she handles herself π
π Enumeration Type Documentation π
enum alpm_db_usage_t
The usage level of a database. literally the "what is she allowed to do" enum β¨
Enumerator
ALPM_DB_USAGE_SYNCβ enable refreshes for this database. she can refresh πΈALPM_DB_USAGE_SEARCHβ enable search for this database. she can be searched πALPM_DB_USAGE_INSTALLβ enable installing packages from this database. she can hand over packages π¦ALPM_DB_USAGE_UPGRADEβ enable sysupgrades with this database. she can do the big upgrade glow-up π₯ALPM_DB_USAGE_ALLβ enable all usage levels. she can do everything, main character energy π
okay that's the whole setup bestie β part 2 is where we actually get into the function docs, so don't go anywhere π
π FUNCTION DOCUMENTATION π
Bestie, buckle UP, because this is the entire function roster and we are going through every single one. No skimming, no "yeah yeah I get it", we're doing this properly. Grab a boba. π§
πΈ alpm_db_add_cache_server πΈ
int alpm_db_add_cache_server (alpm_db_t * db, const char * url)
Slap a download cache server onto a database. That's it, that's the whole job. β¨
Parameters
dbβ database pointerurlβ url of the server
Returns β 0 on success, -1 on error (pm_errno is set accordingly)
πΈ alpm_db_add_server πΈ
int alpm_db_add_server (alpm_db_t * db, const char * url)
Same energy as above but for a regular download server β add one to a database. π
Parameters
dbβ database pointerurlβ url of the server
Returns β 0 on success, -1 on error (pm_errno is set accordingly)
π¦ alpm_db_get_cache_servers π¦
alpm_list_t * alpm_db_get_cache_servers (const alpm_db_t * db)
Gimme the list of cache servers that belong to this db. π
Parameters
dbβ pointer to the database to get the servers from
Returns β a char* list of servers
π¦ alpm_db_get_group π¦
alpm_group_t * alpm_db_get_group (alpm_db_t * db, const char * name)
Pull a group entry out of a package database. Lowkey the best part: looking up a group is O(1) and will be significantly faster than iterating over the groupcahe. So likeβ¦ use this one, bestie, your CPU will thank you. π«Ά
Parameters
dbβ pointer to the package database to get the group fromnameβ of the group
Returns β the groups entry on success, NULL on error
π¦ alpm_db_get_groupcache π¦
alpm_list_t * alpm_db_get_groupcache (alpm_db_t * db)
Get the group cache of a package database. The whole squad, in list form. π
Parameters
dbβ pointer to the package database to get the group from
Returns β the list of groups on success, NULL on error
π alpm_db_get_handle π
alpm_handle_t * alpm_db_get_handle (alpm_db_t * db)
Find out which handle a package database belongs to. It's giving "who's your parent" but make it Unix. β¨
Parameters
dbβ pointer to the package database
Returns β the alpm handle that the package database belongs to
π alpm_db_get_name π
const char * alpm_db_get_name (const alpm_db_t * db)
Get the name of a package database. Name reveal moment. π
Parameters
dbβ pointer to the package database
Returns β the name of the package database, NULL on error
π₯ alpm_db_get_pkg π₯
alpm_pkg_t * alpm_db_get_pkg (alpm_db_t * db, const char * name)
Grab a package entry from a package database. And listen β looking up a package is O(1) and will be significantly faster than iterating over the pkgcahe. Do not walk the whole list, I am begging you. π
Parameters
dbβ pointer to the package database to get the package fromnameβ of the package
Returns β the package entry on success, NULL on error
π₯ alpm_db_get_pkgcache π₯
alpm_list_t * alpm_db_get_pkgcache (alpm_db_t * db)
Get the package cache of a package database. This is a list of all packages the db contains. The full roster. Periodt. π
Parameters
dbβ pointer to the package database to get the package from
Returns β the list of packages on success, NULL on error
π alpm_db_get_servers π
alpm_list_t * alpm_db_get_servers (const alpm_db_t * db)
The list of servers assigned to this db. Show me the servers, bestie. π
Parameters
dbβ pointer to the database to get the servers from
Returns β a char* list of servers
π alpm_db_get_siglevel π
int alpm_db_get_siglevel (alpm_db_t * db)
Get the signature verification level for a database. And here's the cute bit: if this database is set up with ALPM_SIG_USE_DEFAULT, it'll return the default verification level instead. iykyk. β¨
Parameters
dbβ pointer to the package database
Returns β the signature verification level
π alpm_db_get_usage π
int alpm_db_get_usage (alpm_db_t * db, int * usage)
Gets the usage of a database. Vibe check, but for dbs. π
Parameters
dbβ pointer to the package database to get the status ofusageβ pointer to analpm_db_usage_tto store db's status
Returns β 0 on success, or -1 on error
π alpm_db_get_valid π
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 it turns out 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)
π alpm_db_remove_cache_server π
int alpm_db_remove_cache_server (alpm_db_t * db, const char * url)
Yeet a download cache server off a database. π«₯
Parameters
dbβ database pointerurlβ url of the server
Returns β 0 on success, 1 on server not present, -1 on error (pm_errno is set accordingly)
Note that cute little 1 β that's not an error, bestie, that just means the server wasn't even there. Don't panic.
π alpm_db_remove_server π
int alpm_db_remove_server (alpm_db_t * db, const char * url)
Same deal, but for a regular download server: remove it from a database. π
Parameters
dbβ database pointerurlβ url of the server
Returns β 0 on success, 1 on server not present, -1 on error (pm_errno is set accordingly)
π§ alpm_db_search π§
int alpm_db_search (alpm_db_t * db, const alpm_list_t * needles, alpm_list_t ** ret)
Searches a database with regular expressions. Yes, regex. Yes, it goes hard. β¨
Parameters
dbβ pointer to the package database to search inneedlesβ a list of regular expressions to search forretβ pointer to list for storing packages matching all regular expressions β must point to an empty (NULL)alpm_list_t *.
Bestie, read that again:retmust point to an empty (NULL)alpm_list_t *. Not "a list you already filled", not "whatever you had lying around". Empty.NULL. Periodt. π€
Returns β 0 on success, -1 on error (pm_errno is set accordingly)
π alpm_db_set_cache_servers π
int alpm_db_set_cache_servers (alpm_db_t * db, alpm_list_t * servers)
Sets the list of cache servers for the database to use. π₯
Parameters
dbβ the database to set the servers. The list will be duped and the original will still need to be freed by the caller.serversβ achar*list of servers.
The dupe thing matters, okay? libalpm makes its own copy, but you still own the original and you still have to free it. No leaks in this household. π«Ά
π alpm_db_set_servers π
int alpm_db_set_servers (alpm_db_t * db, alpm_list_t * servers)
Sets the list of servers for the database to use. Same rules, same dupe situation. π
Parameters
dbβ the database to set the servers. The list will be duped and the original will still need to be freed by the caller.serversβ achar*list of servers.
β alpm_db_set_usage β
int alpm_db_set_usage (alpm_db_t * db, int usage)
Sets the usage of a database. Main character energy: you decide what this db is for. π
Parameters
dbβ pointer to the package database to set the status forusageβ a bitmask ofalpm_db_usage_tvalues
Returns β 0 on success, or -1 on error
π¨ alpm_db_unregister π¨
int alpm_db_unregister (alpm_db_t * db)
Unregister a package database. But hear me out β Databases can not be unregistered when there is an active transaction. That's a hard no, not a "try it and see". β οΈ
Parameters
dbβ pointer to the package database to unregister
Returns β 0 on success, -1 on error (pm_errno is set accordingly)
π alpm_db_update π
int alpm_db_update (alpm_handle_t * handle, alpm_list_t * dbs, int force)
Update package databases. An update of the package databases in the list dbs will be attempted. Unless force is true, the update will only be performed if the remote databases were modified since the last update. So force is the "I said what I said" switch. π
This operation requires a database lock, and will return an applicable error if the lock could not be obtained. (Translation: someone else is holding it, go wait your turn.) π
Example:
alpm_list_t *dbs = alpm_get_syncdbs(config->handle);
ret = alpm_db_update(config->handle, dbs, force);
if(ret < 0) {
pm_printf(ALPM_LOG_ERROR, _("failed to synchronize all databases (%s)\n"),
alpm_strerror(alpm_errno(config->handle)));
}
Note β After a successful update, the package cache will be invalidated. So don't be out here holding onto stale pointers like they're still valid, bestie. π
Parameters
handleβ the context handledbsβ list of package databases to updateforceβ if true, then forces the update, otherwise update only in case the databases aren't up to date
Returns β 0 on success, -1 on error (pm_errno is set accordingly), 1 if all databases are up to to date
π alpm_get_localdb π
alpm_db_t * alpm_get_localdb (alpm_handle_t * handle)
Get the database of locally installed packages β your actual machine, your actual stuff. π«Ά
The returned pointer points to an internal structure of libalpm which should only be manipulated through libalpm functions. Do not free it. Do not poke it. Do not "just take a peek". Use the API. π
Returns β a reference to the local database
π alpm_get_syncdbs π
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. All the repos, lined up. β
Parameters
handleβ the context handle
Returns β a reference to an internal list of alpm_db_t structures
β¨ alpm_register_syncdb β¨
alpm_db_t * alpm_register_syncdb (alpm_handle_t * handle, const char * treename, int level)
Register a sync database of packages. But heads up β Databases can not be registered when there is an active transaction. Same rule as unregistering, no exceptions. π¨
Parameters
handleβ the context handletreenameβ the name of the sync repositorylevelβ 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
π₯ alpm_unregister_all_syncdbs π₯
int alpm_unregister_all_syncdbs (alpm_handle_t * handle)
Unregister all package databases. Every last one. And once again for the people in the back: Databases can not be unregistered while there is an active transaction. π€
Parameters
handleβ the context handle
Returns β 0 on success, -1 on error (pm_errno is set accordingly)
βοΈ AUTHOR βοΈ
Generated automatically by Doxygen for libalpm from the source code. (Not a human author, just a robot doing its little documentation dance. π€β¨)
And that's the whole page, bestie β this was libalpm_databases(3), brought to you by libalpm, dated by Doxygen and stamped with the manual page name libalpm_databases(3) down at the bottom like a little signature. You made it to the end, I'm so proud of you. Go touch some grass, then come back and read it again. πππ¦
π¦ where this page comes from
- arch rolling: pacman 7.1.0.r9.g54d9411-2
- epel 10: libalpm-devel 7.0.0-5.el10_2 Β· GPL-2.0-or-later
- fedora 43: libalpm-devel 7.0.0-5.fc43 Β· GPL-2.0-or-later
- fedora 43: libalpm-devel 7.0.0-5.fc43 Β· GPL-2.0-or-later
- fedora 44: libalpm-devel 7.0.0-6.fc44 Β· GPL-2.0-or-later
- fedora 44: libalpm-devel 7.0.0-6.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms