xbps-install: fix cnt stats and align issues in the column output mode.

- The counter stats were not taken into account.
- Align version/new version with pkgs that have long versions (chromium).
This commit is contained in:
Juan RP 2014-11-05 10:16:57 +01:00
parent 9566a0e737
commit 42bbc60154

View File

@ -103,14 +103,14 @@ print_trans_colmode(struct transaction *trans, int cols)
pnamelen = find_longest_pkgname(trans); pnamelen = find_longest_pkgname(trans);
/* header length */ /* header length */
hdrlen = 4 + pnamelen + 48; hdrlen = 4 + pnamelen + 60;
if (cols <= hdrlen) if (cols <= hdrlen)
return false; return false;
printf("Name"); printf("Name");
for (x = 4; x < pnamelen; x++) for (x = 4; x < pnamelen; x++)
printf(" "); printf(" ");
printf("Action Version New version Download size\n"); printf("Action Version New version Download size\n");
while ((obj = xbps_object_iterator_next(trans->iter)) != NULL) { while ((obj = xbps_object_iterator_next(trans->iter)) != NULL) {
xbps_dictionary_t ipkgd; xbps_dictionary_t ipkgd;
@ -128,6 +128,18 @@ print_trans_colmode(struct transaction *trans, int cols)
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
if (strcmp(tract, "install") == 0) {
trans->inst_pkgcnt++;
} else if (strcmp(tract, "update") == 0) {
trans->up_pkgcnt++;
} else if (strcmp(tract, "remove") == 0) {
trans->rm_pkgcnt++;
} else if (strcmp(tract, "configure") == 0) {
trans->cf_pkgcnt++;
}
if (dload) {
trans->dl_pkgcnt++;
}
if ((strcmp(tract, "update") == 0) || strcmp(tract, "remove") == 0) { if ((strcmp(tract, "update") == 0) || strcmp(tract, "remove") == 0) {
ipkgd = xbps_pkgdb_get_pkg(trans->xhp, pkgname); ipkgd = xbps_pkgdb_get_pkg(trans->xhp, pkgname);
assert(ipkgd); assert(ipkgd);
@ -144,7 +156,7 @@ print_trans_colmode(struct transaction *trans, int cols)
/* print action */ /* print action */
printf("%s ", tract); printf("%s ", tract);
for (x = strlen(tract); x < 7; x++) for (x = strlen(tract); x < 9; x++)
printf(" "); printf(" ");
/* print installed version */ /* print installed version */
@ -153,7 +165,7 @@ print_trans_colmode(struct transaction *trans, int cols)
/* print new version */ /* print new version */
printf("%s ", iver); printf("%s ", iver);
for (x = strlen(iver); x < 14; x++) for (x = strlen(iver); x < 17; x++)
printf(" "); printf(" ");
if (strcmp(tract, "remove") == 0) { if (strcmp(tract, "remove") == 0) {
@ -166,7 +178,7 @@ print_trans_colmode(struct transaction *trans, int cols)
size[1] = '\0'; size[1] = '\0';
} }
printf("%s ", ver); printf("%s ", ver);
for (x = strlen(ver); x < 18; x++) for (x = strlen(ver); x < 22; x++)
printf(" "); printf(" ");
/* print download size */ /* print download size */
printf("%s ", size); printf("%s ", size);