From fa70357276aa66229905b456f2e5b64421f931fb Mon Sep 17 00:00:00 2001 From: "Christopher P. Bills" Date: Mon, 6 May 2013 22:25:59 -0700 Subject: [PATCH] added test for multi-arch support - dpkg-query doesn't recognize 'binary:Package' as a format variable - if dpkg --print-foreign-architectures fails, change to old format --- blueprint/backend/apt.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/blueprint/backend/apt.py b/blueprint/backend/apt.py index 80fa841..94b1bda 100644 --- a/blueprint/backend/apt.py +++ b/blueprint/backend/apt.py @@ -11,10 +11,19 @@ def apt(b, r): logging.info('searching for APT packages') + # define a default output format string for dpkg-query + output_format = '${Status}\x1E${binary:Package}\x1E${Version}\n' + + # try running dpkg --print-foreign-architectures to see if dpkg is + # multi-arch aware. if not, revert to old style output_format + rv = subprocess.call(['dpkg', '--print-foreign-architectures'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if rv != 0: + output_format = '${Status}\x1E${Package}\x1E${Version}\n' + # Try for the full list of packages. If this fails, don't even # bother with the rest because this is probably a Yum/RPM-based # system. - output_format = '${Status}\x1E${binary:Package}\x1E${Version}\n' try: p = subprocess.Popen(['dpkg-query','-Wf',output_format], close_fds=True, stdout=subprocess.PIPE)