Skip to content

Commit

Permalink
Fix identification of installed packages in Ubuntu 14.04
Browse files Browse the repository at this point in the history
Ubuntu 14.04 comes with an apt-get that produces slightly differently
formatted output, which makes our code for detecting installed packages
fail.  This adjusted code works with Ubuntu 14.04 as well as older
Ubuntu and Debian versions.
  • Loading branch information
opera-jl authored and jensl committed May 26, 2014
1 parent 6da8411 commit dee45e9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions installation/prereqs.py
Expand Up @@ -69,7 +69,6 @@ def install_packages(arguments, *packages):
default=True)
if not aptget_approved: aptget = False
if aptget:
installed_anything = False
aptget_env = os.environ.copy()
if arguments.headless:
aptget_env["DEBIAN_FRONTEND"] = "noninteractive"
Expand All @@ -81,13 +80,16 @@ def install_packages(arguments, *packages):
aptget_output = subprocess.check_output(
[aptget, "-qq", "-y", "install"] + list(packages),
env=aptget_env)
installed = {}
for line in aptget_output.splitlines():
match = re.search(r"([^ ]+) \(.* \.\.\./([^)]+\.deb)\) \.\.\.", line)
match = re.match(r"^Setting up ([^ ]+) \(([^)]+)\) \.\.\.", line)
if match:
need_blankline = True
installed_anything = True
print "Installed: %s (%s)" % (match.group(1), match.group(2))
return installed_anything
package_name, version = match.groups()
if package_name in packages:
need_blankline = True
installed[package_name] = version
print "Installed: %s (%s)" % (package_name, version)
return installed
else:
return False

Expand Down

0 comments on commit dee45e9

Please sign in to comment.