XBPS Library API 20240111
The X Binary Package System
Data Structures | Enumerations | Functions
Initialization and finalization functions

Data Structures

struct  xbps_state_cb_data
 Structure to be passed as argument to the state function callback. All members are read-only and set internally by libxbps. More...
 
struct  xbps_fetch_cb_data
 Structure to be passed to the fetch function callback. More...
 
struct  xbps_unpack_cb_data
 Structure to be passed to the unpack function callback. More...
 
struct  xbps_handle
 Generic XBPS structure handler for initialization. More...
 

Enumerations

enum  xbps_state_t
 

Functions

void void void void int xbps_init (struct xbps_handle *xhp)
 
void xbps_end (struct xbps_handle *xhp)
 

Detailed Description

Use these functions to initialize some parameters before start using libxbps and finalize usage to release resources at the end.


Data Structure Documentation

◆ xbps_state_cb_data

struct xbps_state_cb_data

Definition at line 389 of file xbps.h.

Collaboration diagram for xbps_state_cb_data:

Data Fields

struct xbps_handlexhp
 
const char * desc
 
const char * arg
 
int err
 
xbps_state_t state
 

Field Documentation

◆ xhp

xhp

Pointer to our struct xbps_handle passed to xbps_init().

Definition at line 395 of file xbps.h.

◆ desc

desc

Current state string description.

Definition at line 401 of file xbps.h.

◆ arg

arg

State string argument. String set on this variable may change depending on state.

Definition at line 408 of file xbps.h.

◆ err

err

Current state error value (set internally, read-only).

Definition at line 414 of file xbps.h.

◆ state

state

Current state.

Definition at line 420 of file xbps.h.

◆ xbps_fetch_cb_data

struct xbps_fetch_cb_data

This structure is passed as argument to the fetch progress function callback and its members will be updated when there's any progress. All members marked as read-only in this struct are set internally by xbps_unpack_binary_pkg() and shouldn't be modified in the passed function callback.

Definition at line 433 of file xbps.h.

Collaboration diagram for xbps_fetch_cb_data:

Data Fields

struct xbps_handlexhp
 
off_t file_size
 
off_t file_offset
 
off_t file_dloaded
 
const char * file_name
 
bool cb_start
 
bool cb_update
 
bool cb_end
 

Field Documentation

◆ xhp

xhp

Pointer to our struct xbps_handle passed to xbps_init().

Definition at line 439 of file xbps.h.

◆ file_size

file_size

Filename size for the file to be fetched.

Definition at line 445 of file xbps.h.

◆ file_offset

file_offset

Current offset for the filename being fetched.

Definition at line 451 of file xbps.h.

◆ file_dloaded

file_dloaded

Bytes downloaded for the file being fetched.

Definition at line 457 of file xbps.h.

◆ file_name

file_name

File name being fetched.

Definition at line 463 of file xbps.h.

◆ cb_start

cb_start

If true the function callback should be prepared to start the transfer progress.

Definition at line 470 of file xbps.h.

◆ cb_update

cb_update

If true the function callback should be prepared to update the transfer progress.

Definition at line 477 of file xbps.h.

◆ cb_end

cb_end

If true the function callback should be prepated to end the transfer progress.

Definition at line 484 of file xbps.h.

◆ xbps_unpack_cb_data

struct xbps_unpack_cb_data

This structure is passed as argument to the unpack progress function callback and its members will be updated when there's any progress. All members in this struct are set internally by libxbps and should be used in read-only mode in the supplied function callback.

Definition at line 497 of file xbps.h.

Collaboration diagram for xbps_unpack_cb_data:

Data Fields

struct xbps_handlexhp
 
const char * pkgver
 
const char * entry
 
int64_t entry_size
 
ssize_t entry_extract_count
 
ssize_t entry_total_count
 
bool entry_is_conf
 

Field Documentation

◆ xhp

xhp

Pointer to our struct xbps_handle passed to xbps_init().

Definition at line 503 of file xbps.h.

◆ pkgver

pkgver

Package name/version string of package being unpacked.

Definition at line 509 of file xbps.h.

◆ entry

entry

Entry pathname string.

Definition at line 515 of file xbps.h.

◆ entry_size

entry_size

Entry file size.

Definition at line 521 of file xbps.h.

◆ entry_extract_count

entry_extract_count

Total number of extracted entries.

Definition at line 527 of file xbps.h.

◆ entry_total_count

entry_total_count

Total number of entries in package.

Definition at line 533 of file xbps.h.

◆ entry_is_conf

entry_is_conf

If true "entry" is a configuration file.

Definition at line 539 of file xbps.h.

◆ xbps_handle

struct xbps_handle

This structure sets some global properties for libxbps, to set some function callbacks and data to the fetch, transaction and unpack functions, the root and cache directory, flags, etc.

Definition at line 550 of file xbps.h.

Collaboration diagram for xbps_handle:

Data Fields

xbps_array_t repositories
 
xbps_dictionary_t pkgdb
 
xbps_dictionary_t transd
 
int(* state_cb )(const struct xbps_state_cb_data *, void *)
 
void * state_cb_data
 
void(* unpack_cb )(const struct xbps_unpack_cb_data *, void *)
 
void * unpack_cb_data
 
void(* fetch_cb )(const struct xbps_fetch_cb_data *, void *)
 
void * fetch_cb_data
 
char * pkgdb_plist
 
const char * target_arch
 
char confdir [XBPS_MAXPATH+sizeof(XBPS_SYSCONF_PATH)]
 
char rootdir [XBPS_MAXPATH]
 
char cachedir [XBPS_MAXPATH+sizeof(XBPS_CACHE_PATH)]
 
char metadir [XBPS_MAXPATH+sizeof(XBPS_META_PATH)]
 
char native_arch [64]
 
int flags
 

Field Documentation

◆ repositories

repositories

Proplib array of strings with repositories, overriding the list in the configuration file.

Definition at line 563 of file xbps.h.

Referenced by xbps_init(), xbps_repo_remove(), xbps_repo_store(), and xbps_rpool_foreach().

◆ pkgdb

◆ transd

transd

Proplib dictionary with transaction objects, required by xbps_transaction_commit().

Definition at line 583 of file xbps.h.

Referenced by xbps_transaction_autoremove_pkgs(), xbps_transaction_commit(), xbps_transaction_prepare(), and xbps_transaction_remove_pkg().

◆ state_cb

int(* state_cb) (const struct xbps_state_cb_data *, void *)

Pointer to the supplifed function callback to be used in the XBPS possible states.

Definition at line 588 of file xbps.h.

◆ state_cb_data

state_cb_data

Pointer to user supplied data to be passed as argument to the xbps_state_cb function callback.

Definition at line 595 of file xbps.h.

◆ unpack_cb

void(* unpack_cb) (const struct xbps_unpack_cb_data *, void *)

Pointer to the supplied function callback to be used in xbps_unpack_binary_pkg().

Definition at line 600 of file xbps.h.

◆ unpack_cb_data

unpack_cb_data

Pointer to user supplied data to be passed as argument to the xbps_unpack_cb function callback.

Definition at line 607 of file xbps.h.

◆ fetch_cb

void(* fetch_cb) (const struct xbps_fetch_cb_data *, void *)

Pointer to the supplied function callback to be used in xbps_fetch_file().

Definition at line 612 of file xbps.h.

◆ fetch_cb_data

fetch_cb_data

Pointer to user supplied data to be passed as argument to the xbps_fetch_cb function callback.

Definition at line 619 of file xbps.h.

◆ pkgdb_plist

pkgdb_plist

Absolute pathname to the pkgdb plist file.

Definition at line 625 of file xbps.h.

Referenced by xbps_pkgdb_lock(), and xbps_pkgdb_update().

◆ target_arch

target_arch

Target architecture, as set by XBPS_TARGET_ARCH from environment.

Definition at line 631 of file xbps.h.

Referenced by xbps_init(), xbps_pkg_arch_match(), xbps_pkg_exec_buffer(), xbps_repo_path_with_name(), and xbps_transaction_commit().

◆ confdir

confdir

Full path to the xbps configuration directory.

Definition at line 637 of file xbps.h.

Referenced by xbps_init().

◆ rootdir

rootdir

Root directory for all operations in XBPS. If unset, defaults to '/'.

Definition at line 650 of file xbps.h.

Referenced by xbps_init(), xbps_pkg_exec_buffer(), xbps_pkgdb_lock(), xbps_symlink_target(), and xbps_transaction_commit().

◆ cachedir

cachedir

Cache directory to store downloaded binary packages. If unset, defaults to XBPS_CACHE_PATH (relative to rootdir).

Definition at line 657 of file xbps.h.

Referenced by xbps_binpkg_exists(), xbps_init(), xbps_pkg_path(), xbps_remote_binpkg_exists(), xbps_repository_pkg_path(), and xbps_transaction_commit().

◆ metadir

metadir

Metadata directory for all operations in XBPS. If unset, defaults to XBPS_CACHE_PATH (relative to rootdir).

Definition at line 664 of file xbps.h.

Referenced by xbps_init(), xbps_pkgdb_get_pkg_files(), xbps_pkgdb_lock(), xbps_repo_key_import(), and xbps_verify_signature().

◆ native_arch

native_arch

Machine architecture, defaults to uname(2) machine if XBPS_ARCH is not set from environment.

Definition at line 671 of file xbps.h.

Referenced by xbps_init(), xbps_pkg_arch_match(), xbps_pkg_exec_buffer(), xbps_repo_path_with_name(), and xbps_transaction_commit().

◆ flags

flags

Flags to be set globally by ORing them, possible value:

    - XBPS_FLAG_* (see above)

Definition at line 679 of file xbps.h.

Referenced by xbps_configure_pkg(), xbps_init(), xbps_rpool_get_pkg(), xbps_transaction_commit(), xbps_transaction_install_pkg(), xbps_transaction_prepare(), and xbps_transaction_update_pkg().

Enumeration Type Documentation

◆ xbps_state_t

Integer representing the xbps callback returned state. Possible values:

  • XBPS_STATE_UKKNOWN: state hasn't been prepared or unknown error.
  • XBPS_STATE_TRANS_DOWNLOAD: transaction is downloading binary packages.
  • XBPS_STATE_TRANS_VERIFY: transaction is verifying binary package integrity.
  • XBPS_STATE_TRANS_RUN: transaction is performing operations: install, update, remove, replace.
  • XBPS_STATE_TRANS_CONFIGURE: transaction is configuring all unpacked packages.
  • XBPS_STATE_TRANS_FAIL: transaction has failed.
  • XBPS_STATE_DOWNLOAD: a binary package is being downloaded.
  • XBPS_STATE_VERIFY: a binary package is being verified.
  • XBPS_STATE_REMOVE: a package is being removed.
  • XBPS_STATE_REMOVE_DONE: a package has been removed successfully.
  • XBPS_STATE_REMOVE_FILE: a package file is being removed.
  • XBPS_STATE_REMOVE_OBSOLETE: an obsolete package file is being removed.
  • XBPS_STATE_REPLACE: a package is being replaced.
  • XBPS_STATE_INSTALL: a package is being installed.
  • XBPS_STATE_INSTALL_DONE: a package has been installed successfully.
  • XBPS_STATE_UPDATE: a package is being updated.
  • XBPS_STATE_UPDATE_DONE: a package has been updated successfully.
  • XBPS_STATE_UNPACK: a package is being unpacked.
  • XBPS_STATE_CONFIGURE: a package is being configured.
  • XBPS_STATE_CONFIGURE_DONE: a package has been configured successfully.
  • XBPS_STATE_CONFIG_FILE: a package configuration file is being processed.
  • XBPS_STATE_REPOSYNC: a remote repository's package index is being synchronized.
  • XBPS_STATE_VERIFY_FAIL: binary package integrity has failed.
  • XBPS_STATE_DOWNLOAD_FAIL: binary package download has failed.
  • XBPS_STATE_REMOVE_FAIL: a package removal has failed.
  • XBPS_STATE_REMOVE_FILE_FAIL: a package file removal has failed.
  • XBPS_STATE_REMOVE_FILE_HASH_FAIL: a package file removal has failed due to hash.
  • XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL: an obsolete package file removal has failed.
  • XBPS_STATE_CONFIGURE_FAIL: package configure has failed.
  • XBPS_STATE_CONFIG_FILE_FAIL: package configuration file operation has failed.
  • XBPS_STATE_UPDATE_FAIL: package update has failed.
  • XBPS_STATE_UNPACK_FAIL: package unpack has failed.
  • XBPS_STATE_REPOSYNC_FAIL: syncing remote repositories has failed.
  • XBPS_STATE_REPO_KEY_IMPORT: repository is signed and needs to import pubkey.
  • XBPS_STATE_INVALID_DEP: package has an invalid dependency.
  • XBPS_STATE_SHOW_INSTALL_MSG: package must show a post-install message.
  • XBPS_STATE_SHOW_REMOVE_MSG: package must show a pre-remove message.
  • XBPS_STATE_ALTGROUP_ADDED: package has registered an alternative group.
  • XBPS_STATE_ALTGROUP_REMOVED: package has unregistered an alternative group.
  • XBPS_STATE_ALTGROUP_SWITCHED: alternative group has been switched.
  • XBPS_STATE_ALTGROUP_LINK_ADDED: link added by an alternative group.
  • XBPS_STATE_ALTGROUP_LINK_REMOVED: link removed by an alternative group.
  • XBPS_STATE_UNPACK_FILE_PRESERVED: package unpack preserved a file.
  • XBPS_STATE_PKGDB: pkgdb upgrade in progress.
  • XBPS_STATE_PKGDB_DONE: pkgdb has been upgraded successfully.

Definition at line 329 of file xbps.h.

Function Documentation

◆ xbps_init()

void void void void int xbps_init ( struct xbps_handle xhp)

Initialize the XBPS library with the following steps:

  • Set function callbacks for fetching and unpacking.
  • Set default cache connections for libfetch.
  • Parse configuration file.
Parameters
[in]xhpPointer to an xbps_handle struct.
Note
It's assumed that xhp is a valid pointer.
Returns
0 on success, an errno value otherwise.

Definition at line 46 of file initend.c.

References xbps_handle::cachedir, xbps_handle::confdir, xbps_handle::flags, xbps_handle::metadir, xbps_handle::native_arch, xbps_handle::repositories, xbps_handle::rootdir, xbps_handle::target_arch, xbps_path_clean(), xbps_path_join(), xbps_path_prepend(), and xbps_strlcpy().

Here is the call graph for this function:

◆ xbps_end()

void xbps_end ( struct xbps_handle xhp)

Releases all resources used by libxbps.

Parameters
[in]xhpPointer to an xbps_handle struct.

Definition at line 180 of file initend.c.