Beispiel #1
0
 public function execute()
 {
     $versions = Config::getInstalledPhpVersions();
     $currentVersion = Config::getCurrentPhpName();
     if (empty($versions)) {
         return $this->logger->notice("Please install at least one PHP with your prefered version.");
     }
     if ($currentVersion === false or !in_array($currentVersion, $versions)) {
         $this->logger->writeln("* (system)");
     }
     foreach ($versions as $version) {
         $versionPrefix = Config::getVersionInstallPrefix($version);
         if ($currentVersion == $version) {
             $this->logger->writeln($this->formatter->format(sprintf('* %-15s', $version), 'bold'));
         } else {
             $this->logger->writeln($this->formatter->format(sprintf('  %-15s', $version), 'bold'));
         }
         if ($this->options->dir) {
             $this->logger->writeln(sprintf("    Prefix:   %s", $versionPrefix));
         }
         // TODO: use Build class to get the variants
         if ($this->options->variants && file_exists($versionPrefix . DIRECTORY_SEPARATOR . 'phpbrew.variants')) {
             $info = unserialize(file_get_contents($versionPrefix . DIRECTORY_SEPARATOR . 'phpbrew.variants'));
             echo "    Variants: ";
             echo wordwrap(VariantParser::revealCommandArguments($info), 75, " \\\n              ");
             echo "\n";
         }
     }
 }
Beispiel #2
0
 public function execute($version)
 {
     $version = preg_replace('/^php-/', '', $version);
     $releaseList = ReleaseList::getReadyInstance($this->options);
     $releases = $releaseList->getReleases();
     $versionInfo = $releaseList->getVersion($version);
     if (!$versionInfo) {
         throw new Exception("Version {$version} not found.");
     }
     $version = $versionInfo['version'];
     $distUrl = 'http://www.php.net/get/' . $versionInfo['filename'] . '/from/this/mirror';
     if ($mirrorSite = $this->options->mirror) {
         // http://tw1.php.net/distributions/php-5.3.29.tar.bz2
         $distUrl = $mirrorSite . '/distributions/' . $versionInfo['filename'];
     }
     $prepare = new PrepareDirectoryTask($this->logger, $this->options);
     $prepare->run();
     $distFileDir = Config::getDistFileDir();
     $download = new DownloadTask($this->logger, $this->options);
     $targetDir = $download->download($distUrl, $distFileDir, $versionInfo['md5']);
     if (!file_exists($targetDir)) {
         throw new Exception('Download failed.');
     }
     $this->logger->info("Done, please look at: {$targetDir}");
 }
Beispiel #3
0
 public function execute()
 {
     $root = Config::getPhpbrewRoot();
     $php = Config::getCurrentPhpName();
     $file = "{$root}/php/{$php}/etc/php.ini";
     Utils::editor($file);
 }
Beispiel #4
0
 protected function getVersions()
 {
     $versions = Config::getInstalledPhpVersions();
     return array_map(function ($version) {
         return str_replace('php-', '', $version);
     }, $versions);
 }
Beispiel #5
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();
 }
Beispiel #6
0
 public function execute()
 {
     $releaseList = new ReleaseList();
     $releases = array();
     //always fetch list from remote when --old presents, because the local file may not contain the old versions
     // and --old is seldom used.
     if (!$releaseList->foundLocalReleaseList() || $this->options->update || $this->options->old) {
         $fetchTask = new FetchReleaseListTask($this->logger, $this->options);
         $releases = $fetchTask->fetch();
     } else {
         $this->logger->info(sprintf('Read local release list (last update: %s UTC).', gmdate('Y-m-d H:i:s', filectime(Config::getPHPReleaseListPath()))));
         $releases = $releaseList->loadLocalReleaseList();
         $this->logger->info('You can run `phpbrew update` or `phpbrew known --update` to get a newer release list.');
     }
     foreach ($releases as $majorVersion => $versions) {
         if (version_compare($majorVersion, '5.2', 'le') && !$this->options->old) {
             continue;
         }
         $versionList = array_keys($versions);
         if (!$this->options->more) {
             array_splice($versionList, 8);
         }
         $this->logger->writeln($this->formatter->format("{$majorVersion}: ", 'yellow') . wordwrap(implode(', ', $versionList), 80, "\n" . str_repeat(' ', 5)) . (!$this->options->more ? ' ...' : ''));
     }
     if ($this->options->old) {
         $this->logger->warn('phpbrew need php 5.3 or above to run. build/switch to versions below 5.3 at your own risk.');
     }
 }
Beispiel #7
0
 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");
 }
Beispiel #8
0
 public function execute($version = null)
 {
     // get current version
     if (!$version) {
         $version = getenv('PHPBREW_PHP');
     }
     // $currentVersion;
     $root = Config::getPhpbrewRoot();
     $home = Config::getPhpbrewHome();
     $lookup = getenv('PHPBREW_LOOKUP_PREFIX');
     // $versionBuildPrefix = Config::getVersionBuildPrefix($version);
     // $versionBinPath     = Config::getVersionBinPath($version);
     echo "export PHPBREW_ROOT={$root}\n";
     echo "export PHPBREW_HOME={$home}\n";
     echo "export PHPBREW_LOOKUP_PREFIX={$lookup}\n";
     if ($version !== false) {
         // checking php version exists
         $version = Utils::findLatestPhpVersion($version);
         $targetPhpBinPath = Config::getVersionBinPath($version);
         if (!is_dir($targetPhpBinPath)) {
             throw new Exception("# php version: " . $version . " not exists.");
         }
         echo 'export PHPBREW_PHP=' . $version . "\n";
         echo 'export PHPBREW_PATH=' . ($version ? Config::getVersionBinPath($version) : '') . "\n";
     }
 }
Beispiel #9
0
 public function arguments($args)
 {
     $args->add('extensions')->suggestions(function () {
         return array_map(function ($path) {
             return basename(basename($path, '.disabled'), '.ini');
         }, glob(Config::getCurrentPhpDir() . '/var/db/*.{ini,disabled}', GLOB_BRACE));
     });
 }
Beispiel #10
0
 public function __construct()
 {
     $this->root = Config::getPhpbrewRoot();
     $this->baseDir = $this->root . DIRECTORY_SEPARATOR . 'register';
     if (!file_exists($this->baseDir)) {
         mkdir($this->baseDir, 0755, true);
     }
 }
Beispiel #11
0
 public function arguments($args)
 {
     $args->add('extensions')->suggestions(function () {
         $extension = '.ini.disabled';
         return array_map(function ($path) use($extension) {
             return basename($path, $extension);
         }, glob(Config::getCurrentPhpDir() . "/var/db/*{$extension}"));
     });
 }
Beispiel #12
0
 public function testDownloadByCurlCommand()
 {
     $downloader = new UrlDownloaderForTest($this->logger, new OptionResult());
     $downloader->setIsCurlCommandAvailable(true);
     $actualFilePath = tempnam(Config::getTempFileDir(), '');
     $downloader->download('http://httpbin.org/', $actualFilePath);
     $this->assertTrue($downloader->isCurlCommandAvailable());
     $this->assertFileExists($actualFilePath);
 }
Beispiel #13
0
 public function install(Extension $ext, array $configureOptions = array())
 {
     $sourceDir = $ext->getSourceDirectory();
     $pwd = getcwd();
     $buildLogPath = $sourceDir . DIRECTORY_SEPARATOR . 'build.log';
     $make = new MakeTask($this->logger, $this->options);
     $make->setBuildLogPath($buildLogPath);
     $this->logger->info("Log stored at: {$buildLogPath}");
     $this->logger->info("Changing directory to {$sourceDir}");
     chdir($sourceDir);
     if (!$this->options->{'no-clean'} && $ext->isBuildable()) {
         $clean = new MakeTask($this->logger, $this->options);
         $clean->setQuiet();
         $clean->clean($ext);
     }
     if ($ext->getConfigM4File() !== "config.m4" && !file_exists($sourceDir . DIRECTORY_SEPARATOR . 'config.m4')) {
         symlink($ext->getConfigM4File(), $sourceDir . DIRECTORY_SEPARATOR . 'config.m4');
     }
     // If the php version is specified, we should get phpize with the correct version.
     $this->logger->info('===> Phpize...');
     Utils::system("phpize > {$buildLogPath} 2>&1", $this->logger);
     // here we don't want to use closure, because
     // 5.2 does not support closure. We haven't decided whether to
     // support 5.2 yet.
     $escapeOptions = array_map('escapeshellarg', $configureOptions);
     $this->logger->info("===> Configuring...");
     $phpConfig = Config::getCurrentPhpConfigBin();
     if (file_exists($phpConfig)) {
         $this->logger->debug("Appending argument: --with-php-config={$phpConfig}");
         $escapeOptions[] = '--with-php-config=' . $phpConfig;
     }
     // Utils::system('./configure ' . join(' ', $escapeOptions) . ' >> build.log 2>&1');
     $cmd = './configure ' . join(' ', $escapeOptions);
     if (!$this->logger->isDebug()) {
         $cmd .= " >> {$buildLogPath} 2>&1";
     }
     Utils::system($cmd, $this->logger);
     $this->logger->info("===> Building...");
     if ($this->logger->isDebug()) {
         passthru('make');
     } else {
         $make->run($ext);
     }
     $this->logger->info("===> Installing...");
     // This function is disabled when PHP is running in safe mode.
     if ($this->logger->isDebug()) {
         passthru('make install');
     } else {
         $make->install($ext);
     }
     // TODO: use getSharedLibraryPath()
     $this->logger->debug("Installed extension library: " . $ext->getSharedLibraryPath());
     // Try to find the installed path by pattern
     // Installing shared extensions: /Users/c9s/.phpbrew/php/php-5.4.10/lib/php/extensions/debug-non-zts-20100525/
     chdir($pwd);
     $this->logger->info("===> Extension is installed.");
 }
Beispiel #14
0
 public function arguments($args)
 {
     $args->add('extensions')->suggestions(function () {
         $extdir = Config::getBuildDir() . '/' . Config::getCurrentPhpName() . '/ext';
         return array_filter(scandir($extdir), function ($d) use($extdir) {
             return $d != '.' && $d != '..' && is_dir($extdir . DIRECTORY_SEPARATOR . $d);
         });
     });
 }
Beispiel #15
0
 public function execute()
 {
     $file = php_ini_loaded_file();
     if (!file_exists($file)) {
         $php = Config::getCurrentPhpName();
         $this->logger->warn("Sorry, I can't find the {$file} file for php {$php}.");
         return;
     }
     Utils::editor($file);
 }
Beispiel #16
0
 public static function runUse($version)
 {
     putenv("PHPBREW_BIN=" . Config::getPhpbrewHome() . '/bin');
     putenv("PHPBREW_HOME=" . Config::getPhpbrewHome());
     putenv("PHPBREW_LOOKUP_PREFIX=/usr/local/Cellar:/usr/local");
     putenv("PHPBREW_PATH=" . Config::getPhpbrewHome() . "/php/php-{$version}/bin");
     putenv("PHPBREW_PHP=php-{$version}");
     putenv("PHPBREW_ROOT=" . Config::getPhpbrewRoot());
     putenv('PATH=' . getenv('PHPBREW_PATH') . ':' . self::getCleanPath());
 }
Beispiel #17
0
 private function _test($downloader)
 {
     $instance = DownloadFactory::getInstance($this->logger, new OptionResult(), $downloader);
     if ($instance->hasSupport(false)) {
         $actualFilePath = tempnam(Config::getTempFileDir(), '');
         $instance->download('http://httpbin.org/', $actualFilePath);
         $this->assertFileExists($actualFilePath);
     } else {
         $this->markTestSkipped();
     }
 }
Beispiel #18
0
 public function purgeExtension(Extension $ext)
 {
     if ($sourceDir = $ext->getSourceDirectory()) {
         $currentPhpExtensionDirectory = Config::getBuildDir() . '/' . Config::getCurrentPhpName() . '/ext';
         $extName = $ext->getExtensionName();
         $extensionDir = $currentPhpExtensionDirectory . DIRECTORY_SEPARATOR . $extName;
         if (file_exists($extensionDir)) {
             Utils::system("rm -rvf {$extensionDir}");
         }
     }
 }
Beispiel #19
0
 public function execute($buildName)
 {
     // this block is important for tests only
     $root = Config::getPhpbrewRoot();
     $home = Config::getPhpbrewHome();
     putenv("PHPBREW_ROOT={$root}");
     putenv("PHPBREW_HOME={$home}");
     putenv("PHPBREW_PHP={$buildName}");
     putenv("PHPBREW_PATH={$root}/{$buildName}/bin");
     putenv("PHPBREW_BIN={$home}/bin");
     $this->logger->warning("You should not see this, if you see this, it means you didn't load the ~/.phpbrew/bashrc script, please check if bashrc is sourced in your shell.");
 }
Beispiel #20
0
 public function patch($build, $options)
 {
     if ($this->check($build)) {
         $this->logger->info("---> Moving php.dSYM to php ");
         if (!$options->dryrun) {
             $dSYM = $build->getBinDirectory() . DIRECTORY_SEPARATOR . 'php.dSYM';
             $buildPrefix = Config::getBuildPrefix();
             $php = $buildPrefix . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'php';
             rename($dSYM, $php);
         }
     }
 }
Beispiel #21
0
    public function execute()
    {
        // $currentVersion;
        $root = Config::getPhpbrewRoot();
        $home = Config::getPhpbrewHome();
        $buildDir = Config::getBuildDir();
        $buildPrefix = Config::getBuildPrefix();
        // $versionBuildPrefix = Config::getVersionBuildPrefix($version);
        // $versionBinPath     = Config::getVersionBinPath($version);
        if (!file_exists($root)) {
            mkdir($root, 0755, true);
        }
        touch($root . DIRECTORY_SEPARATOR . '.metadata_never_index');
        // prevent spotlight index here
        if ($root != $home) {
            touch($home . DIRECTORY_SEPARATOR . '.metadata_never_index');
        }
        if ($this->options->{'config'} !== null) {
            copy($this->options->{'config'}, $root . DIRECTORY_SEPARATOR . 'config.yaml');
        }
        if (!file_exists($home)) {
            mkdir($home, 0755, true);
        }
        if (!file_exists($buildPrefix)) {
            mkdir($buildPrefix, 0755, true);
        }
        if (!file_exists($buildDir)) {
            mkdir($buildDir, 0755, true);
        }
        // write bashrc script to phpbrew home
        file_put_contents($home . '/bashrc', $this->getBashScript());
        echo <<<EOS
Phpbrew environment is initialized, required directories are created under

    {$home}

Paste the following line(s) to the end of your ~/.bashrc and start a
new shell, phpbrew should be up and fully functional from there:

    source {$home}/bashrc

To enable PHP version info in your shell prompt, please set PHPBREW_SET_PROMPT=1
in your `~/.bashrc` before you source `~/.phpbrew/bashrc`

    export PHPBREW_SET_PROMPT=1

For further instructions, simply run `phpbrew` to see the help message.

Enjoy phpbrew at \$HOME!!

EOS;
    }
Beispiel #22
0
 /**
  * Unpacks the source tarball file.
  *
  * @param string $targetFilePath absolute file path
  */
 public function extract(Build $build, $targetFilePath, $extractDir = NULL)
 {
     $extractDirTemp = Config::getTempFileDir();
     if (!$extractDir) {
         $extractDir = dirname($targetFilePath);
     }
     $extractedDirTemp = $extractDirTemp . DIRECTORY_SEPARATOR . preg_replace('#\\.tar\\.(gz|bz2)$#', '', basename($targetFilePath));
     $extractedDir = $extractDir . DIRECTORY_SEPARATOR . $build->getName();
     if ($build->getState() >= Build::STATE_EXTRACT && file_exists($extractedDir . DIRECTORY_SEPARATOR . 'configure')) {
         $this->info("===> Distribution file was successfully extracted, skipping...");
         return $extractedDir;
     }
     // NOTICE: Always extract to prevent incomplete extraction
     $this->info("===> Extracting {$targetFilePath} to {$extractedDirTemp}");
     system("tar -C {$extractDirTemp} -xf {$targetFilePath}", $ret);
     if ($ret != 0) {
         throw new RuntimeException('Extract failed.');
     }
     clearstatcache(true);
     if (!is_dir($extractedDirTemp)) {
         // retry with github extracted dir path
         $extractedDirTemp = $extractDirTemp . DIRECTORY_SEPARATOR . 'php-src-' . preg_replace('#\\.tar\\.(gz|bz2)$#', '', basename($targetFilePath));
         if (!is_dir($extractedDirTemp)) {
             throw new RuntimeException("Unable to find {$extractedDirTemp}");
         }
     }
     if (is_dir($extractedDir)) {
         $this->info("===> Removing {$extractedDir}");
         system("rm -rf {$extractedDir}", $ret);
         if ($ret !== 0) {
             throw new RuntimeException("Unable to remove {$extractedDir}.");
         }
     }
     $this->info("===> Moving {$extractedDirTemp} to {$extractedDir}");
     if (!rename($extractedDirTemp, $extractedDir)) {
         throw new RuntimeException("Unable to move {$extractedDirTemp} to {$extractedDir}");
     }
     $build->setState(Build::STATE_EXTRACT);
     return $extractedDir;
     /*
      * XXX: unless we have a fast way to verify the extraction.
     if ($this->options->force || ! file_exists($extractedDir . DIRECTORY_SEPARATOR . 'configure')) {
         $this->info("===> Extracting $targetFilePath...");
         system("tar -C $dir -xjf $targetFilePath", $ret);
         if ($ret != 0) {
             die('Extract failed.');
         }
     } else {
         $this->info("Found existing $extractedDir, Skip extracting.");
     }
     */
 }
Beispiel #23
0
 public function execute()
 {
     if ($this->options->{'php'} !== null) {
         $php = Utils::findLatestPhpVersion($this->options->{'php'});
     } else {
         $php = Config::getCurrentPhpName();
     }
     $buildDir = Config::getBuildDir();
     $extDir = $buildDir . DIRECTORY_SEPARATOR . $php . DIRECTORY_SEPARATOR . 'ext';
     // listing all local extensions
     if (version_compare('php-' . phpversion(), $php, '==')) {
         $loaded = array_map('strtolower', get_loaded_extensions());
     } else {
         $this->logger->info('PHP version is different from current active version.');
         $this->logger->info('Only available extensions are listed.');
         $this->logger->info('You will not see which of them are loaded.');
         $loaded = array();
     }
     // list for extensions which are not enabled
     $extensions = array();
     if (is_dir($extDir)) {
         $fp = opendir($extDir);
         if ($fp !== false) {
             while ($file = readdir($fp)) {
                 if ($file === '.' || $file === '..') {
                     continue;
                 }
                 if (is_file($extDir . '/' . $file)) {
                     continue;
                 }
                 $n = strtolower(preg_replace('#-[\\d\\.]+$#', '', $file));
                 if (in_array($n, $loaded)) {
                     continue;
                 }
                 $extensions[] = $n;
             }
             sort($loaded);
             sort($extensions);
             closedir($fp);
         }
     }
     $this->logger->info('Loaded extensions:');
     foreach ($loaded as $ext) {
         $this->logger->info("  [*] {$ext}");
     }
     $this->logger->info('Available extensions:');
     foreach ($extensions as $ext) {
         $this->logger->info("  [ ] {$ext}");
     }
 }
Beispiel #24
0
 public function execute()
 {
     $buildDir = Config::getCurrentBuildDir();
     $extDir = $buildDir . DIRECTORY_SEPARATOR . 'ext';
     // list for extensions which are not enabled
     $extensions = array();
     $extensionNames = array();
     // some extension source not in root directory
     $lookupDirectories = array('', 'ext', 'extension');
     if (file_exists($extDir) && is_dir($extDir)) {
         $this->logger->debug("Scanning {$extDir}...");
         foreach (scandir($extDir) as $extName) {
             if ($extName == "." || $extName == "..") {
                 continue;
             }
             $dir = $extDir . DIRECTORY_SEPARATOR . $extName;
             foreach ($lookupDirectories as $lookupDirectory) {
                 $extensionDir = $dir . (empty($lookupDirectory) ? '' : DIRECTORY_SEPARATOR . $lookupDirectory);
                 if ($m4files = ExtensionFactory::configM4Exists($extensionDir)) {
                     $this->logger->debug("Loading extension information {$extName} from {$extensionDir}");
                     foreach ($m4files as $m4file) {
                         try {
                             $ext = ExtensionFactory::createM4Extension($extName, $m4file);
                             // $ext = ExtensionFactory::createFromDirectory($extName, $dir);
                             $extensions[$ext->getExtensionName()] = $ext;
                             $extensionNames[] = $extName;
                             break;
                         } catch (Exception $e) {
                         }
                     }
                     break;
                 }
             }
         }
     }
     $this->logger->info('Loaded extensions:');
     foreach ($extensions as $extName => $ext) {
         if (extension_loaded($extName)) {
             $this->describeExtension($ext);
         }
     }
     $this->logger->info('Available local extensions:');
     foreach ($extensions as $extName => $ext) {
         if (extension_loaded($extName)) {
             continue;
         }
         $this->describeExtension($ext);
     }
 }
Beispiel #25
0
 public function execute($buildName)
 {
     $prefix = Config::getVersionInstallPrefix($buildName);
     if (!file_exists($prefix)) {
         throw new Exception("{$prefix} does not exist.");
     }
     $prompter = new \CLIFramework\Prompter();
     $answer = $prompter->ask("Are you sure to delete {$buildName}?", array('Y', 'n'), 'Y');
     if (strtolower($answer) == "y") {
         Utils::recursive_unlink($prefix, $this->logger);
         $this->logger->info("{$buildName} is removed.  I hope you're not surprised. :)");
     } else {
         $this->logger->info("Let me guess, you drunk tonight.");
     }
 }
Beispiel #26
0
 public function prepareForVersion($version)
 {
     $home = Config::getPhpbrewRoot();
     $buildDir = Config::getBuildDir();
     $variantsDir = Config::getVariantsDir();
     $buildPrefix = Config::getVersionBuildPrefix($version);
     if (!file_exists($variantsDir)) {
         mkdir($variantsDir, 0755, true);
     }
     if (!file_exists($buildDir)) {
         mkdir($buildDir, 0755, true);
     }
     if (!file_exists($buildPrefix)) {
         mkdir($buildPrefix, 0755, true);
     }
 }
Beispiel #27
0
 public function execute($appName)
 {
     $apps = AppStore::all();
     if (!isset($apps[$appName])) {
         throw new Exception("App {$appName} not found.");
     }
     $app = $apps[$appName];
     $targetDir = Config::getRoot() . DIRECTORY_SEPARATOR . 'bin';
     $target = $targetDir . DIRECTORY_SEPARATOR . $app['as'];
     DownloadFactory::getInstance($this->logger, $this->options)->download($app['url'], $target);
     $this->logger->info('Changing permissions to 0755');
     if ($mod = $this->options->chmod) {
         chmod($target, octdec($mod));
     } else {
         chmod($target, 0755);
     }
     $this->logger->info("Downloaded at {$target}");
 }
 public function run(Build $build = NULL)
 {
     $dirs = array();
     $dirs[] = Config::getPhpbrewRoot();
     $dirs[] = Config::getPhpbrewHome();
     $dirs[] = Config::getBuildDir();
     $dirs[] = Config::getDistFileDir();
     $dirs[] = Config::getVariantsDir();
     if ($build) {
         $dirs[] = Config::getInstallPrefix() . DIRECTORY_SEPARATOR . $build->getName();
     }
     foreach ($dirs as $dir) {
         if (!file_exists($dir)) {
             $this->logger->debug("Creating directory {$dir}");
             mkdir($dir, 0755, true);
         }
     }
 }
Beispiel #29
0
 public function execute($version)
 {
     if ($this->options->all) {
         $buildDir = Config::getBuildDir() . DIRECTORY_SEPARATOR . $version;
         if (!file_exists($buildDir)) {
             $this->logger->info("Source directory " . $buildDir . " does not exist.");
         } else {
             $this->logger->info("Source directory " . $buildDir . " found, deleting...");
             Utils::recursive_unlink($buildDir, $this->logger);
         }
     } else {
         $make = new MakeTask($this->logger);
         $make->setQuiet();
         $build = new Build($version);
         if ($make->clean($build)) {
             $this->logger->info("Distribution is cleaned up. Woof! ");
         }
     }
 }
 public function renameSourceDirectory(Extension $ext)
 {
     $currentPhpExtensionDirectory = Config::getBuildDir() . '/' . Config::getCurrentPhpName() . '/ext';
     $extName = $ext->getExtensionName();
     $name = $ext->getName();
     $extensionDir = $currentPhpExtensionDirectory . DIRECTORY_SEPARATOR . $extName;
     $extensionExtractDir = $currentPhpExtensionDirectory . DIRECTORY_SEPARATOR . $name;
     if ($name != $extName) {
         $this->logger->info("===> Rename source directory to {$extensionDir}...");
         $cmds = array("rm -rf {$extensionDir}", "mv {$extensionExtractDir} {$extensionDir}");
         foreach ($cmds as $cmd) {
             $this->logger->debug($cmd);
             Utils::system($cmd);
         }
         // replace source directory to new source directory
         $sourceDir = str_replace($extensionExtractDir, $extensionDir, $ext->getSourceDirectory());
         $ext->setSourceDirectory($sourceDir);
         $ext->setName($extName);
     }
 }