Esempio n. 1
0
def _install_php(version, fpm, xdebug):
    package.ensure(
        [
            "build-essential",
            "lemon",
            "libbz2-dev",
            "libpcre3-dev",
            "libc-client2007e-dev",
            "libcurl4-gnutls-dev",
            "libexpat1-dev",
            "libfreetype6-dev",
            "libgmp3-dev",
            "libicu-dev",
            "libjpeg8-dev",
            "libltdl-dev",
            "libmcrypt-dev",
            "libmhash-dev",
            "libpng12-dev",
            "libreadline-dev",
            "libssl1.0.0",
            "libssl-dev",
            "libt1-dev",
            "libtidy-dev",
            "libxml2-dev",
            "libxslt1-dev",
            "re2c",
            "zlib1g-dev",
        ]
    )

    def configure(value):
        key = "PHP_BUILD_CONFIGURE_OPTS"
        return 'export %(key)s="%(value)s $%(key)s"' % locals()

    prefix = "$HOME/.phpenv/versions/%s" % version

    # Force the usage of pear because pyrus is unable to install APC
    # See https://github.com/CHH/php-build/blob/master/man/php-build.1.ronn#L79
    pear_path = "%s/pear" % prefix
    pear = configure("--with-pear=%s" % pear_path)
    dir.ensure(pear_path, recursive=True)

    # We only support this two configuration options! Why?
    # - Xdebug is already integrated into php-build
    # - FPM is a very common flag
    #
    # But if you want to configure php even further? Own definition files!
    # See https://github.com/CHH/php-build/blob/master/man/php-build.1.ronn#L54
    fpm = (fpm and configure("--enable-fpm")) or "true"
    xdebug = (xdebug and "true") or 'export PHP_BUILD_XDEBUG_ENABLE="off"'

    with ctx.prefix(pear):
        with ctx.prefix(xdebug):
            with ctx.prefix(fpm):
                run("php-build %s %s" % (version, prefix))

    # Some executables (like php-fpm) aren't available through phpenv without
    # this symlinks
    with ctx.cd(prefix):
        run('find sbin/ -type f -exec ln -sf "$(pwd)/{}" -t "$(pwd)/bin" \;')
Esempio n. 2
0
def create(path, recursive=False, mode=None, owner=None, group=None):
    recursive = recursive and '-p' or ''

    if exists(path):
        return

    run('mkdir %s %s' % (recursive, path))
    attributes(path, mode=mode, owner=owner, group=group)
Esempio n. 3
0
def create(path, recursive=False, mode=None, owner=None, group=None):
    recursive = recursive and '-p' or ''

    if exists(path):
        return

    core.run('mkdir %s %s' % (recursive, path))
    attributes(path, mode=mode, owner=owner, group=group)
Esempio n. 4
0
def install():
    package.ensure("curl")

    if not command.exists("pythonbrew"):
        url = "https://raw.github.com" \
            + "/utahta/pythonbrew/master/pythonbrew-install"
        run("curl -s %s | bash" % url)
    else:
        run("pythonbrew update")
Esempio n. 5
0
def _create_network(name, subnet):
    tempfile = file.temp()
    try:
        definition = _NETWORK_TEMPLATE % dict(name=name, subnet=subnet)
        file.write(tempfile, definition)
        core.run("virsh net-define %s" % tempfile)
        core.run("virsh net-autostart %s" % name)
    finally:
        file.remove(tempfile)
Esempio n. 6
0
def _install_apc():
    installed = run("pecl list | grep -i apc; true")
    if installed:
        return

    run("yes '' | pecl install apc")

    bin_path = run("phpenv which php")
    conf_path = bin_path.replace("/bin/php", "/etc/conf.d")
    file.write(conf_path + "/apc.ini", "extension=apc.so")
Esempio n. 7
0
def _install_apc():
    installed = run("pecl list | grep -i apc; true")
    if installed:
        return

    run("yes '' | pecl install apc")

    bin_path = run("phpenv which php")
    conf_path = bin_path.replace("/bin/php", "/etc/conf.d")
    file.write(conf_path + "/apc.ini", "extension=apc.so")
Esempio n. 8
0
def install():
    package.ensure(['git-core', 'curl', 'build-essential'])
    tmpdir = dir.temp()

    try:
        with ctx.cd(tmpdir):
            repo = 'git://github.com/sstephenson/ruby-build.git'
            run('git clone %s ./ --depth 1' % repo)
            sudo('./install.sh')
    finally:
        dir.remove(tmpdir, recursive=True)
Esempio n. 9
0
def install(version, _update=True):
    nodejs_nvm.ensure()

    if not version.startswith("v"):
        version = "v" + version

    status = run("nvm use %s" % version)
    if status.find("not installed yet") != -1 or _update:
        run("nvm install %s > /dev/null" % version)

    run("nvm alias default %s" % version)
Esempio n. 10
0
def install():
    package.ensure(["git-core", "libssl-dev", "curl", "build-essential"])

    if not dir.exists(".nvm"):
        run("git clone git://github.com/creationix/nvm.git .nvm")
    else:
        with ctx.cd(".nvm"):
            run("git pull")

    _ensure_autoload(".bashrc")
    _ensure_autoload(".zshrc")
Esempio n. 11
0
def install():
    package.ensure("git-core")

    if not dir.exists(".rbenv"):
        run("git clone git://github.com/sstephenson/rbenv.git .rbenv")
    else:
        with ctx.cd(".rbenv"):
            run("git pull")

    _ensure_autoload(".bashrc")
    _ensure_autoload(".zshrc")
Esempio n. 12
0
def install():
    package.ensure(["git-core", "openjdk-7-jre"])

    if not dir.exists(".awsenv"):
        run("git clone git://github.com/michaelcontento/awsenv.git .awsenv")
        return

    with ctx.cd(".awsenv"):
        run("git pull")

    _ensure_autoload(".bashrc")
    _ensure_autoload(".zshrc")
Esempio n. 13
0
def install(version, fpm=False, xdebug=False):
    php_build.ensure()
    php_phpenv.ensure()

    switched = run("phpenv global %s; true" % version)
    if not switched == "":
        _install_php(version, fpm, xdebug)
        run("phpenv global %s" % version)

    run("phpenv rehash")
    _install_apc()
    _install_composer()
Esempio n. 14
0
def install(version, fpm=False, xdebug=False):
    php_build.ensure()
    php_phpenv.ensure()

    switched = run("phpenv global %s; true" % version)
    if not switched == "":
        _install_php(version, fpm, xdebug)
        run("phpenv global %s" % version)

    run("phpenv rehash")
    _install_apc()
    _install_composer()
Esempio n. 15
0
    def _upload(self):
        # TODO Warn if there are local changes
        tmp_tar = git.create_archive(self.revision)

        try:
            core.put(tmp_tar, "deploy.tar.gz")
            core.run("tar -xzf deploy.tar.gz")
            file.remove("deploy.tar.gz")

            with ctx.unpatched_state():
                file.write("VERSION", git.revparse(self.revision))
        finally:
            core.local("rm -rf %s" % tmp_tar)
Esempio n. 16
0
def install():
    package.ensure(["curl", "git-core"])

    if not dir.exists(".php-build"):
        core.run("git clone git://github.com/CHH/php-build .php-build")

    with ctx.cd(".php-build"):
        core.run("git pull")
        dir.create("versions")
        dir.create("tmp")

    _ensure_autoload(".bashrc")
    _ensure_autoload(".zshrc")
Esempio n. 17
0
    def _upload(self):
        # TODO Warn if there are local changes
        tmp_tar = git.create_archive(self.revision)

        try:
            core.put(tmp_tar, "deploy.tar.gz")
            core.run("tar -xzf deploy.tar.gz")
            file.remove("deploy.tar.gz")

            with ctx.unpatched_state():
                file.write("VERSION", git.revparse(self.revision))
        finally:
            core.local("rm -rf %s" % tmp_tar)
Esempio n. 18
0
def install():
    package.ensure(["curl", "git-core"])

    url = "https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh"
    if not dir.exists(".phpenv"):
        run("curl -s %s | bash" % url)
    else:
        run("curl -s %s | UPDATE=yes bash" % url)

    dir.create(".phpenv/versions")

    _ensure_autoload(".bashrc")
    _ensure_autoload(".zshrc")
Esempio n. 19
0
def install(version, _update=True):
    ruby_rbenv.ensure()
    ruby_build.ensure()

    status = run("rbenv global %s; true" % version)
    if not status == "" or _update:
        run("rbenv install %s" % version)
        run("rbenv global %s" % version)

    run("rbenv rehash")
    run("gem install --no-ri --no-rdoc bundler")
Esempio n. 20
0
def _upload(owner, upload_dir, revision):
    tmp_tar = git.create_archive(revision)

    try:
        with ctx.cd(upload_dir):
            with ctx.sudo():
                put(tmp_tar, 'deploy.tar.gz')
                file.attributes('deploy.tar.gz', owner=owner)

            with ctx.sudo(owner):
                run('tar -xzf deploy.tar.gz')
                file.remove('deploy.tar.gz')
                file.write('VERSION', git.revparse(revision))
    finally:
        local('rm -rf %s' % tmp_tar)
Esempio n. 21
0
def install():
    package.ensure("git-core")
    package.ensure([
        "build-essential", "zlib1g-dev", "libssl-dev",
        "libxml2-dev", "libsqlite3-dev"
    ])
    ruby_rbenv.ensure()

    dir.ensure(".rbenv/plugins")
    with ctx.cd(".rbenv/plugins"):
        if not dir.exists("ruby-build"):
            run("git clone git://github.com/sstephenson/ruby-build.git")
            return

        with ctx.cd("ruby-build"):
            run("git pull")
Esempio n. 22
0
 def __init__(self, cwd=None, name=None):
     self.cwd = cwd or core.run("pwd").stdout
     self.name = name or git.repository_name()
     self.releases_to_keep = 15
     self.revision = "HEAD"
     self._hooks = []
     self._init_folders()
Esempio n. 23
0
 def __init__(self, cwd=None, name=None):
     self.cwd = cwd or core.run("pwd").stdout
     self.name = name or git.repository_name()
     self.releases_to_keep = 15
     self.revision = "HEAD"
     self._hooks = []
     self._init_folders()
Esempio n. 24
0
def _list_networks():
    """Return a dictionary of network name to active status bools.

        Sample virsh net-list output::

    Name                 State      Autostart
    -----------------------------------------
    default              active     yes
    juju-test            inactive   no
    foobar               inactive   no

    Parsing the above would return::
    {"default": True, "juju-test": False, "foobar": False}

    See: http://goo.gl/kXwfC
    """
    output = core.run("virsh net-list --all")
    networks = {}

    # Take the header off and normalize whitespace.
    net_lines = [n.strip() for n in output.splitlines()[2:]]
    for line in net_lines:
        if not line:
            continue
        name, state, auto = line.split()
        networks[name] = state == "active"
    return networks
Esempio n. 25
0
def install():
    package.ensure("git-core")
    package.ensure([
        "build-essential", "zlib1g-dev", "libssl-dev", "libxml2-dev",
        "libsqlite3-dev"
    ])
    ruby_rbenv.ensure()

    dir.ensure(".rbenv/plugins")
    with ctx.cd(".rbenv/plugins"):
        if not dir.exists("ruby-build"):
            run("git clone git://github.com/sstephenson/ruby-build.git")
            return

        with ctx.cd("ruby-build"):
            run("git pull")
Esempio n. 26
0
 def on_before_activate(self):
     values = {
         "folders": self.folders,
         "name": self.name,
         "user": core.run("echo $USER").stdout
     }
     content = self._template.format(**values)
     service.add_upstart(self._service, content)
Esempio n. 27
0
def install(name=_DEFAULT_NAME, subnet=_DEFAULT_SUBNET, _update=True):
    packages = ["lxc", "debootstrap", "libvirt-bin"]
    if _update:
        package.install(packages)
    else:
        package.ensure(packages)

    networks = _list_networks()
    if name not in networks:
        _create_network(name, subnet)
        core.run("virsh net-start %s" % name)
    else:
        if not networks[name]:
            core.run("virsh net-start %s" % name)

    with ctx.sudo():
        config = _LXC_NETWORK % dict(name=name, subnet=subnet)
        file.write("/etc/lxc/net-lxc.conf", config, mode="a+r")
Esempio n. 28
0
def is_installed(name):
    with ctx.settings(warn_only=True):
        res = core.run("dpkg -s %s" % name)
        for line in res.splitlines():
            if line.startswith("Status: "):
                status = line[8:]
                if "installed" in status.split(" "):
                    return True
        return False
Esempio n. 29
0
def is_installed(name):
    with ctx.settings(warn_only=True):
        res = run("dpkg -s %s" % name)
        for line in res.splitlines():
            if line.startswith("Status: "):
                status = line[8:]
                if "installed" in status.split(" "):
                    return True
        return False
Esempio n. 30
0
    def _layout(self):
        current_user = core.run("echo $USER").stdout

        for type, path in self.folders.iteritems():
            if not dir.exists(path):
                if type != "current":
                    dir.create(path, recursive=True)
            else:
                with ctx.sudo():
                    dir.attributes(path, owner=current_user, recursive=True)
Esempio n. 31
0
    def _layout(self):
        current_user = core.run("echo $USER").stdout

        for type, path in self.folders.iteritems():
            if not dir.exists(path):
                if type != "current":
                    dir.create(path, recursive=True)
            else:
                with ctx.sudo():
                    dir.attributes(path, owner=current_user, recursive=True)
Esempio n. 32
0
def ensure(version=_VERSION):
    if command.exists('ruby'):
        raw_installed_version = run('ruby -v | cut -d" " -f2')
        installed_version = _convert_version_to_string(raw_installed_version)
    else:
        installed_version = '0'
    
    required_version = _convert_version_to_string(version)
    if installed_version < required_version:
        install(version)
Esempio n. 33
0
def _install_php(version, fpm, xdebug):
    package.ensure([
        "build-essential", "lemon", "libbz2-dev", "libpcre3-dev",
        "libc-client2007e-dev", "libcurl4-gnutls-dev", "libexpat1-dev",
        "libfreetype6-dev", "libgmp3-dev", "libicu-dev", "libjpeg8-dev",
        "libltdl-dev", "libmcrypt-dev", "libmhash-dev", "libpng12-dev",
        "libreadline-dev", "libssl1.0.0", "libssl-dev", "libt1-dev",
        "libtidy-dev", "libxml2-dev", "libxslt1-dev", "re2c", "zlib1g-dev"
    ])

    def configure(value):
        key = "PHP_BUILD_CONFIGURE_OPTS"
        return 'export %(key)s="%(value)s $%(key)s"' % locals()

    prefix = "$HOME/.phpenv/versions/%s" % version

    # Force the usage of pear because pyrus is unable to install APC
    # See https://github.com/CHH/php-build/blob/master/man/php-build.1.ronn#L79
    pear_path = "%s/pear" % prefix
    pear = configure("--with-pear=%s" % pear_path)
    dir.ensure(pear_path, recursive=True)

    # We only support this two configuration options! Why?
    # - Xdebug is already integrated into php-build
    # - FPM is a very common flag
    #
    # But if you want to configure php even further? Own definition files!
    # See https://github.com/CHH/php-build/blob/master/man/php-build.1.ronn#L54
    fpm = (fpm and configure("--enable-fpm")) or "true"
    xdebug = (xdebug and "true") or 'export PHP_BUILD_XDEBUG_ENABLE="off"'

    with ctx.prefix(pear):
        with ctx.prefix(xdebug):
            with ctx.prefix(fpm):
                run("php-build %s %s" % (version, prefix))

    # Some executables (like php-fpm) aren't available through phpenv without
    # this symlinks
    with ctx.cd(prefix):
        run('find sbin/ -type f -exec ln -sf "$(pwd)/{}" -t "$(pwd)/bin" \;')
Esempio n. 34
0
def install(version=_VERSION, options=_OPTIONS):
    package.ensure(['git-core', 'libssl-dev', 'curl', 'build-essential'])
    tmpdir = dir.temp()

    try:
        with ctx.cd(tmpdir):
            repo = 'git://github.com/joyent/node.git' 
            run('git clone %s ./ --depth 1' % repo)
            run('git checkout %s' % version)
            run('./configure %s' % options)
            run('make > /dev/null')
            sudo('make install')
    finally:
        dir.remove(tmpdir, recursive=True)
Esempio n. 35
0
 def on_before_activate(self):
     # TODO: Use shell from the current user
     # TODO: Allow changes to the used environment
     values = {
         "folders": self.folders,
         "name": self.name,
         "user": core.run("echo $USER").stdout,
         "config": self._config,
         "env": "production",
         "shell": "/bin/bash -i"
     }
     content = self._template.format(**values)
     service.add_upstart(self._service, content)
Esempio n. 36
0
 def on_before_activate(self):
     # TODO: Use shell from the current user
     # TODO: Allow changes to the used environment
     values = {
         "folders": self.folders,
         "name": self.name,
         "user": core.run("echo $USER").stdout,
         "config": self._config,
         "env": "production",
         "shell": "/bin/bash -i"
     }
     content = self._template.format(**values)
     service.add_upstart(self._service, content)
Esempio n. 37
0
def install(version=_VERSION, options=_OPTIONS):
    package.ensure(["git-core", "build-essential"])
    tmpdir = dir.temp()

    try:
        with ctx.cd(tmpdir):
            run("git clone git://github.com/antirez/redis.git ./ --depth 1")
            run("git checkout %s" % version)
            run("make %s > /dev/null" % options)
            sudo("make install")
    finally:
        dir.remove(tmpdir, recursive=True)
Esempio n. 38
0
def install(version=_VERSION, options=_OPTIONS):
    package.ensure(['git-core', 'build-essential'])
    tmpdir = dir.temp()

    try:
        with ctx.cd(tmpdir):
            run('git clone git://github.com/antirez/redis.git ./ --depth 1')
            run('git checkout %s' % version)
            run('make %s > /dev/null' % options)
            sudo('make install')
    finally:
        dir.remove(tmpdir, recursive=True)
Esempio n. 39
0
 def _cleanup(self):
     with ctx.cd(self.folders["releases"]):
         core.run("ls -1 | sort -V | head -n-%s | xargs -l1 rm -rf"
             % self.releases_to_keep)
Esempio n. 40
0
 def _dependencies_requirements_txt(self):
     if command.exists("pip"):
         core.run("pip install -r requirements.txt --use-mirrors")
Esempio n. 41
0
def touch(location, mode=None, owner=None, group=None):
    core.run('touch %s' % location)
    attributes(location, mode=mode, owner=owner, group=group)
Esempio n. 42
0
def remove(location, recursive=False, force=True):
    force = force and '-f' or ''
    recursive = recursive and '-r' or ''

    core.run('rm %s %s %s' % (force, recursive, location))
Esempio n. 43
0
 def _dependencies_gemfile(self):
     if command.exists("bundle"):
         core.run("bundle")
Esempio n. 44
0
 def _dependencies_requirements_txt(self):
     if command.exists("pip"):
         core.run("pip install -r requirements.txt --use-mirrors")
Esempio n. 45
0
 def _dependencies_package_json(self):
     if command.exists("npm"):
         core.run("npm install")
Esempio n. 46
0
def copy(source, destination, force=True, mode=None, owner=None, group=None):
    force = force and '-f' or ''

    core.run('cp %s %s %s' % (force, source, destination))
    attributes(destination, mode=mode, owner=owner, group=group)
Esempio n. 47
0
 def _dependencies_package_json(self):
     if command.exists("npm"):
         core.run("npm install")
Esempio n. 48
0
 def _dependencies_gemfile(self):
     if command.exists("bundle"):
         core.run("bundle")
Esempio n. 49
0
 def _cleanup(self):
     with ctx.cd(self.folders["releases"]):
         core.run("ls -1 | sort -V | head -n-%s | xargs -l1 rm -rf"
             % self.releases_to_keep)