Exemple #1
0
def _validate_target_distribution(dist, dist_name=None):
    """Check target matches environment setting (for sanity)

    Throws exception on error
    """
    env.logger.debug("Checking target distribution " + env.distribution)
    if dist in ["debian", "ubuntu"]:
        tag = env.safe_run_output("cat /proc/version")
        if tag.lower().find(dist) == -1:
           # hmmm, test issue file
            tag2 = env.safe_run_output("cat /etc/issue")
            if tag2.lower().find(dist) == -1:
                raise ValueError("Distribution does not match machine; are you using correct fabconfig for " + dist)
        if env.edition.short_name in ["minimal"]:
            # "minimal editions don't actually change any of the apt
            # source except adding biolinux, so won't cause this
            # problem and don't need to match dist_name"
            return
        if not dist_name:
            raise ValueError("Must specify a dist_name property when working with distribution %s" % dist)
        # Does this new method work with CentOS, do we need this.
        actual_dist_name = env.safe_run_output("cat /etc/*release | grep DISTRIB_CODENAME | cut -f 2 -d =")
        if actual_dist_name.lower().find(dist_name) == -1:
            raise ValueError("Distribution does not match machine; are you using correct fabconfig for " + dist)
    else:
        env.logger.debug("Unknown target distro")
Exemple #2
0
def _validate_target_distribution(dist, dist_name=None):
    """Check target matches environment setting (for sanity)

    Throws exception on error
    """
    env.logger.debug("Checking target distribution " + env.distribution)
    if dist in ["debian", "ubuntu"]:
        tag = env.safe_run_output("cat /proc/version")
        if tag.lower().find(dist) == -1:
            # hmmm, test issue file
            tag2 = env.safe_run_output("cat /etc/issue")
            if tag2.lower().find(dist) == -1:
                raise ValueError("Distribution does not match machine; are you using correct fabconfig for " + dist)
        if not dist_name:
            raise ValueError("Must specify a dist_name property when working with distribution %s" % dist)
        # Does this new method work with CentOS, do we need this.
        if dist == "debian":
            actual_dist_name = _debian_dist_name(env)
        else:
            actual_dist_name = _ubuntu_dist_name(env)
        if actual_dist_name != dist_name:
            raise ValueError(
                "Distribution does not match machine; are you using correct fabconfig <"
                + actual_dist_name
                + "> for "
                + dist
            )
    else:
        env.logger.debug("Unknown target distro")
Exemple #3
0
def _validate_target_distribution(dist, dist_name=None):
    """Check target matches environment setting (for sanity)

    Throws exception on error
    """
    env.logger.debug("Checking target distribution " + env.distribution)
    if dist in ["debian", "ubuntu"]:
        tag = env.safe_run_output("cat /proc/version")
        if tag.lower().find(dist) == -1:
            # hmmm, test issue file
            tag2 = env.safe_run_output("cat /etc/issue")
            if tag2.lower().find(dist) == -1:
                raise ValueError(
                    "Distribution does not match machine; are you using correct fabconfig for "
                    + dist)
        if not dist_name:
            raise ValueError(
                "Must specify a dist_name property when working with distribution %s"
                % dist)
        # Does this new method work with CentOS, do we need this.
        if dist == 'debian':
            actual_dist_name = _debian_dist_name(env)
        else:
            actual_dist_name = _ubuntu_dist_name(env)
        if actual_dist_name != dist_name:
            raise ValueError(
                "Distribution does not match machine; are you using correct fabconfig <"
                + actual_dist_name + "> for " + dist)
    else:
        env.logger.debug("Unknown target distro")
def _validate_target_distribution(dist, dist_name=None):
    """Check target matches environment setting (for sanity)

    Throws exception on error
    """
    env.logger.debug("Checking target distribution " + env.distribution)
    if dist in ["debian", "ubuntu"]:
        tag = env.safe_run_output("cat /proc/version")
        if tag.lower().find(dist) == -1:
            # hmmm, test issue file
            tag2 = env.safe_run_output("cat /etc/issue")
            if tag2.lower().find(dist) == -1:
                raise ValueError(
                    "Distribution does not match machine; are you using correct fabconfig for "
                    + dist)
        if env.edition.short_name in ["minimal"]:
            # "minimal editions don't actually change any of the apt
            # source except adding biolinux, so won't cause this
            # problem and don't need to match dist_name"
            return
        if not dist_name:
            raise ValueError(
                "Must specify a dist_name property when working with distribution %s"
                % dist)
        # Does this new method work with CentOS, do we need this.
        actual_dist_name = _ubuntu_dist_name(env)
        if actual_dist_name != dist_name:
            raise ValueError(
                "Distribution does not match machine; are you using correct fabconfig for "
                + dist)
    else:
        env.logger.debug("Unknown target distro")
Exemple #5
0
def _connect_native_packages(env, pkg_install, lib_install):
    """Connect native installed packages to local versions.

    This helps setup a non-sudo environment to handle software
    that needs a local version in our non-root directory tree.
    """
    bin_dir = os.path.join(env.system_install, "bin")
    path = env.safe_run_output("echo $PATH")
    comment_line = "# CloudBioLinux PATH updates"
    if not env.safe_contains(env.shell_config, comment_line):
        env.safe_append(env.shell_config, "\n" + comment_line)
    if bin_dir not in path and env.safe_exists(env.shell_config):
        add_path = "export PATH=%s:$PATH" % bin_dir
        if not env.safe_contains(env.shell_config, add_path):
            env.safe_append(env.shell_config, add_path)
    ldlib_path = os.path.join(env.system_install, "lib")
    add_ldlibrary = "export LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH" % ldlib_path
    if not env.safe_contains(env.shell_config, add_ldlibrary):
        env.safe_append(env.shell_config, add_ldlibrary)
    perl_export = (
        "export PERL5LIB=%s/lib/perl5:%s/lib/perl5/site_perl:${PERL5LIB}" %
        (env.system_install, env.system_install))
    if not env.safe_contains(env.shell_config, perl_export):
        env.safe_append(env.shell_config, perl_export)
    if "python" in pkg_install and "python" in lib_install:
        _create_local_virtualenv(env.system_install)
def _connect_native_packages(env, pkg_install, lib_install):
    """Connect native installed packages to local versions.

    This helps setup a non-sudo environment to handle software
    that needs a local version in our non-root directory tree.
    """
    bin_dir = os.path.join(env.system_install, "bin")
    path = env.safe_run_output("echo $PATH")
    comment_line = "# CloudBioLinux PATH updates"
    if not env.safe_contains(env.shell_config, comment_line):
        env.safe_append(env.shell_config, "\n" + comment_line)
    if bin_dir not in path and env.safe_exists(env.shell_config):
        add_path = "export PATH=%s:$PATH" % bin_dir
        if not env.safe_contains(env.shell_config, add_path):
            env.safe_append(env.shell_config, add_path)
    ldlib_path = os.path.join(env.system_install, "lib")
    add_ldlibrary = "export LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH" % ldlib_path
    if not env.safe_contains(env.shell_config, add_ldlibrary):
        env.safe_append(env.shell_config, add_ldlibrary)
    perl_export = ("export PERL5LIB=%s/lib/perl5:%s/lib/perl5/site_perl:${PERL5LIB}"
                   % (env.system_install, env.system_install))
    if not env.safe_contains(env.shell_config, perl_export):
        env.safe_append(env.shell_config, perl_export)
    if "python" in pkg_install and "python" in lib_install:
        _create_local_virtualenv(env.system_install)
def _determine_distribution(env):
    """
    Attempt to automatically determine the distribution of the target machine.

    Currently works for Ubuntu, CentOS, Debian, Scientific Linux and Mac OS X.
    """
    with quiet():
        output = env.safe_run_output("cat /etc/*release").lower()
    if output.find("distrib_id=ubuntu") >= 0:
        return "ubuntu"
    elif output.find("centos release") >= 0:
        return "centos"
    elif output.find("red hat enterprise linux server release") >= 0:
        return "centos"
    elif output.find("scientific linux release") >= 0:
        return "scientificlinux"
    elif env.safe_exists("/etc/debian_version"):
        return "debian"
    # check for file used by Python's platform.mac_ver
    elif env.safe_exists("/System/Library/CoreServices/SystemVersion.plist"):
        return "macosx"
    else:
        raise Exception(
            "Attempt to automatically determine Linux distribution of target machine failed, please manually specify distribution in fabricrc.txt"
        )
def _setup_deb_general():
    """Shared settings for different debian based/derived distributions.
    """
    env.logger.debug("Debian-shared setup")
    env.sources_file = "/etc/apt/sources.list.d/cloudbiolinux.list"
    env.global_sources_file = "/etc/apt/sources.list"
    env.apt_preferences_file = "/etc/apt/preferences"
    if not hasattr(env, "python_version_ext"):
        env.python_version_ext = ""
    if not hasattr(env, "ruby_version_ext"):
        env.ruby_version_ext = "1.9.1"
    if not env.has_key("java_home"):
        # Try to determine java location from update-alternatives
        java_home = "/usr/lib/jvm/java-7-openjdk-amd64"
        with quiet():
            java_info = env.safe_run_output("update-alternatives --display java")
        for line in java_info.split("\n"):
            if line.strip().startswith("link currently points to"):
                java_home = line.split()[-1].strip()
                java_home = java_home.replace("/jre/bin/java", "")
        env.java_home = java_home
    shared_sources = [
        "deb http://download.virtualbox.org/virtualbox/debian %s contrib",  # virtualbox
    ]
    return shared_sources
def _setup_deb_general():
    """Shared settings for different debian based/derived distributions.
    """
    env.logger.debug("Debian-shared setup")
    env.sources_file = "/etc/apt/sources.list.d/cloudbiolinux.list"
    env.global_sources_file = "/etc/apt/sources.list"
    env.apt_preferences_file = "/etc/apt/preferences"
    if not hasattr(env, "python_version_ext"):
        env.python_version_ext = ""
    if not hasattr(env, "ruby_version_ext"):
        env.ruby_version_ext = "1.9.1"
    if not env.has_key("java_home"):
        # Try to determine java location from update-alternatives
        java_home = "/usr/lib/jvm/java-7-openjdk-amd64"
        with quiet():
            java_info = env.safe_run_output(
                "update-alternatives --display java")
        for line in java_info.split("\n"):
            if line.strip().startswith("link currently points to"):
                java_home = line.split()[-1].strip()
                java_home = java_home.replace("/jre/bin/java", "")
        env.java_home = java_home
    shared_sources = [
        "deb http://nebc.nerc.ac.uk/bio-linux/ unstable bio-linux",  # Bio-Linux
        "deb http://download.virtualbox.org/virtualbox/debian %s contrib",  # virtualbox
    ]
    return shared_sources
def _determine_distribution(env):
    """
    Attempt to automatically determine the distribution of the target machine.

    Currently works for Ubuntu, CentOS, Debian, Scientific Linux and Mac OS X.
    """
    with quiet():
        output = env.safe_run_output("cat /etc/*release").lower()
    if output.find("distrib_id=ubuntu") >= 0:
        return "ubuntu"
    elif output.find("centos release") >= 0:
        return "centos"
    elif output.find("centos linux release") >= 0:
        return "centos"
    elif output.find("red hat") >= 0:
        return "centos"
    elif output.find("fedora release") >= 0:
        return "centos"
    elif output.find("amzn") >= 0:  # Amazon AMIs are Red-Hat based
        return "centos"
    elif output.find("suse linux") >= 0:
        return "suse"
    elif output.find("opensuse") >= 0:
        return "suse"
    elif output.find("scientific linux") >= 0:
        return "scientificlinux"
    elif env.safe_exists("/etc/debian_version"):
        return "debian"
    elif output.find("id=arch") >= 0:
        return "arch"
    # check for file used by Python's platform.mac_ver
    elif env.safe_exists("/System/Library/CoreServices/SystemVersion.plist"):
        return "macosx"
    else:
        raise Exception("Attempt to automatically determine Linux distribution of target machine failed, please manually specify distribution in fabricrc.txt")
Exemple #11
0
def _setup_distribution_environment(ignore_distcheck=False):
    """Setup distribution environment
    """
    env.logger.info("Distribution %s" % env.distribution)

    if env.hosts == ["vagrant"]:
        _setup_vagrant_environment()
    elif env.hosts == ["localhost"]:
        _setup_local_environment()
    if env.distribution == "ubuntu":
        _setup_ubuntu()
    elif env.distribution == "centos":
        _setup_centos()
    elif env.distribution == "scientificlinux":
        _setup_scientificlinux()
    elif env.distribution == "debian":
        _setup_debian()
    else:
        raise ValueError("Unexpected distribution %s" % env.distribution)
    configure_runsudo(env)
    if not ignore_distcheck:
        _validate_target_distribution(env.distribution, env.get('dist_name', None))
    _cloudman_compatibility(env)
    _setup_nixpkgs()
    _setup_fullpaths(env)
    # allow us to check for packages only available on 64bit machines
    machine = env.safe_run_output("uname -m")
    env.is_64bit = machine.find("_64") > 0
def _setup_distribution_environment(ignore_distcheck=False):
    """Setup distribution environment
    """
    env.logger.info("Distribution %s" % env.distribution)

    if env.hosts == ["vagrant"]:
        _setup_vagrant_environment()
    elif env.hosts == ["localhost"]:
        _setup_local_environment()
    if env.distribution == "ubuntu":
        _setup_ubuntu()
    elif env.distribution == "centos":
        _setup_centos()
    elif env.distribution == "scientificlinux":
        _setup_scientificlinux()
    elif env.distribution == "debian":
        _setup_debian()
    else:
        raise ValueError("Unexpected distribution %s" % env.distribution)
    configure_runsudo(env)
    if not ignore_distcheck:
        _validate_target_distribution(env.distribution,
                                      env.get('dist_name', None))
    _cloudman_compatibility(env)
    _setup_nixpkgs()
    _setup_fullpaths(env)
    # allow us to check for packages only available on 64bit machines
    machine = env.safe_run_output("uname -m")
    env.is_64bit = machine.find("_64") > 0
def _setup_fullpaths(env):
    home_dir = env.safe_run_output("echo $HOME")
    for attr in ["data_files", "galaxy_home", "local_install"]:
        if hasattr(env, attr):
            x = getattr(env, attr)
            if x.startswith("~"):
                x = x.replace("~", home_dir)
                setattr(env, attr, x)
def _setup_fullpaths(env):
    home_dir = env.safe_run_output("echo $HOME")
    for attr in ["data_files", "galaxy_home", "local_install"]:
        if hasattr(env, attr):
            x = getattr(env, attr)
            if x.startswith("~"):
                x = x.replace("~", home_dir)
                setattr(env, attr, x)
Exemple #15
0
def _setup_distribution_environment(ignore_distcheck=False):
    """Setup distribution environment.

    In low-level terms, this method attempts to populate various values in the fabric
    env data structure for use other places in CloudBioLinux.
    """
    if "distribution" not in env:
        env.distribution = "__auto__"
    if "dist_name" not in env:
        env.dist_name = "__auto__"
    env.logger.info("Distribution %s" % env.distribution)

    if env.hosts == ["vagrant"]:
        _setup_vagrant_environment()
    elif env.hosts == ["localhost"]:
        _setup_local_environment()
    configure_runsudo(env)
    if env.distribution == "__auto__":
        env.distribution = _determine_distribution(env)
    if env.distribution == "ubuntu":
        ## TODO: Determine if dist_name check works with debian.
        if env.dist_name == "__auto__":
            env.dist_name = _ubuntu_dist_name(env)
        _setup_ubuntu()
    elif env.distribution == "centos":
        _setup_centos()
    elif env.distribution == "scientificlinux":
        _setup_scientificlinux()
    elif env.distribution == "debian":
        if env.dist_name == "__auto__":
            env.dist_name = _debian_dist_name(env)
        _setup_debian()
    elif env.distribution == "arch":
        pass  # No package support for Arch yet
    elif env.distribution == "suse":
        pass  # No package support for SUSE yet
    elif env.distribution == "macosx":
        _setup_macosx(env)
        ignore_distcheck = True
    else:
        raise ValueError("Unexpected distribution %s" % env.distribution)
    if not ignore_distcheck:
        _validate_target_distribution(env.distribution,
                                      env.get('dist_name', None))
    _cloudman_compatibility(env)
    _setup_nixpkgs()
    _setup_fullpaths(env)
    # allow us to check for packages only available on 64bit machines
    machine = env.safe_run_output("uname -m")
    env.is_64bit = machine.find("_64") > 0
def _setup_distribution_environment(ignore_distcheck=False):
    """Setup distribution environment.

    In low-level terms, this method attempts to populate various values in the fabric
    env data structure for use other places in CloudBioLinux.
    """
    if "distribution" not in env:
        env.distribution = "__auto__"
    if "dist_name" not in env:
        env.dist_name = "__auto__"
    env.logger.info("Distribution %s" % env.distribution)

    if env.hosts == ["vagrant"]:
        _setup_vagrant_environment()
    elif env.hosts == ["localhost"]:
        _setup_local_environment()
    configure_runsudo(env)
    if env.distribution == "__auto__":
        env.distribution = _determine_distribution(env)
    if env.distribution == "ubuntu":
        ## TODO: Determine if dist_name check works with debian.
        if env.dist_name == "__auto__":
            env.dist_name = _ubuntu_dist_name(env)
        _setup_ubuntu()
    elif env.distribution == "centos":
        _setup_centos()
    elif env.distribution == "scientificlinux":
        _setup_scientificlinux()
    elif env.distribution == "debian":
        if env.dist_name == "__auto__":
            env.dist_name = _debian_dist_name(env)
        _setup_debian()
    elif env.distribution == "arch":
        pass  # No package support for Arch yet
    elif env.distribution == "suse":
        pass  # No package support for SUSE yet
    elif env.distribution == "macosx":
        _setup_macosx(env)
        ignore_distcheck = True
    else:
        raise ValueError("Unexpected distribution %s" % env.distribution)
    if not ignore_distcheck:
        _validate_target_distribution(env.distribution, env.get('dist_name', None))
    _cloudman_compatibility(env)
    _setup_nixpkgs()
    _setup_fullpaths(env)
    # allow us to check for packages only available on 64bit machines
    machine = env.safe_run_output("uname -m")
    env.is_64bit = machine.find("_64") > 0
Exemple #17
0
def _connect_native_packages(env, pkg_install, lib_install):
    """Connect native installed packages to local versions.

    This helps setup a non-sudo environment to handle software
    that needs a local version in our non-root directory tree.
    """
    bin_dir = os.path.join(env.system_install, "bin")
    exports = _get_shell_exports(env)
    path = env.safe_run_output("echo $PATH")
    comment_line = "# CloudBioLinux PATH updates"
    if not env.safe_contains(env.shell_config, comment_line):
        env.safe_append(env.shell_config, "\n" + comment_line)
    if bin_dir not in path and env.safe_exists(env.shell_config):
        if not env.safe_contains(env.shell_config, exports["path"]):
            env.safe_append(env.shell_config, exports["path"])
    if "python" in pkg_install and "python" in lib_install:
        _create_local_virtualenv(env.system_install)
Exemple #18
0
def _determine_distribution(env):
    """
    Attempt to automatically determine the distribution of the target machine.

    Currently works for Ubuntu, CentOS, Debian, Scientific Linux and Mac OS X.
    """
    with quiet():
        output = env.safe_run_output("cat /etc/*release").lower()
    if output.find("id=ubuntu") >= 0:
        return "ubuntu"
    elif output.find("centos release") >= 0:
        return "centos"
    elif output.find("centos linux release") >= 0:
        return "centos"
    elif output.find("red hat enterprise linux") >= 0:
        return "centos"
    elif output.find("fedora") >= 0:
        return "centos"
    # Amazon AMIs are Red-Hat based
    elif output.find("amzn") >= 0 or output.find("amazon") >= 0:
        return "centos"
    elif output.find("suse linux") >= 0:
        return "suse"
    elif output.find("opensuse") >= 0:
        return "suse"
    elif output.find("scientific linux") >= 0:
        return "scientificlinux"
    elif env.safe_exists("/etc/debian_version"):
        return "debian"
    elif output.find("id=arch") >= 0 or output.find('id_like="arch"') >= 0:
        return "arch"
    elif output.find("antergos") >= 0:
        return "arch"
    # check for file used by Python's platform.mac_ver
    elif env.safe_exists("/System/Library/CoreServices/SystemVersion.plist"):
        return "macosx"
    else:
        raise Exception(
            "Attempt to automatically determine Linux distribution of target machine failed:\n%s"
            % output)
def _debian_dist_name(env):
    """
    Determine Debian dist name (e.g. squeeze).
    """
    return env.safe_run_output("lsb_release -a | grep Codename | cut -f 2")
def _ubuntu_dist_name(env):
    """
    Determine Ubuntu dist name (e.g. precise or quantal).
    """
    return env.safe_run_output(
        "cat /etc/*release | grep DISTRIB_CODENAME | cut -f 2 -d =")
def _debian_dist_name(env):
    """
    Determine Debian dist name (e.g. squeeze).
    """
    return env.safe_run_output("lsb_release -a | grep Codename | cut -f 2")
def _ubuntu_dist_name(env):
    """
    Determine Ubuntu dist name (e.g. precise or quantal).
    """
    return env.safe_run_output("cat /etc/*release | grep DISTRIB_CODENAME | cut -f 2 -d =")