26 #include <sys/utsname.h>
34 #include "xbps_api_impl.h"
45 prop_dictionary_t repod, d = NULL;
46 size_t i, ntotal = 0, nmissing = 0;
51 if (xhp->repo_pool != NULL)
53 else if (xhp->cfg == NULL)
56 xhp->repo_pool = prop_array_create();
57 if (xhp->repo_pool == NULL)
60 for (i = 0; i < cfg_size(xhp->cfg,
"repositories"); i++) {
61 repouri = cfg_getnstr(xhp->cfg,
"repositories", i);
71 if (access(plist, R_OK) == -1) {
72 xbps_dbg_printf(xhp,
"[rpool] `%s' cannot be "
73 "internalized: %s\n", repouri, strerror(errno));
77 repod = prop_dictionary_internalize_from_zfile(plist);
79 if (prop_object_type(repod) != PROP_TYPE_DICTIONARY) {
80 xbps_dbg_printf(xhp,
"[rpool] `%s' cannot be "
81 "internalized: %s\n", repouri, strerror(errno));
88 if ((d = prop_dictionary_create()) == NULL) {
90 prop_object_release(repod);
93 if (!prop_dictionary_set_cstring_nocopy(d,
"uri", repouri)) {
95 prop_object_release(repod);
96 prop_object_release(d);
99 if (!prop_dictionary_set(d,
"index", repod)) {
101 prop_object_release(repod);
102 prop_object_release(d);
105 prop_object_release(repod);
106 if (!prop_array_add(xhp->repo_pool, d)) {
108 prop_object_release(d);
111 xbps_dbg_printf(xhp,
"[rpool] `%s' registered.\n", repouri);
113 if (ntotal - nmissing == 0) {
119 prop_array_make_immutable(xhp->repo_pool);
120 xbps_dbg_printf(xhp,
"[rpool] initialized ok.\n");
123 xbps_rpool_release(xhp);
136 if (xhp->repo_pool == NULL)
139 for (i = 0; i < prop_array_count(xhp->repo_pool); i++) {
140 d = prop_array_get(xhp->repo_pool, i);
141 if (xhp->
flags & XBPS_FLAG_DEBUG) {
142 prop_dictionary_get_cstring_nocopy(d,
"uri", &uri);
143 xbps_dbg_printf(xhp,
"[rpool] unregistered "
144 "repository '%s'\n", uri);
146 prop_object_release(d);
148 prop_object_release(xhp->repo_pool);
149 xhp->repo_pool = NULL;
150 xbps_dbg_printf(xhp,
"[rpool] released ok.\n");
159 if (xhp->cfg == NULL)
162 for (i = 0; i < cfg_size(xhp->cfg,
"repositories"); i++) {
163 repouri = cfg_getnstr(xhp->cfg,
"repositories", i);
165 if (uri && strcmp(repouri, uri))
168 if (xbps_rindex_sync(xhp, repouri, file) == -1) {
170 "[rpool] `%s' failed to fetch `%s': %s\n",
172 fetchLastErrCode == 0 ? strerror(errno) :
193 if ((rv = xbps_rpool_init(xhp)) != 0) {
196 "[rpool] empty repository list.\n");
197 }
else if (rv != ENOENT && rv != ENOTSUP) {
199 "[rpool] couldn't initialize: %s\n",
205 for (i = 0; i < prop_array_count(xhp->repo_pool); i++) {
206 d = prop_array_get(xhp->repo_pool, i);
207 prop_dictionary_get_cstring_nocopy(d,
"uri", &rpi.
uri);
208 rpi.
repod = prop_dictionary_get(d,
"index");
210 rv = (*fn)(&rpi, arg, &done);