Beispiel #1
0
 public function download($url, $dir, $md5 = NULL)
 {
     if (!is_writable($dir)) {
         throw new Exception("Directory is not writable: {$dir}");
     }
     $downloader = new UrlDownloader($this->logger, $this->options);
     $basename = $downloader->resolveDownloadFileName($url);
     if (!$basename) {
         throw new Exception("Can not parse url: {$url}");
     }
     $targetFilePath = $dir . DIRECTORY_SEPARATOR . $basename;
     if (!$this->options->force && file_exists($targetFilePath)) {
         $this->logger->info('Checking distribution checksum...');
         $md5a = md5_file($targetFilePath);
         if ($md5 && $md5a != $md5) {
             $this->logger->warn("Checksum mismatch: {$md5a} != {$md5}");
             $this->logger->info("Re-Downloading...");
             $downloader->download($url, $targetFilePath);
         } else {
             $this->logger->info('Checksum matched: ' . $md5);
         }
     } else {
         $downloader->download($url, $targetFilePath);
     }
     return $targetFilePath;
 }
Beispiel #2
0
 public function installFromPecl($packageName, $version = 'stable', $configureOptions = array())
 {
     $url = $this->findPeclPackageUrl($packageName, $version);
     $downloader = new Downloader\UrlDownloader($this->logger);
     $basename = $downloader->download($url);
     $info = pathinfo($basename);
     $extension_dir = getcwd() . "/{$packageName}";
     // extract
     $this->logger->info("===> Extracting {$basename}...");
     Utils::system("tar xf {$basename}");
     Utils::system("rm -rf {$packageName}");
     Utils::system("mv {$info['filename']} {$packageName}");
     Utils::system("mv package.xml {$packageName}");
     return $this->runInstall($packageName, $extension_dir, $configureOptions);
 }
Beispiel #3
0
 public function execute($appName)
 {
     $apps = AppStore::all();
     if (!isset($apps[$appName])) {
         throw new Exception("App {$appName} not found.");
     }
     $app = $apps[$appName];
     $targetDir = Config::getPhpbrewRoot() . DIRECTORY_SEPARATOR . 'bin';
     $target = $targetDir . DIRECTORY_SEPARATOR . $app['as'];
     $downloader = new UrlDownloader($this->logger, $this->options);
     $downloader->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 download(Provider $provider, $version = 'stable')
 {
     $url = $provider->buildPackageDownloadUrl($version);
     $downloader = new Downloader\UrlDownloader($this->logger, $this->options);
     $basename = $provider->resolveDownloadFileName($version);
     $distDir = Config::getDistFileDir();
     $targetFilePath = $distDir . DIRECTORY_SEPARATOR . $basename;
     $downloader->download($url, $targetFilePath);
     $info = pathinfo($basename);
     $currentPhpExtensionDirectory = Config::getBuildDir() . '/' . Config::getCurrentPhpName() . '/ext';
     // tar -C ~/.phpbrew/build/php-5.5.8/ext -xvf ~/.phpbrew/distfiles/memcache-2.2.7.tgz
     $extensionDir = $currentPhpExtensionDirectory . DIRECTORY_SEPARATOR . $provider->getPackageName();
     if (!file_exists($extensionDir)) {
         mkdir($extensionDir, 0755, true);
     }
     $this->logger->info("===> Extracting to {$currentPhpExtensionDirectory}...");
     $cmds = array_merge($provider->extractPackageCommands($currentPhpExtensionDirectory, $targetFilePath), $provider->postExtractPackageCommands($currentPhpExtensionDirectory, $targetFilePath));
     foreach ($cmds as $cmd) {
         $this->logger->debug($cmd);
         Utils::system($cmd);
     }
     return $extensionDir;
 }