On Thu, Dec 23, 2010 at 05:34:28PM -0800, Steve Langasek wrote: > Output pkg:arch in dpkg -l output for non-native packages, and parse pkg:arch > syntax in input arguments to dpkg -l > --- > src/query.c | 29 +++++++++++++++++++++++++++-- > 1 files changed, 27 insertions(+), 2 deletions(-)
Likewise, an updated version of this patch rebased against current dpkg. -- Steve Langasek Give me a lever long enough and a Free OS Debian Developer to set it on, and I can move the world. Ubuntu Developer http://www.debian.org/ [email protected] [email protected]
>From f0e5dedc28ec2680ab29905fcd5cffa7847fb697 Mon Sep 17 00:00:00 2001 From: Steve Langasek <[email protected]> Date: Sat, 5 Sep 2009 00:36:25 -0700 Subject: [PATCH 2/2] pkg:arch handling for dpkg -l To: [email protected] Output pkg:arch in dpkg -l output for non-native packages, and parse pkg:arch syntax in input arguments to dpkg -l --- src/querycmd.c | 29 +++++++++++++++++++++++++++-- 1 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/querycmd.c b/src/querycmd.c index dbeed30..ba1282b 100644 --- a/src/querycmd.c +++ b/src/querycmd.c @@ -79,6 +79,7 @@ list1package(struct pkginfo *pkg, bool *head, struct pkg_array *array) int i,l,w; static int nw,vw,dw; const char *pdesc; + char *pname; static char format[80] = ""; if (format[0] == '\0') { @@ -89,6 +90,9 @@ list1package(struct pkginfo *pkg, bool *head, struct pkg_array *array) int plen, vlen, dlen; plen = strlen(array->pkgs[i]->name); + if (strcmp(ARCHITECTURE, array->pkgs[i]->installed.architecture) != 0 && + strcmp("all", array->pkgs[i]->installed.architecture) != 0) + plen += strlen(array->pkgs[i]->installed.architecture) + 1; vlen = strlen(versiondescribe(&array->pkgs[i]->installed.version, vdew_nonambig)); pkg_summary(array->pkgs[i], &dlen); @@ -150,11 +154,20 @@ Desired=Unknown/Install/Remove/Purge/Hold\n\ pdesc = pkg_summary(pkg, &l); l = min(l, dw); + if (pkg->installed.architecture && + strcmp(ARCHITECTURE, pkg->installed.architecture) != 0 && + strcmp("all", pkg->installed.architecture) != 0) + { + pname = m_malloc(strlen(pkg->installed.architecture) + strlen(pkg->name) + 2); + sprintf(pname, "%s:%s", pkg->name, pkg->installed.architecture); + } else { + pname = (char *)pkg->name; + } printf(format, "uihrp"[pkg->want], "ncHUFWti"[pkg->status], " R"[pkg->eflag], - pkg->name, + pname, versiondescribe(&pkg->installed.version, vdew_nonambig), l, pdesc); } @@ -189,9 +202,21 @@ listpackages(const char *const *argv) memset(found, 0, sizeof(int) * argc); for (i = 0; i < array.n_pkgs; i++) { + char *arch, *pkgname; pkg = array.pkgs[i]; for (ip = 0; ip < argc; ip++) { - if (!fnmatch(argv[ip], pkg->name, 0)) { + pkgname = m_strdup(argv[ip]); + arch = strchr(pkgname, ':'); + if (arch) { + *arch = '\0'; + arch++; + } + if (!fnmatch(pkgname, pkg->name, 0) && + (!pkg->installed.architecture || + (arch && fnmatch(arch, pkg->installed.architecture, 0) == 0) || + (!arch && (strcmp(ARCHITECTURE, pkg->installed.architecture) == 0 || + strcmp("all", pkg->installed.architecture) == 0)))) + { list1package(pkg, &head, &array); found[ip]++; break; -- 1.7.1

