2009-03-30 Tollef Fog Heen <tfheen@err.no>
+ * pkg.[ch], parse.[ch], main.c, check/Makefile.am,
+ check/check-missing, check/missing-requires-private.pc:
+ Skip Requires.private unless we need to look at them for cflags.
+ Add test case. Thanks to Loïc Minier for most of the idea and the
+ implementation. Debian #475031
+
* check/common: Run all tests in the C locale
* check/common: Add support for non-zero return codes to test
TESTS = check-cflags check-libs check-define-variable \
check-libs-private check-requires-private check-includedir \
- check-conflicts
+ check-conflicts check-missing
EXTRA_DIST = $(TESTS) common simple.pc requires-test.pc public-dep.pc \
- private-dep.pc includedir.pc
+ private-dep.pc includedir.pc missing-requires-private.pc
--- /dev/null
+#! /bin/sh
+
+# Make sure we're POSIX
+if [ "$PKG_CONFIG_SHELL_IS_POSIX" != "1" ]; then
+ PKG_CONFIG_SHELL_IS_POSIX=1 PATH=`getconf PATH` exec sh $0 "$@"
+fi
+
+. ${srcdir}/common
+
+# non-existent package; call should fail and cause no output
+EXPECT_RETURN=1
+RESULT=""
+ARGS="pkg-non-existent"
+run_test
+
+# tests below are on an existing package, but with missing Requires.private;
+# when pkg-config outputs error, the actual error text isn't checked
+# package exists
+ARGS="missing-requires-private"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+# get Libs
+ARGS="--libs missing-requires-private"
+EXPECT_RETURN=0
+RESULT="-L/missing-requires-private/lib -lmissing-requires-private"
+run_test
+
+# Libs.private should fail (verbosely, but the output isn't verified)
+ARGS="--silence-errors --static --libs missing-requires-private"
+EXPECT_RETURN=1
+RESULT=""
+run_test
+
+# Cflags.private should fail (verbosely, but the output isn't verified)
+ARGS="--silence-errors --static --cflags missing-requires-private"
+EXPECT_RETURN=1
+RESULT=""
+run_test
+
+# Cflags should fail (verbosely, but the output isn't verified)
+ARGS="--silence-errors --cflags missing-requires-private"
+EXPECT_RETURN=1
+RESULT=""
+run_test
+
+# get includedir var
+ARGS="--variable includedir missing-requires-private"
+EXPECT_RETURN=0
+RESULT="/usr/include/somedir"
+run_test
--- /dev/null
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include/somedir
+
+Name: Missing Requires.private test package
+Description: Dummy package for testing with a missing Requires.private
+Version: 1.0.0
+Requires.private: pkg-non-existent-private-dep
+Libs: -L/missing-requires-private/lib -lmissing-requires-private
+Cflags: -I/missing-requires-private/include
+foodir: bar
else
disable_private_libs();
+ /* honor Requires.private if any Cflags are requested or any static
+ * libs are requested */
+
+ if (want_I_cflags || want_other_cflags || want_cflags ||
+ (want_static_lib_list && (want_libs || want_l_libs || want_L_libs)))
+ enable_requires_private();
+
if (want_my_version)
{
printf ("%s\n", VERSION);
/*
- * Copyright (C) 2006-2008 Tollef Fog Heen <tfheen@err.no>
+ * Copyright (C) 2006-2009 Tollef Fog Heen <tfheen@err.no>
* Copyright (C) 2001, 2002, 2005-2006 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
#endif
static void
-parse_line (Package *pkg, const char *untrimmed, const char *path, gboolean ignore_requires, gboolean ignore_private_libs)
+parse_line (Package *pkg, const char *untrimmed, const char *path,
+ gboolean ignore_requires, gboolean ignore_private_libs,
+ gboolean ignore_requires_private)
{
char *str;
char *p;
else if (strcmp (tag, "Version") == 0)
parse_version (pkg, p, path);
else if (strcmp (tag, "Requires.private") == 0)
- parse_requires_private (pkg, p, path);
+ {
+ if (!ignore_requires_private)
+ parse_requires_private (pkg, p, path);
+ }
else if (strcmp (tag, "Requires") == 0)
{
if (ignore_requires == FALSE)
}
Package*
-parse_package_file (const char *path, gboolean ignore_requires, gboolean ignore_private_libs)
+parse_package_file (const char *path, gboolean ignore_requires,
+ gboolean ignore_private_libs,
+ gboolean ignore_requires_private)
{
FILE *f;
Package *pkg;
{
one_line = TRUE;
- parse_line (pkg, str->str, path, ignore_requires, ignore_private_libs);
+ parse_line (pkg, str->str, path, ignore_requires, ignore_private_libs,
+ ignore_requires_private);
g_string_truncate (str, 0);
}
#include "pkg.h"
Package *parse_package_file (const char *path, gboolean ignore_requires,
- gboolean ignore_private_libs);
+ gboolean ignore_private_libs,
+ gboolean ignore_requires_private);
Package *get_compat_package (const char *name);
gboolean disable_uninstalled = FALSE;
gboolean ignore_requires = FALSE;
+gboolean ignore_requires_private = TRUE;
gboolean ignore_private_libs = TRUE;
void
}
debug_spew ("Reading '%s' from file '%s'\n", name, location);
- pkg = parse_package_file (location, ignore_requires, ignore_private_libs);
+ pkg = parse_package_file (location, ignore_requires, ignore_private_libs,
+ ignore_requires_private);
if (pkg == NULL)
{
print_package_list (void)
{
int mlen = 0;
-
+
ignore_requires = TRUE;
+ ignore_requires_private = TRUE;
g_hash_table_foreach (locations, max_len_foreach, &mlen);
g_hash_table_foreach (locations, packages_foreach, GINT_TO_POINTER (mlen + 1));
{
ignore_private_libs = TRUE;
}
+
+
+void
+enable_requires_private(void)
+{
+ ignore_requires_private = FALSE;
+}
+
+void
+disable_requires_private(void)
+{
+ ignore_requires_private = TRUE;
+}
void enable_private_libs(void);
void disable_private_libs(void);
+void enable_requires_private(void);
+void disable_requires_private(void);
/* If TRUE, do not automatically prefer uninstalled versions */
extern gboolean disable_uninstalled;