소스 검색

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 년 전
부모
커밋
43c2ba382c
2개의 변경된 파일13개의 추가작업 그리고 8개의 파일을 삭제
  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
 \fB\-\-showformat\fP option.
 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
 .BR \-s ", " \-\-status " \fIpackage-name\fP..."
 Report status of specified package. This just displays the entry in
@@ -217,15 +219,18 @@ fields in control files):
     \fBsource:Version\fP
 .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
 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
 run:
 
 .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
 .
 .SH "EXIT STATUS"

+ 4 - 4
src/querycmd.c

@@ -55,7 +55,7 @@
 #include "infodb.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;
 
@@ -107,7 +107,7 @@ list_format_init(struct list_format *fmt, struct pkg_array *array)
     for (i = 0; i < array->n_pkgs; i++) {
       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,
                                     vdew_nonambig));
       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_status(pkg),
          pkg_abbrev_eflag(pkg),
-         pkg->set->name,
+         pkg_name(pkg, pnaw_nonambig),
          versiondescribe(&pkg->installed.version, vdew_nonambig),
          l, pdesc);
 }
@@ -300,7 +300,7 @@ static int searchoutput(struct filenamenode *namenode) {
   while ((pkg_owner = filepackages_iter_next(iter))) {
     if (found)
       fputs(", ", stdout);
-    fputs(pkg_owner->set->name, stdout);
+    fputs(pkg_name(pkg_owner, pnaw_nonambig), stdout);
     found++;
   }
   filepackages_iter_free(iter);