getConfigParam() public static method

public static getConfigParam ( $param = null )
Ejemplo n.º 1
0
 public function execute($extName, $version = 'stable')
 {
     $logger = $this->getLogger();
     $extensions = array();
     if (Utils::startsWith($extName, '+')) {
         $config = Config::getConfigParam('extensions');
         $extName = ltrim($extName, '+');
         if (isset($config[$extName])) {
             foreach ($config[$extName] as $extensionName => $extOptions) {
                 $args = explode(' ', $extOptions);
                 $extensions[$extensionName] = $this->getExtData($args);
             }
         } else {
             $logger->info('Extension set name not found. Have you configured it at the config.yaml file?');
         }
     } else {
         $args = array_slice(func_get_args(), 1);
         $extensions[$extName] = $this->getExtData($args);
     }
     if ($this->options->{'php-version'} !== null) {
         $phpVersion = Utils::findLatestPhpVersion($this->options->{'php-version'});
         Config::setPhpVersion($phpVersion);
     }
     foreach ($extensions as $extensionName => $extData) {
         $extension = new Extension($extensionName, $logger);
         $extension->install($extData->version, $extData->options);
     }
     Config::useSystemPhpVersion();
 }
Ejemplo n.º 2
0
 public function execute($extName, $version = 'stable')
 {
     if ((preg_match('#^git://#', $extName) || preg_match('#\\.git$#', $extName)) && !preg_match("#github|bitbucket#", $extName)) {
         $pathinfo = pathinfo($extName);
         $repoUrl = $extName;
         $extName = $pathinfo['filename'];
         $extDir = Config::getBuildDir() . DIRECTORY_SEPARATOR . Config::getCurrentPhpName() . DIRECTORY_SEPARATOR . 'ext' . DIRECTORY_SEPARATOR . $extName;
         if (!file_exists($extDir)) {
             passthru("git clone {$repoUrl} {$extDir}", $ret);
             if ($ret != 0) {
                 return $this->logger->error('Clone failed.');
             }
         }
     }
     $extensions = array();
     if (Utils::startsWith($extName, '+')) {
         $config = Config::getConfigParam('extensions');
         $extName = ltrim($extName, '+');
         if (isset($config[$extName])) {
             foreach ($config[$extName] as $extensionName => $extOptions) {
                 $args = explode(' ', $extOptions);
                 $extensions[$extensionName] = $this->getExtConfig($args);
             }
         } else {
             $this->logger->info('Extension set name not found. Have you configured it at the config.yaml file?');
         }
     } else {
         $args = array_slice(func_get_args(), 1);
         $extensions[$extName] = $this->getExtConfig($args);
     }
     $extensionList = new ExtensionList();
     $manager = new ExtensionManager($this->logger);
     foreach ($extensions as $extensionName => $extConfig) {
         $provider = $extensionList->exists($extensionName);
         if (!$provider) {
             throw new Exception("Could not find provider for {$extensionName}.");
         }
         $extensionName = $provider->getPackageName();
         $ext = ExtensionFactory::lookupRecursive($extensionName);
         $always_redownload = $this->options->{'pecl'} || $this->options->{'redownload'} || !$provider->isBundled($extensionName);
         // Extension not found, use pecl to download it.
         if (!$ext || $always_redownload) {
             // not every project has stable branch, using master as default version
             $args = array_slice(func_get_args(), 1);
             if (!isset($args[0]) || $args[0] != $extConfig->version) {
                 $extConfig->version = $provider->getDefaultVersion();
             }
             $extensionDownloader = new ExtensionDownloader($this->logger, $this->options);
             $extensionDownloader->download($provider, $extConfig->version);
             // Reload the extension
             if ($provider->shouldLookupRecursive()) {
                 $ext = ExtensionFactory::lookupRecursive($extensionName);
             } else {
                 $ext = ExtensionFactory::lookup($extensionName);
             }
             if ($ext) {
                 $extensionDownloader->renameSourceDirectory($ext);
             }
         }
         if (!$ext) {
             throw new Exception("{$extensionName} not found.");
         }
         $manager->installExtension($ext, $extConfig->options);
     }
 }
Ejemplo n.º 3
0
 /**
  * Build variants to configure options from php build object.
  *
  * @param Build $build The build object, contains version information
  *
  * @return array|void
  * @throws \Exception
  */
 public function build(Build $build)
 {
     $customVirtualVariants = Config::getConfigParam('variants');
     foreach (array_keys($build->getVariants()) as $variantName) {
         if (isset($customVirtualVariants[$variantName])) {
             foreach ($customVirtualVariants[$variantName] as $lib => $params) {
                 if (is_array($params)) {
                     $this->variants[$lib] = $params;
                 }
             }
         }
     }
     // reset builtList
     $this->builtList = array();
     // reset built options
     if ($build->hasVariant('all') || $build->hasVariant('neutral')) {
         $this->options = array();
     } else {
         // build common options
         $this->options = array('--disable-all', '--enable-phar', '--enable-session', '--enable-short-tags', '--enable-tokenizer', '--with-pcre-regex');
         if ($prefix = Utils::findIncludePrefix('zlib.h')) {
             $this->addOptions('--with-zlib=' . $prefix);
         }
     }
     if ($prefix = Utils::findLibPrefix('x86_64-linux-gnu')) {
         $this->addOptions("--with-libdir=lib/x86_64-linux-gnu");
     } elseif ($prefix = Utils::findLibPrefix('i386-linux-gnu')) {
         $this->addOptions("--with-libdir=lib/i386-linux-gnu");
     }
     // enable/expand virtual variants
     foreach ($this->virtualVariants as $name => $variantNames) {
         if ($build->isEnabledVariant($name)) {
             foreach ($variantNames as $subVariantName) {
                 // enable the sub-variant only if it's not already enabled
                 // in order to not override a non-default value with the default
                 if (!$build->isEnabledVariant($subVariantName)) {
                     $build->enableVariant($subVariantName);
                 }
             }
             // it's a virtual variant, can not be built by buildVariant
             // method.
             $build->removeVariant($name);
         }
     }
     // Remove these enabled variant for disabled variants.
     $build->resolveVariants();
     // before we build these options from variants,
     // we need to check the enabled and disabled variants
     $this->checkConflicts($build);
     foreach ($build->getVariants() as $feature => $userValue) {
         if ($options = $this->buildVariant($build, $feature, $userValue)) {
             $this->addOptions($options);
         }
     }
     foreach ($build->getDisabledVariants() as $feature => $true) {
         if ($options = $this->buildDisableVariant($build, $feature)) {
             $this->addOptions($options);
         }
     }
     /*
     $opts = array_merge( $opts ,
         $this->getVersionSpecificOptions($version) );
     */
     $options = array_merge(array(), $this->options);
     // reset options
     $this->options = array();
     return $options;
 }
Ejemplo n.º 4
0
 public function execute($extName, $version = 'stable')
 {
     if (version_compare(PHP_VERSION, '7.0.0') > 0) {
         $this->logger->warn("Warning: Some extension won't be able to be built with php7. If the extension\nsupports php7 in another branch or new major version, you will need to specify\nthe branch name or version name explicitly.\n\nFor example, to install memcached extension for php7, use:\n\n    phpbrew ext install github:php-memcached-dev/php-memcached php7 -- --disable-memcached-sasl\n");
     }
     if (strtolower($extName) === 'apc' && version_compare(PHP_VERSION, '5.6.0') > 0) {
         $this->logger->warn('apc is not compatible with php 5.6+ versions, install apcu instead.');
     }
     // Detect protocol
     if ((preg_match('#^git://#', $extName) || preg_match('#\\.git$#', $extName)) && !preg_match('#github|bitbucket#', $extName)) {
         $pathinfo = pathinfo($extName);
         $repoUrl = $extName;
         $extName = $pathinfo['filename'];
         $extDir = Config::getBuildDir() . DIRECTORY_SEPARATOR . Config::getCurrentPhpName() . DIRECTORY_SEPARATOR . 'ext' . DIRECTORY_SEPARATOR . $extName;
         if (!file_exists($extDir)) {
             passthru("git clone {$repoUrl} {$extDir}", $ret);
             if ($ret != 0) {
                 return $this->logger->error('Clone failed.');
             }
         }
     }
     // Expand extensionset from config
     $extensions = array();
     if (Utils::startsWith($extName, '+')) {
         $config = Config::getConfigParam('extensions');
         $extName = ltrim($extName, '+');
         if (isset($config[$extName])) {
             foreach ($config[$extName] as $extensionName => $extOptions) {
                 $args = explode(' ', $extOptions);
                 $extensions[$extensionName] = $this->getExtConfig($args);
             }
         } else {
             $this->logger->info('Extension set name not found. Have you configured it at the config.yaml file?');
         }
     } else {
         $args = array_slice(func_get_args(), 1);
         $extensions[$extName] = $this->getExtConfig($args);
     }
     $extensionList = new ExtensionList($this->logger, $this->options);
     $manager = new ExtensionManager($this->logger);
     foreach ($extensions as $extensionName => $extConfig) {
         $provider = $extensionList->exists($extensionName);
         if (!$provider) {
             throw new Exception("Could not find provider for {$extensionName}.");
         }
         $extensionName = $provider->getPackageName();
         $ext = ExtensionFactory::lookupRecursive($extensionName);
         $always_redownload = $this->options->{'pecl'} || $this->options->{'redownload'} || !$provider->isBundled($extensionName);
         // Extension not found, use pecl to download it.
         if (!$ext || $always_redownload) {
             // not every project has stable branch, using master as default version
             $args = array_slice(func_get_args(), 1);
             if (!isset($args[0]) || $args[0] != $extConfig->version) {
                 $extConfig->version = $provider->getDefaultVersion();
             }
             $extensionDownloader = new ExtensionDownloader($this->logger, $this->options);
             $extensionDownloader->download($provider, $extConfig->version);
             // Reload the extension
             if ($provider->shouldLookupRecursive()) {
                 $ext = ExtensionFactory::lookupRecursive($extensionName);
             } else {
                 $ext = ExtensionFactory::lookup($extensionName);
             }
             if ($ext) {
                 $extensionDownloader->renameSourceDirectory($ext);
             }
         }
         if (!$ext) {
             throw new Exception("{$extensionName} not found.");
         }
         $manager->installExtension($ext, $extConfig->options);
     }
 }