mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-15 22:05:02 -05:00
* Cleaned up direct pm_fprintf usage (move to MSG/ERR macros for now)
* Moved some stderr output to stdout * Remove "RETRIEVE_LOCAL" trans event as libdownload handles local files
This commit is contained in:
parent
4e0b649c3a
commit
d8fd645c4c
@ -173,7 +173,9 @@ int yesno(char *fmt, ...)
|
|||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(str, LOG_STR_LEN, fmt, args);
|
vsnprintf(str, LOG_STR_LEN, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
pm_fprintf(stderr, NL, str);
|
|
||||||
|
/* Use stderr so questions are always displayed when redirecting output */
|
||||||
|
ERR(NL, str);
|
||||||
|
|
||||||
if(fgets(response, 32, stdin)) {
|
if(fgets(response, 32, stdin)) {
|
||||||
/* trim whitespace and newlines */
|
/* trim whitespace and newlines */
|
||||||
|
@ -184,6 +184,7 @@ static void cleanup(int signum)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(signum != 0 && config->op_d_vertest == 0) {
|
if(signum != 0 && config->op_d_vertest == 0) {
|
||||||
|
/* TODO why is this here? */
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +296,7 @@ static int parseargs(int argc, char *argv[])
|
|||||||
case 2: logmask |= PM_LOG_DOWNLOAD; /*fall through */
|
case 2: logmask |= PM_LOG_DOWNLOAD; /*fall through */
|
||||||
case 1: logmask |= PM_LOG_DEBUG; break;
|
case 1: logmask |= PM_LOG_DEBUG; break;
|
||||||
default:
|
default:
|
||||||
pm_fprintf(stderr, NL, _("error: '%s' is not a valid debug level"), optarg);
|
ERR(NL, _("error: '%s' is not a valid debug level"), optarg);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
printf("logmask = %d\n", logmask);
|
printf("logmask = %d\n", logmask);
|
||||||
@ -331,7 +332,7 @@ static int parseargs(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
||||||
pm_fprintf(stderr, NL, _("error: '%s' is not a valid db path\n"), optarg);
|
ERR(NL, _("error: '%s' is not a valid db path\n"), optarg);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
alpm_option_set_dbpath(optarg);
|
alpm_option_set_dbpath(optarg);
|
||||||
@ -361,7 +362,7 @@ static int parseargs(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if(realpath(optarg, root) == NULL) {
|
if(realpath(optarg, root) == NULL) {
|
||||||
pm_fprintf(stderr, NL, _("error: '%s' is not a valid root path\n"), optarg);
|
ERR(NL, _("error: '%s' is not a valid root path\n"), optarg);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
alpm_option_set_root(strdup(root));
|
alpm_option_set_root(strdup(root));
|
||||||
|
@ -41,22 +41,6 @@ extern config_t *config;
|
|||||||
|
|
||||||
static int prevpercent=0; /* for less progressbar output */
|
static int prevpercent=0; /* for less progressbar output */
|
||||||
|
|
||||||
/* refactored function from cb_trans_evt */
|
|
||||||
static void retrieve_local(void *data1, void *data2)
|
|
||||||
{
|
|
||||||
const unsigned int maxcols = getcols();
|
|
||||||
char out[PATH_MAX];
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
MSG(NL, " %s [", (char*)data1);
|
|
||||||
STRNCPY(out, (char*)data2, maxcols-42);
|
|
||||||
MSG(CL, "%s", out);
|
|
||||||
for(i = strlen(out); i < maxcols-43; i++) {
|
|
||||||
MSG(CL, " ");
|
|
||||||
}
|
|
||||||
fputs(_("] 100% LOCAL "), stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Callback to handle transaction events
|
/* Callback to handle transaction events
|
||||||
*/
|
*/
|
||||||
void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
|
void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
|
||||||
@ -65,7 +49,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
|
|||||||
|
|
||||||
switch(event) {
|
switch(event) {
|
||||||
case PM_TRANS_EVT_CHECKDEPS_START:
|
case PM_TRANS_EVT_CHECKDEPS_START:
|
||||||
pm_fprintf(stderr, NL, _("checking dependencies... "));
|
MSG(NL, _("checking dependencies... "));
|
||||||
break;
|
break;
|
||||||
case PM_TRANS_EVT_FILECONFLICTS_START:
|
case PM_TRANS_EVT_FILECONFLICTS_START:
|
||||||
if(config->noprogressbar) {
|
if(config->noprogressbar) {
|
||||||
@ -73,13 +57,13 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PM_TRANS_EVT_CLEANUP_START:
|
case PM_TRANS_EVT_CLEANUP_START:
|
||||||
pm_fprintf(stderr, NL, _("cleaning up... "));
|
MSG(NL, _("cleaning up... "));
|
||||||
break;
|
break;
|
||||||
case PM_TRANS_EVT_RESOLVEDEPS_START:
|
case PM_TRANS_EVT_RESOLVEDEPS_START:
|
||||||
pm_fprintf(stderr, NL, _("resolving dependencies... "));
|
MSG(NL, _("resolving dependencies... "));
|
||||||
break;
|
break;
|
||||||
case PM_TRANS_EVT_INTERCONFLICTS_START:
|
case PM_TRANS_EVT_INTERCONFLICTS_START:
|
||||||
pm_fprintf(stderr, NL, _("looking for inter-conflicts... "));
|
MSG(NL, _("looking for inter-conflicts... "));
|
||||||
break;
|
break;
|
||||||
case PM_TRANS_EVT_FILECONFLICTS_DONE:
|
case PM_TRANS_EVT_FILECONFLICTS_DONE:
|
||||||
if(config->noprogressbar) {
|
if(config->noprogressbar) {
|
||||||
@ -90,7 +74,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
|
|||||||
case PM_TRANS_EVT_CLEANUP_DONE:
|
case PM_TRANS_EVT_CLEANUP_DONE:
|
||||||
case PM_TRANS_EVT_RESOLVEDEPS_DONE:
|
case PM_TRANS_EVT_RESOLVEDEPS_DONE:
|
||||||
case PM_TRANS_EVT_INTERCONFLICTS_DONE:
|
case PM_TRANS_EVT_INTERCONFLICTS_DONE:
|
||||||
pm_fprintf(stderr, CL, _("done.\n"));
|
MSG(CL, _("done.\n"));
|
||||||
break;
|
break;
|
||||||
case PM_TRANS_EVT_EXTRACT_DONE:
|
case PM_TRANS_EVT_EXTRACT_DONE:
|
||||||
if(config->noprogressbar) {
|
if(config->noprogressbar) {
|
||||||
@ -167,9 +151,6 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
|
|||||||
MSG(NL, _(":: Retrieving packages from %s...\n"), (char*)data1);
|
MSG(NL, _(":: Retrieving packages from %s...\n"), (char*)data1);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
break;
|
break;
|
||||||
case PM_TRANS_EVT_RETRIEVE_LOCAL:
|
|
||||||
retrieve_local(data1, data2);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user