Source for file Install.php
Documentation is available at Install.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// $Id: Install.php,v 1.53.2.1 2004/10/19 04:08:42 cellog Exp $
require_once "PEAR/Command/Common.php";
require_once "PEAR/Installer.php";
* PEAR commands for installation or deinstallation/upgrading of
class PEAR_Command_Install extends PEAR_Command_Common
'summary' => 'Install Package',
'function' => 'doInstall',
'doc' => 'will overwrite newer installed packages',
'doc' => 'ignore dependencies, install anyway',
'register-only' => array (
'doc' => 'do not install files, only register the package as installed',
'doc' => 'soft install, fail silently, or upgrade if already installed',
'doc' => 'don\'t build C extensions',
'doc' => 'request uncompressed files when downloading',
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
'ignore-errors' => array (
'doc' => 'force install even if there were errors',
'doc' => 'install all required and optional dependencies',
'doc' => 'install all required dependencies',
Installs one or more PEAR packages. You can specify a package to
"Package-1.0.tgz" : installs from a local file
"http://example.com/Package-1.0.tgz" : installs from
"package.xml" : installs the package described in
package.xml. Useful for testing, or for wrapping a PEAR package in
another package manager such as RPM.
"Package" : queries your configured server
({config master_server}) and downloads the newest package with
the preferred quality/state ({config preferred_state}).
More than one package may be specified at once. It is ok to mix these
four ways of specifying packages.
'summary' => 'Upgrade Package',
'function' => 'doInstall',
'doc' => 'overwrite newer installed packages',
'doc' => 'ignore dependencies, upgrade anyway',
'register-only' => array (
'doc' => 'do not install files, only register the package as upgraded',
'doc' => 'don\'t build C extensions',
'doc' => 'request uncompressed files when downloading',
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
'ignore-errors' => array (
'doc' => 'force install even if there were errors',
'doc' => 'install all required and optional dependencies',
'doc' => 'install all required dependencies',
Upgrades one or more PEAR packages. See documentation for the
"install" command for ways to specify a package.
When upgrading, your package will be updated if the provided new
package has a higher version number (use the -f option if you need to
More than one package may be specified at once.
'summary' => 'Upgrade All Packages',
'function' => 'doInstall',
'doc' => 'ignore dependencies, upgrade anyway',
'register-only' => array (
'doc' => 'do not install files, only register the package as upgraded',
'doc' => 'don\'t build C extensions',
'doc' => 'request uncompressed files when downloading',
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
'ignore-errors' => array (
'doc' => 'force install even if there were errors',
Upgrades all packages that have a newer release available. Upgrades are
done only if there is a release available of the state specified in
"preferred_state" (currently {config preferred_state}), or a state considered
'summary' => 'Un-install Package',
'function' => 'doUninstall',
'doc' => 'ignore dependencies, uninstall anyway',
'register-only' => array (
'doc' => 'do not remove files, only register the packages as not installed',
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
'ignore-errors' => array (
'doc' => 'force install even if there were errors',
Uninstalls one or more PEAR packages. More than one package may be
'summary' => 'Unpacks a Pecl Package',
'function' => 'doBundle',
'doc' => 'Optional destination directory for unpacking (defaults to current path or "ext" if exists)',
'doc' => 'Force the unpacking even if there were errors in the package',
Unpacks a Pecl Package into the selected location. It will download the
* PEAR_Command_Install constructor.
function PEAR_Command_Install (&$ui, &$config)
parent ::PEAR_Command_Common ($ui, $config);
function doInstall ($command, $options, $params)
require_once 'PEAR/Downloader.php';
if (empty ($this->installer)) {
$this->installer = &new PEAR_Installer ($this->ui);
if ($command == 'upgrade') {
$options['upgrade'] = true;
if ($command == 'upgrade-all') {
include_once "PEAR/Remote.php";
$options['upgrade'] = true;
$remote = &new PEAR_Remote ($this->config);
$state = $this->config->get ('preferred_state');
if (empty ($state) || $state == 'any') {
$latest = $remote->call ("package.listLatestReleases");
$latest = $remote->call ("package.listLatestReleases", $state);
if (PEAR ::isError ($latest)) {
$reg = new PEAR_Registry ($this->config->get ('php_dir'));
foreach ($latest as $package => $info) {
if (!isset ($installed[$package])) {
// skip packages we don't have installed
$inst_version = $reg->packageInfo ($package, 'version');
// installed version is up-to-date
$this->ui->outputData (array ('data' => " Will upgrade $package" ), $command);
$this->downloader = &new PEAR_Downloader ($this->ui, $options, $this->config);
$this->downloader->download ($params);
$errors = $this->downloader->getErrorMsgs ();
$err['data'] = array ($errors);
$err['headline'] = 'Install Errors';
$this->ui->outputData ($err);
return $this->raiseError (" $command failed" );
$downloaded = $this->downloader->getDownloadedPackages ();
$this->installer->sortPkgDeps ($downloaded);
foreach ($downloaded as $pkg) {
$info = $this->installer->install ($pkg['file'], $options, $this->config);
PEAR ::popErrorHandling ();
if (PEAR ::isError ($info)) {
$this->ui->outputData ('ERROR: ' . $info->getMessage ());
if ($this->config->get ('verbose') > 0 ) {
$label = " $info[package] $info[version]";
$out = array ('data' => " $command ok: $label" );
if (isset ($info['release_warnings'])) {
$out['release_warnings'] = $info['release_warnings'];
$this->ui->outputData ($out, $command);
return $this->raiseError (" $command failed" );
function doUninstall ($command, $options, $params)
if (empty ($this->installer)) {
$this->installer = &new PEAR_Installer ($this->ui);
return $this->raiseError ("Please supply the package(s) you want to uninstall");
include_once 'PEAR/Registry.php';
$reg = new PEAR_Registry ($this->config->get ('php_dir'));
foreach ($params as $pkg) {
$info = $reg->packageInfo ($pkg);
$this->installer->sortPkgDeps ($newparams, true );
foreach($newparams as $info) {
$params[] = $info['info']['package'];
foreach ($params as $pkg) {
if ($this->installer->uninstall ($pkg, $options)) {
if ($this->config->get ('verbose') > 0 ) {
$this->ui->outputData (" uninstall ok: $pkg" , $command);
return $this->raiseError (" uninstall failed: $pkg" );
(cox) It just downloads and untars the package, does not do
any check that the PEAR_Installer::_installFile() does.
function doBundle ($command, $options, $params)
if (empty ($this->installer)) {
$this->installer = &new PEAR_Downloader ($this->ui);
$installer = &$this->installer;
return $this->raiseError ("Please supply the package you want to bundle");
if ($installer->validPackageName ($pkgfile)) {
$pkgfile = $installer->getPackageDownloadUrl ($pkgfile);
return $this->raiseError (" Could not open the package file: $pkgfile" );
return $this->raiseError ("No package file given");
// Download package -----------------------------------------------
$downloaddir = $installer->config ->get ('download_dir');
if (empty ($downloaddir)) {
$installer->log (2 , '+ tmp dir created at ' . $downloaddir);
$callback = $this->ui ? array (&$installer, '_downloadCallback') : null;
$file = $installer->downloadHttp ($pkgfile, $this->ui, $downloaddir, $callback);
if (PEAR ::isError ($file)) {
return $this->raiseError ($file);
// Parse xml file -----------------------------------------------
$pkginfo = $installer->infoFromTgzFile ($pkgfile);
if (PEAR ::isError ($pkginfo)) {
return $this->raiseError ($pkginfo);
$installer->validatePackageInfo ($pkginfo, $errors, $warnings);
// XXX We allow warnings, do we have to do it?
if (empty ($options['force'])) {
return $this->raiseError ("The following errors where found:\n".
$this->log (0 , "warning : the following errors were found:\n".
$pkgname = $pkginfo['package'];
// Unpacking -------------------------------------------------
if (isset ($options['destination'])) {
if (!is_dir($options['destination'])) {
System::mkdir ('-p ' . $options['destination']);
$dest = realpath($options['destination']);
if (is_dir($pwd . DIRECTORY_SEPARATOR . 'ext')) {
$dest = $pwd . DIRECTORY_SEPARATOR . 'ext';
$dest .= DIRECTORY_SEPARATOR . $pkgname;
$orig = $pkgname . '-' . $pkginfo['version'];
$tar = new Archive_Tar ($pkgfile);
if (!@$tar->extractModify ($dest, $orig)) {
return $this->raiseError (" unable to unpack $pkgfile" );
$this->ui->outputData (" Package ready at '$dest'" );
Documentation generated on Mon, 11 Mar 2019 14:23:57 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|