/** temporary directory */
var $tmpdir;
+ /** PEAR_Registry object used by the installer */
+ var $registry;
+
// }}}
// {{{ constructor
{
// XXX FIXME Add here code to manage packages database
//$this->loadPackageList("$this->statedir/packages.lst");
- $registry = new PEAR_Registry;
+ if (empty($this->registry)) {
+ $this->registry = new PEAR_Registry;
+ }
$oldcwd = getcwd();
$need_download = false;
if (preg_match('#^(http|ftp)://#', $pkgfile)) {
$need_download = true;
} elseif (!@is_file($pkgfile)) {
- return $this->raiseError("Could not open the package file: $pkgfile");
+ return $this->raiseError("could not open the package file: $pkgfile");
}
// Download package -----------------------------------------------
// To allow relative package file calls
if (!chdir(dirname($pkgfile))) {
- return $this->raiseError('Unable to chdir to pakage directory');
+ return $this->raiseError('unable to chdir to package directory');
}
$pkgfile = getcwd() . DIRECTORY_SEPARATOR . basename($pkgfile);
$tar = new Archive_Tar($pkgfile, true);
if (!$tar->extract($tmpdir)) {
chdir($oldcwd);
- return $this->raiseError("Unable to unpack $pkgfile");
+ return $this->raiseError("unable to unpack $pkgfile");
}
$file = basename($pkgfile);
// Assume the decompressed dir name
if (($pos = strrpos($file, '.')) === false) {
chdir($oldcwd);
- return $this->raiseError("package doesn't follow the package name convention");
+ return $this->raiseError("invalid package name");
}
$pkgdir = substr($file, 0, $pos);
$descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
if (!is_file($descfile)) {
chdir($oldcwd);
- return $this->raiseError("No package.xml file after extracting the archive.");
+ return $this->raiseError("no package.xml file after extracting the archive");
}
// Parse xml file -----------------------------------------------
return $pkginfo;
}
- if ($registry->packageExists($pkginfo['package'])) {
+ if ($this->registry->packageExists($pkginfo['package'])) {
return $this->raiseError("package already installed");
}
// Copy files to dest dir ---------------------------------------
if (!is_dir($this->phpdir)) {
chdir($oldcwd);
- return $this->raiseError("No script destination directory found\n",
+ return $this->raiseError("no script destination directory found",
null, PEAR_ERROR_DIE);
}
$tmp_path = dirname($descfile);
$fname = $tmp_path . DIRECTORY_SEPARATOR . $fname;
$this->_installFile($fname, $dest_dir, $atts);
}
- $registry->addPackage($pkginfo['package'], $pkginfo);
+ $this->registry->addPackage($pkginfo['package'], $pkginfo);
chdir($oldcwd);
return true;
}