This commit is contained in:
Martin Jansen 2003-10-05 16:42:18 +00:00
parent a05dbd3a28
commit dd66cd587f
7 changed files with 183 additions and 26 deletions

View file

@ -42,6 +42,8 @@ require_once "PEAR.php";
*/ */
class PEAR_Autoloader extends PEAR class PEAR_Autoloader extends PEAR
{ {
// {{{ properties
/** /**
* Map of methods and classes where they are defined * Map of methods and classes where they are defined
* *
@ -60,6 +62,9 @@ class PEAR_Autoloader extends PEAR
*/ */
var $_method_map = array(); var $_method_map = array();
// }}}
// {{{ addAutoload()
/** /**
* Add one or more autoload entries. * Add one or more autoload entries.
* *
@ -85,6 +90,9 @@ class PEAR_Autoloader extends PEAR
} }
} }
// }}}
// {{{ removeAutoload()
/** /**
* Remove an autoload entry. * Remove an autoload entry.
* *
@ -101,6 +109,9 @@ class PEAR_Autoloader extends PEAR
return $ok; return $ok;
} }
// }}}
// {{{ addAggregateObject()
/** /**
* Add an aggregate object to this object. If the specified class * Add an aggregate object to this object. If the specified class
* is not defined, loading it will be attempted following PEAR's * is not defined, loading it will be attempted following PEAR's
@ -131,6 +142,9 @@ class PEAR_Autoloader extends PEAR
} }
} }
// }}}
// {{{ removeAggregateObject()
/** /**
* Remove an aggregate object. * Remove an aggregate object.
* *
@ -154,6 +168,9 @@ class PEAR_Autoloader extends PEAR
return $ok; return $ok;
} }
// }}}
// {{{ __call()
/** /**
* Overloaded object call handler, called each time an * Overloaded object call handler, called each time an
* undefined/aggregated method is invoked. This method repeats * undefined/aggregated method is invoked. This method repeats
@ -179,6 +196,8 @@ class PEAR_Autoloader extends PEAR
} }
return false; return false;
} }
// }}}
} }
overload("PEAR_Autoloader"); overload("PEAR_Autoloader");

View file

@ -206,7 +206,7 @@ class PEAR_Builder extends PEAR_Common
return $this->raiseError("`phpize' failed"); return $this->raiseError("`phpize' failed");
} }
// start of interactive part // {{{ start of interactive part
$configure_command = "$dir/configure"; $configure_command = "$dir/configure";
if (isset($info['configure_options'])) { if (isset($info['configure_options'])) {
foreach ($info['configure_options'] as $o) { foreach ($info['configure_options'] as $o) {
@ -222,9 +222,9 @@ class PEAR_Builder extends PEAR_Common
} }
} }
} }
// end of interactive part // }}} end of interactive part
// make configurable // FIXME make configurable
if(!$user=getenv('USER')){ if(!$user=getenv('USER')){
$user='defaultuser'; $user='defaultuser';
} }

View file

@ -96,6 +96,8 @@ $GLOBALS['_PEAR_Command_uiobject'] = null;
*/ */
class PEAR_Command class PEAR_Command
{ {
// {{{ factory()
/** /**
* Get the right object for executing a command. * Get the right object for executing a command.
* *
@ -123,6 +125,9 @@ class PEAR_Command
return $obj; return $obj;
} }
// }}}
// {{{ & getFrontendObject()
/** /**
* Get instance of frontend object. * Get instance of frontend object.
* *
@ -136,6 +141,9 @@ class PEAR_Command
return $GLOBALS['_PEAR_Command_uiobject']; return $GLOBALS['_PEAR_Command_uiobject'];
} }
// }}}
// {{{ & setFrontendClass()
/** /**
* Load current frontend class. * Load current frontend class.
* *
@ -166,6 +174,9 @@ class PEAR_Command
return PEAR::raiseError("no such class: $uiclass"); return PEAR::raiseError("no such class: $uiclass");
} }
// }}}
// {{{ setFrontendType()
/** /**
* Set current frontend. * Set current frontend.
* *
@ -179,6 +190,9 @@ class PEAR_Command
return PEAR_Command::setFrontendClass($uiclass); return PEAR_Command::setFrontendClass($uiclass);
} }
// }}}
// {{{ registerCommands()
/** /**
* Scan through the Command directory looking for classes * Scan through the Command directory looking for classes
* and see what commands they implement. * and see what commands they implement.
@ -232,6 +246,9 @@ class PEAR_Command
return true; return true;
} }
// }}}
// {{{ getCommands()
/** /**
* Get the list of currently supported commands, and what * Get the list of currently supported commands, and what
* classes implement them. * classes implement them.
@ -248,6 +265,9 @@ class PEAR_Command
return $GLOBALS['_PEAR_Command_commandlist']; return $GLOBALS['_PEAR_Command_commandlist'];
} }
// }}}
// {{{ getShortcuts()
/** /**
* Get the list of command shortcuts. * Get the list of command shortcuts.
* *
@ -263,6 +283,9 @@ class PEAR_Command
return $GLOBALS['_PEAR_Command_shortcuts']; return $GLOBALS['_PEAR_Command_shortcuts'];
} }
// }}}
// {{{ getGetoptArgs()
/** /**
* Compiles arguments for getopt. * Compiles arguments for getopt.
* *
@ -287,6 +310,9 @@ class PEAR_Command
return $obj->getGetoptArgs($command, $short_args, $long_args); return $obj->getGetoptArgs($command, $short_args, $long_args);
} }
// }}}
// {{{ getDescription()
/** /**
* Get description for a command. * Get description for a command.
* *
@ -301,6 +327,9 @@ class PEAR_Command
return @$GLOBALS['_PEAR_Command_commanddesc'][$command]; return @$GLOBALS['_PEAR_Command_commanddesc'][$command];
} }
// }}}
// {{{ getHelp()
/** /**
* Get help for command. * Get help for command.
* *
@ -317,6 +346,7 @@ class PEAR_Command
} }
return false; return false;
} }
// }}}
} }
?> ?>

View file

@ -39,6 +39,7 @@ define('PEAR_DEPENDENCY_MISSING_OPTIONAL', -6);
*/ */
class PEAR_Dependency class PEAR_Dependency
{ {
// {{{ constructor
/** /**
* Constructor * Constructor
* *
@ -51,6 +52,9 @@ class PEAR_Dependency
$this->registry = &$registry; $this->registry = &$registry;
} }
// }}}
// {{{ callCheckMethod()
/** /**
* This method maps the XML dependency definition to the * This method maps the XML dependency definition to the
* corresponding one from PEAR_Dependency * corresponding one from PEAR_Dependency
@ -105,6 +109,9 @@ class PEAR_Dependency
} }
} }
// }}}
// {{{ checkPackage()
/** /**
* Package dependencies check method * Package dependencies check method
* *
@ -163,6 +170,9 @@ class PEAR_Dependency
return PEAR_DEPENDENCY_BAD_DEPENDENCY; return PEAR_DEPENDENCY_BAD_DEPENDENCY;
} }
// }}}
// {{{ checkPackageUninstall()
/** /**
* Check package dependencies on uninstall * Check package dependencies on uninstall
* *
@ -197,6 +207,9 @@ class PEAR_Dependency
return ($error) ? true : false; return ($error) ? true : false;
} }
// }}}
// {{{ checkExtension()
/** /**
* Extension dependencies check method * Extension dependencies check method
* *
@ -241,6 +254,9 @@ class PEAR_Dependency
return $code; return $code;
} }
// }}}
// {{{ checkOS()
/** /**
* Operating system dependencies check method * Operating system dependencies check method
* *
@ -265,6 +281,9 @@ class PEAR_Dependency
return PEAR_DEPENDENCY_CONFLICT; return PEAR_DEPENDENCY_CONFLICT;
} }
// }}}
// {{{ checkPHP()
/** /**
* PHP version check method * PHP version check method
* *
@ -288,6 +307,9 @@ class PEAR_Dependency
return false; return false;
} }
// }}}
// {{{ checkProgram()
/** /**
* External program check method. Looks for executable files in * External program check method. Looks for executable files in
* directories listed in the PATH environment variable. * directories listed in the PATH environment variable.
@ -312,6 +334,9 @@ class PEAR_Dependency
return PEAR_DEPENDENCY_MISSING; return PEAR_DEPENDENCY_MISSING;
} }
// }}}
// {{{ checkSAPI()
/** /**
* SAPI backend check method. Version comparison is not yet * SAPI backend check method. Version comparison is not yet
* available here. * available here.
@ -337,6 +362,8 @@ class PEAR_Dependency
return PEAR_DEPENDENCY_CONFLICT; return PEAR_DEPENDENCY_CONFLICT;
} }
// }}}
// {{{ checkZend()
/** /**
* Zend version check method * Zend version check method
@ -361,6 +388,9 @@ class PEAR_Dependency
return false; return false;
} }
// }}}
// {{{ signOperator()
/** /**
* Converts text comparing operators to them sign equivalents * Converts text comparing operators to them sign equivalents
* *
@ -384,6 +414,9 @@ class PEAR_Dependency
} }
} }
// }}}
// {{{ codeFromRelation()
/** /**
* Convert relation into corresponding code * Convert relation into corresponding code
* *
@ -413,5 +446,7 @@ class PEAR_Dependency
} }
return $code; return $code;
} }
// }}}
} }
?> ?>

View file

@ -39,6 +39,8 @@ require_once 'PEAR/Dependency.php';
class PEAR_DependencyDB extends PEAR class PEAR_DependencyDB extends PEAR
{ {
// {{{ properties
var $pear_reg = false; var $pear_reg = false;
var $pear_dep = false; var $pear_dep = false;
var $depdb_file = false; var $depdb_file = false;
@ -46,6 +48,9 @@ class PEAR_DependencyDB extends PEAR
var $lock_fp = false; var $lock_fp = false;
var $depdb_version = '1.0'; var $depdb_version = '1.0';
// }}}
// {{{ & singleton()
function &singleton($depdb_file, $reg_file) function &singleton($depdb_file, $reg_file)
{ {
$obj = new PEAR_DependencyDB; $obj = new PEAR_DependencyDB;
@ -58,6 +63,9 @@ class PEAR_DependencyDB extends PEAR
return $obj; return $obj;
} }
// }}}
// {{{ assertDepsDB()
function assertDepsDB() function assertDepsDB()
{ {
if (!is_file($this->depdb_file)) { if (!is_file($this->depdb_file)) {
@ -71,6 +79,9 @@ class PEAR_DependencyDB extends PEAR
} }
} }
// }}}
// {{{ _lock()
function _lock($mode = LOCK_EX) function _lock($mode = LOCK_EX)
{ {
if (!eregi('Windows 9', php_uname())) { if (!eregi('Windows 9', php_uname())) {
@ -116,6 +127,7 @@ class PEAR_DependencyDB extends PEAR
return $ret; return $ret;
} }
// }}}
// {{{ rebuildDepsFile() // {{{ rebuildDepsFile()
function rebuildDB() function rebuildDB()
@ -134,6 +146,9 @@ class PEAR_DependencyDB extends PEAR
return true; return true;
} }
// }}}
// {{{ & _getDepDB()
function &_getDepDB() function &_getDepDB()
{ {
if (!$fp = fopen($this->depdb_file, 'r')) { if (!$fp = fopen($this->depdb_file, 'r')) {
@ -144,6 +159,9 @@ class PEAR_DependencyDB extends PEAR
return unserialize($data); return unserialize($data);
} }
// }}}
// {{{ _writeDepDB()
function _writeDepDB(&$deps) function _writeDepDB(&$deps)
{ {
if (PEAR::isError($e = $this->_lock(LOCK_EX))) { if (PEAR::isError($e = $this->_lock(LOCK_EX))) {
@ -158,7 +176,10 @@ class PEAR_DependencyDB extends PEAR
$this->_unlock(); $this->_unlock();
return true; return true;
} }
// }}}
/* /*
// {{{ removePackageDep()
function removePackageDep($package) function removePackageDep($package)
{ {
$data = &$this->_depGetDepDB(); $data = &$this->_depGetDepDB();
@ -184,8 +205,11 @@ class PEAR_DependencyDB extends PEAR
} }
return $this->_depWriteDepDB(); return $this->_depWriteDepDB();
} }
// }}}
*/ */
// {{{ checkAction()
function checkAction($action, $package, $new_version = null) function checkAction($action, $package, $new_version = null)
{ {
$depdb = &$this->_getDepDB(); $depdb = &$this->_getDepDB();
@ -229,11 +253,17 @@ class PEAR_DependencyDB extends PEAR
} }
} }
// }}}
// {{{ commitAction()
function commitAction($action, $package) function commitAction($action, $package)
{ {
} }
// }}}
// {{{ setPackageDep()
/** /**
* Update or insert a the dependencies of a package, prechecking * Update or insert a the dependencies of a package, prechecking
* that the package won't break any dependency in the process * that the package won't break any dependency in the process

View file

@ -165,19 +165,21 @@ class PEAR_Installer extends PEAR_Common
*/ */
function _installFile($file, $atts, $tmp_path, $options) function _installFile($file, $atts, $tmp_path, $options)
{ {
// {{{ return if this file is meant for another platform
static $os; static $os;
if (isset($atts['platform'])) { if (isset($atts['platform'])) {
if (empty($os)) { if (empty($os)) {
include_once "OS/Guess.php"; include_once "OS/Guess.php";
$os = new OS_Guess(); $os = new OS_Guess();
} }
// return if this file is meant for another platform
if (!$os->matchSignature($atts['platform'])) { if (!$os->matchSignature($atts['platform'])) {
$this->log(3, "skipped $file (meant for $atts[platform], we are ".$os->getSignature().")"); $this->log(3, "skipped $file (meant for $atts[platform], we are ".$os->getSignature().")");
return PEAR_INSTALLER_SKIPPED; return PEAR_INSTALLER_SKIPPED;
} }
} }
// }}}
// {{{ assemble the destination paths
switch ($atts['role']) { switch ($atts['role']) {
case 'doc': case 'doc':
case 'data': case 'data':
@ -223,6 +225,8 @@ class PEAR_Installer extends PEAR_Common
$final_dest_file = $this->_prependPath($dest_file, $this->installroot); $final_dest_file = $this->_prependPath($dest_file, $this->installroot);
$dest_dir = dirname($final_dest_file); $dest_dir = dirname($final_dest_file);
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file); $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
// }}}
if (!@is_dir($dest_dir)) { if (!@is_dir($dest_dir)) {
if (!$this->mkDirHier($dest_dir)) { if (!$this->mkDirHier($dest_dir)) {
return $this->raiseError("failed to mkdir $dest_dir", return $this->raiseError("failed to mkdir $dest_dir",
@ -244,6 +248,7 @@ class PEAR_Installer extends PEAR_Common
$md5sum = md5_file($dest_file); $md5sum = md5_file($dest_file);
} }
} else { } else {
// {{{ file with replacements
if (!file_exists($orig_file)) { if (!file_exists($orig_file)) {
return $this->raiseError("file does not exist", return $this->raiseError("file does not exist",
PEAR_INSTALLER_FAILED); PEAR_INSTALLER_FAILED);
@ -297,7 +302,9 @@ class PEAR_Installer extends PEAR_Common
PEAR_INSTALLER_FAILED); PEAR_INSTALLER_FAILED);
} }
fclose($wp); fclose($wp);
// }}}
} }
// {{{ check the md5
if (isset($md5sum)) { if (isset($md5sum)) {
if (strtolower($md5sum) == strtolower($atts['md5sum'])) { if (strtolower($md5sum) == strtolower($atts['md5sum'])) {
$this->log(2, "md5sum ok: $final_dest_file"); $this->log(2, "md5sum ok: $final_dest_file");
@ -312,6 +319,8 @@ class PEAR_Installer extends PEAR_Common
} }
} }
} }
// }}}
// {{{ set file permissions
if (!OS_WINDOWS) { if (!OS_WINDOWS) {
if ($atts['role'] == 'script') { if ($atts['role'] == 'script') {
$mode = 0777 & ~(int)octdec($this->config->get('umask')); $mode = 0777 & ~(int)octdec($this->config->get('umask'));
@ -324,6 +333,7 @@ class PEAR_Installer extends PEAR_Common
$this->log(0, "failed to change mode of $dest_file"); $this->log(0, "failed to change mode of $dest_file");
} }
} }
// }}}
$this->addFileOperation("rename", array($dest_file, $final_dest_file)); $this->addFileOperation("rename", array($dest_file, $final_dest_file));
// Store the full path where the file was installed for easy unistall // Store the full path where the file was installed for easy unistall
$this->addFileOperation("installed_as", array($file, $installed_as, $this->addFileOperation("installed_as", array($file, $installed_as,
@ -391,7 +401,7 @@ class PEAR_Installer extends PEAR_Common
{ {
$n = count($this->file_operations); $n = count($this->file_operations);
$this->log(2, "about to commit $n file operations"); $this->log(2, "about to commit $n file operations");
// first, check permissions and such manually // {{{ first, check permissions and such manually
$errors = array(); $errors = array();
foreach ($this->file_operations as $tr) { foreach ($this->file_operations as $tr) {
list($type, $data) = $tr; list($type, $data) = $tr;
@ -423,6 +433,7 @@ class PEAR_Installer extends PEAR_Common
} }
} }
// }}}
$m = sizeof($errors); $m = sizeof($errors);
if ($m > 0) { if ($m > 0) {
foreach ($errors as $error) { foreach ($errors as $error) {
@ -430,7 +441,7 @@ class PEAR_Installer extends PEAR_Common
} }
return false; return false;
} }
// really commit the transaction // {{{ really commit the transaction
foreach ($this->file_operations as $tr) { foreach ($this->file_operations as $tr) {
list($type, $data) = $tr; list($type, $data) = $tr;
switch ($type) { switch ($type) {
@ -466,6 +477,7 @@ class PEAR_Installer extends PEAR_Common
break; break;
} }
} }
// }}}
$this->log(2, "successfully committed $n file operations"); $this->log(2, "successfully committed $n file operations");
$this->file_operations = array(); $this->file_operations = array();
return true; return true;
@ -559,7 +571,7 @@ class PEAR_Installer extends PEAR_Common
} }
// }}} // }}}
// {{ extractDownloadFileName($pkgfile, &$version) // {{{ extractDownloadFileName($pkgfile, &$version)
function extractDownloadFileName($pkgfile, &$version) function extractDownloadFileName($pkgfile, &$version)
{ {
@ -591,6 +603,7 @@ class PEAR_Installer extends PEAR_Common
function _downloadFile($pkgfile, &$config, $options, &$errors, $version, function _downloadFile($pkgfile, &$config, $options, &$errors, $version,
$origpkgfile, $state) $origpkgfile, $state)
{ {
// {{{ check the package filename, and whether it's already installed
$need_download = false; $need_download = false;
if (preg_match('#^(http|ftp)://#', $pkgfile)) { if (preg_match('#^(http|ftp)://#', $pkgfile)) {
$need_download = true; $need_download = true;
@ -613,8 +626,9 @@ class PEAR_Installer extends PEAR_Common
return; return;
} }
} }
// }}}
// Download package ----------------------------------------------- // {{{ Download package -----------------------------------------------
if ($need_download) { if ($need_download) {
$downloaddir = $config->get('download_dir'); $downloaddir = $config->get('download_dir');
if (empty($downloaddir)) { if (empty($downloaddir)) {
@ -652,6 +666,7 @@ class PEAR_Installer extends PEAR_Common
} }
$pkgfile = $file; $pkgfile = $file;
} }
// }}}
return $pkgfile; return $pkgfile;
} }
@ -684,6 +699,7 @@ class PEAR_Installer extends PEAR_Common
// - onlyreqdeps : install all required dependencies as well // - onlyreqdeps : install all required dependencies as well
// - alldeps : install all dependencies, including optional // - alldeps : install all dependencies, including optional
// //
// {{{ determine preferred state, installroot, etc
if (!$willinstall) { if (!$willinstall) {
$willinstall = array(); $willinstall = array();
} }
@ -705,9 +721,10 @@ class PEAR_Installer extends PEAR_Common
} else { } else {
$this->installroot = ''; $this->installroot = '';
} }
// }}}
$this->registry = &new PEAR_Registry($php_dir); $this->registry = &new PEAR_Registry($php_dir);
// download files in this list if necessary // {{{ download files in this list if necessary
foreach($packages as $pkgfile) { foreach($packages as $pkgfile) {
if (!is_file($pkgfile)) { if (!is_file($pkgfile)) {
$origpkgfile = $pkgfile; $origpkgfile = $pkgfile;
@ -720,7 +737,7 @@ class PEAR_Installer extends PEAR_Common
continue; continue;
} }
if ($version === null) { if ($version === null) {
// use preferred state if no version number was specified // {{{ use preferred state if no version number was specified
include_once 'PEAR/Remote.php'; include_once 'PEAR/Remote.php';
$curver = $this->registry->packageInfo($pkgfile, 'version'); $curver = $this->registry->packageInfo($pkgfile, 'version');
$remote = &new PEAR_Remote($config); $remote = &new PEAR_Remote($config);
@ -758,6 +775,7 @@ class PEAR_Installer extends PEAR_Common
"'pear install $_err_latest' or set the 'preferred_state' ". "'pear install $_err_latest' or set the 'preferred_state' ".
"to '$_err_latest_state' for installing this package."); "to '$_err_latest_state' for installing this package.");
} }
// }}}
} else { } else {
$pkgfile = $this->_downloadFile($pkgfile, $config, $options, $pkgfile = $this->_downloadFile($pkgfile, $config, $options,
$errors, $version, $origpkgfile, $errors, $version, $origpkgfile,
@ -778,9 +796,10 @@ class PEAR_Installer extends PEAR_Common
$installpackages[] = array('pkg' => $tempinfo['package'], $installpackages[] = array('pkg' => $tempinfo['package'],
'file' => $pkgfile, 'info' => $tempinfo); 'file' => $pkgfile, 'info' => $tempinfo);
} }
// }}}
// extract dependencies from downloaded files and then download them // {{{ extract dependencies from downloaded files and then download
// if necessary // them if necessary
if (isset($options['alldeps']) || isset($options['onlyreqdeps'])) { if (isset($options['alldeps']) || isset($options['onlyreqdeps'])) {
include_once "PEAR/Remote.php"; include_once "PEAR/Remote.php";
$remote = new PEAR_Remote($config); $remote = new PEAR_Remote($config);
@ -790,7 +809,7 @@ class PEAR_Installer extends PEAR_Common
$installed = array_flip($installed); $installed = array_flip($installed);
} }
$deppackages = array(); $deppackages = array();
// construct the list of dependencies for each file // {{{ construct the list of dependencies for each file
foreach ($mywillinstall as $package => $alldeps) { foreach ($mywillinstall as $package => $alldeps) {
if (!is_array($alldeps)) { if (!is_array($alldeps)) {
continue; continue;
@ -805,7 +824,7 @@ class PEAR_Installer extends PEAR_Common
$this->log(0, "skipping Package $package optional dependency $info[name]"); $this->log(0, "skipping Package $package optional dependency $info[name]");
continue; continue;
} }
// get releases // {{{ get releases
$releases = $remote->call('package.info', $info['name'], 'releases'); $releases = $remote->call('package.info', $info['name'], 'releases');
if (PEAR::isError($releases)) { if (PEAR::isError($releases)) {
return $releases; return $releases;
@ -855,8 +874,9 @@ class PEAR_Installer extends PEAR_Common
$deppackages[] = $info['name']; $deppackages[] = $info['name'];
continue; continue;
} }
// }}}
// see if a dependency must be upgraded // {{{ see if a dependency must be upgraded
$inst_version = $this->registry->packageInfo($info['name'], 'version'); $inst_version = $this->registry->packageInfo($info['name'], 'version');
if (!isset($info['version'])) { if (!isset($info['version'])) {
// this is a rel='has' dependency, check against latest // this is a rel='has' dependency, check against latest
@ -872,8 +892,10 @@ class PEAR_Installer extends PEAR_Common
continue; continue;
} }
$deppackages[] = $info['name']; $deppackages[] = $info['name'];
// }}}
} // foreach($alldeps } // foreach($alldeps
} // foreach($willinstall }
// }}} foreach($willinstall
if (count($deppackages)) { if (count($deppackages)) {
// check dependencies' dependencies // check dependencies' dependencies
@ -889,7 +911,7 @@ class PEAR_Installer extends PEAR_Common
$this->download($deppackages, $options, $config, $installpackages, $this->download($deppackages, $options, $config, $installpackages,
$errors, $installed, $willinstall, $state); $errors, $installed, $willinstall, $state);
} }
} // if --alldeps or --onlyreqdeps } // }}} if --alldeps or --onlyreqdeps
} }
// }}} // }}}
@ -932,7 +954,7 @@ class PEAR_Installer extends PEAR_Common
if (substr($pkgfile, -4) == '.xml') { if (substr($pkgfile, -4) == '.xml') {
$descfile = $pkgfile; $descfile = $pkgfile;
} else { } else {
// Decompress pack in tmp dir ------------------------------------- // {{{ Decompress pack in tmp dir -------------------------------------
// To allow relative package file names // To allow relative package file names
$oldcwd = getcwd(); $oldcwd = getcwd();
@ -951,7 +973,7 @@ class PEAR_Installer extends PEAR_Common
return $this->raiseError("unable to unpack $pkgfile"); return $this->raiseError("unable to unpack $pkgfile");
} }
// ----- Look for existing package file // {{{ Look for existing package file
$descfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml'; $descfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml';
if (!is_file($descfile)) { if (!is_file($descfile)) {
@ -967,7 +989,9 @@ class PEAR_Installer extends PEAR_Common
$flag_old_format = true; $flag_old_format = true;
$this->log(0, "warning : you are using an archive with an old format"); $this->log(0, "warning : you are using an archive with an old format");
} }
// }}}
// <== XXX This part should be removed later on // <== XXX This part should be removed later on
// }}}
} }
if (!is_file($descfile)) { if (!is_file($descfile)) {
@ -993,7 +1017,7 @@ class PEAR_Installer extends PEAR_Common
$pkgname = $pkginfo['package']; $pkgname = $pkginfo['package'];
// Check dependencies ------------------------------------------- // {{{ Check dependencies -------------------------------------------
if (isset($pkginfo['release_deps']) && empty($options['nodeps'])) { if (isset($pkginfo['release_deps']) && empty($options['nodeps'])) {
$dep_errors = ''; $dep_errors = '';
$error = $this->checkDeps($pkginfo, $dep_errors); $error = $this->checkDeps($pkginfo, $dep_errors);
@ -1009,9 +1033,10 @@ class PEAR_Installer extends PEAR_Common
} }
} }
} }
// }}}
// {{{ checks to do when not in "force" mode
if (empty($options['force'])) { if (empty($options['force'])) {
// checks to do when not in "force" mode
$test = $this->registry->checkFileMap($pkginfo); $test = $this->registry->checkFileMap($pkginfo);
if (sizeof($test)) { if (sizeof($test)) {
$tmp = $test; $tmp = $test;
@ -1031,6 +1056,7 @@ class PEAR_Installer extends PEAR_Common
} }
} }
} }
// }}}
$this->startFileTransaction(); $this->startFileTransaction();
@ -1060,7 +1086,7 @@ class PEAR_Installer extends PEAR_Common
} }
} }
// Copy files to dest dir --------------------------------------- // {{{ Copy files to dest dir ---------------------------------------
// info from the package it self we want to access from _installFile // info from the package it self we want to access from _installFile
$this->pkginfo = &$pkginfo; $this->pkginfo = &$pkginfo;
@ -1087,6 +1113,7 @@ class PEAR_Installer extends PEAR_Common
} }
// <== XXX This part should be removed later on // <== XXX This part should be removed later on
// {{{ install files
foreach ($pkginfo['filelist'] as $file => $atts) { foreach ($pkginfo['filelist'] as $file => $atts) {
$this->expectError(PEAR_INSTALLER_FAILED); $this->expectError(PEAR_INSTALLER_FAILED);
$res = $this->_installFile($file, $atts, $tmp_path, $options); $res = $this->_installFile($file, $atts, $tmp_path, $options);
@ -1107,7 +1134,9 @@ class PEAR_Installer extends PEAR_Common
unset($pkginfo['filelist'][$file]); unset($pkginfo['filelist'][$file]);
} }
} }
// }}}
// {{{ compile and install source files
if ($this->source_files > 0 && empty($options['nobuild'])) { if ($this->source_files > 0 && empty($options['nobuild'])) {
$this->log(1, "$this->source_files source files, building"); $this->log(1, "$this->source_files source files, building");
$bob = &new PEAR_Builder($this->ui); $bob = &new PEAR_Builder($this->ui);
@ -1137,15 +1166,17 @@ class PEAR_Installer extends PEAR_Common
); );
} }
} }
// }}}
} }
if (!$this->commitFileTransaction()) { if (!$this->commitFileTransaction()) {
$this->rollbackFileTransaction(); $this->rollbackFileTransaction();
return $this->raiseError("commit failed", PEAR_INSTALLER_FAILED); return $this->raiseError("commit failed", PEAR_INSTALLER_FAILED);
} }
// }}}
$ret = false; $ret = false;
// Register that the package is installed ----------------------- // {{{ Register that the package is installed -----------------------
if (empty($options['upgrade'])) { if (empty($options['upgrade'])) {
// if 'force' is used, replace the info in registry // if 'force' is used, replace the info in registry
if (!empty($options['force']) && $this->registry->packageExists($pkgname)) { if (!empty($options['force']) && $this->registry->packageExists($pkgname)) {
@ -1163,6 +1194,7 @@ class PEAR_Installer extends PEAR_Common
if (!$ret) { if (!$ret) {
return $this->raiseError("Adding package $pkgname to registry failed"); return $this->raiseError("Adding package $pkgname to registry failed");
} }
// }}}
return $pkginfo; return $pkginfo;
} }
@ -1206,8 +1238,8 @@ class PEAR_Installer extends PEAR_Common
$this->log(0, $warning); $this->log(0, $warning);
} }
} }
// {{{ Delete the files
$this->startFileTransaction(); $this->startFileTransaction();
// Delete the files
if (PEAR::isError($err = $this->_deletePackageFiles($package))) { if (PEAR::isError($err = $this->_deletePackageFiles($package))) {
$this->rollbackFileTransaction(); $this->rollbackFileTransaction();
return $this->raiseError($err); return $this->raiseError($err);
@ -1229,6 +1261,7 @@ class PEAR_Installer extends PEAR_Common
$this->rollbackFileTransaction(); $this->rollbackFileTransaction();
} }
} }
// }}}
// Register that the package is no longer installed // Register that the package is no longer installed
return $this->registry->deletePackage($package); return $this->registry->deletePackage($package);
@ -1277,6 +1310,7 @@ class PEAR_Installer extends PEAR_Common
} }
} }
} }
// {{{ failed dependencies
$n = count($failed_deps); $n = count($failed_deps);
if ($n > 0) { if ($n > 0) {
for ($i = 0; $i < $n; $i++) { for ($i = 0; $i < $n; $i++) {
@ -1305,7 +1339,9 @@ class PEAR_Installer extends PEAR_Common
} }
return true; return true;
} }
// }}}
// {{{ optional dependencies
$count_optional = count($optional_deps); $count_optional = count($optional_deps);
if ($count_optional > 0) { if ($count_optional > 0) {
$errors = "Optional dependencies:"; $errors = "Optional dependencies:";
@ -1326,6 +1362,7 @@ class PEAR_Installer extends PEAR_Common
} }
return false; return false;
} }
// }}}
} }
return false; return false;
} }
@ -1374,6 +1411,7 @@ class PEAR_Installer extends PEAR_Common
// }}} // }}}
} }
// {{{ md5_file() utility function
if (!function_exists("md5_file")) { if (!function_exists("md5_file")) {
function md5_file($filename) { function md5_file($filename) {
$fp = fopen($filename, "r"); $fp = fopen($filename, "r");
@ -1383,5 +1421,6 @@ if (!function_exists("md5_file")) {
return md5($contents); return md5($contents);
} }
} }
// }}}
?> ?>

View file

@ -97,7 +97,7 @@ class PEAR_Packager extends PEAR_Common
$filelist = array(); $filelist = array();
$i = 0; $i = 0;
// Copy files ----------------------------------------------- // {{{ Copy files -----------------------------------------------
foreach ($this->pkginfo['filelist'] as $fname => $atts) { foreach ($this->pkginfo['filelist'] as $fname => $atts) {
if (!file_exists($fname)) { if (!file_exists($fname)) {
chdir($oldcwd); chdir($oldcwd);
@ -111,6 +111,7 @@ class PEAR_Packager extends PEAR_Common
$this->log(2, "Adding file $fname"); $this->log(2, "Adding file $fname");
} }
} }
// }}}
$new_xml = $this->xmlFromInfo($this->pkginfo); $new_xml = $this->xmlFromInfo($this->pkginfo);
if (PEAR::isError($new_xml)) { if (PEAR::isError($new_xml)) {
chdir($oldcwd); chdir($oldcwd);
@ -129,7 +130,7 @@ class PEAR_Packager extends PEAR_Common
fwrite($np, $new_xml); fwrite($np, $new_xml);
fclose($np); fclose($np);
// TAR the Package ------------------------------------------- // {{{ TAR the Package -------------------------------------------
$ext = $compress ? '.tgz' : '.tar'; $ext = $compress ? '.tgz' : '.tar';
$dest_package = $oldcwd . DIRECTORY_SEPARATOR . $pkgver . $ext; $dest_package = $oldcwd . DIRECTORY_SEPARATOR . $pkgver . $ext;
$tar =& new Archive_Tar($dest_package, $compress); $tar =& new Archive_Tar($dest_package, $compress);
@ -155,6 +156,7 @@ class PEAR_Packager extends PEAR_Common
$this->log(1, "Tag the released code with `pear cvstag $pkgfile'"); $this->log(1, "Tag the released code with `pear cvstag $pkgfile'");
$this->log(1, "(or set the CVS tag $cvstag by hand)"); $this->log(1, "(or set the CVS tag $cvstag by hand)");
} }
// }}}
chdir($oldcwd); chdir($oldcwd);
return $dest_package; return $dest_package;
} }
@ -162,6 +164,7 @@ class PEAR_Packager extends PEAR_Common
// }}} // }}}
} }
// {{{ md5_file() utility function
if (!function_exists('md5_file')) { if (!function_exists('md5_file')) {
function md5_file($file) { function md5_file($file) {
if (!$fd = @fopen($file, 'r')) { if (!$fd = @fopen($file, 'r')) {
@ -172,5 +175,6 @@ if (!function_exists('md5_file')) {
return $md5; return $md5;
} }
} }
// }}}
?> ?>