31#include "xbps_api_impl.h"
34xbps_transaction_store(
struct xbps_handle *xhp, xbps_array_t pkgs,
35 xbps_dictionary_t pkgrd,
bool autoinst)
37 xbps_dictionary_t d, pkgd;
38 xbps_array_t replaces;
39 const char *pkgver, *pkgname, *curpkgver, *repo;
47 if (!xbps_dictionary_get_cstring_nocopy(pkgrd,
"pkgver", &pkgver)) {
50 if (!xbps_dictionary_get_cstring_nocopy(pkgrd,
"pkgname", &pkgname)) {
53 d = xbps_find_pkg_in_array(pkgs, pkgname, 0);
54 if (xbps_object_type(d) == XBPS_TYPE_DICTIONARY) {
56 if (!xbps_dictionary_get_cstring_nocopy(d,
"pkgver", &curpkgver)) {
60 if (rv == 0 || rv == -1) {
68 if (!xbps_remove_pkg_from_array_by_pkgver(pkgs, curpkgver)) {
71 xbps_dbg_printf(
"[trans] replaced %s with %s\n", curpkgver, pkgver);
75 if ((pkgd = xbps_dictionary_copy_mutable(pkgrd)) == NULL)
81 if (autoinst && !xbps_dictionary_set_bool(pkgd,
"automatic-install",
true))
87 if ((replaces = xbps_dictionary_get(pkgd,
"replaces")) == NULL)
88 replaces = xbps_array_create();
91 xbps_array_add_cstring(replaces, self_replaced);
94 if (!xbps_dictionary_set(pkgd,
"replaces", replaces))
100 if (!xbps_array_add(pkgs, pkgd))
103 xbps_dictionary_get_cstring_nocopy(pkgd,
"repository", &repo);
105 xbps_set_cb_state(xhp, XBPS_STATE_TRANS_ADDPKG, 0, pkgver,
106 "Found %s in repository %s", pkgver, repo);
108 xbps_dbg_printf(
"[trans] `%s' stored%s (%s)\n", pkgver,
109 autoinst ?
" as automatic install" :
"", repo);
110 xbps_object_release(pkgd);
114 xbps_object_release(pkgd);
Generic XBPS structure handler for initialization.
char * xbps_xasprintf(const char *fmt,...) __attribute__((format(printf
int xbps_cmpver(const char *pkg1, const char *pkg2)