This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=f4bae73fa1158846648d566cb28cdcb7e9aaa90f commit f4bae73fa1158846648d566cb28cdcb7e9aaa90f Author: Guillem Jover <guil...@debian.org> AuthorDate: Sat Aug 11 03:11:42 2018 +0200 dpkg-query: Support dumping all --status and --print-avail records When not passing any argument these commands will dump the entire database. This way external programs will have a proper public interface to get all package records, even when there are unmerged journal entries. Closes: #616342 --- debian/changelog | 2 ++ man/dpkg-query.man | 23 +++++++++------ src/querycmd.c | 86 ++++++++++++++++++++++++++++-------------------------- 3 files changed, 60 insertions(+), 51 deletions(-) diff --git a/debian/changelog b/debian/changelog index b9ace1f54..849710fe8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -89,6 +89,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium introduced in dpkg 1.19.0. * Flush output for dpkg-query --status, --print-avail and --listfiles at the end, instead of after each stanza. + * Add support for dumping all dpkg-query --status and --print-avail records + from the database when no arguments are specified. Closes: #616342 * Architecture support: - Add support for riscv64 CPU. Closes: #822914 Thanks to Manuel A. Fernandez Montecelo <m...@debian.org> diff --git a/man/dpkg-query.man b/man/dpkg-query.man index 36f83580f..28220b462 100644 --- a/man/dpkg-query.man +++ b/man/dpkg-query.man @@ -95,11 +95,14 @@ having the name (extended with the architecture qualifier for \fBMulti\-Arch\fP \fBsame\fP packages) and installed version of the package, separated by a tab. .TP -.BR \-s ", " \-\-status " \fIpackage-name\fP..." +.BR \-s ", " \-\-status " [\fIpackage-name\fP...]" Report status of specified package. This just displays the entry in -the installed package status database. When multiple \fIpackage-name\fP -are listed, the requested status entries are separated by an empty line, -with the same order as specified on the argument list. +the installed package status database. +If no \fIpackage-name\fP is specified it will display all package entries +in the status database (since dpkg 1.19.1). +When multiple \fIpackage-name\fP entries are listed, the requested status +entries are separated by an empty line, with the same order as specified +on the argument list. .TP .BR \-L ", " \-\-listfiles " \fIpackage-name\fP..." List files installed to your system from \fIpackage-name\fP. When multiple @@ -148,11 +151,13 @@ handled like a glob pattern, otherwise any trailing ‘\fB/\fP’ or This command will not list extra files created by maintainer scripts, nor will it list alternatives. .TP -.BR \-p ", " \-\-print\-avail " \fIpackage-name\fP..." -Display details about \fIpackage-name\fP, as found in -\fI%ADMINDIR%/available\fP. When multiple \fIpackage-name\fP are -listed, the requested \fIavailable\fP entries are separated by an empty -line, with the same order as specified on the argument list. +.BR \-p ", " \-\-print\-avail " [\fIpackage-name\fP...]" +Display details about packages, as found in \fI%ADMINDIR%/available\fP. +If no \fIpackage-name\fP is specified, it will display all package entries +in the \fIavailable\fP database (since dpkg 1.19.1). +When multiple \fIpackage-name\fP are listed, the requested \fIavailable\fP +entries are separated by an empty line, with the same order as specified +on the argument list. Users of APT-based frontends should use \fBapt\-cache show\fP \fIpackage-name\fP instead diff --git a/src/querycmd.c b/src/querycmd.c index be54cd567..415235bff 100644 --- a/src/querycmd.c +++ b/src/querycmd.c @@ -395,29 +395,30 @@ print_status(const char *const *argv) struct pkginfo *pkg; int failures = 0; - if (!*argv) - badusage(_("--%s needs at least one package name argument"), cipaction->olong); - modstatdb_open(msdbrw_readonly); - while ((thisarg = *argv++) != NULL) { - pkg = dpkg_options_parse_pkgname(cipaction, thisarg); + if (!*argv) { + writedb_records(stdout, _("<standard output>"), 0); + } else { + while ((thisarg = *argv++) != NULL) { + pkg = dpkg_options_parse_pkgname(cipaction, thisarg); + + if (pkg->status == PKG_STAT_NOTINSTALLED && + pkg->priority == PKG_PRIO_UNKNOWN && + str_is_unset(pkg->section) && + !pkg->archives && + pkg->want == PKG_WANT_UNKNOWN && + !pkg_is_informative(pkg, &pkg->installed)) { + notice(_("package '%s' is not installed and no information is available"), + pkg_name(pkg, pnaw_nonambig)); + failures++; + } else { + writerecord(stdout, _("<standard output>"), pkg, &pkg->installed); + } - if (pkg->status == PKG_STAT_NOTINSTALLED && - pkg->priority == PKG_PRIO_UNKNOWN && - str_is_unset(pkg->section) && - !pkg->archives && - pkg->want == PKG_WANT_UNKNOWN && - !pkg_is_informative(pkg, &pkg->installed)) { - notice(_("package '%s' is not installed and no information is available"), - pkg_name(pkg, pnaw_nonambig)); - failures++; - } else { - writerecord(stdout, _("<standard output>"), pkg, &pkg->installed); + if (*argv != NULL) + putchar('\n'); } - - if (*argv != NULL) - putchar('\n'); } m_output(stdout, _("<standard output>")); @@ -439,24 +440,25 @@ print_avail(const char *const *argv) struct pkginfo *pkg; int failures = 0; - if (!*argv) - badusage(_("--%s needs at least one package name argument"), cipaction->olong); - modstatdb_open(msdbrw_readonly | msdbrw_available_readonly); - while ((thisarg = *argv++) != NULL) { - pkg = dpkg_options_parse_pkgname(cipaction, thisarg); + if (!*argv) { + writedb_records(stdout, _("<standard output>"), wdb_dump_available); + } else { + while ((thisarg = *argv++) != NULL) { + pkg = dpkg_options_parse_pkgname(cipaction, thisarg); - if (!pkg_is_informative(pkg, &pkg->available)) { - notice(_("package '%s' is not available"), - pkgbin_name(pkg, &pkg->available, pnaw_nonambig)); - failures++; - } else { - writerecord(stdout, _("<standard output>"), pkg, &pkg->available); - } + if (!pkg_is_informative(pkg, &pkg->available)) { + notice(_("package '%s' is not available"), + pkgbin_name(pkg, &pkg->available, pnaw_nonambig)); + failures++; + } else { + writerecord(stdout, _("<standard output>"), pkg, &pkg->available); + } - if (*argv != NULL) - putchar('\n'); + if (*argv != NULL) + putchar('\n'); + } } m_output(stdout, _("<standard output>")); @@ -768,16 +770,16 @@ usage(const struct cmdinfo *ci, const char *value) printf(_( "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|--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" -" --control-list <package> Print the package control file list.\n" -" --control-show <package> <file>\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, --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" +" --control-list <package> Print the package control file list.\n" +" --control-show <package> <file>\n" " Show the package control file.\n" -" -c|--control-path <package> [<file>]\n" +" -c, --control-path <package> [<file>]\n" " Print path for package control file.\n" "\n")); -- Dpkg.Org's dpkg