📄 pickle.php
字号:
<?php/** * PEAR_Command_Pickle (pickle command) * * 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 Greg Beaver <cellog@php.net> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Pickle.php,v 1.1.2.1 2005/11/02 16:57:23 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.4.1 *//** * base class */require_once 'PEAR/Command/Common.php';/** * PEAR commands for login/logout * * @category pear * @package PEAR * @author Greg Beaver <cellog@php.net> * @copyright 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 1.4.1 */class PEAR_Command_Pickle extends PEAR_Command_Common{ var $commands = array( 'pickle' => array( 'summary' => 'Build PECL Package', 'function' => 'doPackage', 'shortcut' => 'pi', 'options' => array( 'nocompress' => array( 'shortopt' => 'Z', 'doc' => 'Do not gzip the package file' ), 'showname' => array( 'shortopt' => 'n', 'doc' => 'Print the name of the packaged file.', ), ), 'doc' => '[descfile]Creates a PECL package from its package2.xml file.An automatic conversion will be made to a package.xml 1.0 and written out todisk in the current directory as "package.xml". Note thatonly simple package.xml 2.0 will be converted. package.xml 2.0 with: - dependency types other than required/optional PECL package/ext/php/pearinstaller - more than one extsrcrelease - extbinrelease, phprelease, or bundle release type - dependency groups - ignore tags in release filelist - tasks other than replace - custom roleswill cause pickle to fail, and output an error message. If your package2.xmluses any of these features, you are best off using PEAR_PackageFileManager togenerate both package.xml.' ), ); /** * PEAR_Command_Package constructor. * * @access public */ function PEAR_Command_Pickle(&$ui, &$config) { parent::PEAR_Command_Common($ui, $config); } /** * For unit-testing ease * * @return PEAR_Packager */ function &getPackager() { if (!class_exists('PEAR_Packager')) { require_once 'PEAR/Packager.php'; } $a = &new PEAR_Packager; return $a; } /** * For unit-testing ease * * @param PEAR_Config $config * @param bool $debug * @param string|null $tmpdir * @return PEAR_PackageFile */ function &getPackageFile($config, $debug = false, $tmpdir = null) { if (!class_exists('PEAR_Common')) { require_once 'PEAR/Common.php'; } if (!class_exists('PEAR/PackageFile.php')) { require_once 'PEAR/PackageFile.php'; } $a = &new PEAR_PackageFile($config, $debug, $tmpdir); $common = new PEAR_Common; $common->ui = $this->ui; $a->setLogger($common); return $a; } function doPackage($command, $options, $params) { $this->output = ''; $pkginfofile = isset($params[0]) ? $params[0] : 'package2.xml'; $packager = &$this->getPackager(); if (PEAR::isError($err = $this->_convertPackage($pkginfofile))) { return $err; } $compress = empty($options['nocompress']) ? true : false; $result = $packager->package($pkginfofile, $compress, 'package.xml'); if (PEAR::isError($result)) { return $this->raiseError($result); } // Don't want output, only the package file name just created if (isset($options['showname'])) { $this->ui->outputData($result, $command); } return true; } function _convertPackage($packagexml) { $pkg = &$this->getPackageFile($this->config); $pf2 = &$pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL); if (!is_a($pf2, 'PEAR_PackageFile_v2')) { return $this->raiseError('Cannot process "' . $packagexml . '", is not a package.xml 2.0'); } require_once 'PEAR/PackageFile/v1.php'; $pf = new PEAR_PackageFile_v1; $pf->setConfig($this->config); if (is_array($pf2->getPackageType() != 'extsrc')) { return $this->raiseError('Cannot safely convert "' . $packagexml . '", is not an extension source package. Using a PEAR_PackageFileManager-based ' . 'script is an option'); } if (is_array($pf2->getUsesRole())) { return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom roles. Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option'); } if (is_array($pf2->getUsesTask())) { return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom tasks. Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option'); } $deps = $pf2->getDependencies(); if (isset($deps['group'])) { return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains dependency groups. Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option'); } if (isset($deps['required']['subpackage']) || isset($deps['optional']['subpackage'])) { return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains subpackage dependencies. Using a PEAR_PackageFileManager-based '. 'script is an option'); } if (isset($deps['required']['os'])) { return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains os dependencies. Using a PEAR_PackageFileManager-based '. 'script is an option');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -