[PATCH] dpkg-query: --listfiles without package lists all files
From: Jochen Sprickerhof <jspricke@debian.org>
---
man/dpkg-query.pod | 2 +-
man/dpkg.pod | 2 +-
src/main/main.c | 2 +-
src/query/main.c | 24 ++++++++++++++++++++----
4 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/man/dpkg-query.pod b/man/dpkg-query.pod
index ade71db25..53ab4e3b7 100644
--- a/man/dpkg-query.pod
+++ b/man/dpkg-query.pod
@@ -137,7 +137,7 @@ When multiple I<package-name> entries are listed, the requested status
entries are separated by an empty line, with the same order as specified
on the argument list.
-=item B<-L>, B<--listfiles> I<package-name>...
+=item B<-L>, B<--listfiles> [I<package-name>...]
List files installed to your system from I<package-name>. When multiple
I<package-name>s are listed, the requested lists of files are separated
diff --git a/man/dpkg.pod b/man/dpkg.pod
index f09b7c0d1..2aa2fbecc 100644
--- a/man/dpkg.pod
+++ b/man/dpkg.pod
@@ -596,7 +596,7 @@ List packages matching given pattern.
Report status of specified package.
-=item B<-L>, B<--listfiles> I<package-name>...
+=item B<-L>, B<--listfiles> [I<package-name>...]
List files installed to your system from I<package-name>.
diff --git a/src/main/main.c b/src/main/main.c
index 9cba932aa..d5d95374b 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -104,7 +104,7 @@ usage(const struct cmdinfo *ci, const char *value)
" --forget-old-unavail Forget uninstalled unavailable pkgs.\n"
" -s|--status [<package>...] Display package status details.\n"
" -p|--print-avail [<package>...] Display available version details.\n"
-" -L|--listfiles <package>... List files 'owned' by package(s).\n"
+" -L|--listfiles [<package>...] List files 'owned' by package(s).\n"
" -l|--list [<pattern>...] List packages concisely.\n"
" -S|--search <pattern>... Find package(s) owning file(s).\n"
" -C|--audit [<package>...] Check for broken package(s).\n"
diff --git a/src/query/main.c b/src/query/main.c
index 6e3fe51ef..eabd03180 100644
--- a/src/query/main.c
+++ b/src/query/main.c
@@ -480,15 +480,31 @@ list_files(const char *const *argv)
{
const char *thisarg;
struct fsys_namenode_list *file;
+ struct pkg_array array;
struct pkginfo *pkg;
struct fsys_namenode *namenode;
int failures = 0;
-
- if (!*argv)
- badusage(_("--%s needs at least one package name argument"), cipaction->olong);
+ int i;
modstatdb_open(msdbrw_readonly);
+ if (!*argv) {
+ pkg_array_init_from_hash(&array);
+ for (i = 0; i < array.n_pkgs; i++) {
+ pkg = array.pkgs[i];
+ if (pkg->status != PKG_STAT_NOTINSTALLED) {
+ ensure_packagefiles_available(pkg);
+ file = pkg->files;
+ while (file) {
+ namenode = file->namenode;
+ puts(namenode->name);
+ file = file->next;
+ }
+ }
+ }
+ return 0;
+ }
+
while ((thisarg = *argv++) != NULL) {
pkg = dpkg_options_parse_pkgname(cipaction, thisarg);
@@ -803,7 +819,7 @@ usage(const struct cmdinfo *ci, const char *value)
"Commands:\n"
" -s, --status [<package>...] Display package status details.\n"
" -p, --print-avail [<package>...] Display available version details.\n"
-" -L, --listfiles <package>... List files 'owned' by package(s).\n"
+" -L, --listfiles [<package>...] List files 'owned' by package(s).\n"
" -l, --list [<pattern>...] List packages concisely.\n"
" -W, --show [<pattern>...] Show information on package(s).\n"
" -S, --search <pattern>... Find package(s) owning file(s).\n"
--
2.37.2
Reply to: