XBPS Library API 20240111
The X Binary Package System
Functions
Package database handling functions

Functions

int xbps_pkgdb_lock (struct xbps_handle *xhp)
 
void xbps_pkgdb_unlock (struct xbps_handle *xhp)
 
int xbps_pkgdb_foreach_cb (struct xbps_handle *xhp, int(*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *), void *arg)
 
int xbps_pkgdb_foreach_cb_multi (struct xbps_handle *xhp, int(*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *), void *arg)
 
xbps_dictionary_t xbps_pkgdb_get_pkg (struct xbps_handle *xhp, const char *pkg)
 
xbps_dictionary_t xbps_pkgdb_get_virtualpkg (struct xbps_handle *xhp, const char *pkg)
 
xbps_dictionary_t xbps_pkgdb_get_pkg_files (struct xbps_handle *xhp, const char *pkg)
 
xbps_array_t xbps_pkgdb_get_pkg_revdeps (struct xbps_handle *xhp, const char *pkg)
 
xbps_array_t xbps_pkgdb_get_pkg_fulldeptree (struct xbps_handle *xhp, const char *pkg)
 
int xbps_pkgdb_update (struct xbps_handle *xhp, bool flush, bool update)
 
int xbps_pkg_exec_buffer (struct xbps_handle *xhp, const void *blob, const size_t blobsiz, const char *pkgver, const char *action, bool update)
 
int xbps_pkg_exec_script (struct xbps_handle *xhp, xbps_dictionary_t d, const char *script, const char *action, bool update)
 

Detailed Description

Functions to manipulate the main package database plist file (pkgdb).

The following image shown below shows the proplib structure used by the main package database plist:

Legend:

Text inside of white boxes are the key associated with the object, its data type is specified on its edge, i.e array, bool, integer, string, dictionary.

Function Documentation

◆ xbps_pkgdb_lock()

int xbps_pkgdb_lock ( struct xbps_handle xhp)

Locks the pkgdb to allow a write transaction.

This routine should be called before a write transaction is the target: install, remove or update.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
Returns
0 on success, otherwise an errno value.

Definition at line 67 of file pkgdb.c.

References xbps_handle::metadir, xbps_handle::pkgdb, xbps_handle::pkgdb_plist, xbps_handle::rootdir, xbps_mkpath(), and xbps_xasprintf().

Here is the call graph for this function:

◆ xbps_pkgdb_unlock()

void xbps_pkgdb_unlock ( struct xbps_handle xhp)

Unlocks the pkgdb after a write transaction.

Parameters
[in]xhpThe pointer to the xbps_handle struct.

◆ xbps_pkgdb_foreach_cb()

int xbps_pkgdb_foreach_cb ( struct xbps_handle xhp,
int(*)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *)  fn,
void *  arg 
)

Executes a function callback per a package dictionary registered in the package database (pkgdb) plist.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]fnFunction callback to run for any pkg dictionary.
[in]argArgument to be passed to the function callback.
Returns
0 on success (all objects were processed), otherwise the value returned by the function callback.

Definition at line 343 of file pkgdb.c.

References xbps_handle::pkgdb, and xbps_array_foreach_cb().

Here is the call graph for this function:

◆ xbps_pkgdb_foreach_cb_multi()

int xbps_pkgdb_foreach_cb_multi ( struct xbps_handle xhp,
int(*)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *)  fn,
void *  arg 
)

Executes a function callback per a package dictionary registered in the package database (pkgdb) plist.

This is a multithreaded implementation spawning a thread per core. Each thread processes a fraction of total objects in the pkgdb dictionary.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]fnFunction callback to run for any pkg dictionary.
[in]argArgument to be passed to the function callback.
Returns
0 on success (all objects were processed), otherwise the value returned by the function callback.

Definition at line 361 of file pkgdb.c.

References xbps_handle::pkgdb, and xbps_array_foreach_cb_multi().

Here is the call graph for this function:

◆ xbps_pkgdb_get_pkg()

xbps_dictionary_t xbps_pkgdb_get_pkg ( struct xbps_handle xhp,
const char *  pkg 
)

Returns a package dictionary from the package database (pkgdb), matching pkgname or pkgver object in pkg.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]pkgPackage name or name-version to match.
Returns
The matching proplib package dictionary, NULL otherwise.

Definition at line 379 of file pkgdb.c.

References xbps_handle::pkgdb.

Referenced by xbps_alternatives_set(), xbps_configure_pkg(), xbps_find_pkg_orphans(), xbps_pkg_is_installed(), xbps_pkg_state_installed(), xbps_pkgdb_get_pkg_files(), xbps_pkgdb_get_pkg_revdeps(), xbps_set_pkg_state_installed(), xbps_transaction_commit(), and xbps_transaction_remove_pkg().

Here is the caller graph for this function:

◆ xbps_pkgdb_get_virtualpkg()

xbps_dictionary_t xbps_pkgdb_get_virtualpkg ( struct xbps_handle xhp,
const char *  pkg 
)

Returns a package dictionary from the package database (pkgdb), matching virtual pkgname or pkgver object in pkg.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]pkgPackage name or name-version to match.
Returns
The matching proplib package dictionary, NULL otherwise.

Definition at line 388 of file pkgdb.c.

References xbps_handle::pkgdb.

Referenced by xbps_pkg_is_installed().

Here is the caller graph for this function:

◆ xbps_pkgdb_get_pkg_files()

xbps_dictionary_t xbps_pkgdb_get_pkg_files ( struct xbps_handle xhp,
const char *  pkg 
)

Returns the package dictionary with all files for pkg.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]pkgPackage expression to match.
Returns
The matching package dictionary, NULL otherwise.

Definition at line 482 of file pkgdb.c.

References xbps_handle::metadir, xbps_pkg_name(), xbps_pkgdb_get_pkg(), and xbps_plist_dictionary_from_file().

Here is the call graph for this function:

◆ xbps_pkgdb_get_pkg_revdeps()

xbps_array_t xbps_pkgdb_get_pkg_revdeps ( struct xbps_handle xhp,
const char *  pkg 
)

Returns a proplib array of strings with reverse dependencies for pkg. The array is generated dynamically based on the list of packages currently installed.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]pkgPackage expression to match.
Returns
A proplib array of strings with reverse dependencies for pkg, NULL otherwise.

Definition at line 458 of file pkgdb.c.

References xbps_pkg_name(), and xbps_pkgdb_get_pkg().

Referenced by xbps_find_pkg_orphans(), xbps_transaction_install_pkg(), and xbps_transaction_update_pkg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xbps_pkgdb_get_pkg_fulldeptree()

xbps_array_t xbps_pkgdb_get_pkg_fulldeptree ( struct xbps_handle xhp,
const char *  pkg 
)

Returns a proplib array of strings with a proper sorted list of packages of a full dependency graph for pkg.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]pkgPackage expression to match.
Returns
A proplib array of strings with the full dependency graph for pkg, NULL otherwise.

Definition at line 476 of file pkgdb.c.

Referenced by xbps_find_pkg_orphans().

Here is the caller graph for this function:

◆ xbps_pkgdb_update()

int xbps_pkgdb_update ( struct xbps_handle xhp,
bool  flush,
bool  update 
)

Updates the package database (pkgdb) with new contents from the cached memory copy to disk.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]flushIf true the pkgdb plist contents in memory will be flushed atomically to storage.
[in]updateIf true, the pkgdb plist stored on disk will be re-read and the in memory copy will be refreshed.
Returns
0 on success, otherwise an errno value.

Definition at line 282 of file pkgdb.c.

References xbps_handle::pkgdb, and xbps_handle::pkgdb_plist.

Referenced by xbps_transaction_commit().

Here is the caller graph for this function:

◆ xbps_pkg_exec_buffer()

int xbps_pkg_exec_buffer ( struct xbps_handle xhp,
const void *  blob,
const size_t  blobsiz,
const char *  pkgver,
const char *  action,
bool  update 
)

Creates a temporary file and executes it in rootdir.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]blobThe buffer pointer where the data is stored.
[in]blobsizThe size of the buffer data.
[in]pkgverThe package name/version associated.
[in]actionThe action to execute on the temporary file.
[in]updateSet to true if package is being updated.
Returns
0 on success, or an errno value otherwise.

Definition at line 39 of file package_script.c.

References xbps_handle::native_arch, xbps_handle::rootdir, xbps_handle::target_arch, xbps_pkg_name(), xbps_pkg_version(), and xbps_xasprintf().

Referenced by xbps_pkg_exec_script().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xbps_pkg_exec_script()

int xbps_pkg_exec_script ( struct xbps_handle xhp,
xbps_dictionary_t  d,
const char *  script,
const char *  action,
bool  update 
)

Creates a temporary file and executes it in rootdir.

Parameters
[in]xhpThe pointer to the xbps_handle struct.
[in]dPackage dictionary where the script data is stored.
[in]scriptKey associated with the script in dictionary.
[in]actionThe action to execute on the temporary file.
[in]updateSet to true if package is being updated.
Returns
0 on success, or an errno value otherwise.

Definition at line 144 of file package_script.c.

References xbps_pkg_exec_buffer().

Referenced by xbps_configure_pkg(), and xbps_transaction_commit().

Here is the call graph for this function:
Here is the caller graph for this function: