Przeglądaj źródła

dpkg-query: Only load the available file on -l or -W with new --load-avail

Change the default behaviour of not loading the available file depending
on whether arguments have been passed to the commands, to instead adding
a new explicit option to let the user request the additional information
from the available file.

This is needed to avoid confusion given that with multiarch the
available file can contain multiple instances for the same package.
Guillem Jover 14 lat temu
rodzic
commit
6e8dda4cdb
3 zmienionych plików z 14 dodań i 4 usunięć
  1. 2 0
      debian/changelog
  2. 6 2
      man/dpkg-query.1
  3. 6 2
      src/querycmd.c

+ 2 - 0
debian/changelog

@@ -65,6 +65,8 @@ dpkg (1.16.2) UNRELEASED; urgency=low
   * Add missing --status-logger to dpkg --help output.
   * Do not print bogus errno string for invalid package names in dpkg
     --ignore-depends option.
+  * Change dpkg-query to not load the available file by default for --list
+    and --show, add a new --load-avail option to expose the old behaviour.
 
   [ Raphaël Hertzog ]
   * Update Dpkg::Shlibs to look into multiarch paths when cross-building

+ 6 - 2
man/dpkg-query.1

@@ -2,7 +2,7 @@
 .\"
 .\" Copyright © 2001 Wichert Akkerman <wakkerma@debian.org>
 .\" Copyright © 2006-2007 Frank Lichtenheld <djpig@debian.org>
-.\" Copyright © 2006-2011 Guillem Jover <guillem@debian.org>
+.\" Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
 .\" Copyright © 2008-2011 Raphaël Hertzog <hertzog@debian.org>
 .\"
 .\" This is free software; you can redistribute it and/or modify
@@ -18,7 +18,7 @@
 .\" You should have received a copy of the GNU General Public License
 .\" along with this program.  If not, see <http://www.gnu.org/licenses/>.
 .
-.TH dpkg\-query 1 "2012-01-11" "Debian Project" "dpkg suite"
+.TH dpkg\-query 1 "2012-02-22" "Debian Project" "dpkg suite"
 .SH NAME
 dpkg\-query \- a tool to query the dpkg database
 .
@@ -140,6 +140,10 @@ Show the version and exit.
 Change the location of the \fBdpkg\fR database. The default location is
 \fI/var/lib/dpkg\fP.
 .TP
+.B \-\-load\-avail
+Also load the available file when using the \fB\-\-show\fP and \fB\-\-list\fP
+commands, which now default to only querying the status file.
+.TP
 .BR \-f ", " \-\-showformat=\fIformat\fR
 This option is used to specify the format of the output \fB\-\-show\fP
 will produce. The format is a string that will be output for each package

+ 6 - 2
src/querycmd.c

@@ -54,6 +54,8 @@
 
 static const char* showformat		= "${Package}\t${Version}\n";
 
+static int opt_loadavail = 0;
+
 static int getwidth(void) {
   int fd;
   int res;
@@ -204,7 +206,7 @@ listpackages(const char *const *argv)
   int failures = 0;
   struct list_format fmt;
 
-  if (!*argv)
+  if (!opt_loadavail)
     modstatdb_open(msdbrw_readonly);
   else
     modstatdb_open(msdbrw_readonly | msdbrw_available_readonly);
@@ -478,7 +480,7 @@ showpackages(const char *const *argv)
     return failures;
   }
 
-  if (!*argv)
+  if (!opt_loadavail)
     modstatdb_open(msdbrw_readonly);
   else
     modstatdb_open(msdbrw_readonly | msdbrw_available_readonly);
@@ -643,6 +645,7 @@ usage(const struct cmdinfo *ci, const char *value)
   printf(_(
 "Options:\n"
 "  --admindir=<directory>           Use <directory> instead of %s.\n"
+"  --load-avail                     Use available file on --show and --list.\n"
 "  -f|--showformat=<format>         Use alternative format for --show.\n"
 "\n"), ADMINDIR);
 
@@ -678,6 +681,7 @@ static const struct cmdinfo cmdinfos[]= {
   ACTION( "control-path",                   'c', act_controlpath,   control_path    ),
 
   { "admindir",   0,   1, NULL, &admindir,   NULL          },
+  { "load-avail", 0,   0, &opt_loadavail, NULL, NULL, 1    },
   { "showformat", 'f', 1, NULL, &showformat, NULL          },
   { "help",       'h', 0, NULL, NULL,        usage         },
   { "version",    0,   0, NULL, NULL,        printversion  },