From 4697d636cc4e87083f42deefbcca09e338521fca Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Mon, 7 Oct 2024 17:06:52 -0700 Subject: [PATCH] cli: main: allow use of multiple package names in solution-based queries Query types like --print-requires, --print-requires-private and --print-provides can be used in practice to query information about a calculated solution rather than a single package. Allow this to be done where it makes sense to allow it, while continuing to restrict package-specific queries (like --variable= and --variables) to single packages. Fixes: 541de8bd ("main: handle query selectors that are only usable for single packages correctly") Signed-off-by: Ariadne Conill Closes: #366 --- cli/main.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/cli/main.c b/cli/main.c index cf75bfa..0fdd4af 100644 --- a/cli/main.c +++ b/cli/main.c @@ -1298,24 +1298,24 @@ main(int argc, char *argv[]) if ((want_flags & PKG_INTERNAL_CFLAGS) == PKG_INTERNAL_CFLAGS) want_client_flags |= PKGCONF_PKG_PKGF_DONT_FILTER_INTERNAL_CFLAGS; - /* if these selectors are used, it means that we are inquiring about a single package. - * so signal to libpkgconf that we do not want to use the dependency resolver for more than one level, - * and also limit the SAT problem to a single package. + /* if these selectors are used, it means that we are querying metadata. + * so signal to libpkgconf that we only want to walk the flattened dependency set. */ - if (((want_flags & PKG_REQUIRES) == PKG_REQUIRES || - (want_flags & PKG_REQUIRES_PRIVATE) == PKG_REQUIRES_PRIVATE || - (want_flags & PKG_PROVIDES) == PKG_PROVIDES || - (want_flags & PKG_VARIABLES) == PKG_VARIABLES || - (want_flags & PKG_PATH) == PKG_PATH || - want_variable != NULL)) - { - maximum_package_count = 1; + if ((want_flags & PKG_MODVERSION) == PKG_MODVERSION || + (want_flags & PKG_REQUIRES) == PKG_REQUIRES || + (want_flags & PKG_REQUIRES_PRIVATE) == PKG_REQUIRES_PRIVATE || + (want_flags & PKG_PROVIDES) == PKG_PROVIDES || + (want_flags & PKG_VARIABLES) == PKG_VARIABLES || + (want_flags & PKG_PATH) == PKG_PATH) maximum_traverse_depth = 1; - } - /* we also want to walk only the flattened dependencies if we are requesting --modversion. */ - if ((want_flags & PKG_MODVERSION) == PKG_MODVERSION) - maximum_traverse_depth = 1; + /* if we are asking for a variable, path or list of variables, this only makes sense + * for a single package. + */ + if ((want_flags & PKG_VARIABLES) == PKG_VARIABLES || + (want_flags & PKG_PATH) == PKG_PATH || + want_variable != NULL) + maximum_package_count = 1; if (getenv("PKG_CONFIG_ALLOW_SYSTEM_CFLAGS") != NULL) want_flags |= PKG_KEEP_SYSTEM_CFLAGS;