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));
79 item->pkgn = strdup(pkgn);
84 item->pkgver = pkgver;
87 HASH_ADD_KEYPTR(hh, items, item->pkgn, strlen(pkgn), item);
93addDepn(
struct item *item,
struct item *xitem)
95 struct depn *depn = calloc(1,
sizeof(*depn));
102 depn->dnext = xitem->dbase;
107add_deps_recursive(
struct item *item,
bool first)
115 for (dep = item->dbase; dep; dep = dep->dnext) {
116 int r = add_deps_recursive(dep->item,
false);
125 str = xbps_string_create_cstring(item->pkgver);
129 if (!xbps_array_add_first(result, str))
131 xbps_object_release(str);
138 struct item *item, *itmp;
140 HASH_ITER(hh, items, item, itmp) {
141 HASH_DEL(items, item);
153ordered_depends(
struct xbps_handle *xhp, xbps_dictionary_t pkgd,
bool rpool,
156 xbps_array_t rdeps, provides;
158 struct item *item = NULL, *xitem = NULL;
159 const char *pkgver = NULL, *pkgname = NULL;
164 rdeps = xbps_dictionary_get(pkgd,
"run_depends");
165 provides = xbps_dictionary_get(pkgd,
"provides");
166 xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgname", &pkgname);
168 item = lookupItem(pkgname);
170 int r = add_deps_recursive(item, depth == 0);
176 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver))
179 item = addItem(rdeps, pkgname, pkgver);
183 for (
unsigned int i = 0; i < xbps_array_count(rdeps); i++) {
184 xbps_dictionary_t curpkgd;
185 const char *curdep = NULL;
186 char curdepname[XBPS_NAME_SIZE];
188 xbps_array_get_cstring_nocopy(rdeps, i, &curdep);
199 if (curpkgd == NULL) {
211 "already in provides\n", pkgver, curdep);
214 xitem = lookupItem(curdepname);
216 add_deps_recursive(xitem,
false);
219 xitem = ordered_depends(xhp, curpkgd, rpool, depth+1);
222 addDepn(item, xitem);
226 str = xbps_string_create_cstring(item->pkgver);
231 xbps_array_add_first(result, str);
232 xbps_object_release(str);
238xbps_get_pkg_fulldeptree(
struct xbps_handle *xhp,
const char *pkg,
bool rpool)
240 xbps_dictionary_t pkgd;
242 result = xbps_array_create();
257 if (ordered_depends(xhp, pkgd, rpool, 0) == NULL)
Generic XBPS structure handler for initialization.
#define xbps_unreachable()
Log and abort for code that should be unreachable.
#define xbps_error_oom()
Log out of memory condition.
void xbps_dbg_printf(const char *fmt,...)
Prints debug messages to stderr.
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)