From a382d33d45d5e6c2a8ccca8fc946555f6123416f Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sat, 10 Feb 2007 09:34:59 +0000 Subject: Cleaned up some more output * Questions no longer start with "error:" * downloaded size is output as a float now --- src/pacman/Makefile.am | 8 ++++---- src/pacman/downloadprog.c | 20 +++++++++++--------- src/pacman/log.c | 2 +- src/pacman/util.c | 4 +++- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/pacman/Makefile.am b/src/pacman/Makefile.am index 8e611327..4f524480 100644 --- a/src/pacman/Makefile.am +++ b/src/pacman/Makefile.am @@ -16,10 +16,10 @@ pacman_SOURCES = util.c log.c package.c downloadprog.c trans.c add.c \ pacman_static_SOURCES = $(pacman_SOURCES) -pacman_LDADD = -L$(top_builddir)/lib/libalpm/.libs \ - -ldownload -lalpm +pacman_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.so \ + -ldownload -pacman_static_LDADD = -L$(top_builddir)/lib/libalpm/.libs/ \ - -ldownload -lalpm +pacman_static_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la \ + -ldownload pacman_static_LDFLAGS = $(LDFLAGS) -all-static diff --git a/src/pacman/downloadprog.c b/src/pacman/downloadprog.c index a7aa0284..6a1b4824 100644 --- a/src/pacman/downloadprog.c +++ b/src/pacman/downloadprog.c @@ -53,7 +53,7 @@ void log_progress(const char *filename, int xfered, int total) const int infolen = 50; char *fname, *p; - float rate = 0.0, timediff = 0.0; + float rate = 0.0, timediff = 0.0, f_xfered = 0.0; unsigned int eta_h = 0, eta_m = 0, eta_s = 0; int percent; char rate_size = 'K', xfered_size = 'K'; @@ -112,11 +112,13 @@ void log_progress(const char *filename, int xfered, int total) eta_s -= eta_m * 60; fname = strdup(filename); + /* strip extension if it's there + * NOTE: in the case of package files, only the pkgname is sent now */ if((p = strstr(fname, PM_EXT_PKG)) || (p = strstr(fname, PM_EXT_DB))) { *p = '\0'; } if(strlen(fname) > FILENAME_TRIM_LEN) { - fname[FILENAME_TRIM_LEN] = '\0'; + strcpy(fname + FILENAME_TRIM_LEN -3,"..."); } /* Awesome formatting for progress bar. We need a mess of Kb->Mb->Gb stuff @@ -132,13 +134,13 @@ void log_progress(const char *filename, int xfered, int total) } } - xfered /= 1024; /* convert to K by default */ + f_xfered = (float) xfered / 1024.0; /* convert to K by default */ /* xfered_size = 'K'; was set above */ - if(xfered > 2048) { - xfered /= 1024; + if(f_xfered > 2048.0) { + f_xfered /= 1024.0; xfered_size = 'M'; - if(xfered > 2048) { - xfered /= 1024; + if(f_xfered > 2048.0) { + f_xfered /= 1024.0; xfered_size = 'G'; /* I should seriously hope that archlinux packages never break * the 9999.9GB mark... we'd have more serious problems than the progress @@ -146,8 +148,8 @@ void log_progress(const char *filename, int xfered, int total) } } - printf(" %-*s %6d%c %#6.1f%c/s %02u:%02u:%02u", FILENAME_TRIM_LEN, fname, - xfered, xfered_size, rate, rate_size, eta_h, eta_m, eta_s); + printf(" %-*s %6.1f%c %#6.1f%c/s %02u:%02u:%02u", FILENAME_TRIM_LEN, fname, + f_xfered, xfered_size, rate, rate_size, eta_h, eta_m, eta_s); free(fname); diff --git a/src/pacman/log.c b/src/pacman/log.c index e33001b3..9b2e9bc3 100644 --- a/src/pacman/log.c +++ b/src/pacman/log.c @@ -175,7 +175,7 @@ int yesno(char *fmt, ...) va_end(args); /* Use stderr so questions are always displayed when redirecting output */ - ERR(NL, str); + pm_fprintf(stderr, NL, str); \ if(fgets(response, 32, stdin)) { /* trim whitespace and newlines */ diff --git a/src/pacman/util.c b/src/pacman/util.c index f85a1d10..b39f51f8 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -418,10 +418,12 @@ void fill_progress(const int percent, const int proglen) printf("-"); } } - printf("] %3d%%\r", percent); + printf("] %3d%%", percent); if(percent == 100) { printf("\n"); + } else { + printf("\r"); } fflush(stdout); } -- cgit v1.2.3-70-g09d2