Improve stats in the transaction dictionary.
This commit is contained in:
parent
ec6f7a3013
commit
cc19818680
@ -114,29 +114,33 @@ show_transaction_sizes(struct transaction *trans, int cols)
|
|||||||
/*
|
/*
|
||||||
* Show the list of packages that will be installed.
|
* Show the list of packages that will be installed.
|
||||||
*/
|
*/
|
||||||
if (xbps_dictionary_get_uint32(trans->d, "total-install-pkgs",
|
xbps_dictionary_get_uint32(trans->d, "total-install-pkgs",
|
||||||
&trans->inst_pkgcnt)) {
|
&trans->inst_pkgcnt);
|
||||||
|
if (trans->inst_pkgcnt) {
|
||||||
printf("%u package%s will be installed:\n",
|
printf("%u package%s will be installed:\n",
|
||||||
trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s");
|
trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "install", cols);
|
show_package_list(trans->iter, "install", cols);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (xbps_dictionary_get_uint32(trans->d, "total-update-pkgs",
|
xbps_dictionary_get_uint32(trans->d, "total-update-pkgs",
|
||||||
&trans->up_pkgcnt)) {
|
&trans->up_pkgcnt);
|
||||||
|
if (trans->up_pkgcnt) {
|
||||||
printf("%u package%s will be updated:\n",
|
printf("%u package%s will be updated:\n",
|
||||||
trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s");
|
trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "update", cols);
|
show_package_list(trans->iter, "update", cols);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (xbps_dictionary_get_uint32(trans->d, "total-configure-pkgs",
|
xbps_dictionary_get_uint32(trans->d, "total-configure-pkgs",
|
||||||
&trans->cf_pkgcnt)) {
|
&trans->cf_pkgcnt);
|
||||||
|
if (trans->cf_pkgcnt) {
|
||||||
printf("%u package%s will be configured:\n",
|
printf("%u package%s will be configured:\n",
|
||||||
trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s");
|
trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "configure", cols);
|
show_package_list(trans->iter, "configure", cols);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (xbps_dictionary_get_uint32(trans->d, "total-remove-pkgs",
|
xbps_dictionary_get_uint32(trans->d, "total-remove-pkgs",
|
||||||
&trans->rm_pkgcnt)) {
|
&trans->rm_pkgcnt);
|
||||||
|
if (trans->rm_pkgcnt) {
|
||||||
printf("%u package%s will be removed:\n",
|
printf("%u package%s will be removed:\n",
|
||||||
trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s");
|
trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "remove", cols);
|
show_package_list(trans->iter, "remove", cols);
|
||||||
@ -158,15 +162,15 @@ show_transaction_sizes(struct transaction *trans, int cols)
|
|||||||
"%s\n", strerror(errno));
|
"%s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf("Total download size:\t%6s\n", size);
|
printf("Size to download: %6s\n", size);
|
||||||
}
|
}
|
||||||
if (instsize) {
|
if (instsize) {
|
||||||
if (xbps_humanize_number(size, (int64_t)(instsize+dlsize)) == -1) {
|
if (xbps_humanize_number(size, (int64_t)instsize) == -1) {
|
||||||
xbps_error_printf("humanize_number2 returns "
|
xbps_error_printf("humanize_number2 returns "
|
||||||
"%s\n", strerror(errno));
|
"%s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf("Total installed size:\t%6s\n", size);
|
printf("Size required on disk: %6s\n", size);
|
||||||
}
|
}
|
||||||
if (rmsize) {
|
if (rmsize) {
|
||||||
if (xbps_humanize_number(size, (int64_t)rmsize) == -1) {
|
if (xbps_humanize_number(size, (int64_t)rmsize) == -1) {
|
||||||
@ -174,7 +178,7 @@ show_transaction_sizes(struct transaction *trans, int cols)
|
|||||||
"%s\n", strerror(errno));
|
"%s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf("Total freed size:\t%6s\n", size);
|
printf("Size freed on disk: %6s\n", size);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
@ -90,6 +90,18 @@ compute_transaction_stats(struct xbps_handle *xhp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tsize = 0;
|
tsize = 0;
|
||||||
|
if ((strcmp(tract, "install") == 0) ||
|
||||||
|
(strcmp(tract, "update") == 0)) {
|
||||||
|
xbps_dictionary_get_uint64(obj,
|
||||||
|
"installed_size", &tsize);
|
||||||
|
instsize += tsize;
|
||||||
|
if (xbps_repository_is_remote(repo)) {
|
||||||
|
xbps_dictionary_get_uint64(obj,
|
||||||
|
"filename-size", &tsize);
|
||||||
|
dlsize += tsize;
|
||||||
|
instsize += tsize;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* If removing or updating a package, get installed_size
|
* If removing or updating a package, get installed_size
|
||||||
* from pkg's metadata dictionary.
|
* from pkg's metadata dictionary.
|
||||||
@ -108,39 +120,32 @@ compute_transaction_stats(struct xbps_handle *xhp)
|
|||||||
"installed_size", &tsize);
|
"installed_size", &tsize);
|
||||||
rmsize += tsize;
|
rmsize += tsize;
|
||||||
}
|
}
|
||||||
if ((strcmp(tract, "install") == 0) ||
|
|
||||||
(strcmp(tract, "update") == 0)) {
|
|
||||||
xbps_dictionary_get_uint64(obj,
|
|
||||||
"installed_size", &tsize);
|
|
||||||
instsize += tsize;
|
|
||||||
if (xbps_repository_is_remote(repo)) {
|
|
||||||
xbps_dictionary_get_uint64(obj,
|
|
||||||
"filename-size", &tsize);
|
|
||||||
dlsize += tsize;
|
|
||||||
instsize += tsize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
xbps_object_iterator_release(iter);
|
xbps_object_iterator_release(iter);
|
||||||
|
|
||||||
if (inst_pkgcnt && !xbps_dictionary_set_uint32(xhp->transd,
|
if (instsize > rmsize) {
|
||||||
|
instsize -= rmsize;
|
||||||
|
rmsize = 0;
|
||||||
|
} else if (rmsize > instsize) {
|
||||||
|
rmsize -= instsize;
|
||||||
|
instsize = 0;
|
||||||
|
} else {
|
||||||
|
instsize = rmsize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
||||||
"total-install-pkgs", inst_pkgcnt))
|
"total-install-pkgs", inst_pkgcnt))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (up_pkgcnt && !xbps_dictionary_set_uint32(xhp->transd,
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
||||||
"total-update-pkgs", up_pkgcnt))
|
"total-update-pkgs", up_pkgcnt))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (cf_pkgcnt && !xbps_dictionary_set_uint32(xhp->transd,
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
||||||
"total-configure-pkgs", cf_pkgcnt))
|
"total-configure-pkgs", cf_pkgcnt))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (rm_pkgcnt && !xbps_dictionary_set_uint32(xhp->transd,
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
||||||
"total-remove-pkgs", rm_pkgcnt))
|
"total-remove-pkgs", rm_pkgcnt))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
if (instsize)
|
|
||||||
instsize -= rmsize;
|
|
||||||
if (rmsize)
|
|
||||||
rmsize -= instsize;
|
|
||||||
|
|
||||||
if (!xbps_dictionary_set_uint64(xhp->transd,
|
if (!xbps_dictionary_set_uint64(xhp->transd,
|
||||||
"total-installed-size", instsize))
|
"total-installed-size", instsize))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user