XBPS Library API 20240111
The X Binary Package System
|
Functions | |
bool | xbps_remove_pkgname_from_array (xbps_array_t array, const char *pkgname) |
bool | xbps_remove_string_from_array (xbps_array_t array, const char *str) |
int | xbps_mkpath (const char *path, mode_t mode) |
char * | xbps_xasprintf (const char *fmt,...) __attribute__((format(printf |
char bool | xbps_mmap_file (const char *file, void **mmf, size_t *mmflen, size_t *filelen) |
bool | xbps_file_sha256 (char *dst, size_t len, const char *file) |
bool | xbps_file_sha256_raw (unsigned char *dst, size_t len, const char *file) |
int | xbps_file_sha256_check (const char *file, const char *sha256) |
bool | xbps_verify_signature (struct xbps_repo *repo, const char *sigfile, unsigned char *digest) |
bool | xbps_verify_file_signature (struct xbps_repo *repo, const char *fname) |
int | xbps_pkg_is_installed (struct xbps_handle *xhp, const char *pkg) |
bool | xbps_pkg_is_ignored (struct xbps_handle *xhp, const char *pkg) |
bool | xbps_binpkg_exists (struct xbps_handle *xhp, xbps_dictionary_t pkgd) |
bool | xbps_remote_binpkg_exists (struct xbps_handle *xhp, xbps_dictionary_t pkgd) |
bool | xbps_repository_is_remote (const char *uri) |
char * | xbps_repository_pkg_path (struct xbps_handle *xhp, xbps_dictionary_t pkgd) |
ssize_t | xbps_pkg_path (struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd) |
ssize_t | xbps_pkg_url (struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd) |
ssize_t | xbps_pkg_path_or_url (struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd) |
bool | xbps_pkg_name (char *dst, size_t len, const char *pkg) |
bool | xbps_pkgpattern_name (char *dst, size_t len, const char *pattern) |
const char * | xbps_pkg_version (const char *pkg) |
char * | xbps_binpkg_pkgver (const char *pkg) |
char * | xbps_binpkg_arch (const char *pkg) |
const char * | xbps_pkgpattern_version (const char *pattern) |
int | xbps_pkgpattern_match (const char *pkgver, const char *pattern) |
const char * | xbps_pkg_revision (const char *pkg) |
bool | xbps_pkg_arch_match (struct xbps_handle *xhp, const char *orig, const char *target) |
int | xbps_humanize_number (char *buf, int64_t bytes) |
size_t | xbps_strlcat (char *dst, const char *src, size_t dstsize) |
size_t | xbps_strlcpy (char *dst, const char *src, size_t dstsize) |
bool | xbps_pkg_reverts (xbps_dictionary_t pkg, const char *pkgver) |
int | xbps_cmpver (const char *pkg1, const char *pkg2) |
char * | xbps_pubkey2fp (xbps_data_t pubkey) |
char * | xbps_sanitize_path (const char *src) |
ssize_t | xbps_path_clean (char *path) |
ssize_t | xbps_path_rel (char *dst, size_t len, const char *from, const char *to) |
ssize_t | xbps_path_join (char *dst, size_t len,...) |
ssize_t | xbps_path_append (char *dst, size_t len, const char *suffix) |
ssize_t | xbps_path_prepend (char *dst, size_t len, const char *prefix) |
char * | xbps_symlink_target (struct xbps_handle *xhp, const char *path, const char *target) |
bool | xbps_patterns_match (xbps_array_t patterns, const char *path) |
xbps_array_t | xbps_plist_array_from_file (const char *path) |
xbps_dictionary_t | xbps_plist_dictionary_from_file (const char *path) |
bool xbps_remove_pkgname_from_array | ( | xbps_array_t | array, |
const char * | pkgname | ||
) |
Removes a string object matching pkgname in the array array of strings.
[in] | array | Proplib array of strings. |
[in] | pkgname | pkgname string object to remove. |
Definition at line 112 of file plist_remove.c.
bool xbps_remove_string_from_array | ( | xbps_array_t | array, |
const char * | str | ||
) |
Removes a string object matching str in the array array of strings.
[in] | array | Proplib array of strings. |
[in] | str | string object to remove. |
Definition at line 106 of file plist_remove.c.
Referenced by xbps_alternatives_set(), xbps_alternatives_unregister(), and xbps_repo_remove().
int xbps_mkpath | ( | const char * | path, |
mode_t | mode | ||
) |
Creates a directory (and required components if necessary).
[in] | path | Path for final directory. |
[in] | mode | Mode for final directory (0755 if not specified). |
Definition at line 42 of file mkpath.c.
Referenced by xbps_pkgdb_lock(), xbps_repo_key_import(), and xbps_transaction_commit().
char * xbps_xasprintf | ( | const char * | fmt, |
... | |||
) |
Returns a string by concatenating its variable argument list as specified by the format string fmt.
[in] | fmt | Format string, see printf(3). |
Referenced by xbps_fetch_file_dest_sha256(), xbps_pkg_exec_buffer(), xbps_pkgdb_lock(), xbps_repo_key_import(), xbps_repo_lock(), xbps_repo_path_with_name(), xbps_repository_pkg_path(), xbps_symlink_target(), and xbps_verify_signature().
char bool xbps_mmap_file | ( | const char * | file, |
void ** | mmf, | ||
size_t * | mmflen, | ||
size_t * | filelen | ||
) |
Creates a memory mapped object from file file into mmf with size mmflen, and file size to filelen;
[in] | file | Path to a file. |
[out] | mmf | Memory mapped object. |
[out] | mmflen | Length of memory mapped object. |
[out] | filelen | File size length. |
Definition at line 65 of file util_hash.c.
Referenced by xbps_verify_signature().
bool xbps_file_sha256 | ( | char * | dst, |
size_t | len, | ||
const char * | file | ||
) |
Computes a sha256 hex digest into dst of size len from file file.
[out] | dst | Destination buffer. |
[in] | len | Size of dst must be at least XBPS_SHA256_LENGTH. |
[in] | file | The file to read. |
Definition at line 148 of file util_hash.c.
References xbps_file_sha256_raw().
bool xbps_file_sha256_raw | ( | unsigned char * | dst, |
size_t | len, | ||
const char * | file | ||
) |
Computes a sha256 binary digest into dst of size len from file file.
[out] | dst | Destination buffer. |
[in] | len | Size of dst must be at least XBPS_SHA256_DIGEST_SIZE_LENGTH. |
[in] | file | The file to read. |
Definition at line 116 of file util_hash.c.
Referenced by xbps_file_sha256(), xbps_file_sha256_check(), and xbps_verify_file_signature().
int xbps_file_sha256_check | ( | const char * | file, |
const char * | sha256 | ||
) |
Compares the sha256 hash of the file file with the sha256 string specified by sha256.
[in] | file | Path to a file. |
[in] | sha256 | SHA256 hash to compare. |
Definition at line 201 of file util_hash.c.
References xbps_file_sha256_raw().
bool xbps_verify_signature | ( | struct xbps_repo * | repo, |
const char * | sigfile, | ||
unsigned char * | digest | ||
) |
Verifies the RSA signature sigfile against digest with the RSA public-key associated in repo.
[in] | repo | Repository to use with the RSA public key associated. |
[in] | sigfile | The signature file name used to verify digest. |
[in] | digest | The digest to verify. |
Definition at line 75 of file verifysig.c.
References xbps_repo::idxmeta, xbps_handle::metadir, xbps_repo::uri, xbps_mmap_file(), xbps_plist_dictionary_from_file(), xbps_pubkey2fp(), xbps_xasprintf(), and xbps_repo::xhp.
Referenced by xbps_verify_file_signature().
bool xbps_verify_file_signature | ( | struct xbps_repo * | repo, |
const char * | fname | ||
) |
Verifies the RSA signature of fname with the RSA public-key associated in repo.
[in] | repo | Repository to use with the RSA public key associated. |
[in] | fname | The filename to verify, the signature file must have a .sig2 extension, i.e <fname>.sig2 . |
Definition at line 136 of file verifysig.c.
References xbps_file_sha256_raw(), and xbps_verify_signature().
int xbps_pkg_is_installed | ( | struct xbps_handle * | xhp, |
const char * | pkg | ||
) |
Checks if a package is currently installed in pkgdb by matching pkg. To be installed, the pkg must be in "installed" or "unpacked" state.
[in] | xhp | The pointer to an xbps_handle struct. |
[in] | pkg | Package name, version pattern or exact pkg to match. |
Definition at line 79 of file util.c.
References xbps_pkg_state_dictionary(), xbps_pkgdb_get_pkg(), and xbps_pkgdb_get_virtualpkg().
bool xbps_pkg_is_ignored | ( | struct xbps_handle * | xhp, |
const char * | pkg | ||
) |
Checks if a package is currently ignored by matching pkg. To be ignored, the pkg must be ignored by the users configuration.
[in] | xhp | The pointer to an xbps_handle struct. |
[in] | pkg | Package name, version pattern or exact pkg to match. |
Definition at line 103 of file util.c.
References xbps_match_string_in_array(), xbps_pkg_name(), and xbps_pkgpattern_name().
bool xbps_binpkg_exists | ( | struct xbps_handle * | xhp, |
xbps_dictionary_t | pkgd | ||
) |
Returns true if binary package exists in cachedir or in a local repository, false otherwise.
[in] | xhp | The pointer to an xbps_handle struct. |
[in] | pkgd | Package dictionary returned by rpool. |
Definition at line 429 of file util.c.
References xbps_handle::cachedir, and xbps_repository_is_remote().
bool xbps_remote_binpkg_exists | ( | struct xbps_handle * | xhp, |
xbps_dictionary_t | pkgd | ||
) |
Returns true if binary package and signature exists in cachedir, false otherwise.
[in] | xhp | The pointer to an xbps_handle struct. |
[in] | pkgd | Package dictionary returned by rpool. |
Definition at line 455 of file util.c.
References xbps_handle::cachedir.
bool xbps_repository_is_remote | ( | const char * | uri | ) |
Checks if the URI specified by uri is remote or local.
[in] | uri | URI string. |
Definition at line 66 of file util.c.
Referenced by xbps_binpkg_exists(), xbps_pkg_path(), xbps_repo_store(), and xbps_repository_pkg_path().
char * xbps_repository_pkg_path | ( | struct xbps_handle * | xhp, |
xbps_dictionary_t | pkgd | ||
) |
Returns an allocated string with the full path to the binary package matching pkgd.
The pkgd dictionary must contain the following objects:
[in] | xhp | The pointer to an xbps_handle struct. |
[in] | pkgd | The package dictionary to match. |
Definition at line 393 of file util.c.
References xbps_handle::cachedir, xbps_repository_is_remote(), and xbps_xasprintf().
ssize_t xbps_pkg_path | ( | struct xbps_handle * | xhp, |
char * | dst, | ||
size_t | dstsz, | ||
xbps_dictionary_t | pkgd | ||
) |
Put the path to the binary package pkgd into dst.
The pkgd dictionary must contain the following objects:
[in] | xhp | Pointer to an xbps_handle struct. |
[in] | dst | Destination buffer. |
[in] | dstsz | Destination buffer size. |
[in] | pkgd | Package dictionary. |
-EINVAL | Missing required dictionary entry. |
-ENOBUFS | The path would exceed the supplied dst buffer. |
Definition at line 325 of file util.c.
References xbps_handle::cachedir, and xbps_repository_is_remote().
ssize_t xbps_pkg_url | ( | struct xbps_handle * | xhp, |
char * | dst, | ||
size_t | dstsz, | ||
xbps_dictionary_t | pkgd | ||
) |
Put the url to the binary package pkgd into dst.
The pkgd dictionary must contain the following objects:
[in] | xhp | The pointer to an xbps_handle struct. |
[in] | pkgd | The package dictionary to match. |
-EINVAL | Missing required dictionary entry. |
-ENOBUFS | The path would exceed the supplied dst buffer. |
ssize_t xbps_pkg_path_or_url | ( | struct xbps_handle * | xhp, |
char * | dst, | ||
size_t | dstsz, | ||
xbps_dictionary_t | pkgd | ||
) |
Put the url or path (if cached) to the binary package pkgd into dst.
The pkgd dictionary must contain the following objects:
[in] | xhp | The pointer to an xbps_handle struct. |
[in] | pkgd | The package dictionary to match. |
-EINVAL | Missing required dictionary entry. |
-ENOBUFS | The path would exceed the supplied dst buffer. |
bool xbps_pkg_name | ( | char * | dst, |
size_t | len, | ||
const char * | pkg | ||
) |
Gets the name of a package string. Package strings are composed by a <pkgname>/<version> pair and separated by the minus sign, i.e foo-2.0
.
[out] | dst | Destination buffer to store result. |
[in] | len | Length of dst. |
[in] | pkg | Package version string. |
Definition at line 253 of file util.c.
Referenced by xbps_configure_pkg(), xbps_pkg_exec_buffer(), xbps_pkg_is_ignored(), xbps_pkgdb_get_pkg_files(), xbps_pkgdb_get_pkg_revdeps(), xbps_repo_get_pkg(), xbps_repo_get_pkg_revdeps(), xbps_repo_get_virtualpkg(), xbps_set_pkg_state_installed(), xbps_transaction_install_pkg(), xbps_transaction_update_packages(), and xbps_transaction_update_pkg().
bool xbps_pkgpattern_name | ( | char * | dst, |
size_t | len, | ||
const char * | pattern | ||
) |
Gets a the package name of a package pattern string specified by the pattern argument.
Package patterns are composed of the package name and either a equals (foo=2.0
) constraint or a greater than (foo>2.0
) or greater equals (foo>=2.0
) or lower than (foo<2.0
) or lower equals (foo<=2.0
) or a combination of both (foo>=1.0<2.0
).
[out] | dst | Destination buffer to store result. |
[in] | len | Length of dst. |
[in] | pattern | A package pattern. |
Definition at line 289 of file util.c.
Referenced by xbps_pkg_is_ignored().
const char * xbps_pkg_version | ( | const char * | pkg | ) |
Gets the package version in a package string, i.e foo-2.0
.
[in] | pkg | Package string. |
Definition at line 124 of file util.c.
Referenced by xbps_binpkg_pkgver(), xbps_match_virtual_pkg_in_array(), xbps_pkg_exec_buffer(), and xbps_pkg_reverts().
char * xbps_binpkg_pkgver | ( | const char * | pkg | ) |
Gets the pkgname/version componentn of a binary package string, i.e foo-2.0_1.<arch>.xbps
.
[in] | pkg | Package string. |
Definition at line 150 of file util.c.
References xbps_pkg_version().
char * xbps_binpkg_arch | ( | const char * | pkg | ) |
Gets the architecture component of a binary package string, i.e <pkgver>.<arch>.xbps
.
[in] | pkg | Package string. |
const char * xbps_pkgpattern_version | ( | const char * | pattern | ) |
Gets the package version of a package pattern string specified by the pattern argument.
[in] | pattern | A package pattern. The same rules in xbps_get_pkgpattern_name() apply here. |
Definition at line 317 of file util.c.
Referenced by xbps_match_virtual_pkg_in_array().
int xbps_pkgpattern_match | ( | const char * | pkgver, |
const char * | pattern | ||
) |
Package pattern matching.
There are 3 strategies for version matching:
[in] | pkgver | Package name/version, i.e ‘foo-1.0’. |
[in] | pattern | Package pattern to match against pkgver. |
Definition at line 530 of file util.c.
Referenced by xbps_match_any_virtualpkg_in_rundeps().
const char * xbps_pkg_revision | ( | const char * | pkg | ) |
bool xbps_pkg_arch_match | ( | struct xbps_handle * | xhp, |
const char * | orig, | ||
const char * | target | ||
) |
Returns true if provided string is valid for target architecture.
[in] | xhp | The pointer to an xbps_handle struct. |
[in] | orig | Architecture to match. |
[in] | target | If not NULL, orig will be matched against it rather than returned value of uname(2). |
Definition at line 484 of file util.c.
References xbps_handle::native_arch, and xbps_handle::target_arch.
int xbps_humanize_number | ( | char * | buf, |
int64_t | bytes | ||
) |
Converts the 64 bits signed number specified in bytes to a human parsable string buffer pointed to buf.
[out] | buf | Buffer to store the resulting string. At least it should have space for 6 chars. |
[in] | bytes | 64 bits signed number to convert. |
size_t xbps_strlcat | ( | char * | dst, |
const char * | src, | ||
size_t | dstsize | ||
) |
Append the string src to the end of dst.
[out] | dst | Buffer to store the resulting string. |
[in] | src | Source string. |
[in] | dstsize | Size of the dst buffer. |
Definition at line 566 of file util.c.
Referenced by xbps_fetch_file_dest_sha256(), and xbps_path_append().
size_t xbps_strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | dstsize | ||
) |
Copy up to dstsize - 1 from the string src to dest, NUL-terminating the result if dstsize is not 0.
[out] | dst | Buffer to store the resulting string. |
[in] | src | Source string. |
[in] | dstsize | Size of the dst buffer. |
Definition at line 575 of file util.c.
Referenced by xbps_fetch_file_dest_sha256(), xbps_init(), xbps_path_append(), xbps_path_clean(), xbps_path_prepend(), and xbps_path_rel().
bool xbps_pkg_reverts | ( | xbps_dictionary_t | pkg, |
const char * | pkgver | ||
) |
Tests if pkgver is reverted by pkg
The package version is defined by: ${NAME}-{${VERSION}_${REVISION}.
the name part is ignored.
[in] | pkg | a package which is a candidate to revert pkgver. |
[in] | pkgver | a package version string |
Definition at line 587 of file util.c.
References xbps_pkg_version().
int xbps_cmpver | ( | const char * | pkg1, |
const char * | pkg2 | ||
) |
char * xbps_pubkey2fp | ( | xbps_data_t | pubkey | ) |
Converts a RSA public key in PEM format to a hex fingerprint.
[in] | pubkey | The public-key in PEM format as xbps_data_t. |
Definition at line 66 of file pubkey2fp.c.
Referenced by xbps_repo_key_import(), and xbps_verify_signature().
char * xbps_sanitize_path | ( | const char * | src | ) |
Returns a buffer with a sanitized path from src. This removes multiple slashes.
[in] | src | path component. |
Definition at line 611 of file util.c.
Referenced by xbps_symlink_target().
ssize_t xbps_path_clean | ( | char * | path | ) |
Turns the path in path into the shortest path equivalent to path by purely lexical processing.
[in,out] | path | The path to clean. |
Definition at line 67 of file util_path.c.
References xbps_strlcpy().
Referenced by xbps_init(), and xbps_path_rel().
ssize_t xbps_path_rel | ( | char * | dst, |
size_t | len, | ||
const char * | from, | ||
const char * | to | ||
) |
Returns the relative path from from to to.
[out] | dst | Destination buffer to store result. |
[in] | len | Length of dst. |
[in] | from | The base path. |
[in] | to | The path that becomes relative to from. |
Definition at line 131 of file util_path.c.
References xbps_path_clean(), and xbps_strlcpy().
ssize_t xbps_path_join | ( | char * | dst, |
size_t | len, | ||
... | |||
) |
Joins multiple path components into the dst buffer.
The last argument has to be (char *)NULL.
[out] | dst | Destination buffer to store result. |
[in] | len | Length of dst. |
Definition at line 208 of file util_path.c.
Referenced by xbps_init().
ssize_t xbps_path_append | ( | char * | dst, |
size_t | len, | ||
const char * | suffix | ||
) |
Adds rootdir and path to the dst buffer.
[out] | dst | Destination buffer to store result. |
[in] | len | Length of dst. |
[in] | suffix | Suffix to append. |
Definition at line 219 of file util_path.c.
References xbps_strlcat(), and xbps_strlcpy().
ssize_t xbps_path_prepend | ( | char * | dst, |
size_t | len, | ||
const char * | prefix | ||
) |
Adds rootdir and path to the dst buffer.
[out] | dst | Destination buffer to store result. |
[in] | len | Length of dst. |
[in] | prefix | Prefix to prepend. |
Definition at line 249 of file util_path.c.
References xbps_strlcpy().
Referenced by xbps_init().
char * xbps_symlink_target | ( | struct xbps_handle * | xhp, |
const char * | path, | ||
const char * | target | ||
) |
Returns a sanitized target file of path without the rootdir component.
[in] | xhp | The pointer to an xbps_handle struct. |
[in] | path | path component. |
[in] | target | The stored target file of a symlink. |
Definition at line 638 of file util.c.
References xbps_handle::rootdir, xbps_sanitize_path(), and xbps_xasprintf().
bool xbps_patterns_match | ( | xbps_array_t | patterns, |
const char * | path | ||
) |
Returns true if any of the fnmatch patterns in patterns matches and is not negated by a later match.
[in] | patterns | The patterns to match against. |
[in] | path | The path that is matched against the patterns. |
xbps_array_t xbps_plist_array_from_file | ( | const char * | path | ) |
Internalizes a plist file declared in path and returns a proplib array.
[in] | path | The file path. |
Definition at line 937 of file proplib_wrapper.c.
xbps_dictionary_t xbps_plist_dictionary_from_file | ( | const char * | path | ) |
Internalizes a plist file declared in path and returns a proplib dictionary.
[in] | path | The file path. |
Definition at line 950 of file proplib_wrapper.c.
Referenced by xbps_pkgdb_get_pkg_files(), xbps_repo_key_import(), and xbps_verify_signature().