37#include <xbps/xbps_array.h>
38#include <xbps/xbps_bool.h>
39#include <xbps/xbps_data.h>
40#include <xbps/xbps_dictionary.h>
41#include <xbps/xbps_number.h>
42#include <xbps/xbps_string.h>
44#define XBPS_MAXPATH 512
45#define XBPS_NAME_SIZE 64
53#define XBPS_API_VERSION "20250629"
56 #define XBPS_VERSION "UNSET"
59 #define XBPS_GIT "UNSET"
65#define XBPS_RELVER "XBPS: " XBPS_VERSION \
66 " API: " XBPS_API_VERSION \
73#define XBPS_SYSDIR "/xbps.d"
74#ifndef XBPS_SYSCONF_PATH
75# define XBPS_SYSCONF_PATH "/etc" XBPS_SYSDIR
77#ifndef XBPS_SYSDEFCONF_PATH
78# define XBPS_SYSDEFCONF_PATH "/usr/share" XBPS_SYSDIR
86#define XBPS_META_PATH "var/db/xbps"
93#define XBPS_CACHE_PATH "var/cache/xbps"
99#define XBPS_PKGDB "pkgdb-0.38.plist"
105#define XBPS_PKGPROPS "props.plist"
111#define XBPS_PKGFILES "files.plist"
117#define XBPS_REPODATA_INDEX "index.plist"
123#define XBPS_REPODATA_STAGE "stage.plist"
129#define XBPS_REPODATA_META "index-meta.plist"
136#define XBPS_FLAG_VERBOSE 0x00000001
144#define XBPS_FLAG_FORCE_CONFIGURE 0x00000002
152#define XBPS_FLAG_FORCE_REMOVE_FILES 0x00000004
159#define XBPS_FLAG_INSTALL_AUTO 0x00000010
165#define XBPS_FLAG_DEBUG 0x00000020
173#define XBPS_FLAG_FORCE_UNPACK 0x00000040
180#define XBPS_FLAG_DISABLE_SYSLOG 0x00000080
187#define XBPS_FLAG_BESTMATCH 0x00000100
194#define XBPS_FLAG_IGNORE_CONF_REPOS 0x00000200
201#define XBPS_FLAG_REPOS_MEMSYNC 0x00000400
209#define XBPS_FLAG_FORCE_REMOVE_REVDEPS 0x00000800
216#define XBPS_FLAG_UNPACK_ONLY 0x00001000
223#define XBPS_FLAG_DOWNLOAD_ONLY 0x00002000
230#define XBPS_FLAG_IGNORE_FILE_CONFLICTS 0x00004000
238#define XBPS_FLAG_INSTALL_REPRO 0x00008000
246#define XBPS_FLAG_KEEP_CONFIG 0x00010000
253#define XBPS_FLAG_USE_STAGE 0x00020000
259#define XBPS_FETCH_CACHECONN 32
265#define XBPS_FETCH_CACHECONN_HOST 16
271#define XBPS_FETCH_TIMEOUT 30
277#define XBPS_SHA256_DIGEST_SIZE 32
283#define XBPS_SHA256_SIZE (XBPS_SHA256_DIGEST_SIZE*2)+1
341typedef enum xbps_state {
342 XBPS_STATE_UNKNOWN = 0,
343 XBPS_STATE_TRANS_DOWNLOAD,
344 XBPS_STATE_TRANS_VERIFY,
345 XBPS_STATE_TRANS_FILES,
346 XBPS_STATE_TRANS_RUN,
347 XBPS_STATE_TRANS_CONFIGURE,
348 XBPS_STATE_TRANS_FAIL,
353 XBPS_STATE_REMOVE_DONE,
354 XBPS_STATE_REMOVE_FILE,
355 XBPS_STATE_REMOVE_FILE_OBSOLETE,
357 XBPS_STATE_PURGE_DONE,
360 XBPS_STATE_INSTALL_DONE,
362 XBPS_STATE_UPDATE_DONE,
364 XBPS_STATE_CONFIGURE,
365 XBPS_STATE_CONFIG_FILE,
367 XBPS_STATE_VERIFY_FAIL,
368 XBPS_STATE_FILES_FAIL,
369 XBPS_STATE_DOWNLOAD_FAIL,
370 XBPS_STATE_REMOVE_FAIL,
371 XBPS_STATE_REMOVE_FILE_FAIL,
372 XBPS_STATE_REMOVE_FILE_HASH_FAIL,
373 XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL,
374 XBPS_STATE_PURGE_FAIL,
375 XBPS_STATE_CONFIGURE_FAIL,
376 XBPS_STATE_CONFIG_FILE_FAIL,
377 XBPS_STATE_UPDATE_FAIL,
378 XBPS_STATE_UNPACK_FAIL,
379 XBPS_STATE_REPOSYNC_FAIL,
380 XBPS_STATE_CONFIGURE_DONE,
381 XBPS_STATE_REPO_KEY_IMPORT,
382 XBPS_STATE_INVALID_DEP,
383 XBPS_STATE_UNPACK_FILE_PRESERVED,
385 XBPS_STATE_PKGDB_DONE,
386 XBPS_STATE_TRANS_ADDPKG,
387 XBPS_STATE_ALTGROUP_ADDED,
388 XBPS_STATE_ALTGROUP_REMOVED,
389 XBPS_STATE_ALTGROUP_SWITCHED,
390 XBPS_STATE_ALTGROUP_LINK_ADDED,
391 XBPS_STATE_ALTGROUP_LINK_REMOVED
564 xbps_array_t preserved_files;
565 xbps_array_t ignored_pkgs;
566 xbps_array_t noextract;
581 xbps_dictionary_t pkgdb_revdeps;
582 xbps_dictionary_t vpkgd;
583 xbps_dictionary_t vpkgd_conf;
657 char sysconfdir[XBPS_MAXPATH];
726extern int xbps_verbose_level;
728#if __has_attribute(format)
729# define PRINTF_LIKE(a, b) __attribute__ ((format (printf, a, b)))
731# define PRINTF_LIKE(a, b)
776#define xbps_error_oom() \
777 xbps_error_errno(ENOMEM, "%s:%d %s: out of memory\n", __FILE__, \
797 bool check_state,
bool update);
841 const char *flags,
unsigned char *digest,
857 const char *filename,
const char *flags);
875 const char *filename,
const char *flags,
876 unsigned char *digest,
size_t digestlen);
934 int (*fn)(
struct xbps_handle *, xbps_object_t,
const char *,
void *,
bool *),
952 int (*fn)(
struct xbps_handle *, xbps_object_t,
const char *,
void *,
bool *),
1045 const size_t blobsiz,
1062 xbps_dictionary_t d,
1123 xbps_dictionary_t dict,
1124 int (*fn)(
struct xbps_handle *, xbps_object_t obj,
const char *,
void *arg,
bool *done),
1143 xbps_dictionary_t dict,
1144 int (*fn)(
struct xbps_handle *, xbps_object_t obj,
const char *,
void *arg,
bool *done),
1390typedef enum xbps_trans_type {
1391 XBPS_TRANS_UNKNOWN = 0,
1393 XBPS_TRANS_REINSTALL,
1395 XBPS_TRANS_CONFIGURE,
1515 xbps_dictionary_t stage;
1575 int (*fn)(
struct xbps_repo *,
void *,
bool *),
1797 const size_t buflen,
const char *fname,
const mode_t mode,
1798 const char *uname,
const char *gname);
1821typedef enum pkg_state {
1822 XBPS_PKG_STATE_UNPACKED = 1,
1823 XBPS_PKG_STATE_INSTALLED,
1824 XBPS_PKG_STATE_BROKEN,
1825 XBPS_PKG_STATE_HALF_REMOVED,
1826 XBPS_PKG_STATE_NOT_INSTALLED,
1936bool xbps_mmap_file(const
char *file,
void **mmf,
size_t *mmflen,
size_t *filelen);
1985 unsigned char *digest);
2259size_t xbps_strlcat(
char *dst, const
char *src,
size_t dstsize);
2272size_t xbps_strlcpy(
char *dst, const
char *src,
size_t dstsize);
2301int xbps_cmpver(const
char *pkg1, const
char *pkg2);
2344ssize_t
xbps_path_rel(
char *dst,
size_t len, const
char *from, const
char *to);
int xbps_alternatives_register(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
int xbps_alternatives_set(struct xbps_handle *xhp, const char *pkg, const char *group)
int xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
int xbps_archive_append_buf(struct archive *ar, const void *buf, const size_t buflen, const char *fname, const mode_t mode, const char *uname, const char *gname)
int xbps_fetch_file_sha256(struct xbps_handle *xhp, const char *uri, const char *flags, unsigned char *digest, size_t digestlen)
const char * xbps_fetch_error_string(void)
int xbps_fetch_file_dest(struct xbps_handle *xhp, const char *uri, const char *filename, const char *flags)
int xbps_fetch_file(struct xbps_handle *xhp, const char *uri, const char *flags)
int xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char *filename, const char *flags, unsigned char *digest, size_t digestlen)
char rootdir[XBPS_MAXPATH]
xbps_array_t repositories
ssize_t entry_extract_count
char confdir[XBPS_MAXPATH]
int(* state_cb)(const struct xbps_state_cb_data *, void *)
void(* unpack_cb)(const struct xbps_unpack_cb_data *, void *)
void(* fetch_cb)(const struct xbps_fetch_cb_data *, void *)
char metadir[XBPS_MAXPATH]
ssize_t entry_total_count
char cachedir[XBPS_MAXPATH]
Structure to be passed as argument to the state function callback. All members are read-only and set ...
Structure to be passed to the unpack function callback.
Generic XBPS structure handler for initialization.
Structure to be passed to the fetch function callback.
int xbps_init(struct xbps_handle *xhp)
void xbps_end(struct xbps_handle *xhp)
void xbps_verbose_printf(const char *,...) __attribute__((format(printf
Prints messages to stderr if verbosity is enabled.
int xbps_debug_level
The Debug level.
int xbps_error_errno(int r, const char *fmt,...)
Prints formatted log message to stderr and returns error.
void xbps_dbg_printf(const char *fmt,...)
Prints debug messages to stderr.
void void xbps_error_printf(const char *fmt,...)
Prints error messages to stderr.
void xbps_dbg_printf_append(const char *fmt,...)
Prints debug messages to stderr.
void xbps_warn_printf(const char *fmt,...)
Prints warning messages to stderr.
xbps_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans)
xbps_array_t xbps_pkgdb_get_pkg_fulldeptree(struct xbps_handle *xhp, const char *pkg)
int xbps_pkgdb_foreach_cb_multi(struct xbps_handle *xhp, int(*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *), void *arg)
int xbps_pkg_exec_buffer(struct xbps_handle *xhp, const void *blob, const size_t blobsiz, const char *pkgver, const char *action, bool update)
xbps_dictionary_t xbps_pkgdb_get_pkg_files(struct xbps_handle *xhp, const char *pkg)
void xbps_pkgdb_unlock(struct xbps_handle *xhp)
xbps_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
int xbps_pkgdb_foreach_cb(struct xbps_handle *xhp, int(*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *), void *arg)
xbps_array_t xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
int xbps_pkgdb_update(struct xbps_handle *xhp, bool flush, bool update)
int xbps_pkgdb_lock(struct xbps_handle *xhp)
xbps_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg)
int xbps_pkg_exec_script(struct xbps_handle *xhp, xbps_dictionary_t d, const char *script, const char *action, bool update)
int xbps_pkg_state_installed(struct xbps_handle *xhp, const char *pkgname, pkg_state_t *state)
int xbps_set_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t state)
int xbps_set_pkg_state_installed(struct xbps_handle *xhp, const char *pkgver, pkg_state_t state)
int xbps_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t *state)
char * xbps_archive_fetch_file(const char *url, const char *fname)
xbps_dictionary_t xbps_archive_fetch_plist(const char *url, const char *p)
int xbps_archive_fetch_file_into_fd(const char *url, const char *fname, int fd)
xbps_object_iterator_t xbps_array_iter_from_dict(xbps_dictionary_t dict, const char *key)
bool xbps_match_pkgver_in_array(xbps_array_t array, const char *pkgver)
bool xbps_match_pkgname_in_array(xbps_array_t array, const char *pkgname)
bool xbps_match_pkgdep_in_array(xbps_array_t array, const char *pkgver)
bool xbps_match_string_in_array(xbps_array_t array, const char *val)
bool xbps_match_virtual_pkg_in_dict(xbps_dictionary_t pkgd, const char *str)
int xbps_array_foreach_cb_multi(struct xbps_handle *xhp, xbps_array_t array, xbps_dictionary_t dict, int(*fn)(struct xbps_handle *, xbps_object_t obj, const char *, void *arg, bool *done), void *arg)
bool xbps_match_virtual_pkg_in_array(xbps_array_t array, const char *str)
bool xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps, xbps_array_t provides)
bool xbps_match_pkgpattern_in_array(xbps_array_t array, const char *pattern)
int xbps_array_foreach_cb(struct xbps_handle *xhp, xbps_array_t array, xbps_dictionary_t dict, int(*fn)(struct xbps_handle *, xbps_object_t obj, const char *, void *arg, bool *done), void *arg)
xbps_dictionary_t xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg)
struct xbps_repo * xbps_repo_open(struct xbps_handle *xhp, const char *uri)
void xbps_repo_release(struct xbps_repo *repo)
int xbps_repo_lock(const char *repodir, const char *arch)
bool xbps_repo_remove(struct xbps_handle *xhp, const char *url)
int xbps_repo_key_import(struct xbps_repo *repo)
struct xbps_repo * xbps_repo_public_open(struct xbps_handle *xhp, const char *uri)
void xbps_repo_close(struct xbps_repo *repo)
char * xbps_repo_path(struct xbps_handle *xhp, const char *url)
xbps_dictionary_t xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg)
xbps_array_t xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
void xbps_repo_unlock(const char *repodir, const char *arch, int fd)
bool xbps_repo_store(struct xbps_handle *xhp, const char *url)
xbps_dictionary_t idxmeta
int xbps_rpool_foreach(struct xbps_handle *xhp, int(*fn)(struct xbps_repo *, void *, bool *), void *arg)
struct xbps_repo * xbps_rpool_get_repo(const char *url)
xbps_dictionary_t xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
xbps_dictionary_t xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg)
xbps_array_t xbps_rpool_get_pkg_fulldeptree(struct xbps_handle *xhp, const char *pkg)
xbps_array_t xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
int xbps_rpool_sync(struct xbps_handle *xhp, const char *uri)
int xbps_transaction_commit(struct xbps_handle *xhp)
xbps_trans_type_t xbps_transaction_pkg_type(xbps_dictionary_t pkg_repod)
int xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
int xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
int xbps_transaction_remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive)
bool xbps_transaction_pkg_type_set(xbps_dictionary_t pkg_repod, xbps_trans_type_t type)
int xbps_transaction_prepare(struct xbps_handle *xhp)
int xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkgname, bool force)
int xbps_transaction_update_packages(struct xbps_handle *xhp)
xbps_dictionary_t xbps_plist_dictionary_from_file(const char *path)
bool xbps_remove_pkgname_from_array(xbps_array_t array, const char *pkgname)
char * xbps_pubkey2fp(xbps_data_t pubkey)
char * xbps_xasprintf(const char *fmt,...) __attribute__((format(printf
ssize_t xbps_path_append(char *dst, size_t len, const char *suffix)
int xbps_humanize_number(char *buf, int64_t bytes)
const char * xbps_pkgpattern_version(const char *pattern)
bool xbps_verify_file_signature(struct xbps_repo *repo, const char *fname)
xbps_array_t xbps_plist_array_from_file(const char *path)
int xbps_file_sha256_check(const char *file, const char *sha256)
char bool xbps_mmap_file(const char *file, void **mmf, size_t *mmflen, size_t *filelen)
bool xbps_pkg_name(char *dst, size_t len, const char *pkg)
char * xbps_sanitize_path(const char *src)
bool xbps_patterns_match(xbps_array_t patterns, const char *path)
int xbps_mkpath(const char *path, mode_t mode)
bool xbps_pkg_is_ignored(struct xbps_handle *xhp, const char *pkg)
bool xbps_verify_signature(struct xbps_repo *repo, const char *sigfile, unsigned char *digest)
bool xbps_file_sha256(char *dst, size_t len, const char *file)
ssize_t xbps_pkg_url(struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd)
char * xbps_binpkg_pkgver(const char *pkg)
size_t xbps_strlcpy(char *dst, const char *src, size_t dstsize)
ssize_t xbps_path_clean(char *path)
bool xbps_pkg_reverts(xbps_dictionary_t pkg, const char *pkgver)
bool xbps_remote_binpkg_exists(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
ssize_t xbps_path_prepend(char *dst, size_t len, const char *prefix)
bool xbps_remove_string_from_array(xbps_array_t array, const char *str)
ssize_t xbps_pkg_path(struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd)
int xbps_cmpver(const char *pkg1, const char *pkg2)
ssize_t xbps_pkg_path_or_url(struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd)
int xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg)
char * xbps_binpkg_arch(const char *pkg)
int xbps_pkgpattern_match(const char *pkgver, const char *pattern)
const char * xbps_pkg_revision(const char *pkg)
const char * xbps_pkg_version(const char *pkg)
bool xbps_repository_is_remote(const char *uri)
bool xbps_pkgpattern_name(char *dst, size_t len, const char *pattern)
bool xbps_binpkg_exists(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
ssize_t xbps_path_join(char *dst, size_t len,...)
bool xbps_pkg_arch_match(struct xbps_handle *xhp, const char *orig, const char *target)
char * xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *target)
bool xbps_file_sha256_raw(unsigned char *dst, size_t len, const char *file)
size_t xbps_strlcat(char *dst, const char *src, size_t dstsize)
char * xbps_repository_pkg_path(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
ssize_t xbps_path_rel(char *dst, size_t len, const char *from, const char *to)