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 "20200423"
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_REPOIDX "index.plist"
122#define XBPS_REPOIDX_META "index-meta.plist"
129#define XBPS_FLAG_VERBOSE 0x00000001
137#define XBPS_FLAG_FORCE_CONFIGURE 0x00000002
145#define XBPS_FLAG_FORCE_REMOVE_FILES 0x00000004
152#define XBPS_FLAG_INSTALL_AUTO 0x00000010
158#define XBPS_FLAG_DEBUG 0x00000020
166#define XBPS_FLAG_FORCE_UNPACK 0x00000040
173#define XBPS_FLAG_DISABLE_SYSLOG 0x00000080
180#define XBPS_FLAG_BESTMATCH 0x00000100
187#define XBPS_FLAG_IGNORE_CONF_REPOS 0x00000200
194#define XBPS_FLAG_REPOS_MEMSYNC 0x00000400
202#define XBPS_FLAG_FORCE_REMOVE_REVDEPS 0x00000800
209#define XBPS_FLAG_UNPACK_ONLY 0x00001000
216#define XBPS_FLAG_DOWNLOAD_ONLY 0x00002000
223#define XBPS_FLAG_IGNORE_FILE_CONFLICTS 0x00004000
231#define XBPS_FLAG_INSTALL_REPRO 0x00008000
239#define XBPS_FLAG_KEEP_CONFIG 0x00010000
245#define XBPS_FETCH_CACHECONN 32
251#define XBPS_FETCH_CACHECONN_HOST 16
257#define XBPS_FETCH_TIMEOUT 30
263#define XBPS_SHA256_DIGEST_SIZE 32
269#define XBPS_SHA256_SIZE (XBPS_SHA256_DIGEST_SIZE*2)+1
329typedef enum xbps_state {
330 XBPS_STATE_UNKNOWN = 0,
331 XBPS_STATE_TRANS_DOWNLOAD,
332 XBPS_STATE_TRANS_VERIFY,
333 XBPS_STATE_TRANS_FILES,
334 XBPS_STATE_TRANS_RUN,
335 XBPS_STATE_TRANS_CONFIGURE,
336 XBPS_STATE_TRANS_FAIL,
341 XBPS_STATE_REMOVE_DONE,
342 XBPS_STATE_REMOVE_FILE,
343 XBPS_STATE_REMOVE_FILE_OBSOLETE,
345 XBPS_STATE_PURGE_DONE,
348 XBPS_STATE_INSTALL_DONE,
350 XBPS_STATE_UPDATE_DONE,
352 XBPS_STATE_CONFIGURE,
353 XBPS_STATE_CONFIG_FILE,
355 XBPS_STATE_VERIFY_FAIL,
356 XBPS_STATE_FILES_FAIL,
357 XBPS_STATE_DOWNLOAD_FAIL,
358 XBPS_STATE_REMOVE_FAIL,
359 XBPS_STATE_REMOVE_FILE_FAIL,
360 XBPS_STATE_REMOVE_FILE_HASH_FAIL,
361 XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL,
362 XBPS_STATE_PURGE_FAIL,
363 XBPS_STATE_CONFIGURE_FAIL,
364 XBPS_STATE_CONFIG_FILE_FAIL,
365 XBPS_STATE_UPDATE_FAIL,
366 XBPS_STATE_UNPACK_FAIL,
367 XBPS_STATE_REPOSYNC_FAIL,
368 XBPS_STATE_CONFIGURE_DONE,
369 XBPS_STATE_REPO_KEY_IMPORT,
370 XBPS_STATE_INVALID_DEP,
371 XBPS_STATE_SHOW_INSTALL_MSG,
372 XBPS_STATE_SHOW_REMOVE_MSG,
373 XBPS_STATE_UNPACK_FILE_PRESERVED,
375 XBPS_STATE_PKGDB_DONE,
376 XBPS_STATE_TRANS_ADDPKG,
377 XBPS_STATE_ALTGROUP_ADDED,
378 XBPS_STATE_ALTGROUP_REMOVED,
379 XBPS_STATE_ALTGROUP_SWITCHED,
380 XBPS_STATE_ALTGROUP_LINK_ADDED,
381 XBPS_STATE_ALTGROUP_LINK_REMOVED
554 xbps_array_t preserved_files;
555 xbps_array_t ignored_pkgs;
556 xbps_array_t noextract;
567 xbps_dictionary_t pkgdb_revdeps;
568 xbps_dictionary_t vpkgd;
569 xbps_dictionary_t vpkgd_conf;
637 char confdir[XBPS_MAXPATH+
sizeof(XBPS_SYSCONF_PATH)];
643 char sysconfdir[XBPS_MAXPATH+
sizeof(XBPS_SYSDEFCONF_PATH)];
657 char cachedir[XBPS_MAXPATH+
sizeof(XBPS_CACHE_PATH)];
664 char metadir[XBPS_MAXPATH+
sizeof(XBPS_META_PATH)];
682extern int xbps_debug_level;
684void xbps_dbg_printf(
const char *, ...) __attribute__ ((format (printf, 1, 2)));
685void xbps_dbg_printf_append(const
char *, ...)__attribute__ ((format (printf, 1, 2)));
686void xbps_error_printf(const
char *, ...)__attribute__ ((format (printf, 1, 2)));
687void xbps_warn_printf(const
char *, ...)__attribute__ ((format (printf, 1, 2)));
727 bool check_state,
bool update);
771 const
char *flags,
unsigned char *digest,
787 const
char *filename, const
char *flags);
805 const
char *filename, const
char *flags,
806 unsigned char *digest,
size_t digestlen);
864 int (*fn)(struct
xbps_handle *, xbps_object_t, const
char *,
void *,
bool *),
882 int (*fn)(struct
xbps_handle *, xbps_object_t, const
char *,
void *,
bool *),
975 const
size_t blobsiz,
1053 xbps_dictionary_t dict,
1054 int (*fn)(struct
xbps_handle *, xbps_object_t obj, const
char *,
void *arg,
bool *done),
1073 xbps_dictionary_t dict,
1074 int (*fn)(struct
xbps_handle *, xbps_object_t obj, const
char *,
void *arg,
bool *done),
1320typedef enum xbps_trans_type {
1321 XBPS_TRANS_UNKNOWN = 0,
1323 XBPS_TRANS_REINSTALL,
1325 XBPS_TRANS_CONFIGURE,
1492 int (*fn)(
struct xbps_repo *,
void *,
bool *),
1744 const size_t buflen,
const char *fname,
const mode_t mode,
1745 const char *uname,
const char *gname);
1768typedef enum pkg_state {
1769 XBPS_PKG_STATE_UNPACKED = 1,
1770 XBPS_PKG_STATE_INSTALLED,
1771 XBPS_PKG_STATE_BROKEN,
1772 XBPS_PKG_STATE_HALF_REMOVED,
1773 XBPS_PKG_STATE_NOT_INSTALLED,
1883bool xbps_mmap_file(const
char *file,
void **mmf,
size_t *mmflen,
size_t *filelen);
1932 unsigned char *digest);
2206size_t xbps_strlcat(
char *dst, const
char *src,
size_t dstsize);
2219size_t xbps_strlcpy(
char *dst, const
char *src,
size_t dstsize);
2248int xbps_cmpver(const
char *pkg1, const
char *pkg2);
2291ssize_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 metadir[XBPS_MAXPATH+sizeof(XBPS_META_PATH)]
ssize_t entry_total_count
char rootdir[XBPS_MAXPATH]
xbps_array_t repositories
char confdir[XBPS_MAXPATH+sizeof(XBPS_SYSCONF_PATH)]
int(* state_cb)(const struct xbps_state_cb_data *, void *)
char cachedir[XBPS_MAXPATH+sizeof(XBPS_CACHE_PATH)]
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
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)
struct xbps_repo * xbps_repo_stage_open(struct xbps_handle *xhp, const char *uri)
void xbps_repo_release(struct xbps_repo *repo)
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)
bool xbps_repo_fetch_remote(struct xbps_repo *repo, const char *url)
bool xbps_repo_lock(struct xbps_handle *xhp, const char *uri, int *lockfd, char **lockfname)
xbps_array_t xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
void xbps_repo_unlock(int lockfd, char *lockfname)
char * xbps_repo_path_with_name(struct xbps_handle *xhp, const char *url, const char *name)
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)