⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 installer.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php/** * PEAR_Installer * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * 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 web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category   pear * @package    PEAR * @author     Stig Bakken <ssb@php.net> * @author     Tomas V.V. Cox <cox@idecnet.com> * @author     Martin Jansen <mj@php.net> * @author     Greg Beaver <cellog@php.net> * @copyright  1997-2005 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 * @version    CVS: $Id: Installer.php,v 1.81.2.27.2.4 2006/05/22 10:19:33 cellog Exp $ * @link       http://pear.php.net/package/PEAR * @since      File available since Release 0.1 *//** * Used for installation groups in package.xml 2.0 and platform exceptions */require_once 'OS/Guess.php';require_once 'PEAR/Downloader.php';define('PEAR_INSTALLER_NOBINARY', -240);/** * Administration class used to install PEAR packages and maintain the * installed package database. * * @category   pear * @package    PEAR * @author     Stig Bakken <ssb@php.net> * @author     Tomas V.V. Cox <cox@idecnet.com> * @author     Martin Jansen <mj@php.net> * @author     Greg Beaver <cellog@php.net> * @copyright  1997-2005 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 * @version    Release: @package_version@ * @link       http://pear.php.net/package/PEAR * @since      Class available since Release 0.1 */class PEAR_Installer extends PEAR_Downloader{    // {{{ properties    /** name of the package directory, for example Foo-1.0     * @var string     */    var $pkgdir;    /** directory where PHP code files go     * @var string     */    var $phpdir;    /** directory where PHP extension files go     * @var string     */    var $extdir;    /** directory where documentation goes     * @var string     */    var $docdir;    /** installation root directory (ala PHP's INSTALL_ROOT or     * automake's DESTDIR     * @var string     */    var $installroot = '';    /** debug level     * @var int     */    var $debug = 1;    /** temporary directory     * @var string     */    var $tmpdir;    /**     * PEAR_Registry object used by the installer     * @var PEAR_Registry     */    var $registry;    /**     * array of PEAR_Downloader_Packages     * @var array     */    var $_downloadedPackages;    /** List of file transactions queued for an install/upgrade/uninstall.     *     *  Format:     *    array(     *      0 => array("rename => array("from-file", "to-file")),     *      1 => array("delete" => array("file-to-delete")),     *      ...     *    )     *     * @var array     */    var $file_operations = array();    // }}}    // {{{ constructor    /**     * PEAR_Installer constructor.     *     * @param object $ui user interface object (instance of PEAR_Frontend_*)     *     * @access public     */    function PEAR_Installer(&$ui)    {        parent::PEAR_Common();        $this->setFrontendObject($ui);        $this->debug = $this->config->get('verbose');    }    function setOptions($options)    {        $this->_options = $options;    }    function setConfig(&$config)    {        $this->config = &$config;        $this->_registry = &$config->getRegistry();    }    // }}}    function _removeBackups($files)    {        foreach ($files as $path) {            $this->addFileOperation('removebackup', array($path));        }    }    // {{{ _deletePackageFiles()    /**     * Delete a package's installed files, does not remove empty directories.     *     * @param string package name     * @param string channel name     * @param bool if true, then files are backed up first     * @return bool TRUE on success, or a PEAR error on failure     * @access protected     */    function _deletePackageFiles($package, $channel = false, $backup = false)    {        if (!$channel) {            $channel = 'pear.php.net';        }        if (!strlen($package)) {            return $this->raiseError("No package to uninstall given");        }        if (strtolower($package) == 'pear' && $channel == 'pear.php.net') {            // to avoid race conditions, include all possible needed files            require_once 'PEAR/Task/Common.php';            require_once 'PEAR/Task/Replace.php';            require_once 'PEAR/Task/Unixeol.php';            require_once 'PEAR/Task/Windowseol.php';            require_once 'PEAR/PackageFile/v1.php';            require_once 'PEAR/PackageFile/v2.php';            require_once 'PEAR/PackageFile/Generator/v1.php';            require_once 'PEAR/PackageFile/Generator/v2.php';        }        $filelist = $this->_registry->packageInfo($package, 'filelist', $channel);        if ($filelist == null) {            return $this->raiseError("$channel/$package not installed");        }        $ret = array();        foreach ($filelist as $file => $props) {            if (empty($props['installed_as'])) {                continue;            }            $path = $props['installed_as'];            if ($backup) {                $this->addFileOperation('backup', array($path));                $ret[] = $path;            }            $this->addFileOperation('delete', array($path));        }        if ($backup) {            return $ret;        }        return true;    }    // }}}    // {{{ _installFile()    /**     * @param string filename     * @param array attributes from <file> tag in package.xml     * @param string path to install the file in     * @param array options from command-line     * @access private     */    function _installFile($file, $atts, $tmp_path, $options)    {        // {{{ return if this file is meant for another platform        static $os;        if (!isset($this->_registry)) {            $this->_registry = &$this->config->getRegistry();        }        if (isset($atts['platform'])) {            if (empty($os)) {                $os = new OS_Guess();            }            if (strlen($atts['platform']) && $atts['platform']{0} == '!') {                $negate = true;                $platform = substr($atts['platform'], 1);            } else {                $negate = false;                $platform = $atts['platform'];            }            if ((bool) $os->matchSignature($platform) === $negate) {                $this->log(3, "skipped $file (meant for $atts[platform], we are ".$os->getSignature().")");                return PEAR_INSTALLER_SKIPPED;            }        }        // }}}        $channel = $this->pkginfo->getChannel();        // {{{ assemble the destination paths        switch ($atts['role']) {            case 'doc':            case 'data':            case 'test':                $dest_dir = $this->config->get($atts['role'] . '_dir', null, $channel) .                            DIRECTORY_SEPARATOR . $this->pkginfo->getPackage();                unset($atts['baseinstalldir']);                break;            case 'ext':            case 'php':                $dest_dir = $this->config->get($atts['role'] . '_dir', null, $channel);                break;            case 'script':                $dest_dir = $this->config->get('bin_dir', null, $channel);                break;            case 'src':            case 'extsrc':                $this->source_files++;                return;            default:                return $this->raiseError("Invalid role `$atts[role]' for file $file");        }        $save_destdir = $dest_dir;        if (!empty($atts['baseinstalldir'])) {            $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];        }        if (dirname($file) != '.' && empty($atts['install-as'])) {            $dest_dir .= DIRECTORY_SEPARATOR . dirname($file);        }        if (empty($atts['install-as'])) {            $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);        } else {            $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];        }        $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;        // Clean up the DIRECTORY_SEPARATOR mess        $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;        list($dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"),                                                    array(DIRECTORY_SEPARATOR,                                                          DIRECTORY_SEPARATOR,                                                          DIRECTORY_SEPARATOR),                                                    array($dest_file, $orig_file));        $final_dest_file = $installed_as = $dest_file;        if (isset($this->_options['packagingroot'])) {            $installedas_dest_dir = dirname($final_dest_file);            $installedas_dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);            $final_dest_file = $this->_prependPath($final_dest_file,                $this->_options['packagingroot']);        } else {            $installedas_dest_dir = dirname($final_dest_file);            $installedas_dest_file = $installedas_dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);        }        $dest_dir = dirname($final_dest_file);        $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);        // }}}        if (empty($this->_options['register-only']) && !@is_dir($dest_dir)) {            if (!$this->mkDirHier($dest_dir)) {                return $this->raiseError("failed to mkdir $dest_dir",                                         PEAR_INSTALLER_FAILED);            }            $this->log(3, "+ mkdir $dest_dir");        }        // pretty much nothing happens if we are only registering the install        if (empty($this->_options['register-only'])) {            if (empty($atts['replacements'])) {                if (!file_exists($orig_file)) {                    return $this->raiseError("file $orig_file does not exist",                                             PEAR_INSTALLER_FAILED);                }                if (!@copy($orig_file, $dest_file)) {                    return $this->raiseError("failed to write $dest_file",                                             PEAR_INSTALLER_FAILED);                }                $this->log(3, "+ cp $orig_file $dest_file");                if (isset($atts['md5sum'])) {                    $md5sum = md5_file($dest_file);                }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -