33#include "xbps_api_impl.h"
56trans_find_pkg(
struct xbps_handle *xhp,
const char *pkg,
bool force)
58 xbps_dictionary_t pkg_pkgdb = NULL, pkg_repod = NULL;
63 const char *repoloc, *repopkgver, *instpkgver, *pkgname;
64 char buf[XBPS_NAME_SIZE] = {0};
65 bool autoinst =
false;
79 if (xhp->
flags & XBPS_FLAG_DOWNLOAD_ONLY) {
81 ttype = XBPS_TRANS_DOWNLOAD;
87 if (pkg_pkgdb == NULL) {
89 ttype = XBPS_TRANS_INSTALL;
97 ttype = XBPS_TRANS_REINSTALL;
99 ttype = XBPS_TRANS_UPDATE;
101 if (xbps_dictionary_get(pkg_pkgdb,
"repolock")) {
123 if (
ttype == XBPS_TRANS_UPDATE) {
128 xbps_dictionary_get_cstring_nocopy(
pkg_pkgdb,
132 xbps_dictionary_get_cstring_nocopy(
pkg_repod,
134 xbps_dbg_printf(
"[rpool] Skipping `%s' "
135 "(installed: %s) from repository `%s'\n",
139 }
else if (
ttype == XBPS_TRANS_REINSTALL) {
147 ttype = XBPS_TRANS_UPDATE;
155 if ((
obj = xbps_dictionary_get(
pkg_pkgdb,
"automatic-install")))
156 xbps_dictionary_set(
pkg_repod,
"automatic-install",
obj);
165 if ((
rv = xbps_transaction_init(
xhp)) != 0)
173 if (
ttype == XBPS_TRANS_UPDATE) {
175 xbps_dbg_printf(
"[update] `%s' already queued in "
181 if (!xbps_dictionary_get_cstring_nocopy(
pkg_repod,
"pkgname", &pkgname)) {
193 state = XBPS_PKG_STATE_NOT_INSTALLED;
199 if (state == XBPS_PKG_STATE_NOT_INSTALLED)
200 ttype = XBPS_TRANS_INSTALL;
203 ttype = XBPS_TRANS_HOLD;
215 if (
ttype == XBPS_TRANS_INSTALL)
232 xbps_dictionary_t pkgd;
233 const char *pkgver =
NULL, *pkgname =
NULL;
244 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver)) {
247 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgname", &pkgname)) {
251 rv = trans_find_pkg(
xhp, pkgname,
false);
253 xbps_dbg_printf(
"%s: trans_find_pkg xbps: %d\n",
__func__,
rv);
256 if (
xhp->
flags & XBPS_FLAG_DOWNLOAD_ONLY) {
261 for (
unsigned int i = 0;
i < xbps_array_count(rdeps);
i++) {
263 char curpkgn[XBPS_NAME_SIZE] = {0};
265 xbps_array_get_cstring_nocopy(rdeps,
i, &
curpkgver);
286 xhp->
flags |= XBPS_FLAG_FORCE_REMOVE_REVDEPS;
303 xbps_object_iterator_t
iter;
304 xbps_dictionary_t pkgd;
308 rv = xbps_autoupdate(
xhp);
323 while ((
obj = xbps_object_iterator_next(
iter))) {
324 const char *pkgver =
NULL;
325 char pkgname[XBPS_NAME_SIZE] = {0};
327 pkgd = xbps_dictionary_get_keysym(
xhp->
pkgdb,
obj);
328 if (!xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver)) {
335 rv = trans_find_pkg(
xhp, pkgname,
false);
336 xbps_dbg_printf(
"%s: trans_find_pkg %s: %d\n",
__func__, pkgver,
rv);
347 xbps_object_iterator_release(
iter);
358 rv = xbps_autoupdate(
xhp);
359 xbps_dbg_printf(
"%s: xbps_autoupdate %d\n",
__func__,
rv);
376 if (
xhp->
flags & XBPS_FLAG_DOWNLOAD_ONLY) {
379 for (
unsigned int i = 0;
i < xbps_array_count(rdeps);
i++) {
380 const char *pkgver =
NULL;
381 char pkgname[XBPS_NAME_SIZE] = {0};
383 if (!xbps_array_get_cstring_nocopy(rdeps,
i, &pkgver)) {
391 rv = trans_find_pkg(
xhp, pkgname,
false);
392 xbps_dbg_printf(
"%s: trans_find_pkg %s: %d\n",
__func__, pkgver,
rv);
399 xbps_dbg_printf(
"%s: trans_find_pkg %s: %d\n",
__func__,
pkg,
rv);
409 rv = xbps_autoupdate(
xhp);
426 if (
xhp->
flags & XBPS_FLAG_DOWNLOAD_ONLY) {
429 for (
unsigned int i = 0;
i < xbps_array_count(rdeps);
i++) {
430 const char *pkgver =
NULL;
431 char pkgname[XBPS_NAME_SIZE] = {0};
433 if (!xbps_array_get_cstring_nocopy(rdeps,
i, &pkgver)) {
441 rv = trans_find_pkg(
xhp, pkgname,
false);
442 xbps_dbg_printf(
"%s: trans_find_pkg %s: %d\n",
__func__, pkgver,
rv);
448 xbps_dbg_printf(
"%s: trans_find_pkg %s: %d\n",
__func__,
pkg,
rv);
457 xbps_dictionary_t pkgd;
472 if ((
rv = xbps_transaction_init(
xhp)) != 0)
486 xbps_array_set_cstring_nocopy(
orphans_pkg, 0, pkgname);
489 if (xbps_object_type(
orphans) != XBPS_TYPE_ARRAY)
492 for (
unsigned int i = 0;
i < xbps_array_count(
orphans);
i++) {
495 if (!xbps_transaction_store(
xhp,
pkgs,
obj,
false)) {
507 if (!xbps_transaction_store(
xhp,
pkgs, pkgd,
false)) {
521 if (xbps_array_count(
orphans) == 0) {
528 if ((
rv = xbps_transaction_init(
xhp)) != 0)
535 for (
unsigned int i = 0;
i < xbps_array_count(
orphans);
i++) {
538 if (!xbps_transaction_store(
xhp,
pkgs,
obj,
false)) {
555 if (xbps_object_type(
pkg_repod) != XBPS_TYPE_DICTIONARY)
558 if (!xbps_dictionary_get_uint8(
pkg_repod,
"transaction", &
r))
569 if (xbps_object_type(
pkg_repod) != XBPS_TYPE_DICTIONARY)
573 case XBPS_TRANS_INSTALL:
574 case XBPS_TRANS_UPDATE:
575 case XBPS_TRANS_CONFIGURE:
576 case XBPS_TRANS_REMOVE:
577 case XBPS_TRANS_REINSTALL:
578 case XBPS_TRANS_HOLD:
579 case XBPS_TRANS_DOWNLOAD:
585 if (!xbps_dictionary_set_uint8(
pkg_repod,
"transaction",
r))
Generic XBPS structure handler for initialization.
xbps_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans)
xbps_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
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)
int xbps_pkg_state_installed(struct xbps_handle *xhp, const char *pkgname, pkg_state_t *state)
int xbps_set_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t state)
xbps_dictionary_t xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg)
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)
xbps_trans_type_t xbps_transaction_pkg_type(xbps_dictionary_t pkg_repod)
int xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
int xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
int xbps_transaction_remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive)
bool xbps_transaction_pkg_type_set(xbps_dictionary_t pkg_repod, xbps_trans_type_t ttype)
int xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
int xbps_transaction_update_packages(struct xbps_handle *xhp)
bool xbps_pkg_name(char *dst, size_t len, const char *pkg)
bool xbps_pkg_reverts(xbps_dictionary_t pkg, const char *pkgver)
int xbps_cmpver(const char *pkg1, const char *pkg2)