[PATCH v3] query: permit filter options with --owns
Signed-off-by: Ronan Pigott <ronan@rjp.ie> --- Changes in v2: - Use forward declarations - Drop the unnecessary error message Changes in v3: - Remove one unnecessary forward decl src/pacman/pacman.c | 1 - src/pacman/query.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index e5c6e4200932..320c7654e0a7 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -608,7 +608,6 @@ static void checkargs_query(void) } else if(config->op_q_owns) { invalid_opt(config->group, "--owns", "--groups"); checkargs_query_display_opts("--owns"); - checkargs_query_filter_opts("--owns"); } else if(config->group) { checkargs_query_display_opts("--groups"); } diff --git a/src/pacman/query.c b/src/pacman/query.c index d75c4c801be5..bcf948514ca3 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -135,6 +135,8 @@ cleanup: return (success ? resolved_path : NULL); } +static int filter(alpm_pkg_t *pkg); + static int query_fileowner(alpm_list_t *targets) { int ret = 0; @@ -210,6 +212,9 @@ static int query_fileowner(alpm_list_t *targets) } for(i = packages; i && (!found || is_dir); i = alpm_list_next(i)) { + if (!filter(i->data)) { + continue; + } if(alpm_filelist_contains(alpm_pkg_get_files(i->data), rel_path)) { print_query_fileowner(rpath, i->data); found = 1; -- 2.41.0
On 3/6/23 07:14, Ronan Pigott wrote:
Signed-off-by: Ronan Pigott <ronan@rjp.ie> ---
Changes in v2: - Use forward declarations - Drop the unnecessary error message Changes in v3: - Remove one unnecessary forward decl
The filtering only works when there is filtering to be done: $ ./build/pacman -Qoe /opt/genymotion/ /opt/genymotion/ is owned by test 1-1 /opt/genymotion/ is owned by genymotion 3.4.0-1 $ ./build/pacman -Qom /opt/genymotion/ /opt/genymotion/ is owned by test 1-1 /opt/genymotion/ is owned by genymotion 3.4.0-1 It does work on /etc on my system, as there is explicitly and non-explicitly installed packages. When it does work properly, the "No package owns" message will be wrong.
src/pacman/pacman.c | 1 - src/pacman/query.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index e5c6e4200932..320c7654e0a7 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -608,7 +608,6 @@ static void checkargs_query(void) } else if(config->op_q_owns) { invalid_opt(config->group, "--owns", "--groups"); checkargs_query_display_opts("--owns"); - checkargs_query_filter_opts("--owns"); } else if(config->group) { checkargs_query_display_opts("--groups"); } diff --git a/src/pacman/query.c b/src/pacman/query.c index d75c4c801be5..bcf948514ca3 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -135,6 +135,8 @@ cleanup: return (success ? resolved_path : NULL); }
+static int filter(alpm_pkg_t *pkg); + static int query_fileowner(alpm_list_t *targets) { int ret = 0; @@ -210,6 +212,9 @@ static int query_fileowner(alpm_list_t *targets) }
for(i = packages; i && (!found || is_dir); i = alpm_list_next(i)) { + if (!filter(i->data)) { + continue; + } if(alpm_filelist_contains(alpm_pkg_get_files(i->data), rel_path)) { print_query_fileowner(rpath, i->data); found = 1;
participants (2)
-
Allan McRae
-
Ronan Pigott