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

📄 builder.php

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
     * (/var/tmp/pear-build-USER/PACKAGE-VERSION).     *     * @param string|PEAR_PackageFile_v* $descfile path to XML package description file, or     *               a PEAR_PackageFile object     *     * @param mixed $callback callback function used to report output,     * see PEAR_Builder::_runCommand for details     *     * @return array an array of associative arrays with built files,     * format:     * array( array( 'file' => '/path/to/ext.so',     *               'php_api' => YYYYMMDD,     *               'zend_mod_api' => YYYYMMDD,     *               'zend_ext_api' => YYYYMMDD ),     *        ... )     *     * @access public     *     * @see PEAR_Builder::_runCommand     */    function build($descfile, $callback = null)    {        $this->current_callback = $callback;        if (PEAR_OS == "Windows") {            return $this->_build_win32($descfile,$callback);        }        if (PEAR_OS != 'Unix') {            return $this->raiseError("building extensions not supported on this platform");        }        if (is_object($descfile)) {            $pkg = $descfile;            $descfile = $pkg->getPackageFile();        } else {            $pf = &new PEAR_PackageFile($this->config);            $pkg = &$pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL);            if (PEAR::isError($pkg)) {                return $pkg;            }        }        $dir = dirname($descfile);        $old_cwd = getcwd();        if (!file_exists($dir) || !is_dir($dir) || !chdir($dir)) {            return $this->raiseError("could not chdir to $dir");        }        $vdir = $pkg->getPackage() . '-' . $pkg->getVersion();        if (is_dir($vdir)) {            chdir($vdir);        }        $dir = getcwd();        $this->log(2, "building in $dir");        putenv('PATH=' . $this->config->get('bin_dir') . ':' . getenv('PATH'));        $err = $this->_runCommand("phpize", array(&$this, 'phpizeCallback'));        if (PEAR::isError($err)) {            return $err;        }        if (!$err) {            return $this->raiseError("`phpize' failed");        }        // {{{ start of interactive part        $configure_command = "$dir/configure";        $configure_options = $pkg->getConfigureOptions();        if ($configure_options) {            foreach ($configure_options as $o) {                $default = array_key_exists('default', $o) ? $o['default'] : null;                list($r) = $this->ui->userDialog('build',                                                 array($o['prompt']),                                                 array('text'),                                                 array($default));                if (substr($o['name'], 0, 5) == 'with-' &&                    ($r == 'yes' || $r == 'autodetect')) {                    $configure_command .= " --$o[name]";                } else {                    $configure_command .= " --$o[name]=".trim($r);                }            }        }        // }}} end of interactive part        // FIXME make configurable        if(!$user=getenv('USER')){            $user='defaultuser';        }        $build_basedir = "/var/tmp/pear-build-$user";        $build_dir = "$build_basedir/$vdir";        $inst_dir = "$build_basedir/install-$vdir";        $this->log(1, "building in $build_dir");        if (is_dir($build_dir)) {            System::rm(array('-rf', $build_dir));        }        if (!System::mkDir(array('-p', $build_dir))) {            return $this->raiseError("could not create build dir: $build_dir");        }        $this->addTempFile($build_dir);        if (!System::mkDir(array('-p', $inst_dir))) {            return $this->raiseError("could not create temporary install dir: $inst_dir");        }        $this->addTempFile($inst_dir);        if (getenv('MAKE')) {            $make_command = getenv('MAKE');        } else {            $make_command = 'make';        }        $to_run = array(            $configure_command,            $make_command,            "$make_command INSTALL_ROOT=\"$inst_dir\" install",            "find \"$inst_dir\" -ls"            );        if (!file_exists($build_dir) || !is_dir($build_dir) || !chdir($build_dir)) {            return $this->raiseError("could not chdir to $build_dir");        }        putenv('PHP_PEAR_VERSION=1.6.1');        foreach ($to_run as $cmd) {            $err = $this->_runCommand($cmd, $callback);            if (PEAR::isError($err)) {                chdir($old_cwd);                return $err;            }            if (!$err) {                chdir($old_cwd);                return $this->raiseError("`$cmd' failed");            }        }        if (!($dp = opendir("modules"))) {            chdir($old_cwd);            return $this->raiseError("no `modules' directory found");        }        $built_files = array();        $prefix = exec("php-config --prefix");        $this->_harvestInstDir($prefix, $inst_dir . DIRECTORY_SEPARATOR . $prefix, $built_files);        chdir($old_cwd);        return $built_files;    }    // }}}    // {{{ phpizeCallback()    /**     * Message callback function used when running the "phpize"     * program.  Extracts the API numbers used.  Ignores other message     * types than "cmdoutput".     *     * @param string $what the type of message     * @param mixed $data the message     *     * @return void     *     * @access public     */    function phpizeCallback($what, $data)    {        if ($what != 'cmdoutput') {            return;        }        $this->log(1, rtrim($data));        if (preg_match('/You should update your .aclocal.m4/', $data)) {            return;        }        $matches = array();        if (preg_match('/^\s+(\S[^:]+):\s+(\d{8})/', $data, $matches)) {            $member = preg_replace('/[^a-z]/', '_', strtolower($matches[1]));            $apino = (int)$matches[2];            if (isset($this->$member)) {                $this->$member = $apino;                //$msg = sprintf("%-22s : %d", $matches[1], $apino);                //$this->log(1, $msg);            }        }    }    // }}}    // {{{ _runCommand()    /**     * Run an external command, using a message callback to report     * output.  The command will be run through popen and output is     * reported for every line with a "cmdoutput" message with the     * line string, including newlines, as payload.     *     * @param string $command the command to run     *     * @param mixed $callback (optional) function to use as message     * callback     *     * @return bool whether the command was successful (exit code 0     * means success, any other means failure)     *     * @access private     */    function _runCommand($command, $callback = null)    {        $this->log(1, "running: $command");        $pp = popen("$command 2>&1", "r");        if (!$pp) {            return $this->raiseError("failed to run `$command'");        }        if ($callback && $callback[0]->debug == 1) {            $olddbg = $callback[0]->debug;            $callback[0]->debug = 2;        }        while ($line = fgets($pp, 1024)) {            if ($callback) {                call_user_func($callback, 'cmdoutput', $line);            } else {                $this->log(2, rtrim($line));            }        }        if ($callback && isset($olddbg)) {            $callback[0]->debug = $olddbg;        }        if (is_resource($pp)) {            $exitcode = pclose($pp);        } else {            $exitcode = -1;        }        return ($exitcode == 0);    }    // }}}    // {{{ log()    function log($level, $msg)    {        if ($this->current_callback) {            if ($this->debug >= $level) {                call_user_func($this->current_callback, 'output', $msg);            }            return;        }        return PEAR_Common::log($level, $msg);    }    // }}}}?>

⌨️ 快捷键说明

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