dependency2.php

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 1,299 行 · 第 1/4 页

PHP
1,299
字号
        if ($found) {            $version = $param->getVersion();            $installed = false;            $downloaded = true;        } else {            if ($this->_registry->packageExists($dep['name'], $dep['channel'])) {                $installed = true;                $downloaded = false;                $version = $this->_registry->packageinfo($dep['name'], 'version',                    $dep['channel']);            } else {                if ($dep['channel'] == 'pecl.php.net' && $this->_registry->packageExists($dep['name'],                      'pear.php.net')) {                    $installed = true;                    $downloaded = false;                    $version = $this->_registry->packageinfo($dep['name'], 'version',                        'pear.php.net');                } else {                    $version = 'not installed or downloaded';                    $installed = false;                    $downloaded = false;                }            }        }        $extra = $this->_getExtraString($dep);        if (isset($dep['exclude'])) {            if (!is_array($dep['exclude'])) {                $dep['exclude'] = array($dep['exclude']);            }        }        if (!isset($dep['min']) && !isset($dep['max']) &&              !isset($dep['recommended']) && !isset($dep['exclude'])) {            if ($installed || $downloaded) {                $installed = $installed ? 'installed' : 'downloaded';                if (isset($dep['conflicts'])) {                    if ($version) {                        $rest = ", $installed version is " . $version;                    } else {                        $rest = '';                    }                    if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                        return $this->raiseError('%s conflicts with package "' . $depname . '"' .                            $extra . $rest);                    } else {                        return $this->warning('warning: %s conflicts with package "' . $depname . '"' .                            $extra . $rest);                    }                }                return true;            } else {                if (isset($dep['conflicts'])) {                    return true;                }                if ($required) {                    if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                        return $this->raiseError('%s requires package "' . $depname . '"' .                            $extra);                    } else {                        return $this->warning('warning: %s requires package "' . $depname . '"' .                            $extra);                    }                } else {                    return $this->warning('%s can optionally use package "' . $depname . '"' .                        $extra);                }            }        }        if (!$installed && !$downloaded) {            if (isset($dep['conflicts'])) {                return true;            }            if ($required) {                if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                    return $this->raiseError('%s requires package "' . $depname . '"' .                        $extra);                } else {                    return $this->warning('warning: %s requires package "' . $depname . '"' .                        $extra);                }            } else {                return $this->warning('%s can optionally use package "' . $depname . '"' .                    $extra);            }        }        $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 && !isset($dep['conflicts'])) {            $installed = $installed ? 'installed' : 'downloaded';            $dep['package'] = $dep['name'];            $dep = $this->_registry->parsedPackageNameToString($dep, true);            if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                return $this->raiseError('%s requires package "' . $depname . '"' .                    $extra . ", $installed version is " . $version);            } else {                return $this->warning('warning: %s requires package "' . $depname . '"' .                    $extra . ", $installed version is " . $version);            }        } elseif ((isset($dep['min']) || isset($dep['max'])) && !$fail &&              isset($dep['conflicts']) && !isset($dep['exclude'])) {            $installed = $installed ? 'installed' : 'downloaded';            if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                return $this->raiseError('%s conflicts with package "' . $depname . '"' . $extra .                    ", $installed version is " . $version);            } else {                return $this->warning('warning: %s conflicts with package "' . $depname . '"' .                    $extra . ", $installed version is " . $version);            }        }        if (isset($dep['exclude'])) {            $installed = $installed ? 'installed' : 'downloaded';            foreach ($dep['exclude'] as $exclude) {                if (version_compare($version, $exclude, '==') && !isset($dep['conflicts'])) {                    if (!isset($this->_options['nodeps']) &&                          !isset($this->_options['force'])) {                        return $this->raiseError('%s is not compatible with ' .                            $installed . ' package "' .                            $depname . '" version ' .                            $exclude);                    } else {                        return $this->warning('warning: %s is not compatible with ' .                            $installed . ' package "' .                            $depname . '" version ' .                            $exclude);                    }                } elseif (version_compare($version, $exclude, '!=') && isset($dep['conflicts'])) {                    $installed = $installed ? 'installed' : 'downloaded';                    if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                        return $this->raiseError('%s conflicts with package "' . $depname . '"' .                            $extra . ", $installed version is " . $version);                    } else {                        return $this->warning('warning: %s conflicts with package "' . $depname . '"' .                            $extra . ", $installed version is " . $version);                    }                }            }        }        if (isset($dep['recommended'])) {            $installed = $installed ? 'installed' : 'downloaded';            if (version_compare($version, $dep['recommended'], '==')) {                return true;            } else {                if (!$found && $installed) {                    $param = $this->_registry->getPackage($dep['name'], $dep['channel']);                }                if ($param) {                    $found = false;                    foreach ($params as $parent) {                        if ($parent->isEqual($this->_currentPackage)) {                            $found = true;                            break;                        }                    }                    if ($found) {                        if ($param->isCompatible($parent)) {                            return true;                        }                    } else { // this is for validPackage() calls                        $parent = $this->_registry->getPackage($this->_currentPackage['package'],                            $this->_currentPackage['channel']);                        if ($parent !== null) {                            if ($param->isCompatible($parent)) {                                return true;                            }                        }                    }                }                if (!isset($this->_options['nodeps']) && !isset($this->_options['force']) &&                      !isset($this->_options['loose'])) {                    return $this->raiseError('%s dependency package "' . $depname .                        '" ' . $installed . ' version ' . $version .                         ' is not the recommended version ' . $dep['recommended'] .                        ', but may be compatible, use --force to install');                } else {                    return $this->warning('warning: %s dependency package "' . $depname .                        '" ' . $installed . ' version ' . $version .                        ' is not the recommended version ' . $dep['recommended']);                }            }        }        return true;    }    function _validatePackageInstall($dep, $required, $depv1 = false)    {        return $this->_validatePackageDownload($dep, $required, array(), $depv1);    }    /**     * Verify that uninstalling packages passed in to command line is OK.     *     * @param PEAR_Installer $dl     * @return PEAR_Error|true     */    function validatePackageUninstall(&$dl)    {        if (PEAR::isError($this->_dependencydb)) {            return $this->_dependencydb;        }        $params = array();        // construct an array of "downloaded" packages to fool the package dependency checker        // into using these to validate uninstalls of circular dependencies        $downloaded = &$dl->getUninstallPackages();        foreach ($downloaded as $i => $pf) {            if (!class_exists('PEAR_Downloader_Package')) {                require_once 'PEAR/Downloader/Package.php';            }            $dp = &new PEAR_Downloader_Package($dl);            $dp->setPackageFile($downloaded[$i]);            $params[$i] = &$dp;        }        // check cache        $memyselfandI = strtolower($this->_currentPackage['channel']) . '/' .            strtolower($this->_currentPackage['package']);        if (isset($dl->___uninstall_package_cache)) {            $badpackages = $dl->___uninstall_package_cache;            if (isset($badpackages[$memyselfandI]['warnings'])) {                foreach ($badpackages[$memyselfandI]['warnings'] as $warning) {                    $dl->log(0, $warning[0]);                }            }            if (isset($badpackages[$memyselfandI]['errors'])) {                foreach ($badpackages[$memyselfandI]['errors'] as $error) {                    if (is_array($error)) {                        $dl->log(0, $error[0]);                    } else {                        $dl->log(0, $error->getMessage());                    }                }                if (isset($this->_options['nodeps']) || isset($this->_options['force'])) {                    return $this->warning(                        'warning: %s should not be uninstalled, other installed packages depend ' .                        'on this package');                } else {                    return $this->raiseError(                        '%s cannot be uninstalled, other installed packages depend on this package');                }            }            return true;        }        // first, list the immediate parents of each package to be uninstalled        $perpackagelist = array();        $allparents = array();        foreach ($params as $i => $param) {            $a = array('channel' => strtolower($param->getChannel()),                      'package' => strtolower($param->getPackage()));            $deps = $this->_dependencydb->getDependentPackages($a);            if ($deps) {                foreach ($deps as $d) {                    $pardeps = $this->_dependencydb->getDependencies($d);                    foreach ($pardeps as $dep) {                        if (strtolower($dep['dep']['channel']) == $a['channel'] &&                              strtolower($dep['dep']['name']) == $a['package']) {                            if (!isset($perpackagelist[$a['channel'] . '/' . $a['package']])) {                                $perpackagelist[$a['channel'] . '/' . $a['package']] = array();                            }                            $perpackagelist[$a['channel'] . '/' . $a['package']][]                                = array($d['channel'] . '/' . $d['package'], $dep);                            if (!isset($allparents[$d['channel'] . '/' . $d['package']])) {                                $allparents[$d['channel'] . '/' . $d['package']] = array();                            }                            if (!isset($allparents[$d['channel'] . '/' . $d['package']][$a['channel'] . '/' . $a['package']])) {                                $allparents[$d['channel'] . '/' . $d['package']][$a['channel'] . '/' . $a['package']] = array();                            }                            $allparents[$d['channel'] . '/' . $d['package']]                                       [$a['channel'] . '/' . $a['package']][]                                = array($d, $dep);                        }                    }                }            }        }        // next, remove any packages from the parents list that are not installed        $remove = array();        foreach ($allparents as $parent => $d1) {            foreach ($d1 as $d) {                if ($this->_registry->packageExists($d[0][0]['package'], $d[0][0]['channel'])) {                    continue;                }                $remove[$parent] = true;            }        }        // next remove any packages from the parents list that are not passed in for        // uninstallation        foreach ($allparents as $parent => $d1) {            foreach ($d1 as $d) {                foreach ($params as $param) {                    if (strtolower($param->getChannel()) == $d[0][0]['channel'] &&                          strtolower($param->getPackage()) == $d[0][0]['package']) {                        // found it                        continue 3;                    }                }                $remove[$parent] = true;            }        }        // remove all packages whose dependencies fail        // save which ones failed for error reporting        $badchildren = array();        do {            $fail = false;            foreach ($remove as $package => $unused) {                if (!isset($allparents[$package])) {                    continue;                }                foreach ($allparents[$package] as $kid => $d1) {                    foreach ($d1 as $depinfo) {                        if ($depinfo[1]['type'] != 'optional') {                            if (isset($badchildren[$kid])) {                                continue;                            }                            $badchildren[$kid] = true;                            $remove[$kid] = true;                            $fail = true;                            continue 2;                        }                    }

⌨️ 快捷键说明

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