Ejemplo n.º 1
0
def install(java_version=None):
    """
    Install dependencies (curl and unzip) and Install GVM

    ::

        import fabtools

        # Install GVM
        fabtools.gvm.install()

    """
    res = run('gvm help', quiet=True)
    if res.failed:
        family = distrib_family()
        packages = ['curl', 'unzip']
        if family == 'debian':
            require_deb_packages(packages)
        elif family == 'redhat':
            require_rpm_packages(packages)
        elif family == 'sun':
            require_pkg_packages(packages)
        else:
            raise UnsupportedFamily(supported=['debian', 'redhat', 'sun'])

        if java_version is None:
            java()
        else:
            java(version=java_version)

        run('curl -s get.gvmtool.net | bash')
        user = run('whoami')
        run('source "/home/%s/.gvm/bin/gvm-init.sh"' % user)
        configFile = "/home/%s/.gvm/etc/config" % user
        sed(configFile, 'gvm_auto_answer=false', 'gvm_auto_answer=true')
Ejemplo n.º 2
0
def distribute():
    """
    Require `distribute`_ to be installed.

    .. _distribute: http://packages.python.org/distribute/
    """

    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages

    family = distrib_family()

    if family == 'debian':
        require_deb_packages([
            'curl',
            'python-dev',
        ])

    elif family == 'redhat':

        require_rpm_packages([
            'curl',
            'python-devel',
        ])

    if not is_distribute_installed():
        install_distribute()
Ejemplo n.º 3
0
def distribute():
    """
    Require `distribute`_ to be installed.

    .. _distribute: http://packages.python.org/distribute/
    """

    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages

    family = distrib_family()

    if family == 'debian':
        require_deb_packages([
            'curl',
            'python-dev',
        ])

    elif family == 'redhat':

        require_rpm_packages([
            'curl',
            'python-devel',
        ])

    if not is_distribute_installed():
        install_distribute()
Ejemplo n.º 4
0
def setuptools(version=MIN_SETUPTOOLS_VERSION, python_cmd='python'):
    """
    Require `setuptools`_ to be installed.

    If setuptools is not installed, or if a version older than *version*
    is installed, the latest version will be installed.

    .. _setuptools: http://pythonhosted.org/setuptools/
    """

    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages

    if not is_setuptools_installed(python_cmd=python_cmd):
        family = distrib_family()

        if family == 'debian':
            require_deb_packages([
                'curl',
                'python-dev',
            ])

        elif family == 'redhat':

            require_rpm_packages([
                'curl',
                'python-devel',
            ])

        install_setuptools(python_cmd=python_cmd)
Ejemplo n.º 5
0
def setuptools(version=MIN_SETUPTOOLS_VERSION, python_cmd='python'):
    """
    Require `setuptools`_ to be installed.

    If setuptools is not installed, or if a version older than *version*
    is installed, the latest version will be installed.

    .. _setuptools: http://pythonhosted.org/setuptools/
    """

    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages

    if not is_setuptools_installed(python_cmd=python_cmd):
        family = distrib_family()

        if family == 'debian':
            require_deb_packages([
                'curl',
                'python-dev',
            ])

        elif family == 'redhat':

            require_rpm_packages([
                'curl',
                'python-devel',
            ])

        install_setuptools(python_cmd=python_cmd)
Ejemplo n.º 6
0
def install_from_source(version=DEFAULT_VERSION):
    """
    Install Node JS from source.

    ::

        import fabtools

        # Install Node.js
        fabtools.nodejs.install_nodejs()

    .. note:: This function may not work for old versions of Node.js.

    """

    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages
    from fabtools.require import file as require_file

    family = distrib_family()

    if family == 'debian':
        require_deb_packages([
            'build-essential',
            'libssl-dev',
            'python',
        ])

    elif family == 'redhat':
        require_rpm_packages([
            'gcc',
            'gcc-c++',
            'make',
            'openssl-devel',
            'python',
        ])

    filename = 'node-v%s.tar.gz' % version
    foldername = filename[0:-7]

    require_file(url='http://nodejs.org/dist/v%(version)s/%(filename)s' % {
        'version': version,
        'filename': filename,
    })
    run('tar -xzf %s' % filename)
    with cd(foldername):
        run('./configure')
        run('make -j%d' % (cpus() + 1))
        run_as_root('make install')
    run('rm -rf %(filename)s %(foldername)s' % locals())
Ejemplo n.º 7
0
def installed_from_source(version=VERSION):
    """
    Require Redis to be installed from source.

    The compiled binaries will be installed in ``/opt/redis-{version}/``.
    """
    from fabtools.require import directory as require_directory
    from fabtools.require import file as require_file
    from fabtools.require import user as require_user
    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages

    family = distrib_family()

    if family == 'debian':
        require_deb_packages([
            'build-essential',
        ])

    elif family == 'redhat':
        require_rpm_packages([
            'gcc',
            'make',
        ])

    require_user('redis', home='/var/lib/redis', system=True)
    require_directory('/var/lib/redis', owner='redis', use_sudo=True)

    dest_dir = '/opt/redis-%(version)s' % locals()
    require_directory(dest_dir, use_sudo=True, owner='redis')

    if not is_file('%(dest_dir)s/redis-server' % locals()):

        with cd('/tmp'):

            # Download and unpack the tarball
            tarball = 'redis-%(version)s.tar.gz' % locals()
            url = _download_url(version) + tarball
            require_file(tarball, url=url)
            run('tar xzf %(tarball)s' % locals())

            # Compile and install binaries
            with cd('redis-%(version)s' % locals()):
                run('make')

                for filename in BINARIES:
                    run_as_root(
                        'cp -pf src/%(filename)s %(dest_dir)s/' % locals())
                    run_as_root(
                        'chown redis: %(dest_dir)s/%(filename)s' % locals())
Ejemplo n.º 8
0
def installed_from_source(version=VERSION):
    """
    Require Redis to be installed from source.

    The compiled binaries will be installed in ``/opt/redis-{version}/``.
    """
    from fabtools.require import directory as require_directory
    from fabtools.require import file as require_file
    from fabtools.require import user as require_user
    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages

    family = distrib_family()

    if family == "debian":
        require_deb_packages(["build-essential"])

    elif family == "redhat":
        require_rpm_packages(["gcc", "make"])

    require_user("redis", home="/var/lib/redis", system=True)
    require_directory("/var/lib/redis", owner="redis", use_sudo=True)

    dest_dir = "/opt/redis-%(version)s" % locals()
    require_directory(dest_dir, use_sudo=True, owner="redis")

    if not is_file("%(dest_dir)s/redis-server" % locals()):

        with cd("/tmp"):

            # Download and unpack the tarball
            tarball = "redis-%(version)s.tar.gz" % locals()
            url = _download_url(version) + tarball
            require_file(tarball, url=url)
            run("tar xzf %(tarball)s" % locals())

            # Compile and install binaries
            with cd("redis-%(version)s" % locals()):
                run("make")

                for filename in BINARIES:
                    run_as_root("cp -pf src/%(filename)s %(dest_dir)s/" % locals())
                    run_as_root("chown redis: %(dest_dir)s/%(filename)s" % locals())
Ejemplo n.º 9
0
def install_from_source(version=DEFAULT_VERSION):
    """
    Install Node JS from source.

    ::

        import fabtools

        # Install Node.js
        fabtools.nodejs.install_nodejs()

    .. note:: This function may not work for old versions of Node.js.

    """

    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages
    from fabtools.require import file as require_file

    family = distrib_family()

    if family == "debian":
        require_deb_packages(["build-essential", "libssl-dev", "python"])

    elif family == "redhat":
        require_rpm_packages(["gcc", "gcc-c++", "make", "openssl-devel", "python"])

    filename = "node-v%s.tar.gz" % version
    foldername = filename[0:-7]

    require_file(url="http://nodejs.org/dist/v%(version)s/%(filename)s" % {"version": version, "filename": filename})
    run("tar -xzf %s" % filename)
    with cd(foldername):
        run("./configure")
        run("make -j%d" % (cpus() + 1))
        run_as_root("make install")
    run("rm -rf %(filename)s %(foldername)s" % locals())
Ejemplo n.º 10
0
def install_from_source(version=DEFAULT_VERSION, checkinstall=False):
    """
    Install Node JS from source.

    If *checkinstall* is ``True``, a distribution package will be built.

    ::

        import fabtools

        # Install Node.js
        fabtools.nodejs.install_nodejs()

    .. note:: This function may not work for old versions of Node.js.

    """

    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages
    from fabtools.require import file as require_file

    family = distrib_family()

    if family == 'debian':
        packages = [
            'build-essential',
            'libssl-dev',
            'python',
        ]
        if checkinstall:
            packages.append('checkinstall')
        require_deb_packages(packages)

    elif family == 'redhat':
        packages = [
            'gcc',
            'gcc-c++',
            'make',
            'openssl-devel',
            'python',
        ]
        if checkinstall:
            packages.append('checkinstall')
        require_rpm_packages(packages)

    filename = 'node-v%s.tar.gz' % version
    foldername = filename[0:-7]

    require_file(url='http://nodejs.org/dist/v%(version)s/%(filename)s' % {
        'version': version,
        'filename': filename,
    })
    run('tar -xzf %s' % filename)
    with cd(foldername):
        run('./configure')
        run('make -j%d' % (cpus() + 1))
        if checkinstall:
            run_as_root('checkinstall -y --pkgname=nodejs --pkgversion=%(version) '
                        '--showinstall=no make install' % locals())
        else:
            run_as_root('make install')
    run('rm -rf %(filename)s %(foldername)s' % locals())
Ejemplo n.º 11
0
def install_from_source(version=DEFAULT_VERSION, checkinstall=False):
    """
    Install Node JS from source.

    If *checkinstall* is ``True``, a distribution package will be built.

    ::

        import fabtools

        # Install Node.js
        fabtools.nodejs.install_nodejs()

    .. note:: This function may not work for old versions of Node.js.

    """

    from fabtools.require.deb import packages as require_deb_packages
    from fabtools.require.rpm import packages as require_rpm_packages
    from fabtools.require import file as require_file

    family = distrib_family()

    if family == 'debian':
        packages = [
            'build-essential',
            'libssl-dev',
            'python',
        ]
        if checkinstall:
            packages.append('checkinstall')
        require_deb_packages(packages)

    elif family == 'redhat':
        packages = [
            'gcc',
            'gcc-c++',
            'make',
            'openssl-devel',
            'python',
        ]
        if checkinstall:
            packages.append('checkinstall')
        require_rpm_packages(packages)

    filename = 'node-v%s.tar.gz' % version
    foldername = filename[0:-7]

    require_file(url='http://nodejs.org/dist/v%(version)s/%(filename)s' % {
        'version': version,
        'filename': filename,
    })
    run('tar -xzf %s' % filename)
    with cd(foldername):
        run('./configure')
        run('make -j%d' % (cpus() + 1))
        if checkinstall:
            run_as_root(
                'checkinstall -y --pkgname=nodejs --pkgversion=%(version) '
                '--showinstall=no make install' % locals())
        else:
            run_as_root('make install')
    run('rm -rf %(filename)s %(foldername)s' % locals())