32 #include "xbps_api_impl.h"
58 prop_dictionary_t pkg_metad;
59 prop_object_iterator_t iter;
61 uint64_t tsize, dlsize, instsize, rmsize;
62 uint32_t inst_pkgcnt, up_pkgcnt, cf_pkgcnt, rm_pkgcnt;
64 const char *tract, *pkgname, *repo;
66 inst_pkgcnt = up_pkgcnt = cf_pkgcnt = rm_pkgcnt = 0;
67 tsize = dlsize = instsize = rmsize = 0;
73 while ((obj = prop_object_iterator_next(iter)) != NULL) {
78 prop_dictionary_get_cstring_nocopy(obj,
"pkgname", &pkgname);
79 prop_dictionary_get_cstring_nocopy(obj,
"transaction", &tract);
80 prop_dictionary_get_cstring_nocopy(obj,
"repository", &repo);
82 if (strcmp(tract,
"configure") == 0) {
85 }
else if (strcmp(tract,
"install") == 0) {
87 }
else if (strcmp(tract,
"update") == 0) {
89 }
else if (strcmp(tract,
"remove") == 0) {
98 if ((strcmp(tract,
"remove") == 0) ||
99 (strcmp(tract,
"update") == 0)) {
101 if (pkg_metad == NULL)
103 prop_dictionary_get_uint64(pkg_metad,
104 "installed_size", &tsize);
107 if ((strcmp(tract,
"install") == 0) ||
108 (strcmp(tract,
"update") == 0)) {
109 prop_dictionary_get_uint64(obj,
110 "installed_size", &tsize);
113 prop_dictionary_get_uint64(obj,
114 "filename-size", &tsize);
121 !prop_dictionary_set_uint32(xhp->
transd,
"total-install-pkgs",
127 !prop_dictionary_set_uint32(xhp->
transd,
"total-update-pkgs",
133 !prop_dictionary_set_uint32(xhp->
transd,
"total-configure-pkgs",
139 !prop_dictionary_set_uint32(xhp->
transd,
"total-remove-pkgs",
145 if (instsize > rmsize) {
148 }
else if (rmsize > instsize) {
152 instsize = rmsize = 0;
158 if (!prop_dictionary_set_uint64(xhp->
transd,
159 "total-installed-size", instsize)) {
167 if (!prop_dictionary_set_uint64(xhp->
transd,
168 "total-download-size", dlsize)) {
176 if (!prop_dictionary_set_uint64(xhp->
transd,
177 "total-removed-size", rmsize)) {
182 prop_object_iterator_release(iter);
190 prop_array_t unsorted, mdeps, conflicts;
195 if ((xhp->
transd = prop_dictionary_create()) == NULL)
198 if ((unsorted = prop_array_create()) == NULL) {
199 prop_object_release(xhp->
transd);
203 if (!xbps_add_obj_to_dict(xhp->
transd, unsorted,
"unsorted_deps")) {
204 prop_object_release(xhp->
transd);
208 if ((mdeps = prop_array_create()) == NULL) {
209 prop_object_release(xhp->
transd);
213 if (!xbps_add_obj_to_dict(xhp->
transd, mdeps,
"missing_deps")) {
214 prop_object_release(xhp->
transd);
218 if ((conflicts = prop_array_create()) == NULL) {
219 prop_object_release(xhp->
transd);
223 if (!xbps_add_obj_to_dict(xhp->
transd, conflicts,
"conflicts")) {
224 prop_object_release(xhp->
transd);
235 prop_array_t mdeps, conflicts;
244 mdeps = prop_dictionary_get(xhp->
transd,
"missing_deps");
245 if (prop_array_count(mdeps) > 0)
251 conflicts = prop_dictionary_get(xhp->
transd,
"conflicts");
252 if (prop_array_count(conflicts) > 0)
258 if ((rv = xbps_transaction_package_replace(xhp)) != 0) {
259 prop_object_release(xhp->
transd);
266 if ((rv = xbps_transaction_sort(xhp)) != 0) {
267 prop_object_release(xhp->
transd);
276 if ((rv = compute_transaction_stats(xhp)) != 0) {
277 prop_object_release(xhp->
transd);
284 prop_dictionary_remove(xhp->
transd,
"missing_deps");
285 prop_dictionary_remove(xhp->
transd,
"conflicts");
286 prop_dictionary_make_immutable(xhp->
transd);