public function install(Build $build) { $this->info('Installing...'); if ($this->options->sudo) { $cmd = new CommandBuilder('sudo make install'); if (!$this->options->dryrun) { $code = $cmd->passthru($lastline); if ($code !== 0) { throw new SystemCommandException("Install failed: {$lastline}", $build, $build->getBuildLogPath()); } } } else { $cmd = new CommandBuilder('make install'); $cmd->setAppendLog(true); $cmd->setLogPath($build->getBuildLogPath()); $cmd->setStdout($this->options->{'stdout'}); if (!$this->options->dryrun) { $code = $cmd->execute($lastline); if ($code !== 0) { throw new SystemCommandException("Install failed: {$lastline}", $build, $build->getBuildLogPath()); } } } $build->setState(Build::STATE_INSTALL); }
public function run(Build $build, $targets = array()) { if ($build->getState() >= Build::STATE_BUILD) { $this->info("===> Already built, skipping..."); return; } $this->info("===> Building..."); $cmd = new CommandBuilder('make'); $cmd->setAppendLog(true); $cmd->setLogPath($build->getBuildLogPath()); $cmd->setStdout($this->options->{'stdout'}); if (!empty($targets)) { foreach ($targets as $t) { $cmd->addArg($t); } } if ($this->options->nice) { $cmd->nice($this->options->nice); } if ($makeJobs = $this->options->{'jobs'}) { $cmd->addArg("-j{$makeJobs}"); } $this->debug($cmd->getCommand()); if (!$this->options->dryrun) { $startTime = microtime(true); $code = $cmd->execute(); if ($code != 0) { throw new SystemCommandException('Make failed.', $build, $build->getBuildLogPath()); } $buildTime = round((microtime(true) - $startTime) / 60, 1); $this->info("Build finished: {$buildTime} minutes."); } $build->setState(Build::STATE_BUILD); }
public function install($build, $options) { $this->info("Installing..."); $cmd = new CommandBuilder('make install'); $cmd->append = true; if ($this->logPath) { $cmd->stdout = $this->logPath; } if (!$options->dryrun) { $cmd->execute() !== false or die('Install failed.'); } }
public function test($nice = null) { $this->info("Testing..."); $cmd = new CommandBuilder('make test'); if ($nice) { $cmd->nice($nice); } $cmd->append = true; if ($this->logPath !== null) { $cmd->stdout = $this->logPath; } $this->debug('' . $cmd); $cmd->execute() !== false or die('Test failed.'); }
public function install(Build $build) { $this->info("Installing..."); $cmd = new CommandBuilder('make install'); $cmd->setAppendLog(true); $cmd->setLogPath($build->getBuildLogPath()); $cmd->setStdout($this->options->{'stdout'}); if (!$this->options->dryrun) { $code = $cmd->execute(); if ($code != 0) { throw new SystemCommandException('Install failed.', $build->getBuildLogPath()); } } $build->setState(Build::STATE_INSTALL); }
public function build($build, $options) { $this->info("===> Building..."); $cmd = new CommandBuilder('make'); $cmd->append = true; if ($this->logPath) { $cmd->stdout = $this->logPath; } if ($options->nice) { $cmd->nice($options->nice); } if ($makeJobs = $options->{'make-jobs'}) { $cmd->addArg("-j{$makeJobs}"); } $this->debug($cmd->__toString()); if (!$options->dryrun) { $startTime = microtime(true); $cmd->execute() !== false or die('Make failed.'); $buildTime = ceil((microtime(true) - $startTime) / 60); $this->info("Build finished: {$buildTime} minutes."); } }
public function run(Build $build, $nice = null) { $this->info("Testing..."); $cmd = new CommandBuilder('make test'); if ($nice) { $cmd->nice($nice); } $cmd->setAppendLog(true); $cmd->setLogPath($build->getBuildLogPath()); $cmd->setStdout($this->options->{'stdout'}); $this->debug('' . $cmd); $code = $cmd->execute(); if ($code != 0) { throw new RuntimeException('Test failed.'); } }
public function run(Build $build, $nice = null) { $this->info('===> Running tests...'); $cmd = new CommandBuilder('make test'); if ($nice) { $cmd->nice($nice); } $cmd->setAppendLog(true); $cmd->setLogPath($build->getBuildLogPath()); $cmd->setStdout($this->options->{'stdout'}); putenv('NO_INTERACTION=1'); $this->debug('' . $cmd); $code = $cmd->execute($lastline); if ($code !== 0) { throw new SystemCommandException("Test failed: {$lastline}", $build); } }
public function execute($versionName = null) { $args = func_get_args(); array_shift($args); // $currentVersion; $root = Config::getRoot(); $home = Config::getHome(); if ($versionName) { $sourceDir = Config::getBuildDir() . DIRECTORY_SEPARATOR . $versionName; } else { if (!getenv('PHPBREW_PHP')) { $this->logger->error('Error: PHPBREW_PHP environment variable is not defined.'); $this->logger->error(' This command requires you specify a PHP version from your build list.'); $this->logger->error(" And it looks like you haven't switched to a version from the builds that were built with PHPBrew."); $this->logger->error('Suggestion: Please install at least one PHP with your prefered version and switch to it.'); return false; } $sourceDir = Config::getCurrentBuildDir(); } if (!file_exists($sourceDir)) { return $this->logger->error("{$sourceDir} does not exist."); } $this->logger->info('Scanning ' . $sourceDir); $cmd = new CommandBuilder('ctags'); $cmd->arg('-R'); $cmd->arg('-a'); $cmd->arg('-h'); $cmd->arg('.c.h.cpp'); $cmd->arg($sourceDir . DIRECTORY_SEPARATOR . 'main'); $cmd->arg($sourceDir . DIRECTORY_SEPARATOR . 'ext'); $cmd->arg($sourceDir . DIRECTORY_SEPARATOR . 'Zend'); foreach ($args as $a) { $cmd->arg($a); } $this->logger->debug($cmd->__toString()); $cmd->execute(); $this->logger->info('Done'); }
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); }
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); }
public function run(Build $build, $variantOptions) { $extra = $build->getExtraOptions(); $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(); if (!$this->options->{'no-config-cache'}) { // $args[] = "-C"; // project wise cache (--config-cache) $args[] = '--cache-file=' . escapeshellarg(Config::getCacheDir() . DIRECTORY_SEPARATOR . 'config.cache'); } $args[] = '--prefix=' . $prefix; if ($this->options->{'user-config'}) { $args[] = "--with-config-file-path={$prefix}/etc"; $args[] = "--with-config-file-scan-dir={$prefix}/var/db"; } else { $args[] = "--with-config-file-path={$prefix}/etc"; $args[] = "--with-config-file-scan-dir={$prefix}/var/db"; } if ($variantOptions) { $args = array_merge($args, $variantOptions); } $this->debug('Enabled variants: [' . implode(', ', array_keys($build->getVariants())) . ']'); $this->debug('Disabled variants: [' . implode(', ', array_keys($build->getDisabledVariants())) . ']'); // todo: move to pear variant $args[] = "--with-pear={$prefix}/lib/php"; // Options for specific versions // todo: extract to BuildPlan class: PHP53 BuildPlan, PHP54 BuildPlan, PHP55 BuildPlan ? if ($build->compareVersion('5.4') == -1) { // copied from https://github.com/Homebrew/homebrew-php/blob/master/Formula/php53.rb $args[] = '--enable-sqlite-utf8'; $args[] = '--enable-zend-multibyte'; } elseif ($build->compareVersion('5.6') == -1) { $args[] = '--enable-zend-signals'; } 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'}); if (!$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->buildCommand()); if ($this->options->nice) { $cmd->nice($this->options->nice); } if (!$this->options->dryrun) { $code = $cmd->execute($lastline); if ($code !== 0) { throw new SystemCommandException("Configure failed: {$lastline}", $build, $buildLogPath); } } $build->setState(Build::STATE_CONFIGURE); }
public function execute() { $args = func_get_args(); // $currentVersion; $root = Config::getPhpbrewRoot(); $home = Config::getPhpbrewHome(); $buildDir = Config::getBuildDir(); $version = getenv('PHPBREW_PHP'); // XXX: get source dir from current build information $sourceDir = $buildDir . DIRECTORY_SEPARATOR . $version; $this->logger->info($sourceDir); $cmd = new CommandBuilder('ctags'); $cmd->arg('--recurse'); $cmd->arg('-a'); $cmd->arg('-h'); $cmd->arg('.c.h.cpp'); $cmd->arg($sourceDir . DIRECTORY_SEPARATOR . 'main'); $cmd->arg($sourceDir . DIRECTORY_SEPARATOR . 'ext'); $cmd->arg($sourceDir . DIRECTORY_SEPARATOR . 'Zend'); foreach ($args as $a) { $cmd->arg($a); } $this->logger->info($cmd->__toString()); $cmd->execute(); $this->logger->info("Done"); }