32#include "xbps_api_impl.h"
50static struct item *items = NULL;
51static xbps_array_t result;
54lookupItem(
const char *pkgn)
56 struct item *item = NULL;
60 HASH_FIND_STR(items, pkgn, item);
65addItem(xbps_array_t rdeps,
const char *pkgn,
const char *pkgver)
67 struct item *item = NULL;
72 HASH_FIND_STR(items, pkgn, item);
76 item = malloc(
sizeof(*item));
78 item->pkgn = strdup(pkgn);
79 item->pkgver = pkgver;
82 HASH_ADD_KEYPTR(hh, items, item->pkgn, strlen(pkgn), item);
88addDepn(
struct item *item,
struct item *xitem)
90 struct depn *depn = calloc(1,
sizeof(*depn));
97 depn->dnext = xitem->dbase;
102add_deps_recursive(
struct item *item,
bool first)
110 for (dep = item->dbase; dep; dep = dep->dnext)
111 add_deps_recursive(dep->item,
false);
116 str = xbps_string_create_cstring(item->pkgver);
118 xbps_array_add_first(result, str);
119 xbps_object_release(str);
125 struct item *item, *itmp;
127 HASH_ITER(hh, items, item, itmp) {
128 HASH_DEL(items, item);
140ordered_depends(
struct xbps_handle *xhp, xbps_dictionary_t pkgd,
bool rpool,
143 xbps_array_t rdeps, provides;
145 struct item *item = NULL, *xitem = NULL;
146 const char *pkgver = NULL, *pkgname = NULL;
151 rdeps = xbps_dictionary_get(pkgd,
"run_depends");
152 provides = xbps_dictionary_get(pkgd,
"provides");
153 xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgname", &pkgname);
155 item = lookupItem(pkgname);
157 add_deps_recursive(item, depth == 0);
161 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver)) {
165 item = addItem(rdeps, pkgname, pkgver);
168 for (
unsigned int i = 0; i < xbps_array_count(rdeps); i++) {
169 xbps_dictionary_t curpkgd;
170 const char *curdep = NULL;
171 char curdepname[XBPS_NAME_SIZE];
173 xbps_array_get_cstring_nocopy(rdeps, i, &curdep);
184 if (curpkgd == NULL) {
186 xbps_dbg_printf(
"%s: missing dependency '%s'\n", pkgver, curdep);
196 xbps_dbg_printf(
"%s: ignoring dependency %s "
197 "already in provides\n", pkgver, curdep);
200 xitem = lookupItem(curdepname);
202 add_deps_recursive(xitem,
false);
205 xitem = ordered_depends(xhp, curpkgd, rpool, depth+1);
208 xbps_dbg_printf(
"%s: missing dependency '%s'\n", pkgver, curdep);
213 addDepn(item, xitem);
217 str = xbps_string_create_cstring(item->pkgver);
219 xbps_array_add_first(result, str);
220 xbps_object_release(str);
226xbps_get_pkg_fulldeptree(
struct xbps_handle *xhp,
const char *pkg,
bool rpool)
228 xbps_dictionary_t pkgd;
230 result = xbps_array_create();
242 if (ordered_depends(xhp, pkgd, rpool, 0) == NULL)
Generic XBPS structure handler for initialization.
xbps_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
xbps_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg)
bool xbps_match_pkgname_in_array(xbps_array_t array, const char *pkgname)
bool xbps_match_string_in_array(xbps_array_t array, const char *val)
xbps_dictionary_t xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
xbps_dictionary_t xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg)
bool xbps_pkg_name(char *dst, size_t len, const char *pkg)
bool xbps_pkgpattern_name(char *dst, size_t len, const char *pattern)