mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-10 05:18:16 -05:00
Cleaned up some more output
* Questions no longer start with "error:" * downloaded size is output as a float now
This commit is contained in:
parent
7cf6c88105
commit
a382d33d45
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user