36#include <xbps/xbps_array.h>
37#include <xbps/xbps_bool.h>
38#include <xbps/xbps_data.h>
39#include <xbps/xbps_dictionary.h>
40#include <xbps/xbps_number.h>
41#include <xbps/xbps_string.h>
43#define XBPS_MAXPATH 512
44#define XBPS_NAME_SIZE 64
52#define XBPS_API_VERSION "20250521"
55 #define XBPS_VERSION "UNSET"
58 #define XBPS_GIT "UNSET"
64#define XBPS_RELVER "XBPS: " XBPS_VERSION \
65 " API: " XBPS_API_VERSION \
72#define XBPS_SYSDIR "/xbps.d"
73#ifndef XBPS_SYSCONF_PATH
74# define XBPS_SYSCONF_PATH "/etc" XBPS_SYSDIR
76#ifndef XBPS_SYSDEFCONF_PATH
77# define XBPS_SYSDEFCONF_PATH "/usr/share" XBPS_SYSDIR
85#define XBPS_META_PATH "var/db/xbps"
92#define XBPS_CACHE_PATH "var/cache/xbps"
98#define XBPS_PKGDB "pkgdb-0.38.plist"
104#define XBPS_PKGPROPS "props.plist"
110#define XBPS_PKGFILES "files.plist"
116#define XBPS_REPODATA_INDEX "index.plist"
122#define XBPS_REPODATA_STAGE "stage.plist"
128#define XBPS_REPODATA_META "index-meta.plist"
135#define XBPS_FLAG_VERBOSE 0x00000001
143#define XBPS_FLAG_FORCE_CONFIGURE 0x00000002
151#define XBPS_FLAG_FORCE_REMOVE_FILES 0x00000004
158#define XBPS_FLAG_INSTALL_AUTO 0x00000010
164#define XBPS_FLAG_DEBUG 0x00000020
172#define XBPS_FLAG_FORCE_UNPACK 0x00000040
179#define XBPS_FLAG_DISABLE_SYSLOG 0x00000080
186#define XBPS_FLAG_BESTMATCH 0x00000100
193#define XBPS_FLAG_IGNORE_CONF_REPOS 0x00000200
200#define XBPS_FLAG_REPOS_MEMSYNC 0x00000400
208#define XBPS_FLAG_FORCE_REMOVE_REVDEPS 0x00000800
215#define XBPS_FLAG_UNPACK_ONLY 0x00001000
222#define XBPS_FLAG_DOWNLOAD_ONLY 0x00002000
229#define XBPS_FLAG_IGNORE_FILE_CONFLICTS 0x00004000
237#define XBPS_FLAG_INSTALL_REPRO 0x00008000
245#define XBPS_FLAG_KEEP_CONFIG 0x00010000
252#define XBPS_FLAG_USE_STAGE 0x00020000
258#define XBPS_FETCH_CACHECONN 32
264#define XBPS_FETCH_CACHECONN_HOST 16
270#define XBPS_FETCH_TIMEOUT 30
276#define XBPS_SHA256_DIGEST_SIZE 32
282#define XBPS_SHA256_SIZE (XBPS_SHA256_DIGEST_SIZE*2)+1
340typedef enum xbps_state {
341 XBPS_STATE_UNKNOWN = 0,
342 XBPS_STATE_TRANS_DOWNLOAD,
343 XBPS_STATE_TRANS_VERIFY,
344 XBPS_STATE_TRANS_FILES,
345 XBPS_STATE_TRANS_RUN,
346 XBPS_STATE_TRANS_CONFIGURE,
347 XBPS_STATE_TRANS_FAIL,
352 XBPS_STATE_REMOVE_DONE,
353 XBPS_STATE_REMOVE_FILE,
354 XBPS_STATE_REMOVE_FILE_OBSOLETE,
356 XBPS_STATE_PURGE_DONE,
359 XBPS_STATE_INSTALL_DONE,
361 XBPS_STATE_UPDATE_DONE,
363 XBPS_STATE_CONFIGURE,
364 XBPS_STATE_CONFIG_FILE,
366 XBPS_STATE_VERIFY_FAIL,
367 XBPS_STATE_FILES_FAIL,
368 XBPS_STATE_DOWNLOAD_FAIL,
369 XBPS_STATE_REMOVE_FAIL,
370 XBPS_STATE_REMOVE_FILE_FAIL,
371 XBPS_STATE_REMOVE_FILE_HASH_FAIL,
372 XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL,
373 XBPS_STATE_PURGE_FAIL,
374 XBPS_STATE_CONFIGURE_FAIL,
375 XBPS_STATE_CONFIG_FILE_FAIL,
376 XBPS_STATE_UPDATE_FAIL,
377 XBPS_STATE_UNPACK_FAIL,
378 XBPS_STATE_REPOSYNC_FAIL,
379 XBPS_STATE_CONFIGURE_DONE,
380 XBPS_STATE_REPO_KEY_IMPORT,
381 XBPS_STATE_INVALID_DEP,
382 XBPS_STATE_UNPACK_FILE_PRESERVED,
384 XBPS_STATE_PKGDB_DONE,
385 XBPS_STATE_TRANS_ADDPKG,
386 XBPS_STATE_ALTGROUP_ADDED,
387 XBPS_STATE_ALTGROUP_REMOVED,
388 XBPS_STATE_ALTGROUP_SWITCHED,
389 XBPS_STATE_ALTGROUP_LINK_ADDED,
390 XBPS_STATE_ALTGROUP_LINK_REMOVED
563 xbps_array_t preserved_files;
564 xbps_array_t ignored_pkgs;
565 xbps_array_t noextract;
576 xbps_dictionary_t pkgdb_revdeps;
577 xbps_dictionary_t vpkgd;
578 xbps_dictionary_t vpkgd_conf;
652 char sysconfdir[XBPS_MAXPATH];
691extern int xbps_debug_level;
693void xbps_dbg_printf(
const char *, ...) __attribute__ ((format (printf, 1, 2)));
694void xbps_dbg_printf_append(const
char *, ...)__attribute__ ((format (printf, 1, 2)));
695void xbps_error_printf(const
char *, ...)__attribute__ ((format (printf, 1, 2)));
696void xbps_warn_printf(const
char *, ...)__attribute__ ((format (printf, 1, 2)));
736 bool check_state,
bool update);
780 const
char *flags,
unsigned char *digest,
796 const
char *filename, const
char *flags);
814 const
char *filename, const
char *flags,
815 unsigned char *digest,
size_t digestlen);
873 int (*fn)(struct
xbps_handle *, xbps_object_t, const
char *,
void *,
bool *),
891 int (*fn)(struct
xbps_handle *, xbps_object_t, const
char *,
void *,
bool *),
984 const
size_t blobsiz,
1001 xbps_dictionary_t d,
1062 xbps_dictionary_t dict,
1063 int (*fn)(struct
xbps_handle *, xbps_object_t obj, const
char *,
void *arg,
bool *done),
1082 xbps_dictionary_t dict,
1083 int (*fn)(struct
xbps_handle *, xbps_object_t obj, const
char *,
void *arg,
bool *done),
1329typedef enum xbps_trans_type {
1330 XBPS_TRANS_UNKNOWN = 0,
1332 XBPS_TRANS_REINSTALL,
1334 XBPS_TRANS_CONFIGURE,
1454 xbps_dictionary_t stage;
1514 int (*fn)(
struct xbps_repo *,
void *,
bool *),
1736 const size_t buflen,
const char *fname,
const mode_t mode,
1737 const char *uname,
const char *gname);
1760typedef enum pkg_state {
1761 XBPS_PKG_STATE_UNPACKED = 1,
1762 XBPS_PKG_STATE_INSTALLED,
1763 XBPS_PKG_STATE_BROKEN,
1764 XBPS_PKG_STATE_HALF_REMOVED,
1765 XBPS_PKG_STATE_NOT_INSTALLED,
1875bool xbps_mmap_file(const
char *file,
void **mmf,
size_t *mmflen,
size_t *filelen);
1924 unsigned char *digest);
2198size_t xbps_strlcat(
char *dst, const
char *src,
size_t dstsize);
2211size_t xbps_strlcpy(
char *dst, const
char *src,
size_t dstsize);
2240int xbps_cmpver(const
char *pkg1, const
char *pkg2);
2283ssize_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 confdir[XBPS_MAXPATH]
ssize_t entry_total_count
char rootdir[XBPS_MAXPATH]
xbps_array_t repositories
char metadir[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 *)
ssize_t entry_extract_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.
void void void void int xbps_init(struct xbps_handle *xhp)
void xbps_end(struct xbps_handle *xhp)
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)