31 #include "xbps_api_impl.h"
35 prop_array_t unsorted,
36 prop_dictionary_t repo_pkgd,
49 if (!prop_dictionary_set_bool(repo_pkgd,
"automatic-install",
true))
54 prop_array_add(unsorted, repo_pkgd);
55 xbps_dbg_printf_append(xhp,
"(added)\n");
61 add_missing_reqdep(
struct xbps_handle *xhp,
const char *reqpkg)
64 prop_string_t reqpkg_str;
65 prop_object_iterator_t iter = NULL;
68 bool add_pkgdep, pkgfound, update_pkgdep;
71 assert(reqpkg != NULL);
73 add_pkgdep = update_pkgdep = pkgfound =
false;
74 mdeps = prop_dictionary_get(xhp->
transd,
"missing_deps");
76 reqpkg_str = prop_string_create_cstring_nocopy(reqpkg);
77 if (reqpkg_str == NULL)
80 iter = prop_array_iterator(mdeps);
84 while ((obj = prop_object_iterator_next(iter)) != NULL) {
85 const char *curdep, *curver, *pkgver;
86 char *curpkgnamedep = NULL, *pkgnamedep = NULL;
88 assert(prop_object_type(obj) == PROP_TYPE_STRING);
89 curdep = prop_string_cstring_nocopy(obj);
92 if (curver == NULL || pkgver == NULL)
95 if (curpkgnamedep == NULL)
98 if (pkgnamedep == NULL) {
102 if (strcmp(pkgnamedep, curpkgnamedep) == 0) {
104 if (strcmp(curver, pkgver) == 0) {
114 xbps_dbg_printf(xhp,
"Missing pkgdep name matched, "
115 "curver: %s newver: %s\n", curver, pkgver);
123 update_pkgdep =
true;
135 prop_object_iterator_release(iter);
137 prop_array_remove(mdeps, idx);
138 if (add_pkgdep && !xbps_add_obj_to_array(mdeps, reqpkg_str)) {
139 prop_object_release(reqpkg_str);
146 #define MAX_DEPTH 512
150 prop_array_t unsorted,
151 prop_array_t pkg_rdeps_array,
155 prop_dictionary_t curpkgd, tmpd;
157 prop_object_iterator_t iter;
158 prop_array_t curpkgrdeps;
161 const char *reqpkg, *pkgver_q, *reason = NULL;
165 if (*depth >= MAX_DEPTH)
172 iter = prop_array_iterator(pkg_rdeps_array);
175 while ((obj = prop_object_iterator_next(iter))) {
176 reqpkg = prop_string_cstring_nocopy(obj);
177 if (xhp->
flags & XBPS_FLAG_DEBUG) {
178 xbps_dbg_printf(xhp,
"");
179 for (x = 0; x < *depth; x++)
180 xbps_dbg_printf_append(xhp,
" ");
181 xbps_dbg_printf_append(xhp,
"%s: requires dependency '%s': ",
182 curpkg != NULL ? curpkg :
" ", reqpkg);
186 xbps_dbg_printf(xhp,
"can't guess pkgname for %s\n",
198 if (errno && errno != ENOENT) {
201 xbps_dbg_printf(xhp,
"failed to find "
202 "installed pkg for `%s': %s\n",
203 reqpkg, strerror(errno));
207 xbps_dbg_printf_append(xhp,
"not installed ");
209 state = XBPS_PKG_STATE_NOT_INSTALLED;
216 prop_dictionary_get_cstring_nocopy(tmpd,
217 "pkgver", &pkgver_q);
228 xbps_dbg_printf_append(xhp,
229 "[virtual] satisfied by "
230 "`%s'.\n", pkgver_q);
239 xbps_dbg_printf_append(xhp,
241 "must be updated.\n", pkgver_q);
243 }
else if (rv == 1) {
245 if (state == XBPS_PKG_STATE_UNPACKED) {
251 xbps_dbg_printf_append(xhp,
253 ", must be configured.\n",
255 reason =
"configure";
256 }
else if (state == XBPS_PKG_STATE_INSTALLED) {
262 xbps_dbg_printf_append(xhp,
264 "`%s'.\n", pkgver_q);
269 xbps_dbg_printf(xhp,
"failed to match "
270 "pattern %s with %s\n", reqpkg, pkgver_q);
278 if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg)) ||
279 (curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg))) {
280 prop_dictionary_get_cstring_nocopy(curpkgd,
281 "pkgver", &pkgver_q);
282 xbps_dbg_printf_append(xhp,
" (%s queued)\n", pkgver_q);
293 if (errno && errno != ENOENT) {
294 xbps_dbg_printf(xhp,
"failed to find pkg "
295 "for `%s' in rpool: %s\n",
296 reqpkg, strerror(errno));
300 rv = add_missing_reqdep(xhp, reqpkg);
301 if (rv != 0 && rv != EEXIST) {
302 xbps_dbg_printf_append(xhp,
"`%s': "
303 "add_missing_reqdep failed %s\n",
306 }
else if (rv == EEXIST) {
307 xbps_dbg_printf_append(xhp,
"`%s' missing "
308 "dep already added.\n", reqpkg);
312 xbps_dbg_printf_append(xhp,
"`%s' added "
313 "into the missing deps array.\n",
318 prop_dictionary_get_cstring_nocopy(curpkgd,
319 "pkgver", &pkgver_q);
323 xbps_pkg_find_conflicts(xhp, unsorted, curpkgd);
327 prop_dictionary_set_cstring_nocopy(curpkgd,
"transaction", reason);
328 rv = store_dependency(xhp, unsorted, curpkgd, state);
330 xbps_dbg_printf(xhp,
"store_dependency failed for "
331 "`%s': %s\n", reqpkg, strerror(rv));
337 curpkgrdeps = prop_dictionary_get(curpkgd,
"run_depends");
338 if (curpkgrdeps == NULL)
341 if (xhp->
flags & XBPS_FLAG_DEBUG) {
342 xbps_dbg_printf(xhp,
"");
343 for (x = 0; x < *depth; x++)
344 xbps_dbg_printf_append(xhp,
" ");
346 xbps_dbg_printf_append(xhp,
347 "%s: finding dependencies:\n", pkgver_q);
353 rv = find_repo_deps(xhp, unsorted, curpkgrdeps,
356 xbps_dbg_printf(xhp,
"Error checking %s for rundeps: %s\n",
357 reqpkg, strerror(rv));
361 prop_object_iterator_release(iter);
369 prop_array_t unsorted,
370 prop_dictionary_t repo_pkgd)
372 prop_array_t pkg_rdeps;
376 pkg_rdeps = prop_dictionary_get(repo_pkgd,
"run_depends");
377 if (prop_object_type(pkg_rdeps) != PROP_TYPE_ARRAY)
379 else if (prop_array_count(pkg_rdeps) == 0)
382 prop_dictionary_get_cstring_nocopy(repo_pkgd,
"pkgver", &pkgver);
383 xbps_dbg_printf(xhp,
"Finding required dependencies for '%s':\n", pkgver);
388 return find_repo_deps(xhp, unsorted, pkg_rdeps, pkgver, &depth);