|
|
|
@ -61,6 +61,9 @@ class PEAR_Installer extends PEAR_Common |
|
|
|
/** temporary directory */ |
|
|
|
var $tmpdir; |
|
|
|
|
|
|
|
/** PEAR_Registry object used by the installer */ |
|
|
|
var $registry; |
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ constructor
|
|
|
|
@ -91,13 +94,15 @@ class PEAR_Installer extends PEAR_Common |
|
|
|
{ |
|
|
|
// 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 -----------------------------------------------
|
|
|
|
@ -132,7 +137,7 @@ class PEAR_Installer extends PEAR_Common |
|
|
|
|
|
|
|
// 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); |
|
|
|
|
|
|
|
@ -145,20 +150,20 @@ class PEAR_Installer extends PEAR_Common |
|
|
|
$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 -----------------------------------------------
|
|
|
|
@ -168,14 +173,14 @@ class PEAR_Installer extends PEAR_Common |
|
|
|
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); |
|
|
|
@ -190,7 +195,7 @@ class PEAR_Installer extends PEAR_Common |
|
|
|
$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; |
|
|
|
} |
|
|
|
|