xbps: add 2 patches from git master to not print ANSI codes if stdout isn't a tty.
This commit is contained in:
parent
182c4b0a46
commit
4ea71610fc
2 changed files with 85 additions and 1 deletions
srcpkgs/xbps
84
srcpkgs/xbps/patches/ansi_tty_fetch_cb.patch
Normal file
84
srcpkgs/xbps/patches/ansi_tty_fetch_cb.patch
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
From ca5aeebdc9fbbf5c74ad73e36ccea0ee6e7fbf7e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Mon, 10 Dec 2012 11:09:18 +0100
|
||||||
|
Subject: [PATCH 1/2] xbps-install: fetch_cb.c: do not print ANSI escape codes
|
||||||
|
if stdout isn't a tty.
|
||||||
|
|
||||||
|
---
|
||||||
|
bin/xbps-install/fetch_cb.c | 19 ++++++++++++++-----
|
||||||
|
1 file changed, 14 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bin/xbps-install/fetch_cb.c b/bin/xbps-install/fetch_cb.c
|
||||||
|
index 4b4d05a..3497e19 100644
|
||||||
|
--- bin/xbps-install/fetch_cb.c
|
||||||
|
+++ bin/xbps-install/fetch_cb.c
|
||||||
|
@@ -144,9 +144,14 @@ stat_display(struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||||
|
(double)xfpd->file_dloaded) / (double)xfpd->file_size);
|
||||||
|
(void)xbps_humanize_number(totsize, (int64_t)xfpd->file_size);
|
||||||
|
}
|
||||||
|
- fprintf(stderr, "%s: [%s %d%%] %s ETA: %s\033[K\r",
|
||||||
|
- xfpd->file_name, totsize, percentage,
|
||||||
|
- stat_bps(xfpd, xfer), stat_eta(xfpd, xfer));
|
||||||
|
+ if (isatty(fileno(stdout)))
|
||||||
|
+ printf("%s: [%s %d%%] %s ETA: %s\033[K\r",
|
||||||
|
+ xfpd->file_name, totsize, percentage,
|
||||||
|
+ stat_bps(xfpd, xfer), stat_eta(xfpd, xfer));
|
||||||
|
+ else
|
||||||
|
+ printf("%s: [%s %d%%] %s ETA: %s\n",
|
||||||
|
+ xfpd->file_name, totsize, percentage,
|
||||||
|
+ stat_bps(xfpd, xfer), stat_eta(xfpd, xfer));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -165,7 +170,11 @@ fetch_file_progress_cb(struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||||
|
} else if (xfpd->cb_end) {
|
||||||
|
/* end transfer stats */
|
||||||
|
(void)xbps_humanize_number(size, (int64_t)xfpd->file_dloaded);
|
||||||
|
- fprintf(stderr,"%s: %s [avg rate: %s]\033[K\n",
|
||||||
|
- xfpd->file_name, size, stat_bps(xfpd, xfer));
|
||||||
|
+ if (isatty(fileno(stdout)))
|
||||||
|
+ printf("%s: %s [avg rate: %s]\033[K\n",
|
||||||
|
+ xfpd->file_name, size, stat_bps(xfpd, xfer));
|
||||||
|
+ else
|
||||||
|
+ printf("%s: %s [avg rate: %s]\n",
|
||||||
|
+ xfpd->file_name, size, stat_bps(xfpd, xfer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
1.8.0.1
|
||||||
|
|
||||||
|
|
||||||
|
From f2d2b2fde9ddf8aebf2c3e7cc852333c4210b3ca Mon Sep 17 00:00:00 2001
|
||||||
|
From: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Mon, 10 Dec 2012 11:20:59 +0100
|
||||||
|
Subject: [PATCH 2/2] xbps-install: fetch_cb.c: if stdout is a tty use stderr.
|
||||||
|
|
||||||
|
---
|
||||||
|
bin/xbps-install/fetch_cb.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bin/xbps-install/fetch_cb.c b/bin/xbps-install/fetch_cb.c
|
||||||
|
index 3497e19..5093f9e 100644
|
||||||
|
--- bin/xbps-install/fetch_cb.c
|
||||||
|
+++ bin/xbps-install/fetch_cb.c
|
||||||
|
@@ -145,7 +145,7 @@ stat_display(struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||||
|
(void)xbps_humanize_number(totsize, (int64_t)xfpd->file_size);
|
||||||
|
}
|
||||||
|
if (isatty(fileno(stdout)))
|
||||||
|
- printf("%s: [%s %d%%] %s ETA: %s\033[K\r",
|
||||||
|
+ fprintf(stderr, "%s: [%s %d%%] %s ETA: %s\033[K\r",
|
||||||
|
xfpd->file_name, totsize, percentage,
|
||||||
|
stat_bps(xfpd, xfer), stat_eta(xfpd, xfer));
|
||||||
|
else
|
||||||
|
@@ -171,7 +171,7 @@ fetch_file_progress_cb(struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||||
|
/* end transfer stats */
|
||||||
|
(void)xbps_humanize_number(size, (int64_t)xfpd->file_dloaded);
|
||||||
|
if (isatty(fileno(stdout)))
|
||||||
|
- printf("%s: %s [avg rate: %s]\033[K\n",
|
||||||
|
+ fprintf(stderr, "%s: %s [avg rate: %s]\033[K\n",
|
||||||
|
xfpd->file_name, size, stat_bps(xfpd, xfer));
|
||||||
|
else
|
||||||
|
printf("%s: %s [avg rate: %s]\n",
|
||||||
|
--
|
||||||
|
1.8.0.1
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Template file for 'xbps'
|
# Template file for 'xbps'
|
||||||
pkgname=xbps
|
pkgname=xbps
|
||||||
version=0.18.1
|
version=0.18.1
|
||||||
revision=3
|
revision=4
|
||||||
build_style=configure
|
build_style=configure
|
||||||
configure_args="--prefix=/ --exec-prefix=/usr --sbindir=/usr/sbin
|
configure_args="--prefix=/ --exec-prefix=/usr --sbindir=/usr/sbin
|
||||||
--with-tests --with-static"
|
--with-tests --with-static"
|
||||||
|
|
Loading…
Reference in a new issue