26#include <sys/utsname.h>
34#include "xbps_api_impl.h"
48 const char *native_arch = NULL, *p;
53 if (xhp->
flags & XBPS_FLAG_DEBUG)
56 xbps_dbg_printf(
"%s\n", XBPS_RELVER);
62 }
else if (xhp->
rootdir[0] !=
'/') {
63 char cwd[XBPS_MAXPATH];
65 if (getcwd(cwd,
sizeof(cwd)) == NULL)
76 xhp->
rootdir, XBPS_SYSCONF_PATH, (
char *)NULL) == -1)
78 }
else if (xhp->
confdir[0] !=
'/') {
88 if (xhp->sysconfdir[0] ==
'\0') {
90 xhp->
rootdir, XBPS_SYSDEFCONF_PATH, (
char *)NULL) == -1)
96 xbps_fetch_set_cache_connection(XBPS_FETCH_CACHECONN, XBPS_FETCH_CACHECONN_HOST);
98 xhp->vpkgd = xbps_dictionary_create();
99 if (xhp->vpkgd == NULL)
100 return errno ? errno : ENOMEM;
101 xhp->vpkgd_conf = xbps_dictionary_create();
102 if (xhp->vpkgd_conf == NULL)
103 return errno ? errno : ENOMEM;
106 if ((rv = xbps_conf_init(xhp)) != 0)
115 if ((native_arch = getenv(
"XBPS_ARCH")) && *native_arch !=
'\0') {
123 if (uname(&un) == -1)
134 xhp->
rootdir, XBPS_CACHE_PATH, (
char *)NULL) == -1)
136 }
else if (xhp->
cachedir[0] !=
'/') {
148 xhp->
rootdir, XBPS_META_PATH, (
char *)NULL) == -1)
150 }
else if (xhp->
metadir[0] !=
'/') {
159 p = getenv(
"XBPS_SYSLOG");
161 if (strcasecmp(p,
"true") == 0)
162 xhp->
flags &= ~XBPS_FLAG_DISABLE_SYSLOG;
163 else if (strcasecmp(p,
"false") == 0)
164 xhp->
flags |= XBPS_FLAG_DISABLE_SYSLOG;
167 if (xhp->
flags & XBPS_FLAG_DEBUG) {
169 for (
unsigned int i = 0; i < xbps_array_count(xhp->
repositories); i++) {
170 if (!xbps_array_get_cstring_nocopy(xhp->
repositories, i, &repodir))
172 xbps_dbg_printf(
"Repository[%u]=%s\n", i, repodir);
184 xbps_pkgdb_release(xhp);
char metadir[XBPS_MAXPATH+sizeof(XBPS_META_PATH)]
char rootdir[XBPS_MAXPATH]
xbps_array_t repositories
char confdir[XBPS_MAXPATH+sizeof(XBPS_SYSCONF_PATH)]
char cachedir[XBPS_MAXPATH+sizeof(XBPS_CACHE_PATH)]
Generic XBPS structure handler for initialization.
int xbps_init(struct xbps_handle *xhp)
void xbps_end(struct xbps_handle *xhp)
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,...)