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

📄 dependency2.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 4 页
字号:
    function _validatePackageUninstall($dep, $required, $params, &$dl)    {        $dep['package'] = $dep['name'];        $depname = $this->_registry->parsedPackageNameToString($dep, true);        $found = false;        foreach ($params as $param) {            if ($param->isEqual($this->_currentPackage)) {                $found = true;                break;            }        }        $version = $this->_registry->packageinfo($dep['name'], 'version',            $dep['channel']);        if (!$version) {            return true;        }        $extra = $this->_getExtraString($dep);        if (isset($dep['exclude'])) {            if (!is_array($dep['exclude'])) {                $dep['exclude'] = array($dep['exclude']);            }        }        if (isset($dep['conflicts'])) {            return true; // uninstall OK - these packages conflict (probably installed with --force)        }        if (!isset($dep['min']) && !isset($dep['max'])) {            if ($required) {                if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                    return $this->raiseError('%s' . $extra . ' is required by installed package "' .                        $depname . '"');                } else {                    return $this->warning('warning: %s' . $extra .                        ' is required by installed package "' . $depname . '"');                }            } else {                return $this->warning('%s' . $extra .                    ' can be optionally used by installed package "' . $depname . '"');            }        }        $fail = false;        if (isset($dep['min'])) {            if (version_compare($version, $dep['min'], '>=')) {                $fail = true;            }        }        if (isset($dep['max'])) {            if (version_compare($version, $dep['max'], '<=')) {                $fail = true;            }        }        if ($fail) {            if ($found) {                if (!isset($dl->___checked[$this->_currentPackage['channel']]                      [$this->_currentPackage['package']])) {                    $dl->___checked[$this->_currentPackage['channel']]                      [$this->_currentPackage['package']] = true;                    $deps = $this->_dependencydb->getDependentPackageDependencies(                        $this->_currentPackage);                    if ($deps) {                        foreach ($deps as $channel => $info) {                            foreach ($info as $package => $ds) {                                foreach ($ds as $d) {                                    $d['dep']['package'] = $d['dep']['name'];                                    $checker = &new PEAR_Dependency2($this->_config, $this->_options,                                        array('channel' => $channel, 'package' => $package),                                        $this->_state);                                    $dep = $d['dep'];                                    $required = $d['type'] == 'required';                                    $ret = $checker->_validatePackageUninstall($dep, $required, $params,                                        $dl);                                    if (PEAR::isError($ret)) {                                        $fail = true;                                        break 3;                                    }                                }                            }                            $fail = false;                        }                    }                } else {                    return true;                }            }            if (!$fail) {                return true;            }            if ($required) {                if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                    return $this->raiseError($depname . $extra . ' is required by installed package' .                        ' "%s"');                } else {                    return $this->warning('warning: ' . $depname . $extra .                        ' is required by installed package "%s"');                }            } else {                return $this->warning($depname . $extra . ' can be optionally used by installed package' .                        ' "%s"');            }        }        return true;    }    /**     * validate a downloaded package against installed packages     *      * As of PEAR 1.4.3, this will only validate     *     * @param array|PEAR_Downloader_Package|PEAR_PackageFile_v1|PEAR_PackageFile_v2     *              $pkg package identifier (either     *                   array('package' => blah, 'channel' => blah) or an array with     *                   index 'info' referencing an object)     * @param PEAR_Downloader $dl     * @param array $params full list of packages to install     * @return true|PEAR_Error     */    function validatePackage($pkg, &$dl, $params = array())    {        if (is_array($pkg) && isset($pkg['info'])) {            $deps = $this->_dependencydb->getDependentPackageDependencies($pkg['info']);        } else {            $deps = $this->_dependencydb->getDependentPackageDependencies($pkg);        }        $fail = false;        if ($deps) {            if (!class_exists('PEAR_Downloader_Package')) {                require_once 'PEAR/Downloader/Package.php';            }            $dp = &new PEAR_Downloader_Package($dl);            if (is_object($pkg)) {                $dp->setPackageFile($pkg);            } else {                $dp->setDownloadURL($pkg);            }            PEAR::pushErrorHandling(PEAR_ERROR_RETURN);            foreach ($deps as $channel => $info) {                foreach ($info as $package => $ds) {                    foreach ($params as $packd) {                        if (strtolower($packd->getPackage()) == strtolower($package) &&                              $packd->getChannel() == $channel) {                            $dl->log(3, 'skipping installed package check of "' .                                        $this->_registry->parsedPackageNameToString(                                            array('channel' => $channel, 'package' => $package),                                            true) .                                        '", version "' . $packd->getVersion() . '" will be ' .                                        'downloaded and installed');                            continue 2; // jump to next package                        }                    }                    foreach ($ds as $d) {                        $checker = &new PEAR_Dependency2($this->_config, $this->_options,                            array('channel' => $channel, 'package' => $package), $this->_state);                        $dep = $d['dep'];                        $required = $d['type'] == 'required';                        $ret = $checker->_validatePackageDownload($dep, $required, array(&$dp));                        if (is_array($ret)) {                            $dl->log(0, $ret[0]);                        } elseif (PEAR::isError($ret)) {                            $dl->log(0, $ret->getMessage());                            $fail = true;                        }                    }                }            }            PEAR::popErrorHandling();        }        if ($fail) {            return $this->raiseError(                '%s cannot be installed, conflicts with installed packages');        }        return true;    }    /**     * validate a package.xml 1.0 dependency     */    function validateDependency1($dep, $params = array())    {        if (!isset($dep['optional'])) {            $dep['optional'] = 'no';        }        list($newdep, $type) = $this->normalizeDep($dep);        if (!$newdep) {            return $this->raiseError("Invalid Dependency");        }        if (method_exists($this, "validate{$type}Dependency")) {            return $this->{"validate{$type}Dependency"}($newdep, $dep['optional'] == 'no',                $params, true);        }    }    /**     * Convert a 1.0 dep into a 2.0 dep     */    function normalizeDep($dep)    {        $types = array(            'pkg' => 'Package',            'ext' => 'Extension',            'os' => 'Os',            'php' => 'Php'        );        if (isset($types[$dep['type']])) {            $type = $types[$dep['type']];        } else {            return array(false, false);        }        $newdep = array();        switch ($type) {            case 'Package' :                $newdep['channel'] = 'pear.php.net';            case 'Extension' :            case 'Os' :                $newdep['name'] = $dep['name'];            break;        }        $dep['rel'] = PEAR_Dependency2::signOperator($dep['rel']);        switch ($dep['rel']) {            case 'has' :                return array($newdep, $type);            break;            case 'not' :                $newdep['conflicts'] = true;            break;            case '>=' :            case '>' :                $newdep['min'] = $dep['version'];                if ($dep['rel'] == '>') {                    $newdep['exclude'] = $dep['version'];                }            break;            case '<=' :            case '<' :                $newdep['max'] = $dep['version'];                if ($dep['rel'] == '<') {                    $newdep['exclude'] = $dep['version'];                }            break;            case 'ne' :            case '!=' :                $newdep['min'] = '0';                $newdep['max'] = '100000';                $newdep['exclude'] = $dep['version'];            break;            case '==' :                $newdep['min'] = $dep['version'];                $newdep['max'] = $dep['version'];            break;        }        if ($type == 'Php') {            if (!isset($newdep['min'])) {                $newdep['min'] = '4.2.0';            }            if (!isset($newdep['max'])) {                $newdep['max'] = '6.0.0';            }        }        return array($newdep, $type);    }    /**     * Converts text comparing operators to them sign equivalents     *     * Example: 'ge' to '>='     *     * @access public     * @param  string Operator     * @return string Sign equivalent     */    function signOperator($operator)    {        switch($operator) {            case 'lt': return '<';            case 'le': return '<=';            case 'gt': return '>';            case 'ge': return '>=';            case 'eq': return '==';            case 'ne': return '!=';            default:                return $operator;        }    }    function raiseError($msg)    {        if (isset($this->_options['ignore-errors'])) {            return $this->warning($msg);        }        return PEAR::raiseError(sprintf($msg, $this->_registry->parsedPackageNameToString(            $this->_currentPackage, true)));    }    function warning($msg)    {        return array(sprintf($msg, $this->_registry->parsedPackageNameToString(            $this->_currentPackage, true)));    }}?>

⌨️ 快捷键说明

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