Skip to content

Commit

Permalink
added test for multi-arch support
Browse files Browse the repository at this point in the history
- dpkg-query doesn't recognize 'binary:Package' as a format variable
- if dpkg --print-foreign-architectures fails, change to old format
  • Loading branch information
cpbills committed May 7, 2013
1 parent 7df3951 commit fa70357
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion blueprint/backend/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fa70357

Please sign in to comment.