Skip to content

Commit

Permalink
Fix #143 by protecting us from dpkg being missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcrowley committed Jul 12, 2013
1 parent 7eb16b0 commit 574a9fc
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions blueprint/backend/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
def apt(b, r):
logging.info('searching for APT packages')

# define a default output format string for dpkg-query
# 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
with open(os.devnull, 'w') as fnull:
rv = subprocess.call(['dpkg', '--print-foreign-architectures'],
stdout = fnull, stderr = fnull)
if rv != 0:
output_format = '${Status}\x1E${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.
try:
with open(os.devnull, 'w') as fnull:
rv = subprocess.call(['dpkg', '--print-foreign-architectures'],
stdout = fnull, stderr = fnull)
if rv != 0:
output_format = '${Status}\x1E${Package}\x1E${Version}\n'
except OSError:
return

# 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
Expand Down

0 comments on commit 574a9fc

Please sign in to comment.