31#include "xbps_api_impl.h"
47shlib_register(xbps_dictionary_t d,
const char *shlib,
const char *pkgver)
52 if ((array = xbps_dictionary_get(d, shlib)) == NULL) {
54 array = xbps_array_create();
55 xbps_dictionary_set(d, shlib, array);
58 xbps_array_add_cstring_nocopy(array, pkgver);
60 xbps_object_release(array);
63static xbps_dictionary_t
64collect_shlibs(
struct xbps_handle *xhp, xbps_array_t pkgs,
bool req)
67 xbps_object_iterator_t iter;
68 xbps_dictionary_t d, pd;
69 const char *pkgname, *pkgver;
71 d = xbps_dictionary_create();
75 pd = xbps_dictionary_copy(xhp->
pkgdb);
82 iter = xbps_array_iterator(pkgs);
84 while ((obj = xbps_object_iterator_next(iter))) {
85 if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgname", &pkgname))
93 xbps_dictionary_set(pd, pkgname, obj);
95 xbps_object_iterator_release(iter);
100 iter = xbps_dictionary_iterator(pd);
103 while ((obj = xbps_object_iterator_next(iter))) {
105 xbps_dictionary_t pkgd;
107 pkgd = xbps_dictionary_get_keysym(pd, obj);
114 xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver);
115 shobjs = xbps_dictionary_get(pkgd,
116 req ?
"shlib-requires" :
"shlib-provides");
120 for (
unsigned int i = 0; i < xbps_array_count(shobjs); i++) {
121 const char *shlib = NULL;
123 xbps_array_get_cstring_nocopy(shobjs, i, &shlib);
124 xbps_dbg_printf(
"%s: registering %s for %s\n",
125 pkgver, shlib, req ?
"shlib-requires" :
"shlib-provides");
127 shlib_register(d, shlib, pkgver);
129 xbps_dictionary_set_cstring_nocopy(d, shlib, pkgver);
132 xbps_object_iterator_release(iter);
133 xbps_object_release(pd);
138xbps_transaction_check_shlibs(
struct xbps_handle *xhp, xbps_array_t pkgs)
140 xbps_array_t array, mshlibs;
141 xbps_object_t obj, obj2;
142 xbps_object_iterator_t iter;
143 xbps_dictionary_t shrequires, shprovides;
144 const char *pkgver = NULL, *shlib = NULL;
148 shrequires = collect_shlibs(xhp, pkgs,
true);
149 shprovides = collect_shlibs(xhp, pkgs,
false);
151 mshlibs = xbps_dictionary_get(xhp->
transd,
"missing_shlibs");
153 iter = xbps_dictionary_iterator(shrequires);
156 while ((obj = xbps_object_iterator_next(iter))) {
157 shlib = xbps_dictionary_keysym_cstring_nocopy(obj);
158 xbps_dbg_printf(
"%s: checking for `%s': ", __func__, shlib);
159 if ((obj2 = xbps_dictionary_get(shprovides, shlib))) {
160 xbps_dbg_printf_append(
"provided by `%s'\n",
161 xbps_string_cstring_nocopy(obj2));
164 xbps_dbg_printf_append(
"not found\n");
167 array = xbps_dictionary_get_keysym(shrequires, obj);
168 for (
unsigned int i = 0; i < xbps_array_count(array); i++) {
169 xbps_array_get_cstring_nocopy(array, i, &pkgver);
171 "shlib `%s'", pkgver, shlib);
172 xbps_array_add_cstring(mshlibs, buf);
176 xbps_object_iterator_release(iter);
178 xbps_dictionary_remove(xhp->
transd,
"missing_shlibs");
180 xbps_object_release(shprovides);
181 xbps_object_release(shrequires);
Generic XBPS structure handler for initialization.
bool xbps_match_string_in_array(xbps_array_t array, const char *val)
xbps_trans_type_t xbps_transaction_pkg_type(xbps_dictionary_t pkg_repod)
char * xbps_xasprintf(const char *fmt,...) __attribute__((format(printf