function doBundle($command, $options, $params)
{
$opts = array('force' => true, 'nodeps' => true, 'soft' => true, 'downloadonly' => true);
$downloader =& $this->getDownloader($this->ui, $opts, $this->config);
$reg =& $this->config->getRegistry();
if (count($params) < 1) {
return $this->raiseError("Please supply the package you want to bundle");
}
if (isset($options['destination'])) {
if (!is_dir($options['destination'])) {
System::mkdir('-p ' . $options['destination']);
}
$dest = realpath($options['destination']);
} else {
$pwd = getcwd();
$dir = $pwd . DIRECTORY_SEPARATOR . 'ext';
$dest = is_dir($dir) ? $dir : $pwd;
}
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$err = $downloader->setDownloadDir($dest);
PEAR::staticPopErrorHandling();
if (PEAR::isError($err)) {
return PEAR::raiseError('download directory "' . $dest . '" is not writeable.');
}
$result =& $downloader->download(array($params[0]));
if (PEAR::isError($result)) {
return $result;
}
if (!isset($result[0])) {
return $this->raiseError('unable to unpack ' . $params[0]);
}
$pkgfile =& $result[0]->getPackageFile();
$pkgname = $pkgfile->getName();
$pkgversion = $pkgfile->getVersion();
// Unpacking -------------------------------------------------
$dest .= DIRECTORY_SEPARATOR . $pkgname;
$orig = $pkgname . '-' . $pkgversion;
$tar = new Archive_Tar($pkgfile->getArchiveFile());
if (!$tar->extractModify($dest, $orig)) {
return $this->raiseError('unable to unpack ' . $pkgfile->getArchiveFile());
}
$this->ui->outputData("Package ready at '{$dest}'");
// }}}
}