33 #include "xbps_api_impl.h"
61 trans_find_pkg(
struct xbps_handle *xhp,
const char *pkg,
int action)
63 prop_dictionary_t pkg_pkgdb, pkg_repod;
64 prop_array_t unsorted;
65 const char *pkgname, *repoloc, *repover, *repopkgver, *instver, *reason;
74 if (action == TRANS_INSTALL) {
91 prop_dictionary_get_cstring_nocopy(pkg_repod,
"pkgname", &pkgname);
92 prop_dictionary_get_cstring_nocopy(pkg_repod,
"version", &repover);
93 prop_dictionary_get_cstring_nocopy(pkg_repod,
"pkgver", &repopkgver);
94 prop_dictionary_get_cstring_nocopy(pkg_repod,
"repository", &repoloc);
96 if (action == TRANS_UPDATE) {
100 prop_dictionary_get_cstring_nocopy(pkg_pkgdb,
101 "version", &instver);
103 xbps_dbg_printf(xhp,
"[rpool] Skipping `%s-%s' "
104 "(installed: %s-%s) from repository `%s'\n",
105 pkgname, repover, pkgname, instver, repoloc);
112 if ((rv = xbps_transaction_init(xhp)) != 0)
115 unsorted = prop_dictionary_get(xhp->
transd,
"unsorted_deps");
119 xbps_pkg_find_conflicts(xhp, unsorted, pkg_repod);
125 if (action == TRANS_UPDATE) {
126 if (xbps_find_pkg_in_array(unsorted, repopkgver)) {
127 xbps_dbg_printf(xhp,
"[update] `%s' already queued in "
128 "transaction.\n", repopkgver);
133 if ((rv = xbps_repository_find_deps(xhp, unsorted, pkg_repod)) != 0)
143 state = XBPS_PKG_STATE_NOT_INSTALLED;
148 if (state == XBPS_PKG_STATE_UNPACKED)
149 reason =
"configure";
150 else if (state == XBPS_PKG_STATE_NOT_INSTALLED)
157 if (!prop_dictionary_set_cstring_nocopy(pkg_repod,
158 "transaction", reason))
165 if (!prop_array_add(unsorted, pkg_repod))
168 xbps_dbg_printf(xhp,
"%s-%s: added into the transaction (%s).\n",
169 pkgname, repover, repoloc);
178 prop_object_iterator_t iter;
179 const char *pkgname, *holdpkg;
180 bool foundhold =
false, newpkg_found =
false;
184 if ((rv = xbps_pkgdb_init(xhp)) != 0)
187 iter = prop_array_iterator(xhp->pkgdb);
190 while ((obj = prop_object_iterator_next(iter))) {
191 prop_dictionary_get_cstring_nocopy(obj,
"pkgname", &pkgname);
193 for (x = 0; x < cfg_size(xhp->cfg,
"PackagesOnHold"); x++) {
194 holdpkg = cfg_getnstr(xhp->cfg,
"PackagesOnHold", x);
195 if ((strcmp(holdpkg, pkgname) == 0) ||
196 (fnmatch(holdpkg, pkgname, FNM_PERIOD) == 0)) {
197 xbps_dbg_printf(xhp,
"[rpool] package `%s' "
198 "on hold, ignoring updates.\n", pkgname);
207 rv = trans_find_pkg(xhp, pkgname, TRANS_UPDATE);
210 else if (rv == ENOENT || rv == EEXIST || rv == ENODEV) {
218 prop_object_iterator_release(iter);
220 return newpkg_found ? rv : EEXIST;
226 return trans_find_pkg(xhp, pkg, TRANS_UPDATE);
233 prop_dictionary_t pkgd = NULL;
240 if ((state == XBPS_PKG_STATE_INSTALLED) && !reinstall) {
246 return trans_find_pkg(xhp, pkg, TRANS_INSTALL);
254 prop_dictionary_t pkgd;
255 prop_array_t unsorted, orphans, orphans_pkg, reqby;
261 assert(pkgname != NULL);
270 if ((rv = xbps_transaction_init(xhp)) != 0)
273 unsorted = prop_dictionary_get(xhp->
transd,
"unsorted_deps");
281 if ((orphans_pkg = prop_array_create()) == NULL)
284 prop_array_set_cstring_nocopy(orphans_pkg, 0, pkgname);
286 prop_object_release(orphans_pkg);
287 if (prop_object_type(orphans) != PROP_TYPE_ARRAY)
290 count = prop_array_count(orphans);
292 obj = prop_array_get(orphans, count);
293 prop_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver);
294 prop_dictionary_set_cstring_nocopy(obj,
"transaction",
"remove");
295 prop_array_add(unsorted, obj);
296 xbps_dbg_printf(xhp,
"%s: added into transaction (remove).\n", pkgver);
298 prop_object_release(orphans);
303 prop_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver);
304 prop_dictionary_set_cstring_nocopy(pkgd,
"transaction",
"remove");
305 prop_array_add(unsorted, pkgd);
306 xbps_dbg_printf(xhp,
"%s: added into transaction (remove).\n", pkgver);
312 if ((prop_object_type(reqby) == PROP_TYPE_ARRAY) &&
313 (prop_array_count(reqby) > 0))
322 prop_array_t orphans, unsorted;
329 if (prop_object_type(orphans) != PROP_TYPE_ARRAY)
332 count = prop_array_count(orphans);
341 if ((rv = xbps_transaction_init(xhp)) != 0)
344 unsorted = prop_dictionary_get(xhp->
transd,
"unsorted_deps");
349 obj = prop_array_get(orphans, count);
350 prop_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver);
351 prop_dictionary_set_cstring_nocopy(obj,
352 "transaction",
"remove");
353 prop_array_add(unsorted, obj);
354 xbps_dbg_printf(xhp,
"%s: added (remove).\n", pkgver);
358 prop_object_release(orphans);