2005-07-14 13:05:34 +00:00
|
|
|
/*
|
2005-07-14 13:05:14 +00:00
|
|
|
* Copyright (C) 2001, 2002 Red Hat Inc.
|
2005-07-14 13:05:34 +00:00
|
|
|
*
|
2005-07-14 13:05:14 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
2005-07-14 13:05:34 +00:00
|
|
|
*
|
2005-07-14 13:05:14 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
|
* 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "pkg.h"
|
|
|
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2005-07-14 13:04:37 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
#define STRICT
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#undef STRICT
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-10-31 08:46:36 -07:00
|
|
|
char *pcsysrootdir = NULL;
|
|
|
|
|
char *pkg_config_pc_path = NULL;
|
|
|
|
|
|
2012-12-11 07:10:48 -08:00
|
|
|
static gboolean want_my_version = FALSE;
|
|
|
|
|
static gboolean want_version = FALSE;
|
2012-12-11 08:43:37 -08:00
|
|
|
static FlagType pkg_flags = 0;
|
2012-12-11 07:10:48 -08:00
|
|
|
static gboolean want_list = FALSE;
|
|
|
|
|
static gboolean want_static_lib_list = ENABLE_INDIRECT_DEPS;
|
|
|
|
|
static gboolean want_short_errors = FALSE;
|
|
|
|
|
static gboolean want_uninstalled = FALSE;
|
2012-10-31 08:46:36 -07:00
|
|
|
static char *variable_name = NULL;
|
2012-12-11 07:10:48 -08:00
|
|
|
static gboolean want_exists = FALSE;
|
|
|
|
|
static gboolean want_provides = FALSE;
|
|
|
|
|
static gboolean want_requires = FALSE;
|
|
|
|
|
static gboolean want_requires_private = FALSE;
|
2012-10-31 08:46:36 -07:00
|
|
|
static char *required_atleast_version = NULL;
|
|
|
|
|
static char *required_exact_version = NULL;
|
|
|
|
|
static char *required_max_version = NULL;
|
|
|
|
|
static char *required_pkgconfig_version = NULL;
|
2012-12-11 07:10:48 -08:00
|
|
|
static gboolean want_silence_errors = FALSE;
|
|
|
|
|
static gboolean want_variable_list = FALSE;
|
|
|
|
|
static gboolean want_debug_spew = FALSE;
|
|
|
|
|
static gboolean want_verbose_errors = FALSE;
|
|
|
|
|
static gboolean want_stdout_errors = FALSE;
|
2012-12-11 09:35:21 -08:00
|
|
|
static gboolean output_opt_set = FALSE;
|
2005-07-14 13:04:01 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
debug_spew (const char *format, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
gchar *str;
|
2005-07-14 13:04:10 +00:00
|
|
|
FILE* stream;
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
g_return_if_fail (format != NULL);
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
if (!want_debug_spew)
|
|
|
|
|
return;
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
va_start (args, format);
|
|
|
|
|
str = g_strdup_vprintf (format, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
2005-07-14 13:04:10 +00:00
|
|
|
if (want_stdout_errors)
|
|
|
|
|
stream = stdout;
|
|
|
|
|
else
|
|
|
|
|
stream = stderr;
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:10 +00:00
|
|
|
fputs (str, stream);
|
|
|
|
|
fflush (stream);
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
g_free (str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
verbose_error (const char *format, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
gchar *str;
|
2005-07-14 13:05:41 +00:00
|
|
|
FILE* stream;
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
g_return_if_fail (format != NULL);
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
if (!want_verbose_errors)
|
|
|
|
|
return;
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
va_start (args, format);
|
|
|
|
|
str = g_strdup_vprintf (format, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
2005-07-14 13:05:41 +00:00
|
|
|
if (want_stdout_errors)
|
|
|
|
|
stream = stdout;
|
|
|
|
|
else
|
|
|
|
|
stream = stderr;
|
|
|
|
|
|
|
|
|
|
fputs (str, stream);
|
|
|
|
|
fflush (stream);
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
g_free (str);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
static gboolean
|
|
|
|
|
define_variable_cb (const char *opt, const char *arg, gpointer data,
|
|
|
|
|
GError **error)
|
2005-07-14 13:04:01 +00:00
|
|
|
{
|
2010-06-17 08:38:46 -07:00
|
|
|
char *varname;
|
|
|
|
|
char *varval;
|
|
|
|
|
char *tmp;
|
2005-07-14 13:04:01 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
tmp = g_strdup (arg);
|
2005-07-14 13:04:01 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
varname = tmp;
|
|
|
|
|
while (*varname && isspace ((guchar)*varname))
|
|
|
|
|
++varname;
|
2005-07-14 13:04:01 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
varval = varname;
|
|
|
|
|
while (*varval && *varval != '=' && *varval != ' ')
|
|
|
|
|
++varval;
|
2005-07-14 13:04:01 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
while (*varval && (*varval == '=' || *varval == ' '))
|
|
|
|
|
{
|
|
|
|
|
*varval = '\0';
|
|
|
|
|
++varval;
|
|
|
|
|
}
|
2005-07-14 13:04:01 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
if (*varval == '\0')
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "--define-variable argument does not have a value "
|
|
|
|
|
"for the variable\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2005-07-14 13:04:01 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
define_global_variable (varname, varval);
|
2005-07-14 13:04:01 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
g_free (tmp);
|
|
|
|
|
return TRUE;
|
2005-07-14 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-11 08:25:21 -08:00
|
|
|
static gboolean
|
|
|
|
|
output_opt_cb (const char *opt, const char *arg, gpointer data,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2012-12-11 11:30:13 -08:00
|
|
|
static gboolean vercmp_opt_set = FALSE;
|
|
|
|
|
|
2012-12-11 09:35:21 -08:00
|
|
|
/* only allow one output mode, with a few exceptions */
|
|
|
|
|
if (output_opt_set)
|
|
|
|
|
{
|
|
|
|
|
gboolean bad_opt = TRUE;
|
|
|
|
|
|
|
|
|
|
/* multiple flag options (--cflags --libs-only-l) allowed */
|
|
|
|
|
if (pkg_flags != 0 &&
|
|
|
|
|
(strcmp (opt, "--libs") == 0 ||
|
|
|
|
|
strcmp (opt, "--libs-only-l") == 0 ||
|
|
|
|
|
strcmp (opt, "--libs-only-other") == 0 ||
|
|
|
|
|
strcmp (opt, "--libs-only-L") == 0 ||
|
|
|
|
|
strcmp (opt, "--cflags") == 0 ||
|
|
|
|
|
strcmp (opt, "--cflags-only-I") == 0 ||
|
|
|
|
|
strcmp (opt, "--cflags-only-other") == 0))
|
|
|
|
|
bad_opt = FALSE;
|
|
|
|
|
|
|
|
|
|
/* --print-requires and --print-requires-private allowed */
|
|
|
|
|
if ((want_requires && strcmp (opt, "--print-requires-private") == 0) ||
|
|
|
|
|
(want_requires_private && strcmp (opt, "--print-requires") == 0))
|
|
|
|
|
bad_opt = FALSE;
|
|
|
|
|
|
2012-12-11 11:01:59 -08:00
|
|
|
/* --exists allowed with --atleast/exact/max-version */
|
2012-12-11 11:30:13 -08:00
|
|
|
if (want_exists && !vercmp_opt_set &&
|
2012-12-11 11:01:59 -08:00
|
|
|
(strcmp (opt, "--atleast-version") == 0 ||
|
|
|
|
|
strcmp (opt, "--exact-version") == 0 ||
|
|
|
|
|
strcmp (opt, "--max-version") == 0))
|
|
|
|
|
bad_opt = FALSE;
|
|
|
|
|
|
2012-12-11 09:35:21 -08:00
|
|
|
if (bad_opt)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Ignoring incompatible output option \"%s\"\n",
|
|
|
|
|
opt);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-11 08:25:21 -08:00
|
|
|
if (strcmp (opt, "--version") == 0)
|
|
|
|
|
want_my_version = TRUE;
|
|
|
|
|
else if (strcmp (opt, "--modversion") == 0)
|
|
|
|
|
want_version = TRUE;
|
|
|
|
|
else if (strcmp (opt, "--libs") == 0)
|
2012-12-11 08:43:37 -08:00
|
|
|
pkg_flags |= LIBS_ANY;
|
2012-12-11 08:25:21 -08:00
|
|
|
else if (strcmp (opt, "--libs-only-l") == 0)
|
2012-12-11 08:43:37 -08:00
|
|
|
pkg_flags |= LIBS_l;
|
2012-12-11 08:25:21 -08:00
|
|
|
else if (strcmp (opt, "--libs-only-other") == 0)
|
2012-12-11 08:43:37 -08:00
|
|
|
pkg_flags |= LIBS_OTHER;
|
2012-12-11 08:25:21 -08:00
|
|
|
else if (strcmp (opt, "--libs-only-L") == 0)
|
2012-12-11 08:43:37 -08:00
|
|
|
pkg_flags |= LIBS_L;
|
2012-12-11 08:25:21 -08:00
|
|
|
else if (strcmp (opt, "--cflags") == 0)
|
2012-12-11 08:43:37 -08:00
|
|
|
pkg_flags |= CFLAGS_ANY;
|
2012-12-11 08:25:21 -08:00
|
|
|
else if (strcmp (opt, "--cflags-only-I") == 0)
|
2012-12-11 08:43:37 -08:00
|
|
|
pkg_flags |= CFLAGS_I;
|
2012-12-11 08:25:21 -08:00
|
|
|
else if (strcmp (opt, "--cflags-only-other") == 0)
|
2012-12-11 08:43:37 -08:00
|
|
|
pkg_flags |= CFLAGS_OTHER;
|
2012-12-11 08:25:21 -08:00
|
|
|
else if (strcmp (opt, "--variable") == 0)
|
|
|
|
|
variable_name = g_strdup (arg);
|
|
|
|
|
else if (strcmp (opt, "--exists") == 0)
|
|
|
|
|
want_exists = TRUE;
|
|
|
|
|
else if (strcmp (opt, "--print-variables") == 0)
|
|
|
|
|
want_variable_list = TRUE;
|
|
|
|
|
else if (strcmp (opt, "--uninstalled") == 0)
|
|
|
|
|
want_uninstalled = TRUE;
|
2012-12-11 11:01:59 -08:00
|
|
|
else if (strcmp (opt, "--atleast-version") == 0)
|
|
|
|
|
{
|
|
|
|
|
required_atleast_version = g_strdup (arg);
|
|
|
|
|
want_exists = TRUE;
|
2012-12-11 11:30:13 -08:00
|
|
|
vercmp_opt_set = TRUE;
|
2012-12-11 11:01:59 -08:00
|
|
|
}
|
|
|
|
|
else if (strcmp (opt, "--exact-version") == 0)
|
|
|
|
|
{
|
|
|
|
|
required_exact_version = g_strdup (arg);
|
|
|
|
|
want_exists = TRUE;
|
2012-12-11 11:30:13 -08:00
|
|
|
vercmp_opt_set = TRUE;
|
2012-12-11 11:01:59 -08:00
|
|
|
}
|
|
|
|
|
else if (strcmp (opt, "--max-version") == 0)
|
|
|
|
|
{
|
|
|
|
|
required_max_version = g_strdup (arg);
|
|
|
|
|
want_exists = TRUE;
|
2012-12-11 11:30:13 -08:00
|
|
|
vercmp_opt_set = TRUE;
|
2012-12-11 11:01:59 -08:00
|
|
|
}
|
2012-12-11 08:25:21 -08:00
|
|
|
else if (strcmp (opt, "--list-all") == 0)
|
|
|
|
|
want_list = TRUE;
|
|
|
|
|
else if (strcmp (opt, "--print-provides") == 0)
|
|
|
|
|
want_provides = TRUE;
|
|
|
|
|
else if (strcmp (opt, "--print-requires") == 0)
|
|
|
|
|
want_requires = TRUE;
|
|
|
|
|
else if (strcmp (opt, "--print-requires-private") == 0)
|
|
|
|
|
want_requires_private = TRUE;
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2012-12-11 09:35:21 -08:00
|
|
|
output_opt_set = TRUE;
|
2012-12-11 08:25:21 -08:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
static gboolean
|
|
|
|
|
pkg_uninstalled (Package *pkg)
|
|
|
|
|
{
|
|
|
|
|
/* See if > 0 pkgs were uninstalled */
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *tmp;
|
2005-07-14 13:04:01 +00:00
|
|
|
|
|
|
|
|
if (pkg->uninstalled)
|
|
|
|
|
return TRUE;
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
tmp = pkg->requires;
|
|
|
|
|
while (tmp != NULL)
|
|
|
|
|
{
|
|
|
|
|
Package *pkg = tmp->data;
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
if (pkg_uninstalled (pkg))
|
|
|
|
|
return TRUE;
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2012-11-29 05:40:40 -08:00
|
|
|
tmp = g_list_next (tmp);
|
2005-07-14 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-09 09:49:13 +02:00
|
|
|
void
|
|
|
|
|
print_hashtable_key (gpointer key,
|
|
|
|
|
gpointer value,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
printf("%s\n", (gchar*)key);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 08:40:38 -07:00
|
|
|
static void
|
|
|
|
|
init_pc_path (void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
char *instdir, *lpath, *shpath;
|
|
|
|
|
|
|
|
|
|
instdir = g_win32_get_package_installation_directory_of_module (NULL);
|
|
|
|
|
if (instdir == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* This only happens when GetModuleFilename() fails. If it does, that
|
|
|
|
|
* failure should be investigated and fixed.
|
|
|
|
|
*/
|
|
|
|
|
debug_spew ("g_win32_get_package_installation_directory_of_module failed\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lpath = g_build_filename (instdir, "lib", "pkgconfig", NULL);
|
|
|
|
|
shpath = g_build_filename (instdir, "share", "pkgconfig", NULL);
|
|
|
|
|
pkg_config_pc_path = g_strconcat (lpath, G_SEARCHPATH_SEPARATOR_S, shpath,
|
|
|
|
|
NULL);
|
2012-05-29 17:15:34 -07:00
|
|
|
g_free (instdir);
|
|
|
|
|
g_free (lpath);
|
|
|
|
|
g_free (shpath);
|
2012-05-18 08:40:38 -07:00
|
|
|
#else
|
|
|
|
|
pkg_config_pc_path = PKG_CONFIG_PC_PATH;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-31 16:30:45 -07:00
|
|
|
static gboolean
|
|
|
|
|
process_package_args (const char *cmdline, GList **packages, FILE *log)
|
|
|
|
|
{
|
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
GList *reqs;
|
|
|
|
|
|
|
|
|
|
reqs = parse_module_list (NULL, cmdline, "(command line arguments)");
|
|
|
|
|
if (reqs == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Must specify package names on the command line\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (; reqs != NULL; reqs = g_list_next (reqs))
|
|
|
|
|
{
|
|
|
|
|
Package *req;
|
|
|
|
|
RequiredVersion *ver = reqs->data;
|
|
|
|
|
|
|
|
|
|
/* override requested versions with cmdline options */
|
|
|
|
|
if (required_exact_version)
|
|
|
|
|
{
|
|
|
|
|
g_free (ver->version);
|
|
|
|
|
ver->comparison = EQUAL;
|
|
|
|
|
ver->version = g_strdup (required_exact_version);
|
|
|
|
|
}
|
|
|
|
|
else if (required_atleast_version)
|
|
|
|
|
{
|
|
|
|
|
g_free (ver->version);
|
|
|
|
|
ver->comparison = GREATER_THAN_EQUAL;
|
|
|
|
|
ver->version = g_strdup (required_atleast_version);
|
|
|
|
|
}
|
|
|
|
|
else if (required_max_version)
|
|
|
|
|
{
|
|
|
|
|
g_free (ver->version);
|
|
|
|
|
ver->comparison = LESS_THAN_EQUAL;
|
|
|
|
|
ver->version = g_strdup (required_max_version);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (want_short_errors)
|
|
|
|
|
req = get_package_quiet (ver->name);
|
|
|
|
|
else
|
|
|
|
|
req = get_package (ver->name);
|
|
|
|
|
|
|
|
|
|
if (log != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (req == NULL)
|
|
|
|
|
fprintf (log, "%s NOT-FOUND\n", ver->name);
|
|
|
|
|
else
|
|
|
|
|
fprintf (log, "%s %s %s\n", ver->name,
|
|
|
|
|
comparison_to_str (ver->comparison),
|
|
|
|
|
(ver->version == NULL) ? "(null)" : ver->version);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (req == NULL)
|
|
|
|
|
{
|
|
|
|
|
success = FALSE;
|
|
|
|
|
verbose_error ("No package '%s' found\n", ver->name);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!version_test (ver->comparison, req->version, ver->version))
|
|
|
|
|
{
|
|
|
|
|
success = FALSE;
|
|
|
|
|
verbose_error ("Requested '%s %s %s' but version of %s is %s\n",
|
|
|
|
|
ver->name,
|
|
|
|
|
comparison_to_str (ver->comparison),
|
|
|
|
|
ver->version,
|
|
|
|
|
req->name,
|
|
|
|
|
req->version);
|
|
|
|
|
if (req->url)
|
|
|
|
|
verbose_error ("You may find new versions of %s at %s\n",
|
|
|
|
|
req->name, req->url);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*packages = g_list_prepend (*packages, req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*packages = g_list_reverse (*packages);
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-31 08:46:36 -07:00
|
|
|
static const GOptionEntry options_table[] = {
|
2012-12-11 08:25:21 -08:00
|
|
|
{ "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "output version of pkg-config", NULL },
|
|
|
|
|
{ "modversion", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "output version for package", NULL },
|
2012-10-31 08:46:36 -07:00
|
|
|
{ "atleast-pkgconfig-version", 0, 0, G_OPTION_ARG_STRING,
|
|
|
|
|
&required_pkgconfig_version,
|
|
|
|
|
"require given version of pkg-config", "VERSION" },
|
2012-12-11 08:25:21 -08:00
|
|
|
{ "libs", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, &output_opt_cb,
|
2012-10-31 08:46:36 -07:00
|
|
|
"output all linker flags", NULL },
|
|
|
|
|
{ "static", 0, 0, G_OPTION_ARG_NONE, &want_static_lib_list,
|
|
|
|
|
"output linker flags for static linking", NULL },
|
|
|
|
|
{ "short-errors", 0, 0, G_OPTION_ARG_NONE, &want_short_errors,
|
|
|
|
|
"print short errors", NULL },
|
2012-12-11 08:25:21 -08:00
|
|
|
{ "libs-only-l", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "output -l flags", NULL },
|
|
|
|
|
{ "libs-only-other", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "output other libs (e.g. -pthread)", NULL },
|
|
|
|
|
{ "libs-only-L", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "output -L flags", NULL },
|
|
|
|
|
{ "cflags", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, &output_opt_cb,
|
2012-10-31 08:46:36 -07:00
|
|
|
"output all pre-processor and compiler flags", NULL },
|
2012-12-11 08:25:21 -08:00
|
|
|
{ "cflags-only-I", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "output -I flags", NULL },
|
|
|
|
|
{ "cflags-only-other", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "output cflags not covered by the cflags-only-I option",
|
|
|
|
|
NULL },
|
|
|
|
|
{ "variable", 0, 0, G_OPTION_ARG_CALLBACK, &output_opt_cb,
|
2012-10-31 08:46:36 -07:00
|
|
|
"get the value of variable named NAME", "NAME" },
|
|
|
|
|
{ "define-variable", 0, 0, G_OPTION_ARG_CALLBACK, &define_variable_cb,
|
|
|
|
|
"set variable NAME to VALUE", "NAME=VALUE" },
|
2012-12-11 08:25:21 -08:00
|
|
|
{ "exists", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, &output_opt_cb,
|
2012-10-31 08:46:36 -07:00
|
|
|
"return 0 if the module(s) exist", NULL },
|
2012-12-11 08:25:21 -08:00
|
|
|
{ "print-variables", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "output list of variables defined by the module", NULL },
|
|
|
|
|
{ "uninstalled", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "return 0 if the uninstalled version of one or more "
|
|
|
|
|
"module(s) or their dependencies will be used", NULL },
|
2012-12-11 11:01:59 -08:00
|
|
|
{ "atleast-version", 0, 0, G_OPTION_ARG_CALLBACK, &output_opt_cb,
|
2012-10-31 08:46:36 -07:00
|
|
|
"return 0 if the module is at least version VERSION", "VERSION" },
|
2012-12-11 11:01:59 -08:00
|
|
|
{ "exact-version", 0, 0, G_OPTION_ARG_CALLBACK, &output_opt_cb,
|
2012-10-31 08:46:36 -07:00
|
|
|
"return 0 if the module is at exactly version VERSION", "VERSION" },
|
2012-12-11 11:01:59 -08:00
|
|
|
{ "max-version", 0, 0, G_OPTION_ARG_CALLBACK, &output_opt_cb,
|
2012-10-31 08:46:36 -07:00
|
|
|
"return 0 if the module is at no newer than version VERSION", "VERSION" },
|
2012-12-11 08:25:21 -08:00
|
|
|
{ "list-all", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "list all known packages", NULL },
|
2012-10-31 08:46:36 -07:00
|
|
|
{ "debug", 0, 0, G_OPTION_ARG_NONE, &want_debug_spew,
|
|
|
|
|
"show verbose debug information", NULL },
|
|
|
|
|
{ "print-errors", 0, 0, G_OPTION_ARG_NONE, &want_verbose_errors,
|
2012-12-11 11:47:44 -08:00
|
|
|
"show verbose information about missing or conflicting packages "
|
|
|
|
|
"(default unless --exists or --atleast/exact/max-version given on the "
|
|
|
|
|
"command line)", NULL },
|
2012-10-31 08:46:36 -07:00
|
|
|
{ "silence-errors", 0, 0, G_OPTION_ARG_NONE, &want_silence_errors,
|
2012-12-11 11:47:44 -08:00
|
|
|
"be silent about errors (default when --exists or "
|
|
|
|
|
"--atleast/exact/max-version given on the command line)", NULL },
|
2012-10-31 08:46:36 -07:00
|
|
|
{ "errors-to-stdout", 0, 0, G_OPTION_ARG_NONE, &want_stdout_errors,
|
|
|
|
|
"print errors from --print-errors to stdout not stderr", NULL },
|
2012-12-11 08:25:21 -08:00
|
|
|
{ "print-provides", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "print which packages the package provides", NULL },
|
|
|
|
|
{ "print-requires", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "print which packages the package requires", NULL },
|
|
|
|
|
{ "print-requires-private", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
|
&output_opt_cb, "print which packages the package requires for static "
|
|
|
|
|
"linking", NULL },
|
2012-10-31 08:46:36 -07:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
{ "dont-define-prefix", 0, 0, G_OPTION_ARG_NONE, &dont_define_prefix,
|
|
|
|
|
"don't try to override the value of prefix for each .pc file found with "
|
|
|
|
|
"a guesstimated value based on the location of the .pc file", NULL },
|
|
|
|
|
{ "prefix-variable", 0, 0, G_OPTION_ARG_STRING, &prefix_variable,
|
|
|
|
|
"set the name of the variable that pkg-config automatically sets",
|
|
|
|
|
"PREFIX" },
|
|
|
|
|
{ "msvc-syntax", 0, 0, G_OPTION_ARG_NONE, &msvc_syntax,
|
|
|
|
|
"output -l and -L flags for the Microsoft compiler (cl)", NULL },
|
|
|
|
|
#endif
|
|
|
|
|
{ NULL, 0, 0, 0, NULL, NULL, NULL }
|
|
|
|
|
};
|
|
|
|
|
|
2005-07-14 13:05:34 +00:00
|
|
|
int
|
2005-07-14 13:04:01 +00:00
|
|
|
main (int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
GString *str;
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *packages = NULL;
|
2005-07-14 13:04:01 +00:00
|
|
|
char *search_path;
|
|
|
|
|
char *pcbuilddir;
|
|
|
|
|
gboolean need_newline;
|
2008-04-28 20:58:36 +02:00
|
|
|
FILE *log = NULL;
|
2010-06-17 08:38:46 -07:00
|
|
|
GError *error = NULL;
|
|
|
|
|
GOptionContext *opt_context;
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
/* This is here so that we get debug spew from the start,
|
|
|
|
|
* during arg parsing
|
|
|
|
|
*/
|
|
|
|
|
if (getenv ("PKG_CONFIG_DEBUG_SPEW"))
|
|
|
|
|
{
|
|
|
|
|
want_debug_spew = TRUE;
|
|
|
|
|
want_verbose_errors = TRUE;
|
|
|
|
|
want_silence_errors = FALSE;
|
2005-07-14 13:04:19 +00:00
|
|
|
debug_spew ("PKG_CONFIG_DEBUG_SPEW variable enabling debug spew\n");
|
2005-07-14 13:04:01 +00:00
|
|
|
}
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2012-05-18 08:40:38 -07:00
|
|
|
|
|
|
|
|
/* Get the built-in search path */
|
|
|
|
|
init_pc_path ();
|
|
|
|
|
if (pkg_config_pc_path == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Even when we override the built-in search path, we still use it later
|
|
|
|
|
* to add pc_path to the virtual pkg-config package.
|
|
|
|
|
*/
|
|
|
|
|
verbose_error ("Failed to get default search path\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-16 19:57:14 +02:00
|
|
|
search_path = getenv ("PKG_CONFIG_PATH");
|
|
|
|
|
if (search_path)
|
|
|
|
|
{
|
|
|
|
|
add_search_dirs(search_path, G_SEARCHPATH_SEPARATOR_S);
|
|
|
|
|
}
|
2005-07-14 13:07:11 +00:00
|
|
|
if (getenv("PKG_CONFIG_LIBDIR") != NULL)
|
2005-07-14 13:04:01 +00:00
|
|
|
{
|
2005-07-14 13:07:11 +00:00
|
|
|
add_search_dirs(getenv("PKG_CONFIG_LIBDIR"), G_SEARCHPATH_SEPARATOR_S);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-05-18 08:40:38 -07:00
|
|
|
add_search_dirs(pkg_config_pc_path, G_SEARCHPATH_SEPARATOR_S);
|
2005-07-14 13:04:01 +00:00
|
|
|
}
|
2005-07-14 13:06:23 +00:00
|
|
|
|
2008-01-16 23:10:25 +01:00
|
|
|
pcsysrootdir = getenv ("PKG_CONFIG_SYSROOT_DIR");
|
|
|
|
|
if (pcsysrootdir)
|
|
|
|
|
{
|
|
|
|
|
define_global_variable ("pc_sysrootdir", pcsysrootdir);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
define_global_variable ("pc_sysrootdir", "/");
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
pcbuilddir = getenv ("PKG_CONFIG_TOP_BUILD_DIR");
|
|
|
|
|
if (pcbuilddir)
|
|
|
|
|
{
|
|
|
|
|
define_global_variable ("pc_top_builddir", pcbuilddir);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Default appropriate for automake */
|
|
|
|
|
define_global_variable ("pc_top_builddir", "$(top_builddir)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (getenv ("PKG_CONFIG_DISABLE_UNINSTALLED"))
|
|
|
|
|
{
|
|
|
|
|
debug_spew ("disabling auto-preference for uninstalled packages\n");
|
|
|
|
|
disable_uninstalled = TRUE;
|
|
|
|
|
}
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
/* Parse options */
|
|
|
|
|
opt_context = g_option_context_new (NULL);
|
|
|
|
|
g_option_context_add_main_entries (opt_context, options_table, NULL);
|
|
|
|
|
if (!g_option_context_parse(opt_context, &argc, &argv, &error))
|
2005-07-14 13:04:01 +00:00
|
|
|
{
|
2010-06-17 08:38:46 -07:00
|
|
|
fprintf (stderr, "%s\n", error->message);
|
2005-07-14 13:04:01 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-11 10:04:21 -08:00
|
|
|
/* If no output option was set, then --exists is the default. */
|
|
|
|
|
if (!output_opt_set)
|
|
|
|
|
{
|
|
|
|
|
debug_spew ("no output option set, defaulting to --exists\n");
|
|
|
|
|
want_exists = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
/* Error printing is determined as follows:
|
2012-12-11 11:47:44 -08:00
|
|
|
* - for all output options besides --exists and --*-version,
|
|
|
|
|
* it's on by default and --silence-errors can turn it off
|
|
|
|
|
* - for --exists, --*-version, etc. and no options at all,
|
|
|
|
|
* it's off by default and --print-errors will turn it on
|
2005-07-14 13:04:01 +00:00
|
|
|
*/
|
2012-12-11 11:47:44 -08:00
|
|
|
if (!want_exists)
|
2005-07-14 13:04:01 +00:00
|
|
|
{
|
2012-12-11 11:47:44 -08:00
|
|
|
debug_spew ("Error printing enabled by default due to use of output "
|
|
|
|
|
"options besides --exists or --atleast/exact/max-version. "
|
|
|
|
|
"Value of --silence-errors: %d\n",
|
2012-12-11 08:43:37 -08:00
|
|
|
want_silence_errors);
|
2005-07-14 13:04:19 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
if (want_silence_errors && getenv ("PKG_CONFIG_DEBUG_SPEW") == NULL)
|
|
|
|
|
want_verbose_errors = FALSE;
|
|
|
|
|
else
|
|
|
|
|
want_verbose_errors = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-12-11 11:47:44 -08:00
|
|
|
debug_spew ("Error printing disabled by default due to use of output "
|
|
|
|
|
"options --exists, --atleast/exact/max-version or no "
|
|
|
|
|
"output option at all. Value of --print-errors: %d\n",
|
2005-07-14 13:04:19 +00:00
|
|
|
want_verbose_errors);
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
/* Leave want_verbose_errors unchanged, reflecting --print-errors */
|
2005-07-14 13:04:19 +00:00
|
|
|
}
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:19 +00:00
|
|
|
if (want_verbose_errors)
|
|
|
|
|
debug_spew ("Error printing enabled\n");
|
|
|
|
|
else
|
|
|
|
|
debug_spew ("Error printing disabled\n");
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:07:18 +00:00
|
|
|
if (want_static_lib_list)
|
|
|
|
|
enable_private_libs();
|
|
|
|
|
else
|
|
|
|
|
disable_private_libs();
|
|
|
|
|
|
2009-03-30 20:40:53 +02:00
|
|
|
/* honor Requires.private if any Cflags are requested or any static
|
|
|
|
|
* libs are requested */
|
|
|
|
|
|
2012-12-11 08:43:37 -08:00
|
|
|
if (pkg_flags & CFLAGS_ANY || want_requires_private || want_exists ||
|
|
|
|
|
(want_static_lib_list && (pkg_flags & LIBS_ANY)))
|
2009-03-30 20:40:53 +02:00
|
|
|
enable_requires_private();
|
|
|
|
|
|
2009-03-30 20:49:17 +02:00
|
|
|
/* ignore Requires if no Cflags or Libs are requested */
|
|
|
|
|
|
2012-12-11 08:43:37 -08:00
|
|
|
if (pkg_flags == 0 && !want_requires && !want_exists)
|
2009-03-30 20:49:17 +02:00
|
|
|
disable_requires();
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
if (want_my_version)
|
|
|
|
|
{
|
|
|
|
|
printf ("%s\n", VERSION);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (required_pkgconfig_version)
|
|
|
|
|
{
|
|
|
|
|
if (compare_versions (VERSION, required_pkgconfig_version) >= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
package_init ();
|
|
|
|
|
|
|
|
|
|
if (want_list)
|
|
|
|
|
{
|
|
|
|
|
print_package_list ();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
/* Collect packages from remaining args */
|
2005-07-14 13:04:01 +00:00
|
|
|
str = g_string_new ("");
|
2010-06-17 08:38:46 -07:00
|
|
|
while (argc > 1)
|
2005-07-14 13:04:01 +00:00
|
|
|
{
|
2010-06-17 08:38:46 -07:00
|
|
|
argc--;
|
|
|
|
|
argv++;
|
2005-07-14 13:04:01 +00:00
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
g_string_append (str, *argv);
|
2005-07-14 13:04:01 +00:00
|
|
|
g_string_append (str, " ");
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-17 08:38:46 -07:00
|
|
|
g_option_context_free (opt_context);
|
2005-07-14 13:07:18 +00:00
|
|
|
|
2005-07-14 13:05:34 +00:00
|
|
|
g_strstrip (str->str);
|
|
|
|
|
|
2008-03-23 20:51:50 +01:00
|
|
|
if (getenv("PKG_CONFIG_LOG") != NULL)
|
|
|
|
|
{
|
|
|
|
|
log = fopen (getenv ("PKG_CONFIG_LOG"), "a");
|
|
|
|
|
if (log == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Cannot open log file: %s\n",
|
|
|
|
|
getenv ("PKG_CONFIG_LOG"));
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-31 16:30:45 -07:00
|
|
|
/* find and parse each of the packages specified */
|
|
|
|
|
if (!process_package_args (str->str, &packages, log))
|
|
|
|
|
return 1;
|
2012-10-30 17:34:20 -07:00
|
|
|
|
2012-10-31 16:30:45 -07:00
|
|
|
if (log != NULL)
|
|
|
|
|
fclose (log);
|
2012-10-30 17:34:20 -07:00
|
|
|
|
2012-10-31 16:30:45 -07:00
|
|
|
g_string_free (str, TRUE);
|
2012-10-30 17:34:20 -07:00
|
|
|
|
|
|
|
|
if (want_exists)
|
|
|
|
|
return 0; /* if we got here, all the packages existed. */
|
2005-10-16 18:06:02 +00:00
|
|
|
|
2010-05-09 09:49:13 +02:00
|
|
|
if (want_variable_list)
|
|
|
|
|
{
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *tmp;
|
2010-05-09 09:49:13 +02:00
|
|
|
tmp = packages;
|
|
|
|
|
while (tmp != NULL)
|
|
|
|
|
{
|
|
|
|
|
Package *pkg = tmp->data;
|
2012-10-13 09:06:18 -07:00
|
|
|
if (pkg->vars != NULL)
|
|
|
|
|
g_hash_table_foreach(pkg->vars,
|
|
|
|
|
&print_hashtable_key,
|
|
|
|
|
NULL);
|
2012-11-29 05:40:40 -08:00
|
|
|
tmp = g_list_next (tmp);
|
2010-05-09 09:49:13 +02:00
|
|
|
if (tmp) printf ("\n");
|
|
|
|
|
}
|
|
|
|
|
need_newline = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
if (want_uninstalled)
|
|
|
|
|
{
|
|
|
|
|
/* See if > 0 pkgs (including dependencies recursively) were uninstalled */
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *tmp;
|
2005-07-14 13:04:01 +00:00
|
|
|
tmp = packages;
|
|
|
|
|
while (tmp != NULL)
|
|
|
|
|
{
|
|
|
|
|
Package *pkg = tmp->data;
|
|
|
|
|
|
|
|
|
|
if (pkg_uninstalled (pkg))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2012-11-29 05:40:40 -08:00
|
|
|
tmp = g_list_next (tmp);
|
2005-07-14 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
if (want_version)
|
|
|
|
|
{
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *tmp;
|
2005-07-14 13:04:01 +00:00
|
|
|
tmp = packages;
|
|
|
|
|
while (tmp != NULL)
|
|
|
|
|
{
|
|
|
|
|
Package *pkg = tmp->data;
|
|
|
|
|
|
|
|
|
|
printf ("%s\n", pkg->version);
|
|
|
|
|
|
2012-11-29 05:40:40 -08:00
|
|
|
tmp = g_list_next (tmp);
|
2005-07-14 13:04:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-10 20:02:53 +02:00
|
|
|
if (want_provides)
|
|
|
|
|
{
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *tmp;
|
2010-05-10 20:02:53 +02:00
|
|
|
tmp = packages;
|
|
|
|
|
while (tmp != NULL)
|
|
|
|
|
{
|
|
|
|
|
Package *pkg = tmp->data;
|
|
|
|
|
char *key;
|
|
|
|
|
key = pkg->key;
|
|
|
|
|
while (*key == '/')
|
|
|
|
|
key++;
|
|
|
|
|
if (strlen(key) > 0)
|
|
|
|
|
printf ("%s = %s\n", key, pkg->version);
|
2012-11-29 05:40:40 -08:00
|
|
|
tmp = g_list_next (tmp);
|
2010-05-10 20:02:53 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (want_requires)
|
|
|
|
|
{
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *pkgtmp;
|
|
|
|
|
for (pkgtmp = packages; pkgtmp != NULL; pkgtmp = g_list_next (pkgtmp))
|
2010-05-10 20:02:53 +02:00
|
|
|
{
|
|
|
|
|
Package *pkg = pkgtmp->data;
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *reqtmp;
|
2010-05-10 20:02:53 +02:00
|
|
|
|
|
|
|
|
/* process Requires: */
|
2012-11-29 05:40:40 -08:00
|
|
|
for (reqtmp = pkg->requires; reqtmp != NULL; reqtmp = g_list_next (reqtmp))
|
2010-05-10 20:02:53 +02:00
|
|
|
{
|
|
|
|
|
Package *deppkg = reqtmp->data;
|
|
|
|
|
RequiredVersion *req;
|
|
|
|
|
req = g_hash_table_lookup(pkg->required_versions, deppkg->key);
|
|
|
|
|
if ((req == NULL) || (req->comparison == ALWAYS_MATCH))
|
|
|
|
|
printf ("%s\n", deppkg->key);
|
|
|
|
|
else
|
|
|
|
|
printf ("%s %s %s\n", deppkg->key,
|
|
|
|
|
comparison_to_str(req->comparison),
|
|
|
|
|
req->version);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (want_requires_private)
|
|
|
|
|
{
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *pkgtmp;
|
|
|
|
|
for (pkgtmp = packages; pkgtmp != NULL; pkgtmp = g_list_next (pkgtmp))
|
2010-05-10 20:02:53 +02:00
|
|
|
{
|
|
|
|
|
Package *pkg = pkgtmp->data;
|
2012-11-29 05:40:40 -08:00
|
|
|
GList *reqtmp;
|
2010-05-10 20:02:53 +02:00
|
|
|
/* process Requires.private: */
|
2012-11-29 05:40:40 -08:00
|
|
|
for (reqtmp = pkg->requires_private; reqtmp != NULL; reqtmp = g_list_next (reqtmp))
|
2010-05-10 20:02:53 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Package *deppkg = reqtmp->data;
|
|
|
|
|
RequiredVersion *req;
|
|
|
|
|
|
2012-11-29 05:40:40 -08:00
|
|
|
if (g_list_find (pkg->requires, reqtmp->data))
|
2010-05-10 20:02:53 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
req = g_hash_table_lookup(pkg->required_versions, deppkg->key);
|
|
|
|
|
if ((req == NULL) || (req->comparison == ALWAYS_MATCH))
|
|
|
|
|
printf ("%s\n", deppkg->key);
|
|
|
|
|
else
|
|
|
|
|
printf ("%s %s %s\n", deppkg->key,
|
|
|
|
|
comparison_to_str(req->comparison),
|
|
|
|
|
req->version);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
/* Print all flags; then print a newline at the end. */
|
|
|
|
|
need_newline = FALSE;
|
|
|
|
|
|
|
|
|
|
if (variable_name)
|
|
|
|
|
{
|
|
|
|
|
char *str = packages_get_var (packages, variable_name);
|
|
|
|
|
printf ("%s", str);
|
|
|
|
|
g_free (str);
|
|
|
|
|
need_newline = TRUE;
|
|
|
|
|
}
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2012-12-11 08:43:37 -08:00
|
|
|
if (pkg_flags != 0)
|
2005-07-14 13:04:01 +00:00
|
|
|
{
|
2012-12-11 08:43:37 -08:00
|
|
|
char *str = packages_get_flags (packages, pkg_flags);
|
2012-10-16 20:44:16 -07:00
|
|
|
printf ("%s", str);
|
2005-07-14 13:04:01 +00:00
|
|
|
g_free (str);
|
|
|
|
|
need_newline = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (need_newline)
|
|
|
|
|
printf ("\n");
|
2005-07-14 13:05:34 +00:00
|
|
|
|
2005-07-14 13:04:01 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|