def install_yum_deps(deps_to_install, retry=False): # type: (List[str], bool) -> None print(WARNING + "RedHat support is still experimental.") run_as_root(["./scripts/lib/setup-yum-repo"]) # Hack specific to unregistered RHEL system. The moreutils # package requires a perl module package, which isn't available in # the unregistered RHEL repositories. # # Error: Package: moreutils-0.49-2.el7.x86_64 (epel) # Requires: perl(IPC::Run) yum_extra_flags = [] # type: List[str] if vendor == 'RedHat': exitcode, subs_status = subprocess.getstatusoutput("sudo subscription-manager status") if exitcode == 1: # TODO this might overkill since `subscription-manager` is already # called in setup-yum-repo if 'Status' in subs_status: # The output is well-formed yum_extra_flags = ["--skip-broken"] else: print("Unrecognized output. `subscription-manager` might not be available") run_as_root(["yum", "install", "-y"] + yum_extra_flags + deps_to_install) if vendor in ["CentOS", "RedHat"]: # This is how a pip3 is installed to /usr/bin in CentOS/RHEL # for python35 and later. run_as_root(["python36", "-m", "ensurepip"]) # `python36` is not aliased to `python3` by default run_as_root(["ln", "-nsf", "/usr/bin/python36", "/usr/bin/python3"]) postgres_dir = 'pgsql-%s' % (POSTGRES_VERSION,) for cmd in ['pg_config', 'pg_isready', 'psql']: # Our tooling expects these postgres scripts to be at # well-known paths. There's an argument for eventually # making our tooling auto-detect, but this is simpler. run_as_root(["ln", "-nsf", "/usr/%s/bin/%s" % (postgres_dir, cmd), "/usr/bin/%s" % (cmd,)]) # From here, we do the first-time setup/initialization for the postgres database. pg_datadir = "/var/lib/pgsql/%s/data" % (POSTGRES_VERSION,) pg_hba_conf = os.path.join(pg_datadir, "pg_hba.conf") # We can't just check if the file exists with os.path, since the # current user likely doesn't have permission to read the # pg_datadir directory. if subprocess.call(["sudo", "test", "-e", pg_hba_conf]) == 0: # Skip setup if it has been applied previously return run_as_root(["/usr/%s/bin/postgresql-%s-setup" % (postgres_dir, POSTGRES_VERSION), "initdb"], sudo_args = ['-H']) # Use vendored pg_hba.conf, which enables password authentication. run_as_root(["cp", "-a", "puppet/zulip/files/postgresql/centos_pg_hba.conf", pg_hba_conf]) # Later steps will ensure postgres is started # Link in tsearch data files overwrite_symlink("/usr/share/myspell/en_US.dic", "/usr/pgsql-%s/share/tsearch_data/en_us.dict" % (POSTGRES_VERSION,)) overwrite_symlink("/usr/share/myspell/en_US.aff", "/usr/pgsql-%s/share/tsearch_data/en_us.affix" % (POSTGRES_VERSION,))
def install_yum_deps(deps_to_install, retry=False): # type: (List[str], bool) -> None print(WARNING + "CentOS support is still experimental.") run(["sudo", "./scripts/lib/setup-yum-repo"]) run(["sudo", "yum", "install", "-y"] + deps_to_install) postgres_dir = 'pgsql-%s' % (POSTGRES_VERSION, ) for cmd in ['pg_config', 'pg_isready', 'psql']: # Our tooling expects these postgres scripts to be at # well-known paths. There's an argument for eventually # making our tooling auto-detect, but this is simpler. overwrite_symlink("/usr/%s/bin/%s" % (postgres_dir, cmd), "/usr/bin/%s" % (cmd, )) # Compile tsearch-extras from scratch run(["sudo", "./scripts/lib/build-tsearch-extras"]) run([ "sudo", "-H", "/usr/%s/bin/postgresql-%s-setup" % (postgres_dir, POSTGRES_VERSION), "initdb" ]) # Use vendored pg_hba.conf instead pg_hba_conf = "/var/lib/pgsql/%s/data/pg_hba.conf" % (POSTGRES_VERSION, ) run([ "sudo", "cp", "-a", "puppet/zulip/files/postgresql/centos_pg_hba.conf", pg_hba_conf ])
def main() -> None: setup_virtualenv("/srv/zulip-thumbor-venv", THUMBOR_REQS_FILE, patch_activate_script=True) cached_venv_path = setup_virtualenv(VENV_PATH, DEV_REQS_FILE, patch_activate_script=True) overwrite_symlink(cached_venv_path, os.path.join(ZULIP_PATH, "zulip-py3-venv"))
def main() -> None: # Get the correct Python interpreter. If we don't do this and use # `virtualenv -p python3` to create the venv in Travis, the venv # starts referring to the system Python interpreter. python_interpreter = subprocess_text_output(['which', 'python3']) setup_virtualenv("/srv/zulip-thumbor-venv", THUMBOR_REQS_FILE, patch_activate_script=True, virtualenv_args=['-p', 'python2.7']) cached_venv_path = setup_virtualenv( VENV_PATH, DEV_REQS_FILE, patch_activate_script=True, virtualenv_args=['-p', python_interpreter]) overwrite_symlink(cached_venv_path, os.path.join(ZULIP_PATH, "zulip-py3-venv"))
def main() -> None: # Get the correct Python interpreter. If we don't do this and use # `virtualenv -p python3` to create the venv in Travis, the venv # starts referring to the system Python interpreter. python_interpreter = subprocess_text_output(['which', 'python3']) setup_virtualenv("/srv/zulip-thumbor-venv", THUMBOR_REQS_FILE, patch_activate_script=True, virtualenv_args=['-p', 'python2.7']) cached_venv_path = setup_virtualenv( VENV_PATH, DEV_REQS_FILE, patch_activate_script=True, virtualenv_args=['-p', python_interpreter]) overwrite_symlink(cached_venv_path, os.path.join(ZULIP_PATH, "zulip-py3-venv"))
def install_apt_deps(): # type: () -> None # By doing list -> set -> list conversion we remove duplicates. deps_to_install = list(set(SYSTEM_DEPENDENCIES[codename])) if vendor == 'CentOS': print(WARNING + "CentOS support is still experimental.") run(["sudo", "./scripts/lib/setup-yum-repo"]) run(["sudo", "yum", "install", "-y"] + deps_to_install) for cmd in ['pg_config', 'pg_isready', 'psql']: # Our tooling expects these postgres scripts to be at # well-known paths. There's an argument for eventually # making our tooling auto-detect, but this is simpler. overwrite_symlink("/usr/pgsql-10/bin/%s" % (cmd, ), "/usr/bin/%s" % (cmd, )) # Compile tsearch-extras from scratch run(["sudo", "./scripts/lib/build-tsearch-extras"]) run(["sudo", "-H", "/usr/pgsql-10/bin/postgresql-10-setup", "initdb"]) else: # setup-apt-repo does an `apt-get update` run(["sudo", "./scripts/lib/setup-apt-repo"]) run(["sudo", "apt-get", "-y", "install", "--no-install-recommends"] + deps_to_install)