[Piuparts-commits] [piuparts] 07/09: p: use dpkg-query -W instead of dpkg --get-selections

Holger Levsen holger at moszumanska.debian.org
Sat May 16 14:51:33 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 6f790204677ee7aca05890a6b6704fd206995c98
Author: Andreas Beckmann <anbe at debian.org>
Date:   Mon May 4 22:31:43 2015 +0200

    p: use dpkg-query -W instead of dpkg --get-selections
    
    to get arch and version information for installed packages
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 debian/changelog |  3 +++
 piuparts.py      | 15 +++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index a7bd9d0..0c2e689 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ piuparts (0.64) UNRELEASED; urgency=medium
     highlighting in vim. (Thanks DSA!)
 
   [ Andreas Beckmann ]
+  * piuparts.py:
+    - Use 'dpkg-query -W' instead of 'dpkg --get-selections' to record
+      architecture and version information for installed packages, too.
   * piuparts.conf:
     - New global setting: basetgz-sections, used by piuparts-slave only.
     - Switch to separate tarball sections.
diff --git a/piuparts.py b/piuparts.py
index 0fca2b2..266cae5 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -1200,11 +1200,18 @@ class Chroot:
 
     def get_selections(self):
         """Get current package selections in a chroot."""
-        (status, output) = self.run(["dpkg", "--get-selections", "*"])
-        vlist = [line.split() for line in output.split("\n") if line.strip()]
+        # "${Status}" emits three columns, e.g. "install ok installed"
+        (status, output) = self.run(["dpkg-query", "-W", "-f", "${Status}\\t${binary:Package}\\t${Version}\\n"])
         vdict = {}
-        for name, status in vlist:
-            vdict[name] = (status, None)
+        for line in [line for line in output.split("\n") if line.strip()]:
+            token = line.split()
+            status = token[0]
+            name = token[3]
+            if status == "install":
+                version = token[-1]
+            else:
+                version = None
+            vdict[name] = (status, version)
         return vdict
 
     def get_diversions(self):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list