34#include "xbps_api_impl.h"
38xbps_get_remote_repo_string(
const char *uri)
44 if ((url = fetchParseURL(uri)) == NULL)
59 url->host, url->port, url->doc);
65 for (i = 0; i < strlen(p); i++) {
66 if (p[i] ==
'.' || p[i] ==
'/' || p[i] ==
':')
78xbps_repo_sync(
struct xbps_handle *xhp,
const char *uri)
81 const char *arch, *fetchstr = NULL;
82 char *repodata, *lrepodir, *uri_fixedp;
91 uri_fixedp = xbps_get_remote_repo_string(uri);
92 if (uri_fixedp == NULL)
109 prev_umask = umask(022);
111 if (errno != EEXIST) {
112 xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL,
113 errno, NULL,
"[reposync] failed "
114 "to create repodir `%s': %s", lrepodir,
121 if (chdir(lrepodir) == -1) {
122 xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL, errno, NULL,
123 "[reposync] failed to change dir to repodir `%s': %s",
124 lrepodir, strerror(errno));
136 xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC, 0, repodata, NULL);
143 xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL,
144 fetchLastErrCode != 0 ? fetchLastErrCode : errno, NULL,
145 "[reposync] failed to fetch file `%s': %s",
146 repodata, fetchstr ? fetchstr : strerror(errno));
const char * xbps_fetch_error_string(void)
int xbps_fetch_file(struct xbps_handle *xhp, const char *uri, const char *flags)
char metadir[XBPS_MAXPATH+sizeof(XBPS_META_PATH)]
Generic XBPS structure handler for initialization.
char * xbps_xasprintf(const char *fmt,...) __attribute__((format(printf
int xbps_mkpath(const char *path, mode_t mode)
bool xbps_repository_is_remote(const char *uri)