# Path: revolver/core.py
# def run(*args, **kwargs):
#     if not env.sudo_forced:
#         return _run(*args, **kwargs)
# 
#     return sudo(*args, **kwargs)
# 
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
# 
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
# 
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
# 
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
# 
# Path: revolver/tool/php_build.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
# 
# Path: revolver/tool/php_phpenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):


from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, package
from revolver.tool import php_build, php_phpenv
    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"'


# Path: revolver/core.py
# def run(*args, **kwargs):
#     if not env.sudo_forced:
#         return _run(*args, **kwargs)
# 
#     return sudo(*args, **kwargs)
# 
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
# 
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
# 
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
# 
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
# 
# Path: revolver/tool/php_build.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
# 
# Path: revolver/tool/php_phpenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):


# Path: revolver/tool/php.py
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, package
from revolver.tool import php_build, php_phpenv

    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):