31 #include "xbps_api_impl.h"
35 xbps_get_remote_repo_string(
const char *uri)
41 if ((url = fetchParseURL(uri)) == NULL)
56 url->host, url->port, url->doc);
62 for (i = 0; i < strlen(p); i++) {
63 if (p[i] ==
'.' || p[i] ==
'/' || p[i] ==
':')
75 xbps_rindex_sync(
struct xbps_handle *xhp,
const char *uri,
const char *plistf)
77 prop_dictionary_t repod;
78 const char *fetchstr = NULL;
79 char *rpidx, *lrepodir, *uri_fixedp, *lrepofile;
83 rpidx = uri_fixedp = lrepodir = lrepofile = NULL;
89 uri_fixedp = xbps_get_remote_repo_string(uri);
90 if (uri_fixedp == NULL)
105 xhp->un_machine, plistf);
109 if (access(lrepodir, R_OK|X_OK|W_OK) == -1) {
111 xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL,
113 "[reposync] failed to create repodir `%s': %s",
114 lrepodir, strerror(errno));
118 if (chdir(lrepodir) == -1) {
119 xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL,
121 "[reposync] failed to change dir to repodir `%s': %s",
122 lrepodir, strerror(errno));
128 xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC, 0, uri, plistf, NULL);
135 xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL,
136 fetchLastErrCode != 0 ? fetchLastErrCode : errno,
138 "[reposync] failed to fetch file `%s': %s",
139 rpidx, fetchstr ? fetchstr : strerror(errno));
141 }
else if (rv == 0) {
151 repod = prop_dictionary_internalize_from_zfile(lrepofile);
153 xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL, 0, NULL, NULL,
154 "[reposync] downloaded file `%s' is not valid.", rpidx);
155 (void)unlink(lrepofile);
156 (void)
remove(lrepodir);
160 prop_object_release(repod);