Example #1
0
 public function run(Build $build)
 {
     if (!file_exists($build->getSourceDirectory() . DIRECTORY_SEPARATOR . 'configure')) {
         $this->debug("configure file not found, running './buildconf --force'...");
         $lastline = system('./buildconf --force', $status);
         if ($status !== 0) {
             throw new SystemCommandException("buildconf error: {$lastline}", $build);
         }
     }
     foreach ((array) $this->options->patch as $patchPath) {
         // copy patch file to here
         $this->info("===> Applying patch file from {$patchPath} ...");
         // Search for strip parameter
         for ($i = 0; $i <= 16; ++$i) {
             ob_start();
             system("patch -p{$i} --dry-run < {$patchPath}", $return);
             ob_end_clean();
             if ($return === 0) {
                 system("patch -p{$i} < {$patchPath}");
                 break;
             }
         }
     }
     // let's apply patch for libphp{php version}.so (apxs)
     if ($build->isEnabledVariant('apxs2')) {
         $apxs2Checker = new \PhpBrew\Tasks\Apxs2CheckTask($this->logger);
         $apxs2Checker->check($build, $this->options);
     }
     if (!$this->options->{'no-patch'}) {
         $this->logger->info('===> Checking patches...');
         $patches = array();
         $patches[] = new Apache2ModuleNamePatch();
         foreach ($patches as $patch) {
             $this->logger->info('Checking patch for ' . $patch->desc());
             if ($patch->match($build, $this->logger)) {
                 $patched = $patch->apply($build, $this->logger);
                 $this->logger->info("{$patched} changes patched.");
             }
         }
     }
 }
Example #2
0
 public function configure(\PhpBrew\Build $build)
 {
     $variantBuilder = new VariantBuilder();
     $extra = $build->getExtraOptions();
     if (!file_exists('configure')) {
         $this->logger->debug("configure file not found, running buildconf script...");
         system('./buildconf') !== false or die('buildconf error');
     }
     // build configure args
     // XXX: support variants
     $cmd = new CommandBuilder('./configure');
     // putenv('CFLAGS=-O3');
     $prefix = $build->getInstallPrefix();
     $args[] = "--prefix=" . $prefix;
     $args[] = "--with-config-file-path={$prefix}/etc";
     $args[] = "--with-config-file-scan-dir={$prefix}/var/db";
     $args[] = "--with-pear={$prefix}/lib/php";
     // this is to support pear
     $build->enableVariant('xml');
     $variantOptions = $variantBuilder->build($build);
     if ($variantOptions) {
         $args = array_merge($args, $variantOptions);
     }
     $this->logger->debug('Enabled variants: ' . join(', ', array_keys($build->getVariants())));
     $this->logger->debug('Disabled variants: ' . join(', ', array_keys($build->getDisabledVariants())));
     if ($patchFiles = $this->options->patch) {
         foreach ($patchFiles as $patchFile) {
             // copy patch file to here
             $this->logger->info("===> Applying patch file from {$patchFile} ...");
             system("patch -p0 < {$patchFile}");
         }
     }
     // let's apply patch for libphp{php version}.so (apxs)
     if ($build->isEnabledVariant('apxs2')) {
         $apxs2Checker = new \PhpBrew\Tasks\Apxs2CheckTask($this->logger);
         $apxs2Checker->check($build);
         $apxs2Patch = new \PhpBrew\Tasks\Apxs2PatchTask($this->logger);
         $apxs2Patch->patch($build, $this->options);
     }
     foreach ($extra as $a) {
         $args[] = $a;
     }
     $cmd->args($args);
     $this->logger->info("===> Configuring {$build->version}...");
     $cmd->append = false;
     $cmd->stdout = Config::getVersionBuildLogPath($build->name);
     echo "\n\n";
     echo "Use tail command to see what's going on:\n";
     echo "   \$ tail -f {$cmd->stdout}\n\n\n";
     $this->logger->debug($cmd->getCommand());
     if ($this->options->nice) {
         $cmd->nice($this->options->nice);
     }
     $cmd->execute() !== false or die('Configure failed.');
     // Then patch Makefile for PHP 5.3.x on 64bit system.
     $currentVersion = preg_replace('/[^\\d]*(\\d+).(\\d+).*/i', '$1.$2', $this->version);
     if (Utils::support64bit() && version_compare($currentVersion, '5.3', '==')) {
         $this->logger->info("===> Applying patch file for php5.3.x on 64bit machine.");
         system('sed -i \'/^BUILD_/ s/\\$(CC)/\\$(CXX)/g\' Makefile');
         system('sed -i \'/EXTRA_LIBS = /s|$| -lstdc++|\' Makefile');
     }
 }
Example #3
0
 public function run(Build $build, $variantOptions)
 {
     $extra = $build->getExtraOptions();
     if (!file_exists($build->getSourceDirectory() . DIRECTORY_SEPARATOR . 'configure')) {
         $this->debug("configure file not found, running buildconf script...");
         $lastline = system('./buildconf', $status);
         if ($status !== 0) {
             throw new SystemCommandException("buildconf error: {$lastline}");
         }
     }
     $prefix = $build->getInstallPrefix();
     // append cflags
     if ($this->optimizationLevel) {
         $o = $this->optimizationLevel;
         $cflags = getenv('CFLAGS');
         putenv("CFLAGS={$cflags} -O{$o}");
         $_ENV['CFLAGS'] = "{$cflags} -O{$o}";
     }
     $args = array();
     $args[] = "--prefix=" . $prefix;
     $args[] = "--with-config-file-path={$prefix}/etc";
     $args[] = "--with-config-file-scan-dir={$prefix}/var/db";
     $args[] = "--with-pear={$prefix}/lib/php";
     if ($variantOptions) {
         $args = array_merge($args, $variantOptions);
     }
     $this->debug('Enabled variants: ' . join(', ', array_keys($build->getVariants())));
     $this->debug('Disabled variants: ' . join(', ', array_keys($build->getDisabledVariants())));
     foreach ((array) $this->options->patch as $patchPath) {
         // copy patch file to here
         $this->info("===> Applying patch file from {$patchPath} ...");
         // Search for strip parameter
         for ($i = 0; $i <= 16; $i++) {
             ob_start();
             system("patch -p{$i} --dry-run < {$patchPath}", $return);
             ob_end_clean();
             if ($return === 0) {
                 system("patch -p{$i} < {$patchPath}");
                 break;
             }
         }
     }
     // let's apply patch for libphp{php version}.so (apxs)
     if ($build->isEnabledVariant('apxs2')) {
         $apxs2Checker = new \PhpBrew\Tasks\Apxs2CheckTask($this->logger);
         $apxs2Checker->check($build, $this->options);
         $apxs2Patch = new \PhpBrew\Tasks\Apxs2PatchTask($this->logger);
         $apxs2Patch->patch($build, $this->options);
     }
     foreach ($extra as $a) {
         $args[] = $a;
     }
     $cmd = new CommandBuilder('./configure');
     $cmd->args($args);
     $buildLogPath = $build->getBuildLogPath();
     if (file_exists($buildLogPath)) {
         $newPath = $buildLogPath . '.' . filemtime($buildLogPath);
         $this->info("Found existing build.log, renaming it to {$newPath}");
         rename($buildLogPath, $newPath);
     }
     $this->info("===> Configuring {$build->version}...");
     $cmd->setAppendLog(true);
     $cmd->setLogPath($buildLogPath);
     $cmd->setStdout($this->options->{'stdout'});
     $this->logger->info("\n");
     $this->logger->info("Use tail command to see what's going on:");
     $this->logger->info("   \$ tail -F {$buildLogPath}\n\n");
     $this->debug($cmd->getCommand());
     if ($this->options->nice) {
         $cmd->nice($this->options->nice);
     }
     if (!$this->options->dryrun) {
         $code = $cmd->execute();
         if ($code != 0) {
             throw new SystemCommandException("Configure failed: {$code}", $buildLogPath);
         }
     }
     if (!$this->options->{'no-patch'}) {
         $patch64bit = new \PhpBrew\Tasks\Patch64BitSupportTask($this->logger, $this->options);
         if ($patch64bit->match($build)) {
             $patch64bit->patch($build);
         }
     }
     $build->setState(Build::STATE_CONFIGURE);
 }
Example #4
0
 public function configure(Build $build, $options)
 {
     $root = Config::getPhpbrewRoot();
     $buildDir = Config::getBuildDir();
     $variantBuilder = new VariantBuilder();
     $extra = $build->getExtraOptions();
     if (!file_exists('configure')) {
         $this->debug("configure file not found, running buildconf script...");
         system('./buildconf') !== false or die('buildconf error');
     }
     $prefix = $build->getInstallPrefix();
     // append cflags
     if ($this->optimizationLevel) {
         $o = $this->optimizationLevel;
         $cflags = getenv('CFLAGS');
         putenv("CFLAGS={$cflags} -O{$o}");
         $_ENV['CFLAGS'] = "{$cflags} -O{$o}";
     }
     $args = array();
     $args[] = "--prefix=" . $prefix;
     $args[] = "--with-config-file-path={$prefix}/etc";
     $args[] = "--with-config-file-scan-dir={$prefix}/var/db";
     $args[] = "--with-pear={$prefix}/lib/php";
     $variantOptions = $variantBuilder->build($build);
     if ($variantOptions) {
         $args = array_merge($args, $variantOptions);
     }
     $this->debug('Enabled variants: ' . join(', ', array_keys($build->getVariants())));
     $this->debug('Disabled variants: ' . join(', ', array_keys($build->getDisabledVariants())));
     foreach ((array) $options->patch as $patchPath) {
         // copy patch file to here
         $this->info("===> Applying patch file from {$patchPath} ...");
         // Search for strip parameter
         for ($i = 0; $i <= 16; $i++) {
             ob_start();
             system("patch -p{$i} --dry-run < {$patchPath}", $return);
             ob_clean();
             if ($return === 0) {
                 system("patch -p{$i} < {$patchPath}");
                 break;
             }
         }
     }
     // let's apply patch for libphp{php version}.so (apxs)
     if ($build->isEnabledVariant('apxs2')) {
         $apxs2Checker = new \PhpBrew\Tasks\Apxs2CheckTask($this->logger);
         $apxs2Checker->check($build, $options);
         $apxs2Patch = new \PhpBrew\Tasks\Apxs2PatchTask($this->logger);
         $apxs2Patch->patch($build, $options);
     }
     foreach ($extra as $a) {
         $args[] = $a;
     }
     $cmd = new CommandBuilder('./configure');
     $cmd->args($args);
     $this->info("===> Configuring {$build->version}...");
     $cmd->append = false;
     $cmd->stdout = Config::getVersionBuildLogPath($build->name);
     echo "\n\n";
     echo "Use tail command to see what's going on:\n";
     echo "   \$ tail -f {$cmd->stdout}\n\n\n";
     $this->debug($cmd->getCommand());
     if ($options->nice) {
         $cmd->nice($options->nice);
     }
     if (!$options->dryrun) {
         $cmd->execute() !== false or die('Configure failed.');
     }
     $patch64bit = new \PhpBrew\Tasks\Patch64BitSupportTask($this->logger, $options);
     $patch64bit->patch($build, $options);
 }