Forráskód Böngészése

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 éve
szülő
commit
6e8dda4cdb
3 módosított fájl, 14 hozzáadás és 4 törlés
  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.
   * Add missing --status-logger to dpkg --help output.
   * Do not print bogus errno string for invalid package names in dpkg
   * Do not print bogus errno string for invalid package names in dpkg
     --ignore-depends option.
     --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 ]
   [ Raphaël Hertzog ]
   * Update Dpkg::Shlibs to look into multiarch paths when cross-building
   * 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 © 2001 Wichert Akkerman <wakkerma@debian.org>
 .\" Copyright © 2006-2007 Frank Lichtenheld <djpig@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>
 .\" Copyright © 2008-2011 Raphaël Hertzog <hertzog@debian.org>
 .\"
 .\"
 .\" This is free software; you can redistribute it and/or modify
 .\" 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
 .\" You should have received a copy of the GNU General Public License
 .\" along with this program.  If not, see <http://www.gnu.org/licenses/>.
 .\" 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
 .SH NAME
 dpkg\-query \- a tool to query the dpkg database
 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
 Change the location of the \fBdpkg\fR database. The default location is
 \fI/var/lib/dpkg\fP.
 \fI/var/lib/dpkg\fP.
 .TP
 .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
 .BR \-f ", " \-\-showformat=\fIformat\fR
 This option is used to specify the format of the output \fB\-\-show\fP
 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
 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 const char* showformat		= "${Package}\t${Version}\n";
 
 
+static int opt_loadavail = 0;
+
 static int getwidth(void) {
 static int getwidth(void) {
   int fd;
   int fd;
   int res;
   int res;
@@ -204,7 +206,7 @@ listpackages(const char *const *argv)
   int failures = 0;
   int failures = 0;
   struct list_format fmt;
   struct list_format fmt;
 
 
-  if (!*argv)
+  if (!opt_loadavail)
     modstatdb_open(msdbrw_readonly);
     modstatdb_open(msdbrw_readonly);
   else
   else
     modstatdb_open(msdbrw_readonly | msdbrw_available_readonly);
     modstatdb_open(msdbrw_readonly | msdbrw_available_readonly);
@@ -478,7 +480,7 @@ showpackages(const char *const *argv)
     return failures;
     return failures;
   }
   }
 
 
-  if (!*argv)
+  if (!opt_loadavail)
     modstatdb_open(msdbrw_readonly);
     modstatdb_open(msdbrw_readonly);
   else
   else
     modstatdb_open(msdbrw_readonly | msdbrw_available_readonly);
     modstatdb_open(msdbrw_readonly | msdbrw_available_readonly);
@@ -643,6 +645,7 @@ usage(const struct cmdinfo *ci, const char *value)
   printf(_(
   printf(_(
 "Options:\n"
 "Options:\n"
 "  --admindir=<directory>           Use <directory> instead of %s.\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"
 "  -f|--showformat=<format>         Use alternative format for --show.\n"
 "\n"), ADMINDIR);
 "\n"), ADMINDIR);
 
 
@@ -678,6 +681,7 @@ static const struct cmdinfo cmdinfos[]= {
   ACTION( "control-path",                   'c', act_controlpath,   control_path    ),
   ACTION( "control-path",                   'c', act_controlpath,   control_path    ),
 
 
   { "admindir",   0,   1, NULL, &admindir,   NULL          },
   { "admindir",   0,   1, NULL, &admindir,   NULL          },
+  { "load-avail", 0,   0, &opt_loadavail, NULL, NULL, 1    },
   { "showformat", 'f', 1, NULL, &showformat, NULL          },
   { "showformat", 'f', 1, NULL, &showformat, NULL          },
   { "help",       'h', 0, NULL, NULL,        usage         },
   { "help",       'h', 0, NULL, NULL,        usage         },
   { "version",    0,   0, NULL, NULL,        printversion  },
   { "version",    0,   0, NULL, NULL,        printversion  },