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" \;')
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")
def install(): nodejs.ensure() tmpdir = dir.temp() try: with ctx.cd(tmpdir): sudo("curl http://npmjs.org/install.sh | sh") finally: dir.remove(tmpdir, recursive=True)
def install_ppa(name): ensure("python-software-properties") with ctx.cd("/etc/apt/sources.list.d"): name_normalizes = name.replace("/", "-") source_list = "%s-%s.list" % (name_normalizes, server.codename()) if not file.exists(source_list): core.sudo("add-apt-repository ppa:%s" % name) update()
def install_ppa(name): ensure("python-software-properties") with ctx.cd("/etc/apt/sources.list.d"): name_normalizes = name.replace("/", "-") source_list = "%s-%s.list" % (name_normalizes, server.codename()) if not file.exists(source_list): sudo("add-apt-repository ppa:%s" % name) update()
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")
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)
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")
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)
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)
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")
def _dependencies(self): with ctx.cd(self.folders["releases.current"]): if file.exists("package.json"): self._dependencies_package_json() if file.exists("Gemfile"): self._dependencies_gemfile() if file.exists("setup.py"): self._dependencies_setup_py() if file.exists("requirements.txt"): self._dependencies_requirements_txt()
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")
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)
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)
def run(self): self.dispatch_hook("init") self.dispatch_hook("before_layout") try: self._layout() self.dispatch_hook("after_layout") with ctx.cd(self.folders["releases.current"]): self.dispatch_hook("before_upload") self._upload() self.dispatch_hook("after_upload") self.dispatch_hook("before_cleanup") self._cleanup() self.dispatch_hook("after_cleanup") self.dispatch_hook("before_activate") self._activate() except: dir.remove(self.folders["releases.current"], recursive=True) raise with ctx.cd(self.folders["releases.current"]): self.dispatch_hook("after_activate")
def deploy(owner, upload_hook=None, revision='HEAD', keep_versions=10): if not user.exists(owner): log.abort('Specified owner does not exists! Deploy aborted') # Ensure some directories paths = _ensure_layout(owner) new_release_dir = _create_new_release_dir(owner, paths['releases']) paths['new_release'] = new_release_dir # Upload the new version and call the after upload hook _upload(owner, new_release_dir, revision) if upload_hook: with ctx.sudo(owner), ctx.cd(new_release_dir): upload_hook(owner, paths) # Activate the new release and _symlink_release(owner, paths['current'], new_release_dir) _clear_old_releases(paths['releases'], keep_versions) return paths
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" \;')
def _clear_old_releases(directory, keep): with ctx.cd(directory): sudo( 'ls -1 | sort -V | head -n-%s | xargs -l1 rm -rf' % keep )
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)
def site_disable(site): with ctx.sudo(): with ctx.cd('/etc/nginx/sites-enabled'): file.remove(site) reload()
def site_ensure(site, lines): with ctx.sudo(): with ctx.cd('/etc/nginx/sites-available/'): file.write(site, lines) site_enable(site)