Exemplo n.º 1
0
def compile(install):
    print 'Installing PHP'
    ctx = install.builder._ctx
    validate_php_version(ctx)
    validate_php_extensions(ctx)
    convert_php_extensions(ctx)
    build_php_environment(ctx)
    (install
        .package('PHP')
        .config()
            .from_application('.bp-config/php')
            .or_from_build_pack('defaults/config/php/{PHP_VERSION}')
            .to('php/etc')
            .rewrite()
            .done()
        .modules('PHP')
            .find_modules_with_regex('^extension=(.*).so$')
            .from_application('php/etc/php.ini')
            .find_modules_with_regex('^zend_extension=(.*).so$')
            .from_application('php/etc/php.ini')
            .find_modules_with_regex('^zend_extension="(?:.*/)?(.*).so"$')
            .from_application('php/etc/php.ini')
            .include_modules_from('PHP_MODULES')
            .include_module(is_web_app(ctx) and 'fpm' or 'cli')
            .done())
    return 0
Exemplo n.º 2
0
    def _compile(self, install):
        ctx = install.builder._ctx

        (json_file, lock_file) = find_composer_paths(ctx)
        if (os.path.isfile(os.path.join(ctx['BUILD_DIR'],'.bp-config', 'options.json')) and json_file and os.path.isfile(json_file)):
            print('WARNING: A version of PHP has been specified in both `composer.json` and `./bp-config/options.json`.');
            print('WARNING: The version defined in `composer.json` will be used.');

        print 'Installing PHP'
        validate_php_version(ctx)
        print 'PHP %s' % (ctx['PHP_VERSION'])

        major_minor = '.'.join(string.split(ctx['PHP_VERSION'], '.')[0:2])

        (install
            .package('PHP')
            .done())
        validate_php_extensions(ctx)
        convert_php_extensions(ctx)
        (install
            .config()
                .from_application('.bp-config/php')  # noqa
                .or_from_build_pack('defaults/config/php/%s.x' % major_minor)
                .to('php/etc')
                .rewrite()
                .done())
        return 0
Exemplo n.º 3
0
    def _compile(self, install):
        ctx = install.builder._ctx

        (json_file, lock_file) = find_composer_paths(ctx)
        if (os.path.isfile(
                os.path.join(ctx['BUILD_DIR'], '.bp-config', 'options.json'))
                and json_file and os.path.isfile(json_file)):
            print(
                'WARNING: A version of PHP has been specified in both `composer.json` and `./bp-config/options.json`.'
            )
            print(
                'WARNING: The version defined in `composer.json` will be used.'
            )

        print 'Installing PHP'
        validate_php_version(ctx)
        print 'PHP %s' % (ctx['PHP_VERSION'])

        major_minor = '.'.join(string.split(ctx['PHP_VERSION'], '.')[0:2])

        (install.package('PHP').done())
        validate_php_extensions(ctx)
        convert_php_extensions(ctx)
        (install.config().from_application('.bp-config/php')  # noqa
         .or_from_build_pack('defaults/config/php/%s.x' %
                             major_minor).to('php/etc').rewrite().done())
        return 0
Exemplo n.º 4
0
    def _compile(self, install):
        print 'Installing PHP'
        ctx = install.builder._ctx
        validate_php_version(ctx)
        print 'PHP %s' % (ctx['PHP_VERSION'])

        if ctx['PHP_VERSION'].startswith('5.4'):
            print('DEPRECATION WARNING: PHP 5.4 is being declared "End of Life" as of 2015-09-14')
            print('DEPRECATION WARNING: See https://secure.php.net/supported-versions.php for more details')
            print('DEPRECATION WARNING: Upgrade guide can be found at https://secure.php.net/manual/en/migration55.php')
            print('DEPRECATION WARNING: The php-buildpack will no longer support PHP 5.4 after this date')

        (install
            .package('PHP')
            .done())
        validate_php_extensions(ctx)
        convert_php_extensions(ctx)
        (install
            .config()
                .from_application('.bp-config/php')  # noqa
                .or_from_build_pack('defaults/config/php/{PHP_VERSION}')
                .to('php/etc')
                .rewrite()
                .done())
        return 0
Exemplo n.º 5
0
    def _compile(self, install):
        ctx = install.builder._ctx

        (composer_json_file, composer_lock_file) = find_composer_paths(ctx)
        options_json_file = os.path.join(ctx['BUILD_DIR'],'.bp-config', 'options.json')

        if (os.path.isfile(options_json_file) and composer_json_file and os.path.isfile(composer_json_file)):
            # options.json and composer.json both exist. Check to see if both define a PHP version.
            composer_json = json.load(open(composer_json_file,'r'))
            options_json = json.load(open(options_json_file,'r'))

            if composer_json.get('require', {}).get('php') and options_json.get("PHP_VERSION"):
                print('WARNING: A version of PHP has been specified in both `composer.json` and `./bp-config/options.json`.')
                print('WARNING: The version defined in `composer.json` will be used.')

        print 'Installing PHP'
        validate_php_version(ctx)
        print 'PHP %s' % (ctx['PHP_VERSION'])

        major_minor = '.'.join(string.split(ctx['PHP_VERSION'], '.')[0:2])

        (install
            .package('PHP')
            .done())

        validate_php_extensions(ctx)
        convert_php_extensions(ctx)
        (install
            .config()
                .from_application('.bp-config/php')  # noqa
                .or_from_build_pack('defaults/config/php/%s.x' % major_minor)
                .to('php/etc')
                .rewrite()
                .done())
        return 0
Exemplo n.º 6
0
def compile(install):
    print 'Installing PHP'
    ctx = install.builder._ctx
    validate_php_version(ctx)
    validate_php_extensions(ctx)
    convert_php_extensions(ctx)
    build_php_environment(ctx)
    (install
        .package('PHP')
        .config()
            .from_application('.bp-config/php')  # noqa
            .or_from_build_pack('defaults/config/php/{PHP_VERSION}')
            .to('php/etc')
            .rewrite()
            .done()
        .modules('PHP')
            .find_modules_with_regex('^extension=(.*).so$')
            .from_application('php/etc/php.ini')
            .find_modules_with_regex('^zend_extension=(.*).so$')
            .from_application('php/etc/php.ini')
            .find_modules_with_regex('^zend_extension="(?:.*/)?(.*).so"$')
            .from_application('php/etc/php.ini')
            .include_modules_from('PHP_MODULES')
            .include_module(is_web_app(ctx) and 'fpm' or 'cli')
            .done())
    return 0
Exemplo n.º 7
0
 def _compile(self, install):
     print "Installing PHP"
     ctx = install.builder._ctx
     validate_php_version(ctx)
     validate_php_extensions(ctx)
     convert_php_extensions(ctx)
     print "PHP %s" % (ctx["PHP_VERSION"])
     (
         install.package("PHP")
         .config()
         .from_application(".bp-config/php")  # noqa
         .or_from_build_pack("defaults/config/php/{PHP_VERSION}")
         .to("php/etc")
         .rewrite()
         .done()
         .modules("PHP")
         .find_modules_with_regex("^extension=(.*).so$")
         .from_application("php/etc/php.ini")
         .find_modules_with_regex("^zend_extension=(.*).so$")
         .from_application("php/etc/php.ini")
         .find_modules_with_regex('^zend_extension="(?:.*/)?(.*).so"$')
         .from_application("php/etc/php.ini")
         .include_modules_from("PHP_MODULES")
         .include_module(is_web_app(ctx) and "fpm" or "cli")
         .done()
     )
     return 0
Exemplo n.º 8
0
 def _compile(self, install):
     print 'Installing PHP'
     ctx = install.builder._ctx
     validate_php_version(ctx)
     convert_php_extensions(ctx)
     print 'PHP %s' % (ctx['PHP_VERSION'])
     (install.package('PHP').config().from_application(
         '.bp-config/php')  # noqa
      .or_from_build_pack('defaults/config/php/{PHP_VERSION}').to(
          'php/etc').rewrite().done())
     return 0
    def test_validate_php_version(self):
        ctx = {
            'ALL_PHP_VERSIONS': ['5.6.31', '5.6.30', '7.1.0'],
            'PHP_56_LATEST': '5.6.31',
            'PHP_DEFAULT': '7.1.0'
        }

        ctx['PHP_VERSION'] = '5.6.30'
        validate_php_version(ctx)
        eq_('5.6.30', ctx['PHP_VERSION'])

        ctx['PHP_VERSION'] = '5.6.29'
        validate_php_version(ctx)
        eq_(ctx['PHP_DEFAULT'], ctx['PHP_VERSION'])
Exemplo n.º 10
0
 def _compile(self, install):
     print 'Installing PHP'
     ctx = install.builder._ctx
     validate_php_version(ctx)
     convert_php_extensions(ctx)
     print 'PHP %s' % (ctx['PHP_VERSION'])
     (install
         .package('PHP')
         .config()
             .from_application('.bp-config/php')  # noqa
             .or_from_build_pack('defaults/config/php/{PHP_VERSION}')
             .to('php/etc')
             .rewrite()
             .done())
     return 0
Exemplo n.º 11
0
    def _compile(self, install):
        print 'Installing PHP'
        ctx = install.builder._ctx
        validate_php_version(ctx)
        print 'PHP %s' % (ctx['PHP_VERSION'])

        major_minor = '.'.join(string.split(ctx['PHP_VERSION'], '.')[0:2])

        (install.package('PHP').done())
        validate_php_extensions(ctx)
        convert_php_extensions(ctx)
        (install.config().from_application('.bp-config/php')  # noqa
         .or_from_build_pack('defaults/config/php/%s.x' %
                             major_minor).to('php/etc').rewrite().done())
        return 0
Exemplo n.º 12
0
    def _compile(self, install):
        ctx = install.builder._ctx

        (composer_json_file, composer_lock_file) = find_composer_paths(ctx)
        options_json_file = os.path.join(ctx['BUILD_DIR'],'.bp-config', 'options.json')

        if (os.path.isfile(options_json_file) and composer_json_file and os.path.isfile(composer_json_file)):
            # options.json and composer.json both exist. Check to see if both define a PHP version.
            composer_json = json.load(open(composer_json_file,'r'))
            options_json = json.load(open(options_json_file,'r'))

            if composer_json.get('require', {}).get('php') and options_json.get("PHP_VERSION"):
                print('WARNING: A version of PHP has been specified in both `composer.json` and `./bp-config/options.json`.')
                print('WARNING: The version defined in `composer.json` will be used.')

        if ctx.get('OPTIONS_JSON_HAS_PHP_EXTENSIONS', False):
            print("Warning: PHP_EXTENSIONS in options.json is deprecated. See: http://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html")

        print 'Installing PHP'
        validate_php_version(ctx)
        print 'PHP %s' % (ctx['PHP_VERSION'])

        major_minor = '.'.join(string.split(ctx['PHP_VERSION'], '.')[0:2])

        (install
            .package('PHP')
            .done())

        validate_php_ini_extensions(ctx)
        validate_php_extensions(ctx)
        convert_php_extensions(ctx)
        include_fpm_d_confs(ctx)

        (install
            .config()
                .from_application('.bp-config/php')  # noqa
                .or_from_build_pack('defaults/config/php/%s.x' % major_minor)
                .to('php/etc')
                .rewrite()
                .done())

        return 0
Exemplo n.º 13
0
    def _compile(self, install):
        print 'Installing PHP'
        ctx = install.builder._ctx
        validate_php_version(ctx)
        print 'PHP %s' % (ctx['PHP_VERSION'])

        major_minor = '.'.join(string.split(ctx['PHP_VERSION'], '.')[0:2])

        (install
            .package('PHP')
            .done())
        validate_php_extensions(ctx)
        convert_php_extensions(ctx)
        (install
            .config()
                .from_application('.bp-config/php')  # noqa
                .or_from_build_pack('defaults/config/php/%s.x' % major_minor)
                .to('php/etc')
                .rewrite()
                .done())
        return 0
Exemplo n.º 14
0
 def test_validate_php_version(self):
     ctx = {"ALL_PHP_VERSIONS": ["5.4.31", "5.4.30"], "PHP_54_LATEST": "5.4.31", "PHP_VERSION": "5.4.30"}
     validate_php_version(ctx)
     eq_("5.4.30", ctx["PHP_VERSION"])
     ctx["PHP_VERSION"] = "5.4.29"
     validate_php_version(ctx)
     eq_("5.4.31", ctx["PHP_VERSION"])
     ctx["PHP_VERSION"] = "5.4.30"
     validate_php_version(ctx)
     eq_("5.4.30", ctx["PHP_VERSION"])
 def test_validate_php_version(self):
     ctx = {
         'ALL_PHP_VERSIONS': ['5.4.31', '5.4.30'],
         'PHP_54_LATEST': '5.4.31',
         'PHP_VERSION': '5.4.30'
     }
     validate_php_version(ctx)
     eq_('5.4.30', ctx['PHP_VERSION'])
     ctx['PHP_VERSION'] = '5.4.29'
     validate_php_version(ctx)
     eq_('5.4.31', ctx['PHP_VERSION'])
     ctx['PHP_VERSION'] = '5.4.30'
     validate_php_version(ctx)
     eq_('5.4.30', ctx['PHP_VERSION'])
Exemplo n.º 16
0
 def test_validate_php_version(self):
     ctx = {
         'ALL_PHP_VERSIONS': ['5.4.31', '5.4.30'],
         'PHP_54_LATEST': '5.4.31',
         'PHP_VERSION': '5.4.30'
     }
     validate_php_version(ctx)
     eq_('5.4.30', ctx['PHP_VERSION'])
     ctx['PHP_VERSION'] = '5.4.29'
     validate_php_version(ctx)
     eq_('5.4.31', ctx['PHP_VERSION'])
     ctx['PHP_VERSION'] = '5.4.30'
     validate_php_version(ctx)
     eq_('5.4.30', ctx['PHP_VERSION'])