31#include "xbps_api_impl.h"
44check_virtual_pkgs(xbps_array_t mdeps,
45 xbps_dictionary_t trans_pkgd,
46 xbps_dictionary_t rev_pkgd)
49 xbps_array_t provides;
50 const char *pkgver, *vpkgver, *revpkgver, *pkgpattern;
51 char pkgname[XBPS_NAME_SIZE], vpkgname[XBPS_NAME_SIZE];
55 pkgver = vpkgver = revpkgver = pkgpattern = NULL;
56 provides = xbps_dictionary_get(trans_pkgd,
"provides");
58 for (
unsigned int i = 0; i < xbps_array_count(provides); i++) {
59 xbps_dictionary_get_cstring_nocopy(trans_pkgd,
"pkgver", &pkgver);
60 xbps_dictionary_get_cstring_nocopy(rev_pkgd,
"pkgver", &revpkgver);
61 xbps_array_get_cstring_nocopy(provides, i, &vpkgver);
67 rundeps = xbps_dictionary_get(rev_pkgd,
"run_depends");
68 for (
unsigned int x = 0; x < xbps_array_count(rundeps); x++) {
69 xbps_array_get_cstring_nocopy(rundeps, x, &pkgpattern);
75 if (strcmp(vpkgname, pkgname)) {
78 if (!strcmp(vpkgver, pkgpattern) ||
83 str =
xbps_xasprintf(
"%s broken, needs '%s' virtual pkg (got `%s')",
84 revpkgver, pkgpattern, vpkgver);
85 xbps_array_add_cstring(mdeps, str);
94broken_pkg(xbps_array_t mdeps,
const char *dep,
const char *pkg)
98 str =
xbps_xasprintf(
"%s in transaction breaks installed pkg `%s'", pkg, dep);
99 xbps_array_add_cstring(mdeps, str);
104xbps_transaction_check_revdeps(
struct xbps_handle *xhp, xbps_array_t pkgs)
109 mdeps = xbps_dictionary_get(xhp->
transd,
"missing_deps");
111 for (
unsigned int i = 0; i < xbps_array_count(pkgs); i++) {
112 xbps_array_t pkgrdeps, rundeps;
113 xbps_dictionary_t revpkgd;
116 const char *pkgver = NULL, *revpkgver = NULL;
117 char pkgname[XBPS_NAME_SIZE] = {0};
119 obj = xbps_array_get(pkgs, i);
124 if (ttype == XBPS_TRANS_HOLD) {
127 if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver)) {
147 if (!xbps_array_count(pkgrdeps)) {
160 for (
unsigned int x = 0; x < xbps_array_count(pkgrdeps); x++) {
161 const char *curpkgver = NULL;
162 char curdepname[XBPS_NAME_SIZE] = {0};
163 char curpkgname[XBPS_NAME_SIZE] = {0};
166 if (!xbps_array_get_cstring_nocopy(pkgrdeps, x, &curpkgver)) {
176 if ((revpkgd = xbps_find_pkg_in_array(pkgs, pkgname, 0))) {
184 xbps_dictionary_get_cstring_nocopy(revpkgd,
"pkgver", &revpkgver);
190 if (ttype == XBPS_TRANS_REMOVE) {
191 if (xbps_dictionary_get(obj,
"replaced")) {
194 if (xbps_find_pkg_in_array(pkgs, pkgname, XBPS_TRANS_REMOVE)) {
197 broken_pkg(mdeps, curpkgver, pkgver);
203 if (check_virtual_pkgs(mdeps, obj, revpkgd)) {
209 rundeps = xbps_dictionary_get(revpkgd,
"run_depends");
213 if (!
xbps_pkg_name(curpkgname,
sizeof(curpkgname), pkgver)) {
217 for (
unsigned int j = 0; j < xbps_array_count(rundeps); j++) {
218 const char *curdep = NULL;
220 xbps_array_get_cstring_nocopy(rundeps, j, &curdep);
225 if (strcmp(curdepname, curpkgname) == 0) {
243 if (xbps_find_pkg_in_array(pkgs, pkgname, XBPS_TRANS_UPDATE)) {
246 broken_pkg(mdeps, curpkgver, pkgver);
251 mdeps = xbps_dictionary_get(xhp->
transd,
"missing_deps");
252 if (xbps_array_count(mdeps) == 0)
253 xbps_dictionary_remove(xhp->
transd,
"missing_deps");
255 return error ? false :
true;
Generic XBPS structure handler for initialization.
xbps_array_t xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
xbps_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg)
bool xbps_match_pkgdep_in_array(xbps_array_t array, const char *pkgver)
xbps_trans_type_t xbps_transaction_pkg_type(xbps_dictionary_t pkg_repod)
char * xbps_xasprintf(const char *fmt,...) __attribute__((format(printf
bool xbps_pkg_name(char *dst, size_t len, const char *pkg)
bool xbps_pkg_is_ignored(struct xbps_handle *xhp, const char *pkg)
int xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg)
int xbps_pkgpattern_match(const char *pkgver, const char *pattern)
bool xbps_pkgpattern_name(char *dst, size_t len, const char *pattern)