26#include <sys/utsname.h>
33#include "xbps_api_impl.h"
47 const char *native_arch = NULL, *p;
52 if (xhp->
flags & XBPS_FLAG_DEBUG)
55 if (xhp->
flags & XBPS_FLAG_VERBOSE)
56 xbps_verbose_level = 1;
64 }
else if (xhp->
rootdir[0] !=
'/') {
65 char cwd[XBPS_MAXPATH];
67 if (getcwd(cwd,
sizeof(cwd)) == NULL)
78 xhp->
rootdir, XBPS_SYSCONF_PATH, (
char *)NULL) == -1)
80 }
else if (xhp->
confdir[0] !=
'/') {
90 if (xhp->sysconfdir[0] ==
'\0') {
92 xhp->
rootdir, XBPS_SYSDEFCONF_PATH, (
char *)NULL) == -1)
98 xbps_fetch_set_cache_connection(XBPS_FETCH_CACHECONN, XBPS_FETCH_CACHECONN_HOST);
100 xhp->vpkgd = xbps_dictionary_create();
101 if (xhp->vpkgd == NULL)
102 return errno ? errno : ENOMEM;
103 xhp->vpkgd_conf = xbps_dictionary_create();
104 if (xhp->vpkgd_conf == NULL)
105 return errno ? errno : ENOMEM;
108 if ((rv = xbps_conf_init(xhp)) != 0)
117 if ((native_arch = getenv(
"XBPS_ARCH")) && *native_arch !=
'\0') {
125 if (uname(&un) == -1)
136 xhp->
rootdir, XBPS_CACHE_PATH, (
char *)NULL) == -1)
138 }
else if (xhp->
cachedir[0] !=
'/') {
150 xhp->
rootdir, XBPS_META_PATH, (
char *)NULL) == -1)
152 }
else if (xhp->
metadir[0] !=
'/') {
161 p = getenv(
"XBPS_SYSLOG");
163 if (strcasecmp(p,
"true") == 0)
164 xhp->
flags &= ~XBPS_FLAG_DISABLE_SYSLOG;
165 else if (strcasecmp(p,
"false") == 0)
166 xhp->
flags |= XBPS_FLAG_DISABLE_SYSLOG;
169 p = getenv(
"XBPS_STAGING");
171 if (strcasecmp(p,
"true") == 0)
172 xhp->
flags &= ~XBPS_FLAG_USE_STAGE;
173 else if (strcasecmp(p,
"false") == 0)
174 xhp->
flags |= XBPS_FLAG_USE_STAGE;
177 if (xhp->
flags & XBPS_FLAG_DEBUG) {
179 for (
unsigned int i = 0; i < xbps_array_count(xhp->
repositories); i++) {
180 if (!xbps_array_get_cstring_nocopy(xhp->
repositories, i, &repodir))
194 xbps_pkgdb_release(xhp);
char rootdir[XBPS_MAXPATH]
xbps_array_t repositories
char confdir[XBPS_MAXPATH]
char metadir[XBPS_MAXPATH]
char cachedir[XBPS_MAXPATH]
Generic XBPS structure handler for initialization.
int xbps_init(struct xbps_handle *xhp)
void xbps_end(struct xbps_handle *xhp)
int xbps_debug_level
The Debug level.
void xbps_dbg_printf(const char *fmt,...)
Prints debug messages to stderr.
size_t xbps_strlcpy(char *dst, const char *src, size_t dstsize)
ssize_t xbps_path_clean(char *path)
ssize_t xbps_path_prepend(char *dst, size_t len, const char *prefix)
ssize_t xbps_path_join(char *dst, size_t len,...)