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 logging
import platform
try:
import sh
except ImportError:
import pbs as sh
SUPPORTED_PLATFORMS = {
"Ubuntu": [
"trusty",
],
}
APT_DEPENDENCIES = {
"trusty": [
"libffi-dev",
@ -44,23 +52,31 @@ REPO_STOPWORDS_PATH = os.path.join(
"zulip_english.stop",
)
log = logging.getLogger("zulip-provisioner")
# 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:
sh.apt_get.update()
# TODO(lfaraone): add support for other distros
sh.apt_get.install("-y", *APT_DEPENDENCIES["trusty"])
sh.apt_get.install(*APT_DEPENDENCIES["trusty"], assume_yes=True)
temp_deb_path = sh.mktemp("--tmpdir", "package_XXXXXX.deb")
temp_deb_path = sh.mktemp("package_XXXXXX.deb", tmpdir=True)
sh.wget(
"{}/{}_{}_{}.deb".format(
TSEARCH_URL_BASE,
TSEARCH_PACKAGE_NAME["trusty"],
TSEARCH_VERSION,
ARCH,
arch,
),
output_document=temp_deb_path,
)