Przeglądaj źródła

dpkg-query: Update output commands to print package specifiers

This affects --list and --show. Also use package specifiers in the
default output format and document this change in the manual page.

Based-on-patch-by: Raphaël Hertzog <hertzog@debian.org>
Patch-sponsored-by: Linaro Limited

Signed-off-by: Guillem Jover <guillem@debian.org>
Guillem Jover 14 lat temu
rodzic
commit
43c2ba382c
2 zmienionych plików z 13 dodań i 8 usunięć
  1. 9 4
      man/dpkg-query.1
  2. 4 4
      src/querycmd.c

+ 9 - 4
man/dpkg-query.1

@@ -90,7 +90,9 @@ Just like the \fB\-\-list\fP option this will list all packages matching
 the given pattern. However the output can be customized using the
 the given pattern. However the output can be customized using the
 \fB\-\-showformat\fP option.
 \fB\-\-showformat\fP option.
 The default output format gives one line per matching package, each line
 The default output format gives one line per matching package, each line
-having the name and installed version of the package, separated by a tab.
+having the name (extended with the architecture qualifier for
+\fIMuli\-Arch\fP \fBsame\fP packages) and installed version of the package,
+separated by a tab.
 .TP
 .TP
 .BR \-s ", " \-\-status " \fIpackage-name\fP..."
 .BR \-s ", " \-\-status " \fIpackage-name\fP..."
 Report status of specified package. This just displays the entry in
 Report status of specified package. This just displays the entry in
@@ -217,15 +219,18 @@ fields in control files):
     \fBsource:Version\fP
     \fBsource:Version\fP
 .fi
 .fi
 
 
-The default format string is \(lq\fB${Package}\et${Version}\en\fP\(rq.
+The default format string is \(lq\fB${binary:Package}\et${Version}\en\fP\(rq.
 Actually, all other fields found in the status file (i.e. user defined
 Actually, all other fields found in the status file (i.e. user defined
 fields) can be requested, too. They will be printed as-is, though, no
 fields) can be requested, too. They will be printed as-is, though, no
-conversion nor error checking is done on them.
+conversion nor error checking is done on them. \fBbinary:Package\fP is
+a special field that will print the package name with an architecture
+qualifier (like "libc6:amd64") if the package has a \fIMulti\-Arch\fP
+field with a value of \fBsame\fP, and as such its name could be ambiguous.
 To get the name of the dpkg maintainer and the installed version, you could
 To get the name of the dpkg maintainer and the installed version, you could
 run:
 run:
 
 
 .nf
 .nf
-  \fBdpkg\-query \-W \-f=\(aq${Package} ${Version}\\t${Maintainer}\\n\(aq dpkg\fP
+  \fBdpkg\-query \-W \-f=\(aq${binary:Package} ${Version}\\t${Maintainer}\\n\(aq dpkg\fP
 .fi
 .fi
 .
 .
 .SH "EXIT STATUS"
 .SH "EXIT STATUS"

+ 4 - 4
src/querycmd.c

@@ -55,7 +55,7 @@
 #include "infodb.h"
 #include "infodb.h"
 #include "main.h"
 #include "main.h"
 
 
-static const char* showformat		= "${Package}\t${Version}\n";
+static const char *showformat = "${binary:Package}\t${Version}\n";
 
 
 static int opt_loadavail = 0;
 static int opt_loadavail = 0;
 
 
@@ -107,7 +107,7 @@ list_format_init(struct list_format *fmt, struct pkg_array *array)
     for (i = 0; i < array->n_pkgs; i++) {
     for (i = 0; i < array->n_pkgs; i++) {
       int plen, vlen, dlen;
       int plen, vlen, dlen;
 
 
-      plen = strlen(array->pkgs[i]->set->name);
+      plen = strlen(pkg_name(array->pkgs[i], pnaw_nonambig));
       vlen = strlen(versiondescribe(&array->pkgs[i]->installed.version,
       vlen = strlen(versiondescribe(&array->pkgs[i]->installed.version,
                                     vdew_nonambig));
                                     vdew_nonambig));
       pkg_summary(array->pkgs[i], &array->pkgs[i]->installed, &dlen);
       pkg_summary(array->pkgs[i], &array->pkgs[i]->installed, &dlen);
@@ -195,7 +195,7 @@ list1package(struct pkginfo *pkg, struct list_format *fmt, struct pkg_array *arr
          pkg_abbrev_want(pkg),
          pkg_abbrev_want(pkg),
          pkg_abbrev_status(pkg),
          pkg_abbrev_status(pkg),
          pkg_abbrev_eflag(pkg),
          pkg_abbrev_eflag(pkg),
-         pkg->set->name,
+         pkg_name(pkg, pnaw_nonambig),
          versiondescribe(&pkg->installed.version, vdew_nonambig),
          versiondescribe(&pkg->installed.version, vdew_nonambig),
          l, pdesc);
          l, pdesc);
 }
 }
@@ -300,7 +300,7 @@ static int searchoutput(struct filenamenode *namenode) {
   while ((pkg_owner = filepackages_iter_next(iter))) {
   while ((pkg_owner = filepackages_iter_next(iter))) {
     if (found)
     if (found)
       fputs(", ", stdout);
       fputs(", ", stdout);
-    fputs(pkg_owner->set->name, stdout);
+    fputs(pkg_name(pkg_owner, pnaw_nonambig), stdout);
     found++;
     found++;
   }
   }
   filepackages_iter_free(iter);
   filepackages_iter_free(iter);