def _setup_env(env): """ Setup the system environment required to run CloudMan. This primarily refers to installing required Python dependencies (ie, libraries) as defined in CloudMan's requirements.txt file. """ # Get and install required system packages if env.distribution in ["debian", "ubuntu"]: conf_file = 'config.yaml' url = os.path.join(MI_REPO_ROOT_URL, 'conf_files', conf_file) cf = urllib.urlretrieve(url) (packages, _) = _yaml_to_packages(cf[0], 'cloudman') _apt_packages(pkg_list=packages) elif env.distibution in ["centos", "scientificlinux"]: env.logger.warn("No CloudMan system package dependencies for CentOS") pass reqs_file = 'requirements.txt' with _make_tmp_dir() as work_dir: with cd(work_dir): # Get and install requried Python libraries url = os.path.join(CM_REPO_ROOT_URL, reqs_file) run("wget --output-document=%s %s" % (reqs_file, url)) sudo("pip install --upgrade --requirement={0}".format(reqs_file)) # Add a custom vimrc vimrc_url = os.path.join(MI_REPO_ROOT_URL, 'conf_files', 'vimrc') remote_file = '/etc/vim/vimrc' sudo("wget --output-document=%s %s" % (remote_file, vimrc_url)) env.logger.debug("Added a custom vimrc to {0}".format(remote_file)) env.logger.debug("Done setting up CloudMan's environment")
def install_proftpd(env): """Highly configurable GPL-licensed FTP server software. http://proftpd.org/ """ version = "1.3.4c" postgres_ver = "9.1" url = "ftp://ftp.tpnet.pl/pub/linux/proftpd/distrib/source/proftpd-%s.tar.gz" % version modules = "mod_sql:mod_sql_postgres:mod_sql_passwd" extra_modules = env.get("extra_proftp_modules", "") # Comma separated list of extra modules if extra_modules: modules = "%s:%s" % (modules, extra_modules.replace(",", ":")) install_dir = os.path.join(env.install_dir, 'proftpd') remote_conf_dir = os.path.join(install_dir, "etc") # skip install if already present if exists(remote_conf_dir): env.logger.debug( "ProFTPd seems to already be installed in {0}".format(install_dir)) return with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s" % url) with settings(hide('stdout')): run("tar xvzf %s" % os.path.split(url)[1]) with cd("proftpd-%s" % version): run("CFLAGS='-I/usr/include/postgresql' ./configure --prefix=%s " \ "--disable-auth-file --disable-ncurses --disable-ident --disable-shadow " \ "--enable-openssl --with-modules=%s " \ "--with-libraries=/usr/lib/postgresql/%s/lib" % (install_dir, modules, postgres_ver)) sudo("make") sudo("make install") sudo("make clean") # Get the init.d startup script initd_script = 'proftpd.initd' initd_url = os.path.join(REPO_ROOT_URL, 'conf_files', initd_script) remote_file = "/etc/init.d/proftpd" sudo("wget --output-document=%s %s" % (remote_file, initd_url)) sed(remote_file, 'REPLACE_THIS_WITH_CUSTOM_INSTALL_DIR', install_dir, use_sudo=True) sudo("chmod 755 %s" % remote_file) # Set the configuration file conf_file = 'proftpd.conf' conf_url = os.path.join(REPO_ROOT_URL, 'conf_files', conf_file) remote_file = os.path.join(remote_conf_dir, conf_file) sudo("wget --output-document=%s %s" % (remote_file, conf_url)) sed(remote_file, 'REPLACE_THIS_WITH_CUSTOM_INSTALL_DIR', install_dir, use_sudo=True) # Get the custom welcome msg file welcome_msg_file = 'welcome_msg.txt' welcome_url = os.path.join(REPO_ROOT_URL, 'conf_files', welcome_msg_file) sudo("wget --output-document=%s %s" % (os.path.join(remote_conf_dir, welcome_msg_file), welcome_url)) # Stow sudo("cd %s; stow proftpd" % env.install_dir) env.logger.debug("----- ProFTPd %s installed to %s -----" % (version, install_dir))
def _setup_env(env): """ Setup the system environment required to run CloudMan. This means installing required system-level packages (as defined in CBL's ``packages.yaml``, or a flavor thereof) and Python dependencies (i.e., libraries) as defined in CloudMan's ``requirements.txt`` file. """ # Get and install required system packages if env.distribution in ["debian", "ubuntu"]: config_file = get_config_file(env, "packages.yaml") (packages, _) = _yaml_to_packages(config_file.base, 'cloudman') # Allow editions and flavors to modify the package list packages = env.edition.rewrite_config_items("packages", packages) packages = env.flavor.rewrite_config_items("packages", packages) _setup_apt_automation() _apt_packages(pkg_list=packages) elif env.distribution in ["centos", "scientificlinux"]: env.logger.warn("No CloudMan system package dependencies for CentOS") pass # Get and install required Python libraries with _make_tmp_dir() as work_dir: with cd(work_dir): url = os.path.join(CM_REPO_ROOT_URL, 'requirements.txt') _create_python_virtualenv(env, 'CM', reqs_url=url) # Add a custom vimrc vimrc_url = os.path.join(MI_REPO_ROOT_URL, 'conf_files', 'vimrc') remote_file = '/etc/vim/vimrc' sudo("wget --output-document=%s %s" % (remote_file, vimrc_url)) env.logger.debug("Added a custom vimrc to {0}".format(remote_file)) # Setup profile aliases = ['alias lt="ls -ltr"', 'alias ll="ls -l"'] for alias in aliases: _add_to_profiles(alias, ['/etc/bash.bashrc']) env.logger.info("Done setting up CloudMan's environment")
def install_homebrew(env): """Homebrew package manager for OSX and Linuxbrew for linux systems. https://github.com/mxcl/homebrew https://github.com/Homebrew/linuxbrew """ if env.distribution == "macosx": # XXX Test homebrew install on mac env.safe_run('ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"') else: brew_cmd = os.path.join(env.system_install, "bin", "brew") if not env.safe_exists(brew_cmd): with shared._make_tmp_dir() as tmp_dir: with cd(tmp_dir): env.safe_run("git clone https://github.com/Homebrew/linuxbrew.git" ) with cd("linuxbrew"): env.safe_sudo("chown %s %s" % (env.user, env.system_install)) paths = ["bin", "etc", "include", "lib", "lib/pkgconfig", "Library", "sbin", "share", "var", "var/log", "share/locale", "share/man", "share/man/man1", "share/man/man2", "share/man/man3", "share/man/man4", "share/man/man5", "share/man/man6", "share/man/man7", "share/man/man8", "share/info", "share/doc", "share/aclocal"] for path in paths: if env.safe_exists("%s/%s" % (env.system_install, path)): env.safe_sudo("chown %s %s/%s" % (env.user, env.system_install, path)) env.safe_run("mv bin/brew %s/bin" % env.system_install) env.safe_run("mv Library %s" % env.system_install) env.safe_run("mv .git %s" % env.system_install)
def install_hyphy(env): version = env.tool_version url = 'http://www.datam0nk3y.org/svn/hyphy' install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("svn co -r %s %s src" % (version, url)) run("mkdir -p build/Source/Link") run("mkdir build/Source/SQLite") run("cp src/trunk/Core/*.{h,cp,cpp} build/Source") run("cp src/trunk/HeadlessLink/*.{h,cpp} build/Source/SQLite") run("cp src/trunk/NewerFunctionality/*.{h,cpp} build/Source/") run("cp src/SQLite/trunk/*.{c,h} build/Source/SQLite/") run("cp src/trunk/Scripts/*.sh build/") run("cp src/trunk/Mains/main-unix.cpp build/Source/main-unix.cxx") run("cp src/trunk/Mains/hyphyunixutils.cpp build/Source/hyphyunixutils.cpp") run("cp -R src/trunk/{ChartAddIns,DatapanelAddIns,GeneticCodes,Help,SubstitutionClasses,SubstitutionModels,TemplateBatchFiles,TopologyInference,TreeAddIns,UserAddins} build") run("rm build/Source/preferences.cpp") with cd("build"): run("bash build.sh SP") install_cmd("mv build/* %s" % install_dir) _update_default(env, install_dir)
def r_library_installer(config): """Install R libraries using CRAN and Bioconductor. """ if config.get("cran") or config.get("bioc") or config.get("github"): with shared._make_tmp_dir() as tmp_dir: with cd(tmp_dir): # Create an Rscript file with install details. out_file = os.path.join(tmp_dir, "install_packages.R") _make_install_script(out_file, config) # run the script and then get rid of it # try using either rlib_installed = False rscripts = [] conda_bin = shared._conda_cmd(env) if conda_bin: rscripts.append( fabutils.find_cmd( env, os.path.join(os.path.dirname(conda_bin), "Rscript"), "--version")) rscripts.append(fabutils.find_cmd(env, "Rscript", "--version")) for rscript in rscripts: if rscript: env.safe_run("%s %s" % (rscript, out_file)) rlib_installed = True break if not rlib_installed: env.logger.warn( "Rscript not found; skipping install of R libraries.") env.safe_run("rm -f %s" % out_file)
def r_library_installer(config): """Install R libraries using CRAN and Bioconductor. """ if config.get("cran") or config.get("bioc") or config.get("github"): with shared._make_tmp_dir() as tmp_dir: with cd(tmp_dir): # Create an Rscript file with install details. out_file = os.path.join(tmp_dir, "install_packages.R") _make_install_script(out_file, config) # run the script and then get rid of it # try using either rlib_installed = False rscripts = [] conda_bin = shared._conda_cmd(env) if conda_bin: rscripts.append(fabutils.find_cmd(env, os.path.join(os.path.dirname(conda_bin), "Rscript"), "--version")) rscripts.append(fabutils.find_cmd(env, "Rscript", "--version")) for rscript in rscripts: if rscript: env.safe_run("%s %s" % (rscript, out_file)) rlib_installed = True break if not rlib_installed: env.logger.warn("Rscript not found; skipping install of R libraries.") env.safe_run("rm -f %s" % out_file)
def _install_from_url(env, cpanm_cmd, package): """Check version of a dependency and download and install with cpanm if not up to date. Packages installed via URL have the package name, target version and URL separated with '=='. They can also optionally have a build directory or dependency to remove. """ parts = package.split("==") package, target_version, url = parts[:3] args = {} if len(parts) > 3: for key, value in (x.split("=") for x in parts[3:]): args[key] = value with settings(warn_only=True): cur_version = env.safe_run_output("export PERL5LIB=%s/lib/perl5:${PERL5LIB} && " % env.system_install + """perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' %s""" % package) if cur_version != target_version: with cshared._make_tmp_dir() as work_dir: with cd(work_dir): dl_dir = cshared._fetch_and_unpack(url) if args.get("build"): dl_dir = os.path.join(dl_dir, args["build"]) with cd(dl_dir): if args.get("depremove"): for fname in ["Makefile.PL", "MYMETA.json", "MYMETA.yml"]: env.safe_run(r"""sed -i.bak -e '/^.*%s.*/s/^/#/' %s""" % (args["depremove"], fname)) env.safe_run("%s -i --notest --local-lib=%s ." % (cpanm_cmd, env.system_install))
def _perl_library_installer(config): """Install perl libraries from CPAN with cpanminus. """ # TODO: Re-write using confirm button # No need to prevent TOCTTOU, nothing critical is going to be touched if not os.path.isfile("%s/bin/cpanm" % env.system_install): with _make_tmp_dir() as tmp_dir: with cd(tmp_dir): cpanm_header = '' while cpanm_header.find('perl') == -1: run("wget --no-check-certificate http://xrl.us/cpanm -O cpanm") cpanm_header = run('head -n 1 cpanm') run("chmod a+rwx cpanm") env.safe_sudo("mv cpanm %s/bin" % env.system_install) # TODO: Check cpanm file, making sure it is a legitimate perl file, not an HTML page. # cpanm_file = open("%s/bin/cpanm" % env.system_install, 'r') # cpanm_header = cpanm_file.readline() # if cpanm_header.find('perl') == -1: # Retry to download the file sudo_str = "--sudo" if env.use_sudo else "" for lib in env.flavor.rewrite_config_items("perl", config['cpan']): # Need to hack stdin because of some problem with cpanminus script that # causes fabric to hang # http://agiletesting.blogspot.com/2010/03/getting-past-hung-remote-processes-in.html run("cpanm %s --skip-installed --notest %s < /dev/null" % (sudo_str, lib))
def _setup_env(env): """ Setup the system environment required to run CloudMan. This means installing required system-level packages (as defined in CBL's ``packages.yaml``, or a flavor thereof) and Python dependencies (i.e., libraries) as defined in CloudMan's ``requirements.txt`` file. """ # Get and install required system packages if env.distribution in ["debian", "ubuntu"]: config_file = get_config_file(env, "packages.yaml") (packages, _) = _yaml_to_packages(config_file.base, 'cloudman') # Allow flavors to modify the package list packages = env.flavor.rewrite_config_items("packages", packages) _setup_apt_automation() _apt_packages(pkg_list=packages) elif env.distribution in ["centos", "scientificlinux"]: env.logger.warn("No CloudMan system package dependencies for CentOS") pass # Get and install required Python libraries with _make_tmp_dir() as work_dir: with cd(work_dir): url = os.path.join(CM_REPO_ROOT_URL, 'requirements.txt') _create_python_virtualenv(env, 'CM', reqs_url=url) # Add a custom vimrc vimrc_url = os.path.join(MI_REPO_ROOT_URL, 'conf_files', 'vimrc') remote_file = '/etc/vim/vimrc' if env.safe_exists("/etc/vim"): env.safe_sudo("wget --output-document=%s %s" % (remote_file, vimrc_url)) env.logger.debug("Added a custom vimrc to {0}".format(remote_file)) # Setup profile aliases = ['alias lt="ls -ltr"', 'alias ll="ls -l"'] for alias in aliases: _add_to_profiles(alias, ['/etc/bash.bashrc']) env.logger.info("Done setting up CloudMan's environment")
def _install_nginx(env): """Nginx open source web server. http://www.nginx.org/ """ version = "1.2.0" url = "http://nginx.org/download/nginx-%s.tar.gz" % version install_dir = os.path.join(env.install_dir, "nginx") remote_conf_dir = os.path.join(install_dir, "conf") # Skip install if already present if env.safe_exists(remote_conf_dir) and env.safe_contains( os.path.join(remote_conf_dir, "nginx.conf"), "/cloud"): env.logger.debug("Nginx already installed; not installing it again.") return with _make_tmp_dir() as work_dir: with contextlib.nested(cd(work_dir), settings(hide('stdout'))): modules = _get_nginx_modules(env) module_flags = " ".join( ["--add-module=../%s" % x for x in modules]) env.safe_run("wget %s" % url) env.safe_run("tar xvzf %s" % os.path.split(url)[1]) with cd("nginx-%s" % version): env.safe_run( "./configure --prefix=%s --with-ipv6 %s " "--user=galaxy --group=galaxy --with-debug " "--with-http_ssl_module --with-http_gzip_static_module" % (install_dir, module_flags)) env.safe_sed("objs/Makefile", "-Werror", "") env.safe_run("make") env.safe_sudo("make install") env.safe_sudo("cd %s; stow nginx" % env.install_dir) defaults = {"galaxy_home": "/mnt/galaxy/galaxy-app"} _setup_conf_file(env, os.path.join(remote_conf_dir, "nginx.conf"), "nginx.conf", defaults=defaults) nginx_errdoc_file = 'nginx_errdoc.tar.gz' url = os.path.join(REPO_ROOT_URL, nginx_errdoc_file) remote_errdoc_dir = os.path.join(install_dir, "html") with cd(remote_errdoc_dir): env.safe_sudo("wget --output-document=%s/%s %s" % (remote_errdoc_dir, nginx_errdoc_file, url)) env.safe_sudo('tar xvzf %s' % nginx_errdoc_file) env.safe_sudo("mkdir -p %s" % env.install_dir) if not env.safe_exists("%s/nginx" % env.install_dir): env.safe_sudo("ln -s %s/sbin/nginx %s/nginx" % (install_dir, env.install_dir)) # If the guessed symlinking did not work, force it now cloudman_default_dir = "/opt/galaxy/sbin" if not env.safe_exists(cloudman_default_dir): env.safe_sudo("mkdir -p %s" % cloudman_default_dir) if not env.safe_exists(os.path.join(cloudman_default_dir, "nginx")): env.safe_sudo("ln -s %s/sbin/nginx %s/nginx" % (install_dir, cloudman_default_dir)) env.logger.debug("Nginx {0} installed to {1}".format(version, install_dir))
def install_hyphy(env): version = env.tool_version url = 'http://www.datam0nk3y.org/svn/hyphy' install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("svn co -r %s %s src" % (version, url)) run("mkdir -p build/Source/Link") run("mkdir build/Source/SQLite") run("cp src/trunk/Core/*.{h,cp,cpp} build/Source") run("cp src/trunk/HeadlessLink/*.{h,cpp} build/Source/SQLite") run("cp src/trunk/NewerFunctionality/*.{h,cpp} build/Source/") run("cp src/SQLite/trunk/*.{c,h} build/Source/SQLite/") run("cp src/trunk/Scripts/*.sh build/") run("cp src/trunk/Mains/main-unix.cpp build/Source/main-unix.cxx") run("cp src/trunk/Mains/hyphyunixutils.cpp build/Source/hyphyunixutils.cpp" ) run("cp -R src/trunk/{ChartAddIns,DatapanelAddIns,GeneticCodes,Help,SubstitutionClasses,SubstitutionModels,TemplateBatchFiles,TopologyInference,TreeAddIns,UserAddins} build" ) run("rm build/Source/preferences.cpp") with cd("build"): run("bash build.sh SP") install_cmd("mv build/* %s" % install_dir) _update_default(env, install_dir)
def install_gatk(env): version = env.tool_version url = 'ftp://ftp.broadinstitute.org/pub/gsa/GenomeAnalysisTK/GenomeAnalysisTK-%s.tar.bz2' % version pkg_name = 'gatk' install_dir = os.path.join(env.galaxy_tools_dir, pkg_name, version) install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) install_cmd("mkdir -p %s/bin" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget -O gatk.tar.bz2 %s" % url) run("tar -xjf gatk.tar.bz2") install_cmd("cp GenomeAnalysisTK-%s/*.jar %s/bin" % (version, install_dir)) # Create shell script to wrap jar sudo("echo '#!/bin/sh' > %s/bin/gatk" % (install_dir)) sudo("echo 'java -jar %s/bin/GenomeAnalysisTK.jar $@' >> %s/bin/gatk" % (install_dir, install_dir)) sudo("chmod +x %s/bin/gatk" % install_dir) # env file sudo("echo 'PATH=%s/bin:$PATH' > %s/env.sh" % (install_dir, install_dir)) _update_default(env, install_dir) # Link jar to Galaxy's jar dir jar_dir = os.path.join(env.galaxy_jars_dir, pkg_name) if not exists(jar_dir): install_cmd("mkdir -p %s" % jar_dir) tool_dir = os.path.join(env.galaxy_tools_dir, pkg_name, 'default', 'bin') install_cmd('ln --force --symbolic %s/*.jar %s/.' % (tool_dir, jar_dir)) install_cmd('chown --recursive %s:%s %s' % (env.galaxy_user, env.galaxy_user, jar_dir))
def install_proftpd(env): version = "1.3.3d" postgres_ver = "8.4" url = "ftp://mirrors.ibiblio.org/proftpd/distrib/source/proftpd-%s.tar.gz" % version install_dir = os.path.join(env.install_dir, 'proftpd') remote_conf_dir = os.path.join(install_dir, "etc") # skip install if already present if exists(remote_conf_dir): return with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s" % url) with settings(hide('stdout')): run("tar xvzf %s" % os.path.split(url)[1]) with cd("proftpd-%s" % version): run("CFLAGS='-I/usr/include/postgresql' ./configure --prefix=%s --disable-auth-file --disable-ncurses --disable-ident --disable-shadow --enable-openssl --with-modules=mod_sql:mod_sql_postgres:mod_sql_passwd --with-libraries=/usr/lib/postgres/%s/lib" % (install_dir, postgres_ver)) sudo("make") sudo("make install") sudo("make clean") # Get init.d startup script initd_script = 'proftpd' initd_url = os.path.join(REPO_ROOT_URL, 'conf_files', initd_script) sudo("wget --output-document=%s %s" % (os.path.join('/etc/init.d', initd_script), initd_url)) sudo("chmod 755 %s" % os.path.join('/etc/init.d', initd_script)) # Get configuration files proftpd_conf_file = 'proftpd.conf' welcome_msg_file = 'welcome_msg.txt' conf_url = os.path.join(REPO_ROOT_URL, 'conf_files', proftpd_conf_file) welcome_url = os.path.join(REPO_ROOT_URL, 'conf_files', welcome_msg_file) sudo("wget --output-document=%s %s" % (os.path.join(remote_conf_dir, proftpd_conf_file), conf_url)) sudo("wget --output-document=%s %s" % (os.path.join(remote_conf_dir, welcome_msg_file), welcome_url)) sudo("cd %s; stow proftpd" % env.install_dir)
def _create_local_virtualenv(target_dir): """Create virtualenv in target directory for non-sudo installs. """ url = "https://raw.github.com/pypa/virtualenv/master/virtualenv.py" if not os.path.exists(os.path.join(target_dir, "bin", "python")): with _make_tmp_dir() as work_dir: with cd(work_dir): env.safe_run("wget --no-check-certificate %s" % url) env.safe_run("python virtualenv.py %s" % target_dir)
def install_proftpd(env): """Highly configurable GPL-licensed FTP server software. http://proftpd.org/ """ version = "1.3.4c" postgres_ver = "9.1" url = "ftp://ftp.tpnet.pl/pub/linux/proftpd/distrib/source/proftpd-%s.tar.gz" % version modules = "mod_sql:mod_sql_postgres:mod_sql_passwd" extra_modules = env.get("extra_proftp_modules", "") # Comma separated list of extra modules if extra_modules: modules = "%s:%s" % (modules, extra_modules.replace(",", ":")) install_dir = os.path.join(env.install_dir, 'proftpd') remote_conf_dir = os.path.join(install_dir, "etc") # Skip install if already available if env.safe_exists(remote_conf_dir): env.logger.debug("ProFTPd seems to already be installed in {0}".format(install_dir)) return with _make_tmp_dir() as work_dir: with cd(work_dir): env.safe_run("wget %s" % url) with settings(hide('stdout')): env.safe_run("tar xvzf %s" % os.path.split(url)[1]) with cd("proftpd-%s" % version): env.safe_run("CFLAGS='-I/usr/include/postgresql' ./configure --prefix=%s " "--disable-auth-file --disable-ncurses --disable-ident --disable-shadow " "--enable-openssl --with-modules=%s " "--with-libraries=/usr/lib/postgresql/%s/lib" % (install_dir, modules, postgres_ver)) env.safe_sudo("make") env.safe_sudo("make install") env.safe_sudo("make clean") # Get the init.d startup script initd_script = 'proftpd.initd' initd_url = os.path.join(REPO_ROOT_URL, 'conf_files', initd_script) remote_file = "/etc/init.d/proftpd" env.safe_sudo("wget --output-document=%s %s" % (remote_file, initd_url)) env.safe_sed(remote_file, 'REPLACE_THIS_WITH_CUSTOM_INSTALL_DIR', install_dir, use_sudo=True) env.safe_sudo("chmod 755 %s" % remote_file) # Set the configuration file conf_file = 'proftpd.conf' remote_file = os.path.join(remote_conf_dir, conf_file) if "postgres_port" not in env: env.postgres_port = '5910' if "galaxy_ftp_user_password" not in env: env.galaxy_ftp_user_password = '******' proftpd_conf = {'galaxy_uid': env.safe_run('id -u galaxy'), 'galaxy_fs': '/mnt/galaxy', # Should be a var but uncertain how to get it 'install_dir': install_dir} _setup_conf_file(env, remote_file, conf_file, overrides=proftpd_conf, default_source="proftpd.conf.template") # Get the custom welcome msg file welcome_msg_file = 'welcome_msg.txt' welcome_url = os.path.join(REPO_ROOT_URL, 'conf_files', welcome_msg_file) env.safe_sudo("wget --output-document=%s %s" % (os.path.join(remote_conf_dir, welcome_msg_file), welcome_url)) # Stow env.safe_sudo("cd %s; stow proftpd" % env.install_dir) env.logger.debug("----- ProFTPd %s installed to %s -----" % (version, install_dir))
def _install_nginx(env): """Nginx open source web server. http://www.nginx.org/ """ if "use_nginx_package" in env and env.use_nginx_package.upper() in ["TRUE", "YES"]: _install_nginx_package(env) return # Install nginx from directly version = "1.3.8" url = "http://nginx.org/download/nginx-%s.tar.gz" % version install_dir = os.path.join(env.install_dir, "nginx") remote_conf_dir = os.path.join(install_dir, "conf") # Skip install if already present if env.safe_exists(remote_conf_dir) and env.safe_contains(os.path.join(remote_conf_dir, "nginx.conf"), "/cloud"): env.logger.debug("Nginx already installed; not installing it again.") return with _make_tmp_dir() as work_dir: with contextlib.nested(cd(work_dir), settings(hide('stdout'))): modules = _get_nginx_modules(env) module_flags = " ".join(["--add-module=../%s" % x for x in modules]) env.safe_run("wget %s" % url) env.safe_run("tar xvzf %s" % os.path.split(url)[1]) with cd("nginx-%s" % version): env.safe_run("./configure --prefix=%s --with-ipv6 %s " "--user=galaxy --group=galaxy --with-debug " "--with-http_ssl_module --with-http_gzip_static_module " % (install_dir, module_flags)) env.safe_sed("objs/Makefile", "-Werror", "") env.safe_run("make") env.safe_sudo("make install") env.safe_sudo("cd %s; stow nginx" % env.install_dir) defaults = {"galaxy_home": "/mnt/galaxy/galaxy-app"} _setup_conf_file(env, os.path.join(remote_conf_dir, "nginx.conf"), "nginx.conf", defaults=defaults) nginx_errdoc_file = 'nginx_errdoc.tar.gz' url = os.path.join(REPO_ROOT_URL, nginx_errdoc_file) remote_errdoc_dir = os.path.join(install_dir, "html") with cd(remote_errdoc_dir): env.safe_sudo("wget --output-document=%s/%s %s" % (remote_errdoc_dir, nginx_errdoc_file, url)) env.safe_sudo('tar xvzf %s' % nginx_errdoc_file) env.safe_sudo("mkdir -p %s" % env.install_dir) if not env.safe_exists("%s/nginx" % env.install_dir): env.safe_sudo("ln -s %s/sbin/nginx %s/nginx" % (install_dir, env.install_dir)) # If the guessed symlinking did not work, force it now cloudman_default_dir = "/opt/galaxy/sbin" if not env.safe_exists(cloudman_default_dir): env.safe_sudo("mkdir -p %s" % cloudman_default_dir) if not env.safe_exists(os.path.join(cloudman_default_dir, "nginx")): env.safe_sudo("ln -s %s/sbin/nginx %s/nginx" % (install_dir, cloudman_default_dir)) env.logger.debug("Nginx {0} installed to {1}".format(version, install_dir))
def install_augustus(env): default_version = "2.7" version = env.get('tool_version', default_version) url = "http://bioinf.uni-greifswald.de/augustus/binaries/augustus.%s.tar.gz" % version install_dir = env.system_install with _make_tmp_dir() as work_dir: with cd(work_dir): _fetch_and_unpack(url, need_dir=False) env.safe_sudo("mkdir -p '%s'" % install_dir) env.safe_sudo("mv augustus.%s/* '%s'" % (version, install_dir))
def install_unafold(env): """Required by optmage. """ # Since unafold is distributed as an .rpm, we need the program alien to # convert it into a .deb that can be installed on this system. env.safe_sudo("apt-get install -y alien") with _make_tmp_dir() as work_dir: with cd(work_dir): env.safe_run("wget http://dinamelt.rit.albany.edu/download/unafold-3.8-1.x86_64.rpm") env.safe_sudo("alien -i unafold-3.8-1.x86_64.rpm")
def install_sge(env): out_dir = "ge6.2u5" url = "%s/ge62u5_lx24-amd64.tar.gz" % CDN_ROOT_URL install_dir = env.install_dir if exists(os.path.join(install_dir, out_dir)): return with _make_tmp_dir() as work_dir: with contextlib.nested(cd(work_dir), settings(hide('stdout'))): run("wget %s" % url) sudo("chown %s %s" % (env.user, install_dir)) run("tar -C %s -xvzf %s" % (install_dir, os.path.split(url)[1]))
def install_add_scores(env): version = env.tool_version url = 'http://bitbucket.org/natefoo/add_scores/downloads/add_scores_%s_linux2.6_x86_64' % version install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget -O add_scores %s" % url) install_cmd("mv add_scores %s" % install_dir)
def install_sputnik(env): version = env.tool_version url = 'http://bitbucket.org/natefoo/sputnik-mononucleotide/downloads/sputnik_%s_linux2.6_x86_64' % version install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget -O sputnik %s" % url) install_cmd("mv sputnik %s" % install_dir)
def install_haploview(env): url = 'http://www.broadinstitute.org/ftp/pub/mpg/haploview/Haploview_beta.jar' install_dir = env.system_install install_cmd = env.safe_sudo if env.use_sudo else env.safe_run if not env.safe_exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): env.safe_run("wget %s -O %s" % (url, os.path.split(url)[-1])) install_cmd("mv %s %s" % (os.path.split(url)[-1], install_dir)) install_cmd("ln -s %s %s/haploview.jar" % (os.path.split(url)[-1], install_dir)) _update_default(env, install_dir)
def install_haploview(env): url = 'http://www.broadinstitute.org/ftp/pub/mpg/haploview/Haploview_beta.jar' install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s -O %s" % (url, os.path.split(url)[-1])) install_cmd("mv %s %s" % (os.path.split(url)[-1], install_dir)) install_cmd("ln -s %s %s/haploview.jar" % (os.path.split(url)[-1], install_dir)) _update_default(env, install_dir)
def install_augustus(env): version = env.tool_version url = "http://bioinf.uni-greifswald.de/augustus/binaries/augustus.%s.tar.gz" % version install_dir = env.system_install with _make_tmp_dir() as work_dir: with cd(work_dir): _fetch_and_unpack(url, need_dir=False) env.safe_sudo("mkdir -p '%s'" % install_dir) env.safe_sudo("mv * '%s'" % install_dir) env.safe_sudo("echo 'PATH=%s/bin:%s/scripts:$PATH' > %s/env.sh" % (install_dir, install_dir, install_dir)) env.safe_sudo("echo 'export AUGUSTUS_CONFIG_PATH=%s/config' >> %s/env.sh" % (install_dir, install_dir)) _update_default(env, install_dir)
def install_unafold(env): """Required by optmage. """ # Since unafold is distributed as an .rpm, we need the program alien to # convert it into a .deb that can be installed on this system. env.safe_sudo("apt-get install -y alien") with _make_tmp_dir() as work_dir: with cd(work_dir): env.safe_run( "wget http://dinamelt.rit.albany.edu/download/unafold-3.8-1.x86_64.rpm" ) env.safe_sudo("alien -i unafold-3.8-1.x86_64.rpm")
def install_pass(env): url = 'http://www.stat.psu.edu/~yuzhang/software/pass2.tar' install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s -O %s" % (url, os.path.split(url)[-1])) run("tar xf %s" % (os.path.split(url)[-1])) install_cmd("mv pass2 %s" % install_dir) sudo("echo 'PATH=%s:$PATH' > %s/env.sh" % (install_dir, install_dir)) _update_default(env, install_dir)
def install_cufflinks(env): version = env.tool_version url = 'http://cufflinks.cbcb.umd.edu/downloads/cufflinks-%s.Linux_x86_64.tar.gz' % version install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s" % url) run("tar -xvzf %s" % os.path.split(url)[-1]) with cd(os.path.split(url)[-1].split('.tar.gz')[0]): install_cmd("mv * %s" % install_dir)
def install_blast(env): version = env.tool_version url = 'ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/%s/ncbi-blast-%s-x64-linux.tar.gz' % (version[:-1], version) install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s" % url) run("tar -xvzf %s" % os.path.split(url)[-1]) with cd('ncbi-blast-%s/bin' % version): install_cmd("mv * %s" % install_dir)
def install_taxonomy(env): version = env.tool_version url = 'http://bitbucket.org/natefoo/taxonomy/downloads/taxonomy_%s_linux2.6_x86_64.tar.gz' % version install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s" % url) run("tar -xvzf %s" % os.path.split(url)[-1]) with cd(os.path.split(url)[-1].split('.tar.gz')[0]): install_cmd("mv * %s" % install_dir)
def install_megablast(env): version = env.tool_version url = 'ftp://ftp.ncbi.nlm.nih.gov/blast/executables/release/%s/blast-%s-x64-linux.tar.gz' % (version, version) install_dir = env.system_install install_cmd = env.safe_sudo if env.use_sudo else env.safe_run if not env.safe_exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): env.safe_run("wget %s" % url) env.safe_run("tar -xvzf %s" % os.path.split(url)[-1]) with cd('blast-%s/bin' % version): install_cmd("mv * %s" % install_dir)
def install_homebrew(env): """Homebrew package manager for OSX and Linuxbrew for linux systems. https://github.com/mxcl/homebrew https://github.com/Homebrew/linuxbrew """ if env.distribution == "macosx": with quiet(): test_brewcmd = env.safe_run("brew --version") if not test_brewcmd.succeeded: env.safe_run('ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"') else: brewcmd = os.path.join(env.system_install, "bin", "brew") with quiet(): test_brewcmd = env.safe_run("%s --version" % brewcmd) if not test_brewcmd.succeeded or _linuxbrew_origin_problem(brewcmd): with shared._make_tmp_dir() as tmp_dir: with cd(tmp_dir): if env.safe_exists("linuxbrew"): env.safe_run("rm -rf linuxbrew") for cleandir in ["Library", ".git"]: if env.safe_exists("%s/%s" % (env.system_install, cleandir)): env.safe_run("rm -rf %s/%s" % (env.system_install, cleandir)) env.safe_run("git clone https://github.com/Homebrew/linuxbrew.git") with cd("linuxbrew"): if not env.safe_exists(env.system_install): env.safe_sudo("mkdir -p %s" % env.system_install) env.safe_sudo("chown %s %s" % (env.user, env.system_install)) paths = ["bin", "etc", "include", "lib", "lib/pkgconfig", "Library", "sbin", "share", "var", "var/log", "share/java", "share/locale", "share/man", "share/man/man1", "share/man/man2", "share/man/man3", "share/man/man4", "share/man/man5", "share/man/man6", "share/man/man7", "share/man/man8", "share/info", "share/doc", "share/aclocal", "lib/python2.7/site-packages", "lib/python2.6/site-packages", "lib/python3.2/site-packages", "lib/python3.3/site-packages", "lib/perl5", "lib/perl5/site_perl"] if not env.safe_exists("%s/bin" % env.system_install): env.safe_sudo("mkdir -p %s/bin" % env.system_install) for path in paths: if env.safe_exists("%s/%s" % (env.system_install, path)): env.safe_sudo("chown %s %s/%s" % (env.user, env.system_install, path)) if not env.safe_exists("%s/Library" % env.system_install): env.safe_run("mv Library %s" % env.system_install) if not env.safe_exists("%s/.git" % env.system_install): env.safe_run("mv .git %s" % env.system_install) man_dir = "share/man/man1" if not env.safe_exists("%s/%s" % (env.system_install, man_dir)): env.safe_run("mkdir -p %s/%s" % (env.system_install, man_dir)) env.safe_run("mv -f %s/brew.1 %s/%s" % (man_dir, env.system_install, man_dir)) env.safe_run("mv -f bin/brew %s/bin" % env.system_install)
def _perl_library_installer(config): """Install perl libraries from CPAN with cpanminus. """ with _make_tmp_dir() as tmp_dir: with cd(tmp_dir): run("wget --no-check-certificate -O cpanm " "https://raw.github.com/miyagawa/cpanminus/master/cpanm") run("chmod a+rwx cpanm") env.safe_sudo("mv cpanm %s/bin" % env.system_install) sudo_str = "--sudo" if env.use_sudo else "" for lib in env.flavor.rewrite_config_items("perl", config["cpan"]): # Need to hack stdin because of some problem with cpanminus script that # causes fabric to hang # http://agiletesting.blogspot.com/2010/03/getting-past-hung-remote-processes-in.html run("cpanm %s --skip-installed --notest %s < /dev/null" % (sudo_str, lib))
def install_eigenstrat(env): version = env.tool_version url = 'http://www.hsph.harvard.edu/faculty/alkes-price/files/EIG%s.tar.gz' % version install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s -O %s" % (url, os.path.split(url)[-1])) run("tar zxf %s" % (os.path.split(url)[-1])) install_cmd("mv bin %s" % install_dir) sudo("echo 'PATH=%s/bin:$PATH' > %s/env.sh" % (install_dir, install_dir)) _update_default(env, install_dir)
def install_tophat(env): version = env.tool_version url = 'http://tophat.cbcb.umd.edu/downloads/tophat-%s.Linux_x86_64.tar.gz' % version pkg_name = "tophat" install_dir = os.path.join(env.galaxy_tools_dir, pkg_name, version) install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s" % url) run("tar -xvzf %s" % os.path.split(url)[-1]) with cd(os.path.split(url)[-1].split('.tar.gz')[0]): install_cmd("mv * %s" % install_dir)
def install_fbat(env): version = env.tool_version url = 'http://www.biostat.harvard.edu/~fbat/software/fbat%s_linux64.tar.gz' % version.replace('.', '') install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s -O %s" % (url, os.path.split(url)[-1])) run("tar zxf %s" % (os.path.split(url)[-1])) install_cmd("mv fbat %s" % install_dir) sudo("echo 'PATH=%s:$PATH' > %s/env.sh" % (install_dir, install_dir)) _update_default(env, install_dir)
def install_fbat(env): version = env.tool_version url = 'http://www.biostat.harvard.edu/~fbat/software/fbat%s_linux64.tar.gz' % version.replace('.', '') install_dir = env.system_install install_cmd = env.safe_sudo if env.use_sudo else env.safe_run if not env.safe_exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): env.safe_run("wget %s -O %s" % (url, os.path.split(url)[-1])) env.safe_run("tar zxf %s" % (os.path.split(url)[-1])) install_cmd("mv fbat %s" % install_dir) env.safe_sudo("echo 'PATH=%s:$PATH' > %s/env.sh" % (install_dir, install_dir)) _update_default(env, install_dir)
def install_plink(env): version = env.tool_version url = 'http://pngu.mgh.harvard.edu/~purcell/plink/dist/plink-%s-x86_64.zip' % version install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s -O %s" % (url, os.path.split(url)[-1])) run("unzip %s" % (os.path.split(url)[-1])) install_cmd("mv plink-%s-x86_64/plink %s" % (version, install_dir)) sudo("echo 'PATH=%s:$PATH' > %s/env.sh" % (install_dir, install_dir)) _update_default(env, install_dir)
def install_sge(env): """Sun Grid Engine. """ out_dir = "ge6.2u5" url = "%s/ge62u5_lx24-amd64.tar.gz" % CDN_ROOT_URL install_dir = env.install_dir if env.safe_exists(os.path.join(install_dir, out_dir)): return with _make_tmp_dir() as work_dir: with contextlib.nested(cd(work_dir), settings(hide('stdout'))): env.safe_run("wget %s" % url) env.safe_sudo("chown %s %s" % (env.user, install_dir)) env.safe_run("tar -C %s -xvzf %s" % (install_dir, os.path.split(url)[1])) env.logger.debug("SGE setup")
def _install_r_packages(tools_conf): f = tempfile.NamedTemporaryFile() r_packages = tools_conf["r_packages"] bioconductor_packages = tools_conf["bioconductor_packages"] if not r_packages and not bioconductor_packages: return r_cmd = r_packages_template % (_concat_strings(r_packages), _concat_strings(bioconductor_packages)) f.write(r_cmd) f.flush() with _make_tmp_dir() as work_dir: put(f.name, os.path.join(work_dir, 'install_packages.r')) with cd(work_dir): sudo("R --vanilla --slave < install_packages.r") f.close()
def _perl_library_installer(config): """Install perl libraries from CPAN with cpanminus. """ with shared._make_tmp_dir() as tmp_dir: with cd(tmp_dir): env.safe_run("wget --no-check-certificate -O cpanm " "https://raw.github.com/miyagawa/cpanminus/master/cpanm") env.safe_run("chmod a+rwx cpanm") env.safe_sudo("mv cpanm %s/bin" % env.system_install) sudo_str = "--sudo" if env.use_sudo else "" for lib in env.flavor.rewrite_config_items("perl", config['cpan']): # Need to hack stdin because of some problem with cpanminus script that # causes fabric to hang # http://agiletesting.blogspot.com/2010/03/getting-past-hung-remote-processes-in.html env.safe_run("cpanm %s --skip-installed --notest %s < /dev/null" % (sudo_str, lib))
def install_blast(env): version = env.tool_version url = 'ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/%s/ncbi-blast-%s-x64-linux.tar.gz' % ( version[:-1], version) install_dir = env.system_install install_cmd = sudo if env.use_sudo else run if not exists(install_dir): install_cmd("mkdir -p %s" % install_dir) with _make_tmp_dir() as work_dir: with cd(work_dir): run("wget %s" % url) run("tar -xvzf %s" % os.path.split(url)[-1]) with cd('ncbi-blast-%s/bin' % version): bin_dir = _get_bin_dir(env) install_cmd("mv * '%s'" % bin_dir)
def install_nginx(env): version = "0.7.67" upload_module_version = "2.0.12" upload_url = "http://www.grid.net.ru/nginx/download/" \ "nginx_upload_module-%s.tar.gz" % upload_module_version url = "http://nginx.org/download/nginx-%s.tar.gz" % version install_dir = os.path.join(env.install_dir, "nginx") remote_conf_dir = os.path.join(install_dir, "conf") # skip install if already present if exists(remote_conf_dir) and contains( os.path.join(remote_conf_dir, "nginx.conf"), "/cloud"): return with _make_tmp_dir() as work_dir: with contextlib.nested(cd(work_dir), settings(hide('stdout'))): run("wget %s" % upload_url) run("tar -xvzpf %s" % os.path.split(upload_url)[1]) run("wget %s" % url) run("tar xvzf %s" % os.path.split(url)[1]) with cd("nginx-%s" % version): run("./configure --prefix=%s --with-ipv6 --add-module=../nginx_upload_module-%s --user=galaxy --group=galaxy --with-http_ssl_module --with-http_gzip_static_module" % (install_dir, upload_module_version)) run("make") sudo("make install") sudo("cd %s; stow nginx" % env.install_dir) nginx_conf_file = 'nginx.conf' url = os.path.join(REPO_ROOT_URL, nginx_conf_file) with cd(remote_conf_dir): sudo("wget --output-document=%s/%s %s" % (remote_conf_dir, nginx_conf_file, url)) nginx_errdoc_file = 'nginx_errdoc.tar.gz' url = os.path.join(REPO_ROOT_URL, nginx_errdoc_file) remote_errdoc_dir = os.path.join(install_dir, "html") with cd(remote_errdoc_dir): sudo("wget --output-document=%s/%s %s" % (remote_errdoc_dir, nginx_errdoc_file, url)) sudo('tar xvzf %s' % nginx_errdoc_file) cloudman_default_dir = "/opt/galaxy/sbin" sudo("mkdir -p %s" % cloudman_default_dir) if not exists("%s/nginx" % cloudman_default_dir): sudo("ln -s %s/sbin/nginx %s/nginx" % (install_dir, cloudman_default_dir))
def r_library_installer(config): """Install R libraries using CRAN and Bioconductor. """ with shared._make_tmp_dir() as tmp_dir: with cd(tmp_dir): # Create an Rscript file with install details. out_file = os.path.join(tmp_dir, "install_packages.R") _make_install_script(out_file, config) # run the script and then get rid of it rscript = fabutils.find_cmd(env, "Rscript", "--version") if rscript: env.safe_run("%s %s" % (rscript, out_file)) else: env.logger.warn( "Rscript not found; skipping install of R libraries.") env.safe_run("rm -f %s" % out_file)