main: finish --errors-to-stdout support

feature/tap-sh
William Pitcock 2012-07-01 21:21:31 -05:00
parent 2d2ae06809
commit 8a9971ec1f
4 changed files with 26 additions and 15 deletions

View File

@ -62,7 +62,7 @@ pkg_dependency_add(pkg_dependency_t *head, const char *package, const char *vers
dep->prev->next = dep;
#if DEBUG_PARSE
fprintf(stderr, "--> %s %d %s\n", dep->package, dep->compare, dep->version);
fprintf(error_msgout, "--> %s %d %s\n", dep->package, dep->compare, dep->version);
#endif
return dep;
@ -168,7 +168,7 @@ pkg_dependency_parse(pkg_t *pkg, const char *depends)
package = strndup(iter, ptr - iter);
#if DEBUG_PARSE
fprintf(stderr, "Found package: %s\n", package);
fprintf(error_msgout, "Found package: %s\n", package);
#endif
start = ptr;
}
@ -245,7 +245,7 @@ pkg_dependency_parse(pkg_t *pkg, const char *depends)
case AFTER_OPERATOR:
#if DEBUG_PARSE
fprintf(stderr, "Found op: %d\n", compare);
fprintf(error_msgout, "Found op: %d\n", compare);
#endif
if (!isspace(*ptr))
@ -262,7 +262,7 @@ pkg_dependency_parse(pkg_t *pkg, const char *depends)
state = OUTSIDE_MODULE;
#if DEBUG_PARSE
fprintf(stderr, "Found version: %s\n", version);
fprintf(error_msgout, "Found version: %s\n", version);
#endif
deplist = pkg_dependency_add(deplist, package, version, compare);

12
main.c
View File

@ -64,6 +64,8 @@ static char *required_module_version = NULL;
static char *want_variable = NULL;
static char *sysroot_dir = NULL;
FILE *error_msgout = NULL;
static bool
fragment_has_system_dir(pkg_fragment_t *frag)
{
@ -432,6 +434,7 @@ usage(void)
printf(" --version print pkgconf version to stdout\n");
printf(" --atleast-pkgconfig-version check whether or not pkgconf is compatible\n");
printf(" with a specified pkg-config version\n");
printf(" --errors-to-stdout print all errors on stdout instead of stderr\n");
printf("\nchecking specific pkg-config database entries:\n\n");
@ -476,6 +479,7 @@ main(int argc, char *argv[])
pkg_queue_t *pkgq = NULL;
pkg_queue_t *pkgq_head = NULL;
char *builddir;
int want_errors_on_stdout = 0;
struct option options[] = {
{ "version", no_argument, &want_version, 1, },
@ -509,7 +513,7 @@ main(int argc, char *argv[])
{ "exact-version", required_argument, NULL, 28, },
{ "max-version", required_argument, NULL, 29, },
{ "ignore-conflicts", no_argument, &want_ignore_conflicts, 30, },
{ "errors-to-stdout", no_argument, NULL, 31, },
{ "errors-to-stdout", no_argument, &want_errors_on_stdout, 31, },
{ NULL, 0, NULL, 0 }
};
@ -555,6 +559,10 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
error_msgout = stderr;
if (want_errors_on_stdout)
error_msgout = stdout;
if (want_ignore_conflicts || getenv("PKG_CONFIG_IGNORE_CONFLICTS") != NULL)
global_traverse_flags |= PKGF_SKIP_CONFLICTS;
@ -680,7 +688,7 @@ main(int argc, char *argv[])
if (pkgq_head == NULL)
{
fprintf(stderr, "Please specify at least one package name on the command line.\n");
fprintf(error_msgout, "Please specify at least one package name on the command line.\n");
return EXIT_FAILURE;
}

18
pkg.c
View File

@ -592,18 +592,18 @@ pkg_report_graph_error(pkg_t *pkg, pkg_dependency_t *node, unsigned int eflags)
{
if (eflags & PKG_ERRF_PACKAGE_NOT_FOUND)
{
fprintf(stderr, "Package %s was not found in the pkg-config search path.\n", node->package);
fprintf(stderr, "Perhaps you should add the directory containing `%s.pc'\n", node->package);
fprintf(stderr, "to the PKG_CONFIG_PATH environment variable\n");
fprintf(stderr, "No package '%s' found\n", node->package);
fprintf(error_msgout, "Package %s was not found in the pkg-config search path.\n", node->package);
fprintf(error_msgout, "Perhaps you should add the directory containing `%s.pc'\n", node->package);
fprintf(error_msgout, "to the PKG_CONFIG_PATH environment variable\n");
fprintf(error_msgout, "No package '%s' found\n", node->package);
}
else if (eflags & PKG_ERRF_PACKAGE_VER_MISMATCH)
{
fprintf(stderr, "Package dependency requirement '%s %s %s' could not be satisfied.\n",
fprintf(error_msgout, "Package dependency requirement '%s %s %s' could not be satisfied.\n",
node->package, pkg_get_comparator(node), node->version);
if (pkg != NULL)
fprintf(stderr, "Package '%s' has version '%s', required version is '%s %s'\n",
fprintf(error_msgout, "Package '%s' has version '%s', required version is '%s %s'\n",
node->package, pkg->version, pkg_get_comparator(node), node->version);
}
@ -661,11 +661,11 @@ pkg_walk_conflicts_list(pkg_t *root, pkg_dependency_t *deplist, unsigned int fla
pkgdep = pkg_verify_dependency(node, flags, &eflags);
if (eflags == PKG_ERRF_OK)
{
fprintf(stderr, "Version '%s' of '%s' conflicts with '%s' due to satisfying conflict rule '%s %s%s%s'.\n",
fprintf(error_msgout, "Version '%s' of '%s' conflicts with '%s' due to satisfying conflict rule '%s %s%s%s'.\n",
pkgdep->version, pkgdep->realname, root->realname, node->package, pkg_get_comparator(node),
node->version != NULL ? " " : "", node->version != NULL ? node->version : "");
fprintf(stderr, "It may be possible to ignore this conflict and continue, try the\n");
fprintf(stderr, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n");
fprintf(error_msgout, "It may be possible to ignore this conflict and continue, try the\n");
fprintf(error_msgout, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n");
pkg_free(pkgdep);

3
pkg.h
View File

@ -169,4 +169,7 @@ char *pkg_tuple_find_global(const char *key);
void pkg_tuple_free_global(void);
void pkg_tuple_define_global(const char *kv);
/* main.c */
extern FILE *error_msgout;
#endif