Don't assume the user's OS in provision.py

We still need to put in the work to support other platforms, but now at least
we'll error out if you're not on 64-bit Ubuntu 14.04.

(imported from commit 3a35953206906044947e3447c7ab8fca78a76e1e)
This commit is contained in:
Luke Faraone 2015-08-18 19:18:08 -07:00 committed by Tim Abbott
parent 0d7f749ad8
commit 75d0146d33
1 changed files with 21 additions and 5 deletions

View File

@ -1,10 +1,18 @@
import os import os
import logging
import platform
try: try:
import sh import sh
except ImportError: except ImportError:
import pbs as sh import pbs as sh
SUPPORTED_PLATFORMS = {
"Ubuntu": [
"trusty",
],
}
APT_DEPENDENCIES = { APT_DEPENDENCIES = {
"trusty": [ "trusty": [
"libffi-dev", "libffi-dev",
@ -44,23 +52,31 @@ REPO_STOPWORDS_PATH = os.path.join(
"zulip_english.stop", "zulip_english.stop",
) )
log = logging.getLogger("zulip-provisioner")
# TODO: support other architectures # TODO: support other architectures
ARCH = "amd64" if platform.architecture()[0] == '64bit':
arch = 'amd64'
else:
log.critical("Only amd64 is supported.")
vendor, version, codename = platform.dist()
if not (vendor in SUPPORTED_PLATFORMS and codename in SUPPORTED_PLATFORMS[vendor]):
log.critical("Unsupported platform: {} {}".format(vendor, codename))
with sh.sudo: with sh.sudo:
sh.apt_get.update() sh.apt_get.update()
# TODO(lfaraone): add support for other distros sh.apt_get.install(*APT_DEPENDENCIES["trusty"], assume_yes=True)
sh.apt_get.install("-y", *APT_DEPENDENCIES["trusty"])
temp_deb_path = sh.mktemp("--tmpdir", "package_XXXXXX.deb") temp_deb_path = sh.mktemp("package_XXXXXX.deb", tmpdir=True)
sh.wget( sh.wget(
"{}/{}_{}_{}.deb".format( "{}/{}_{}_{}.deb".format(
TSEARCH_URL_BASE, TSEARCH_URL_BASE,
TSEARCH_PACKAGE_NAME["trusty"], TSEARCH_PACKAGE_NAME["trusty"],
TSEARCH_VERSION, TSEARCH_VERSION,
ARCH, arch,
), ),
output_document=temp_deb_path, output_document=temp_deb_path,
) )