From 3f5b27006af3abc45d6edd01121a1959ab52f901 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 5 Nov 2014 10:22:55 +0100
Subject: [PATCH] xbps{,-static}: fix columnt output mode: cnt stats and
 alignment for long versions.

---
 srcpkgs/xbps-static/template                  |  2 +-
 ...-cnt-stats-and-align-issues-in-the-c.patch | 82 +++++++++++++++++++
 srcpkgs/xbps/template                         |  2 +-
 3 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xbps/patches/0009-xbps-install-fix-cnt-stats-and-align-issues-in-the-c.patch

diff --git a/srcpkgs/xbps-static/template b/srcpkgs/xbps-static/template
index 19fec0c7305..31c10010332 100644
--- a/srcpkgs/xbps-static/template
+++ b/srcpkgs/xbps-static/template
@@ -3,7 +3,7 @@
 # NOTE: keep this package synchronized with "srcpkgs/xbps".
 pkgname=xbps-static
 version=0.41
-revision=5
+revision=7
 bootstrap=yes
 build_style=configure
 short_desc="The XBPS package system utilities - static binaries"
diff --git a/srcpkgs/xbps/patches/0009-xbps-install-fix-cnt-stats-and-align-issues-in-the-c.patch b/srcpkgs/xbps/patches/0009-xbps-install-fix-cnt-stats-and-align-issues-in-the-c.patch
new file mode 100644
index 00000000000..a48bb0fc850
--- /dev/null
+++ b/srcpkgs/xbps/patches/0009-xbps-install-fix-cnt-stats-and-align-issues-in-the-c.patch
@@ -0,0 +1,82 @@
+From 42bbc601547b5342ddd5512e7b5e088284fe81c3 Mon Sep 17 00:00:00 2001
+From: Juan RP <xtraeme@gmail.com>
+Date: Wed, 5 Nov 2014 10:16:57 +0100
+Subject: [PATCH] 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).
+---
+ bin/xbps-install/util.c | 22 +++++++++++++++++-----
+ 1 file changed, 17 insertions(+), 5 deletions(-)
+
+diff --git a/bin/xbps-install/util.c b/bin/xbps-install/util.c
+index 3fb68a7..e10bba1 100644
+--- bin/xbps-install/util.c
++++ bin/xbps-install/util.c
+@@ -103,14 +103,14 @@ print_trans_colmode(struct transaction *trans, int cols)
+ 
+ 	pnamelen = find_longest_pkgname(trans);
+ 	/* header length */
+-	hdrlen = 4 + pnamelen + 48;
++	hdrlen = 4 + pnamelen + 60;
+ 	if (cols <= hdrlen)
+ 		return false;
+ 
+ 	printf("Name");
+ 	for (x = 4; x < pnamelen; x++)
+ 		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) {
+ 		xbps_dictionary_t ipkgd;
+@@ -128,6 +128,18 @@ print_trans_colmode(struct transaction *trans, int cols)
+ 		pkgname = xbps_pkg_name(pkgver);
+ 		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) {
+ 			ipkgd = xbps_pkgdb_get_pkg(trans->xhp, pkgname);
+ 			assert(ipkgd);
+@@ -144,7 +156,7 @@ print_trans_colmode(struct transaction *trans, int cols)
+ 
+ 		/* print action */
+ 		printf("%s ", tract);
+-		for (x = strlen(tract); x < 7; x++)
++		for (x = strlen(tract); x < 9; x++)
+ 			printf(" ");
+ 
+ 		/* print installed version */
+@@ -153,7 +165,7 @@ print_trans_colmode(struct transaction *trans, int cols)
+ 
+ 		/* print new version */
+ 		printf("%s ", iver);
+-		for (x = strlen(iver); x < 14; x++)
++		for (x = strlen(iver); x < 17; x++)
+ 			printf(" ");
+ 
+ 		if (strcmp(tract, "remove") == 0) {
+@@ -166,7 +178,7 @@ print_trans_colmode(struct transaction *trans, int cols)
+ 			size[1] = '\0';
+ 		}
+ 		printf("%s ", ver);
+-		for (x = strlen(ver); x < 18; x++)
++		for (x = strlen(ver); x < 22; x++)
+ 			printf(" ");
+ 		/* print download size */
+ 		printf("%s ", size);
+-- 
+2.1.3
+
diff --git a/srcpkgs/xbps/template b/srcpkgs/xbps/template
index 28b6329e12f..c3c6b1f3d7d 100644
--- a/srcpkgs/xbps/template
+++ b/srcpkgs/xbps/template
@@ -1,7 +1,7 @@
 # Template file for 'xbps'
 pkgname=xbps
 version=0.41
-revision=6
+revision=7
 bootstrap=yes
 build_style=configure
 short_desc="The XBPS package system utilities"