31#include "xbps/xbps_array.h"
32#include "xbps_api_impl.h"
35pkg_conflicts_trans(
struct xbps_handle *xhp, xbps_array_t array,
36 xbps_dictionary_t pkg_repod)
38 xbps_array_t pkg_cflicts, trans_cflicts;
39 xbps_dictionary_t pkgd, tpkgd;
41 const char *repopkgver, *repopkgname;
48 pkg_cflicts = xbps_dictionary_get(pkg_repod,
"conflicts");
49 if (xbps_array_count(pkg_cflicts) == 0)
53 if (ttype == XBPS_TRANS_HOLD || ttype == XBPS_TRANS_REMOVE)
56 trans_cflicts = xbps_dictionary_get(xhp->
transd,
"conflicts");
57 if (!xbps_dictionary_get_cstring_nocopy(pkg_repod,
"pkgver", &repopkgver))
59 if (!xbps_dictionary_get_cstring_nocopy(pkg_repod,
"pkgname", &repopkgname))
62 for (
unsigned int i = 0; i < xbps_array_count(pkg_cflicts); i++) {
63 const char *pkgver = NULL, *pkgname = NULL, *cfpkg = NULL;
65 if (!xbps_array_get_cstring_nocopy(pkg_cflicts, i, &cfpkg))
74 if (xbps_dictionary_get(pkgd,
"hold"))
78 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgname", &pkgname))
80 if (strcmp(pkgname, repopkgname) == 0) {
83 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver))
89 if ((tpkgd = xbps_find_pkg_in_array(array, pkgname, 0))) {
91 if (ttype == XBPS_TRANS_INSTALL ||
92 ttype == XBPS_TRANS_UPDATE ||
93 ttype == XBPS_TRANS_REMOVE ||
94 ttype == XBPS_TRANS_HOLD) {
99 "pkg %s with pkg in transaction %s "
100 "(matched by %s [trans])\n", pkgver, repopkgver, cfpkg);
102 "installed pkg %s (matched by %s)",
103 repopkgver, pkgver, cfpkg);
104 if (!xbps_array_add_cstring(trans_cflicts, buf))
111 if ((pkgd = xbps_find_pkg_in_array(array, cfpkg, 0)) ||
112 (pkgd = xbps_find_virtualpkg_in_array(xhp, array, cfpkg, 0))) {
115 if (ttype == XBPS_TRANS_REMOVE || ttype == XBPS_TRANS_HOLD)
118 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgname", &pkgname))
120 if (strcmp(pkgname, repopkgname) == 0)
122 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver))
125 "transaction %s <-> %s (matched by %s [trans])\n",
126 pkgver, repopkgver, cfpkg);
128 "%s in transaction (matched by %s)",
129 repopkgver, pkgver, cfpkg);
132 if (!xbps_array_add_cstring_nocopy(trans_cflicts, buf))
141pkgdb_conflicts_cb(
struct xbps_handle *xhp, xbps_object_t obj,
142 const char *key UNUSED,
void *arg,
bool *done UNUSED)
144 xbps_array_t pkg_cflicts, trans_cflicts, pkgs = arg;
145 xbps_dictionary_t pkgd;
147 const char *repopkgver, *repopkgname;
150 pkg_cflicts = xbps_dictionary_get(obj,
"conflicts");
151 if (xbps_array_count(pkg_cflicts) == 0)
154 if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &repopkgver))
156 if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgname", &repopkgname))
161 if (xbps_find_pkg_in_array(pkgs, repopkgname, 0))
164 trans_cflicts = xbps_dictionary_get(xhp->
transd,
"conflicts");
166 for (
unsigned int i = 0; i < xbps_array_count(pkg_cflicts); i++) {
167 const char *pkgver = NULL, *pkgname = NULL, *cfpkg = NULL;
169 if (!xbps_array_get_cstring_nocopy(pkg_cflicts, i, &cfpkg))
172 if ((pkgd = xbps_find_pkg_in_array(pkgs, cfpkg, 0)) ||
173 (pkgd = xbps_find_virtualpkg_in_array(xhp, pkgs, cfpkg, 0))) {
176 if (ttype == XBPS_TRANS_REMOVE || ttype == XBPS_TRANS_HOLD) {
180 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgname", &pkgname))
182 if (strcmp(pkgname, repopkgname) == 0) {
185 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver))
188 "transaction %s <-> %s (matched by %s [pkgdb])\n",
189 pkgver, repopkgver, cfpkg);
191 "%s in transaction (matched by %s)",
192 repopkgver, pkgver, cfpkg);
195 if (!xbps_array_add_cstring_nocopy(trans_cflicts, buf))
204xbps_transaction_check_conflicts(
struct xbps_handle *xhp, xbps_array_t pkgs)
210 for (
unsigned int i = 0; i < xbps_array_count(pkgs); i++) {
211 r = pkg_conflicts_trans(xhp, pkgs, xbps_array_get(pkgs, i));
223 array = xbps_dictionary_get(xhp->
transd,
"conflicts");
224 if (xbps_array_count(array) == 0)
225 xbps_dictionary_remove(xhp->
transd,
"conflicts");
Generic XBPS structure handler for initialization.
#define xbps_error_oom()
Log out of memory condition.
void xbps_dbg_printf(const char *fmt,...)
Prints debug messages to stderr.
int xbps_pkgdb_foreach_cb_multi(struct xbps_handle *xhp, int(*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *), void *arg)
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)
xbps_trans_type_t xbps_transaction_pkg_type(xbps_dictionary_t pkg_repod)
char * xbps_xasprintf(const char *fmt,...) __attribute__((format(printf