PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/downloader/pearlib/php/PEAR/PackageFileManager.php

https://github.com/organicinternet/magento-design-training
PHP | 1764 lines | 1186 code | 30 blank | 548 comment | 117 complexity | 0fdd6bf5acb600769f7086552492c11d MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * PEAR_PackageFileManager is designed to create and manipulate
  4. * package.xml version 1.0 only.
  5. *
  6. * PHP versions 4 and 5
  7. *
  8. * LICENSE: This source file is subject to version 3.01 of the PHP license
  9. * that is available through the world-wide-web at the following URI:
  10. * http://www.php.net/license/3_01.txt. If you did not receive a copy of
  11. * the PHP License and are unable to obtain it through the web, please
  12. * send a note to license@php.net so we can mail you a copy immediately.
  13. *
  14. * @category PEAR
  15. * @package PEAR_PackageFileManager
  16. * @author Greg Beaver <cellog@php.net>
  17. * @copyright 2003-2007 The PHP Group
  18. * @license http://www.php.net/license/3_01.txt PHP License 3.01
  19. * @version CVS: $Id: PackageFileManager.php,v 1.59 2007/11/19 22:10:41 farell Exp $
  20. * @link http://pear.php.net/package/PEAR_PackageFileManager
  21. * @since File available since Release 0.1
  22. */
  23. /**
  24. * PEAR installer
  25. */
  26. require_once 'PEAR/Common.php';
  27. /**#@+
  28. * Error Codes
  29. */
  30. define('PEAR_PACKAGEFILEMANAGER_NOSTATE', 1);
  31. define('PEAR_PACKAGEFILEMANAGER_NOVERSION', 2);
  32. define('PEAR_PACKAGEFILEMANAGER_NOPKGDIR', 3);
  33. define('PEAR_PACKAGEFILEMANAGER_NOBASEDIR', 4);
  34. define('PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND', 5);
  35. define('PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND_ANYWHERE', 6);
  36. define('PEAR_PACKAGEFILEMANAGER_CANTWRITE_PKGFILE', 7);
  37. define('PEAR_PACKAGEFILEMANAGER_DEST_UNWRITABLE', 8);
  38. define('PEAR_PACKAGEFILEMANAGER_CANTCOPY_PKGFILE', 9);
  39. define('PEAR_PACKAGEFILEMANAGER_CANTOPEN_TMPPKGFILE', 10);
  40. define('PEAR_PACKAGEFILEMANAGER_PATH_DOESNT_EXIST', 11);
  41. define('PEAR_PACKAGEFILEMANAGER_NOCVSENTRIES', 12);
  42. define('PEAR_PACKAGEFILEMANAGER_DIR_DOESNT_EXIST', 13);
  43. define('PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS', 14);
  44. define('PEAR_PACKAGEFILEMANAGER_NOPACKAGE', 15);
  45. define('PEAR_PACKAGEFILEMANAGER_WRONG_MROLE', 16);
  46. define('PEAR_PACKAGEFILEMANAGER_NOSUMMARY', 17);
  47. define('PEAR_PACKAGEFILEMANAGER_NODESC', 18);
  48. define('PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS', 19);
  49. define('PEAR_PACKAGEFILEMANAGER_NO_FILES', 20);
  50. define('PEAR_PACKAGEFILEMANAGER_IGNORED_EVERYTHING', 21);
  51. define('PEAR_PACKAGEFILEMANAGER_INVALID_PACKAGE', 22);
  52. define('PEAR_PACKAGEFILEMANAGER_INVALID_REPLACETYPE', 23);
  53. define('PEAR_PACKAGEFILEMANAGER_INVALID_ROLE', 24);
  54. define('PEAR_PACKAGEFILEMANAGER_PHP_NOT_PACKAGE', 25);
  55. define('PEAR_PACKAGEFILEMANAGER_CVS_PACKAGED', 26);
  56. define('PEAR_PACKAGEFILEMANAGER_NO_PHPCOMPATINFO', 27);
  57. define('PEAR_PACKAGEFILEMANAGER_NONOTES', 28);
  58. define('PEAR_PACKAGEFILEMANAGER_NOLICENSE', 29);
  59. /**#@-*/
  60. /**
  61. * Error messages
  62. * @global array $GLOBALS['_PEAR_PACKAGEFILEMANAGER_ERRORS']
  63. */
  64. $GLOBALS['_PEAR_PACKAGEFILEMANAGER_ERRORS'] =
  65. array(
  66. 'en' =>
  67. array(
  68. PEAR_PACKAGEFILEMANAGER_NOSTATE =>
  69. 'Release State (option \'state\') must by specified in PEAR_PackageFileManager ' .
  70. 'setOptions (snapshot|devel|alpha|beta|stable)',
  71. PEAR_PACKAGEFILEMANAGER_NOVERSION =>
  72. 'Release Version (option \'version\') must be specified in PEAR_PackageFileManager setOptions',
  73. PEAR_PACKAGEFILEMANAGER_NOPKGDIR =>
  74. 'Package source base directory (option \'packagedirectory\') must be ' .
  75. 'specified in PEAR_PackageFileManager setOptions',
  76. PEAR_PACKAGEFILEMANAGER_NOBASEDIR =>
  77. 'Package install base directory (option \'baseinstalldir\') must be ' .
  78. 'specified in PEAR_PackageFileManager setOptions',
  79. PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND =>
  80. 'Base class "%s" can\'t be located',
  81. PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND_ANYWHERE =>
  82. 'Base class "%s" can\'t be located in default or user-specified directories',
  83. PEAR_PACKAGEFILEMANAGER_CANTWRITE_PKGFILE =>
  84. 'Failed to write package.xml file to destination directory',
  85. PEAR_PACKAGEFILEMANAGER_DEST_UNWRITABLE =>
  86. 'Destination directory "%s" is unwritable',
  87. PEAR_PACKAGEFILEMANAGER_CANTCOPY_PKGFILE =>
  88. 'Failed to copy package.xml.tmp file to package.xml',
  89. PEAR_PACKAGEFILEMANAGER_CANTOPEN_TMPPKGFILE =>
  90. 'Failed to open temporary file "%s" for writing',
  91. PEAR_PACKAGEFILEMANAGER_PATH_DOESNT_EXIST =>
  92. 'package.xml file path "%s" doesn\'t exist or isn\'t a directory',
  93. PEAR_PACKAGEFILEMANAGER_NOCVSENTRIES =>
  94. 'Directory "%s" is not a CVS directory (it must have the CVS/Entries file)',
  95. PEAR_PACKAGEFILEMANAGER_DIR_DOESNT_EXIST =>
  96. 'Package source base directory "%s" doesn\'t exist or isn\'t a directory',
  97. PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS =>
  98. 'Run $managerclass->setOptions() before any other methods',
  99. PEAR_PACKAGEFILEMANAGER_NOPACKAGE =>
  100. 'Package Name (option \'package\') must by specified in PEAR_PackageFileManager '.
  101. 'setOptions to create a new package.xml',
  102. PEAR_PACKAGEFILEMANAGER_NOSUMMARY =>
  103. 'Package Summary (option \'summary\') must by specified in PEAR_PackageFileManager' .
  104. ' setOptions to create a new package.xml',
  105. PEAR_PACKAGEFILEMANAGER_NODESC =>
  106. 'Detailed Package Description (option \'description\') must be' .
  107. ' specified in PEAR_PackageFileManager setOptions to create a new package.xml',
  108. PEAR_PACKAGEFILEMANAGER_WRONG_MROLE =>
  109. 'Maintainer role must be one of "%s", was "%s"',
  110. PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS =>
  111. 'Add maintainers to a package before generating the package.xml',
  112. PEAR_PACKAGEFILEMANAGER_NO_FILES =>
  113. 'No files found, check the path "%s"',
  114. PEAR_PACKAGEFILEMANAGER_IGNORED_EVERYTHING =>
  115. 'No files left, check the path "%s" and ignore option "%s"',
  116. PEAR_PACKAGEFILEMANAGER_INVALID_PACKAGE =>
  117. 'Package validation failed:%s%s',
  118. PEAR_PACKAGEFILEMANAGER_INVALID_REPLACETYPE =>
  119. 'Replacement Type must be one of "%s", was passed "%s"',
  120. PEAR_PACKAGEFILEMANAGER_INVALID_ROLE =>
  121. 'Invalid file role passed to addRole, must be one of "%s", was passed "%s"',
  122. PEAR_PACKAGEFILEMANAGER_PHP_NOT_PACKAGE =>
  123. 'addDependency had PHP as a package, use type="php"',
  124. PEAR_PACKAGEFILEMANAGER_CVS_PACKAGED =>
  125. 'path "%path%" contains CVS directory',
  126. PEAR_PACKAGEFILEMANAGER_NO_PHPCOMPATINFO =>
  127. 'PHP_Compat is not installed, cannot detect dependencies',
  128. PEAR_PACKAGEFILEMANAGER_NONOTES =>
  129. 'Release Notes (option \'notes\') must be specified in PEAR_PackageFileManager setOptions',
  130. PEAR_PACKAGEFILEMANAGER_NOLICENSE =>
  131. 'Release License (option \'license\') must be specified in PEAR_PackageFileManager setOptions',
  132. ),
  133. // other language translations go here
  134. );
  135. /**
  136. * PEAR :: PackageFileManager updates the <filelist></filelist> section
  137. * of a PEAR package.xml file to reflect the current files in
  138. * preparation for a release.
  139. *
  140. * The PEAR_PackageFileManager class uses a plugin system to generate the
  141. * list of files in a package. This allows both standard recursive
  142. * directory parsing (plugin type file) and more intelligent options
  143. * such as the CVS browser {@link PEAR_PackageFileManager_Cvs}, which
  144. * grabs all files in a local CVS checkout to create the list, ignoring
  145. * any other local files.
  146. *
  147. * Other options include specifying roles for file extensions (all .php
  148. * files are role="php", for example), roles for directories (all directories
  149. * named "tests" are given role="tests" by default), and exceptions.
  150. * Exceptions are specific pathnames with * and ? wildcards that match
  151. * a default role, but should have another. For example, perhaps
  152. * a debug.tpl template would normally be data, but should be included
  153. * in the docs role. Along these lines, to exclude files entirely,
  154. * use the ignore option.
  155. *
  156. * Required options for a release include version, baseinstalldir, state,
  157. * and packagedirectory (the full path to the local location of the
  158. * package to create a package.xml file for)
  159. *
  160. * Example usage:
  161. * <code>
  162. * <?php
  163. * require_once('PEAR/PackageFileManager.php');
  164. * $packagexml = new PEAR_PackageFileManager;
  165. * $e = $packagexml->setOptions(
  166. * array('baseinstalldir' => 'PhpDocumentor',
  167. * 'version' => '1.2.1',
  168. * 'packagedirectory' => 'C:/Web Pages/chiara/phpdoc2/',
  169. * 'state' => 'stable',
  170. * 'filelistgenerator' => 'cvs', // generate from cvs, use file for directory
  171. * 'notes' => 'We\'ve implemented many new and exciting features',
  172. * 'ignore' => array('TODO', 'tests/'), // ignore TODO, all files in tests/
  173. * 'installexceptions' => array('phpdoc' => '/*'), // baseinstalldir ="/" for phpdoc
  174. * 'dir_roles' => array('tutorials' => 'doc'),
  175. * 'exceptions' => array('README' => 'doc', // README would be data, now is doc
  176. * 'PHPLICENSE.txt' => 'doc'))); // same for the license
  177. * if (PEAR::isError($e)) {
  178. * echo $e->getMessage();
  179. * die();
  180. * }
  181. * $e = $test->addPlatformException('pear-phpdoc.bat', 'windows');
  182. * if (PEAR::isError($e)) {
  183. * echo $e->getMessage();
  184. * exit;
  185. * }
  186. * $packagexml->addRole('pkg', 'doc'); // add a new role mapping
  187. * if (PEAR::isError($e)) {
  188. * echo $e->getMessage();
  189. * exit;
  190. * }
  191. * // replace @PHP-BIN@ in this file with the path to php executable! pretty neat
  192. * $e = $test->addReplacement('pear-phpdoc', 'pear-config', '@PHP-BIN@', 'php_bin');
  193. * if (PEAR::isError($e)) {
  194. * echo $e->getMessage();
  195. * exit;
  196. * }
  197. * $e = $test->addReplacement('pear-phpdoc.bat', 'pear-config', '@PHP-BIN@', 'php_bin');
  198. * if (PEAR::isError($e)) {
  199. * echo $e->getMessage();
  200. * exit;
  201. * }
  202. * // note use of {@link debugPackageFile()} - this is VERY important
  203. * if (isset($_GET['make']) || (isset($_SERVER['argv'][2]) &&
  204. * $_SERVER['argv'][2] == 'make')) {
  205. * $e = $packagexml->writePackageFile();
  206. * } else {
  207. * $e = $packagexml->debugPackageFile();
  208. * }
  209. * if (PEAR::isError($e)) {
  210. * echo $e->getMessage();
  211. * die();
  212. * }
  213. * ?>
  214. * </code>
  215. *
  216. * In addition, a package.xml file can now be generated from
  217. * scratch, with the usage of new options package, summary, description, and
  218. * the use of the {@link addMaintainer()} method
  219. *
  220. * @category PEAR
  221. * @package PEAR_PackageFileManager
  222. * @author Greg Beaver <cellog@php.net>
  223. * @copyright 2003-2007 The PHP Group
  224. * @license http://www.php.net/license/3_01.txt PHP License 3.01
  225. * @version Release: 1.6.3
  226. * @link http://pear.php.net/package/PEAR_PackageFileManager
  227. * @since Class available since Release 0.1
  228. */
  229. class PEAR_PackageFileManager
  230. {
  231. /**
  232. * Format: array(array(regexp-ready string to search for whole path,
  233. * regexp-ready string to search for basename of ignore strings),...)
  234. * @var false|array
  235. * @access private
  236. * @since 0.1
  237. */
  238. var $_ignore = false;
  239. /**
  240. * Contents of the package.xml file
  241. * @var string
  242. * @access private
  243. * @since 0.1
  244. */
  245. var $_packageXml = false;
  246. /**
  247. * Contents of the original package.xml file, if any
  248. * @var string
  249. * @access private
  250. * @since 0.9
  251. */
  252. var $_oldPackageXml = false;
  253. /**
  254. * @access private
  255. * @var PEAR_Common
  256. * @since 0.9
  257. */
  258. var $_pear;
  259. /**
  260. * List of warnings
  261. * @var array
  262. * @access private
  263. * @since 1.1.0
  264. */
  265. var $_warningStack = array();
  266. /**
  267. * flag used to determine whether to use PHP_CompatInfo to detect deps
  268. * @var boolean
  269. * @access private
  270. * @since 1.3.0
  271. */
  272. var $_detectDependencies = false;
  273. /**
  274. * @access private
  275. * @var string
  276. * @since 0.1
  277. */
  278. var $_options = array(
  279. 'packagefile' => 'package.xml',
  280. 'doctype' => 'http://pear.php.net/dtd/package-1.0',
  281. 'filelistgenerator' => 'file',
  282. 'license' => 'PHP License',
  283. 'changelogoldtonew' => true,
  284. 'roles' =>
  285. array(
  286. 'h' => 'src',
  287. 'c' => 'src',
  288. 'm4' => 'src',
  289. 'w32' => 'src',
  290. 'dll' => 'ext',
  291. 'php' => 'php',
  292. 'html' => 'doc',
  293. '*' => 'data',
  294. ),
  295. 'dir_roles' =>
  296. array(
  297. 'docs' => 'doc',
  298. 'examples' => 'doc',
  299. 'tests' => 'test',
  300. ),
  301. 'exceptions' => array(),
  302. 'installexceptions' => array(),
  303. 'installas' => array(),
  304. 'platformexceptions' => array(),
  305. 'scriptphaseexceptions' => array(),
  306. 'ignore' => array(),
  307. 'include' => false,
  308. 'deps' => false,
  309. 'maintainers' => false,
  310. 'notes' => '',
  311. 'changelognotes' => false,
  312. 'outputdirectory' => false,
  313. 'pathtopackagefile' => false,
  314. 'lang' => 'en',
  315. 'configure_options' => array(),
  316. 'replacements' => array(),
  317. 'pearcommonclass' => false,
  318. 'simpleoutput' => false,
  319. 'addhiddenfiles' => false,
  320. 'cleardependencies' => false,
  321. );
  322. /**
  323. * Does nothing, use setOptions
  324. *
  325. * The constructor is not used in order to be able to
  326. * return a PEAR_Error from setOptions
  327. *
  328. * @see setOptions()
  329. * @access public
  330. * @since 0.1
  331. */
  332. function PEAR_PackageFileManager()
  333. {
  334. }
  335. /**
  336. * Set package.xml generation options
  337. *
  338. * The options array is indexed as follows:
  339. * <code>
  340. * $options = array('option_name' => <optionvalue>);
  341. * </code>
  342. *
  343. * The documentation below simplifies this description through
  344. * the use of option_name without quotes
  345. *
  346. * Configuration options:
  347. * - lang: lang controls the language in which error messages are
  348. * displayed. There are currently only English error messages,
  349. * but any contributed will be added over time.<br>
  350. * Possible values: en (default)
  351. * - packagefile: the name of the packagefile, defaults to package.xml
  352. * - pathtopackagefile: the path to an existing package file to read in,
  353. * if different from the packagedirectory
  354. * - packagedirectory: the path to the base directory of the package. For
  355. * package PEAR_PackageFileManager, this path is
  356. * /path/to/pearcvs/pear/PEAR_PackageFileManager where
  357. * /path/to/pearcvs is a local path on your hard drive
  358. * - outputdirectory: the path in which to place the generated package.xml
  359. * by default, this is ignored, and the package.xml is
  360. * created in the packagedirectory
  361. * - filelistgenerator: the <filelist> section plugin which will be used.
  362. * In this release, there are two generator plugins,
  363. * file and cvs. For details, see the docs for these
  364. * plugins
  365. * - usergeneratordir: For advanced users. If you write your own filelist
  366. * generator plugin, use this option to tell
  367. * PEAR_PackageFileManager where to find the file that
  368. * contains it. If the plugin is named foo, the class
  369. * must be named PEAR_PackageFileManager_Foo
  370. * no matter where it is located. By default, the Foo
  371. * plugin is located in PEAR/PackageFileManager/Foo.php.
  372. * If you pass /path/to/foo in this option, setOptions
  373. * will look for PEAR_PackageFileManager_Foo in
  374. * /path/to/foo/Foo.php
  375. * - doctype: Specifies the DTD of the package.xml file. Default is
  376. * http://pear.php.net/dtd/package-1.0
  377. * - pearcommonclass: Specifies the name of the class to instantiate, default
  378. * is PEAR_PackageFileManager_ComplexGenerator or PEAR_Common, but users can
  379. * override this with a custom class that implements
  380. * PEAR_Common's method interface
  381. * - changelogoldtonew: True if the ChangeLog should list from oldest entry to
  382. * newest. Set to false if you would like new entries first
  383. * - simpleoutput: True if the package.xml should not contain md5sum or <provides />
  384. * for readability
  385. * - addhiddenfiles: True if you wish to add hidden files/directories that begin with .
  386. * like .bashrc. This is only used by the File generator. The CVS
  387. * generator will use all files in CVS regardless of format
  388. *
  389. * package.xml simple options:
  390. * - baseinstalldir: The base directory to install this package in. For
  391. * package PEAR_PackageFileManager, this is "PEAR", for
  392. * package PEAR, this is "/"
  393. * - license: The license this release is released under. Default is
  394. * PHP License if left unspecified
  395. * - notes: Release notes, any text describing what makes this release unique
  396. * - changelognotes: notes for the changelog, this should be more detailed than
  397. * the release notes. By default, PEAR_PackageFileManager uses
  398. * the notes option for the changelog as well
  399. * - version: The version number for this release. Remember the convention for
  400. * numbering: initial alpha is between 0 and 1, add b<beta number> for
  401. * beta as in 1.0b1, the integer portion of the version should specify
  402. * backwards compatibility, as in 1.1 is backwards compatible with 1.0,
  403. * but 2.0 is not backwards compatible with 1.10. Also note that 1.10
  404. * is a greater release version than 1.1 (think of it as "one point ten"
  405. * and "one point one"). Bugfix releases should be a third decimal as in
  406. * 1.0.1, 1.0.2
  407. * - package: [optional] Package name. Use this to create a new package.xml, or
  408. * overwrite an existing one from another package used as a template
  409. * - summary: [optional] Summary of package purpose
  410. * - description: [optional] Description of package purpose. Note that the above
  411. * three options are not optional when creating a new package.xml
  412. * from scratch
  413. *
  414. * <b>WARNING</b>: all complex options that require a file path are case-sensitive
  415. *
  416. * package.xml complex options:
  417. * - cleardependencies: since version 1.3.0, this option will erase any existing
  418. * dependencies in the package.xml if set to true
  419. * - ignore: an array of filenames, directory names, or wildcard expressions specifying
  420. * files to exclude entirely from the package.xml. Wildcards are operating system
  421. * wildcards * and ?. file*foo.php will exclude filefoo.php, fileabrfoo.php and
  422. * filewho_is_thisfoo.php. file?foo.php will exclude fileafoo.php and will not
  423. * exclude fileaafoo.php. test/ will exclude all directories and subdirectories of
  424. * ANY directory named test encountered in directory parsing. *test* will exclude
  425. * all files and directories that contain test in their name
  426. * - include: an array of filenames, directory names, or wildcard expressions specifying
  427. * files to include in the listing. All other files will be ignored.
  428. * Wildcards are in the same format as ignore
  429. * - roles: this is an array mapping file extension to install role. This
  430. * specifies default behavior that can be overridden by the exceptions
  431. * option and dir_roles option. use {@link addRole()} to add a new
  432. * role to the pre-existing array
  433. * - dir_roles: this is an array mapping directory name to install role. All
  434. * files in a directory whose name matches the directory will be
  435. * given the install role specified. Single files can be excluded
  436. * from this using the exceptions option. The directory should be
  437. * a relative path from the baseinstalldir, or "/" for the baseinstalldir
  438. * - exceptions: specify file role for specific files. This array maps all files
  439. * matching the exact name of a file to a role as in "file.ext" => "role"
  440. * - deps: dependency array. Pass in an empty array to clear all dependencies, and use
  441. * {@link addDependency()} to add new ones/replace existing ones
  442. * - maintainers: maintainers array. Pass in an empty array to clear all maintainers, and
  443. * use {@link addMaintainer()} to add a new maintainer/replace existing maintainer
  444. * - installexceptions: array mapping of specific filenames to baseinstalldir values. Use
  445. * this to force the installation of a file into another directory,
  446. * such as forcing a script to be in the root scripts directory so that
  447. * it will be in the path. The filename must be a relative path to the
  448. * packagedirectory
  449. * - platformexceptions: array mapping of specific filenames to the platform they should be
  450. * installed on. Use this to specify unix-only files or windows-only
  451. * files. The format of the platform string must be
  452. * OS-version-cpu-extra if any more specific information is needed,
  453. * and the OS must be in lower case as in "windows." The match is
  454. * performed using a regular expression, but uses * and ? wildcards
  455. * instead of .* and .?. Note that hpux/aix/irix/linux are all
  456. * exclusive. To select non-windows, use (*ix|*ux)
  457. * - scriptphaseexceptions: array mapping of scripts to their install phase. This can be
  458. * one of: pre-install, post-install, pre-uninstall, post-uninstall,
  459. * pre-build, post-build, pre-setup, or post-setup
  460. * - installas: array mapping of specific filenames to the filename they should be installed as.
  461. * Use this to specify new filenames for files that should be installed. This will
  462. * often be used in conjunction with platformexceptions if there are two files for
  463. * different OSes that must have the same name when installed.
  464. * - replacements: array mapping of specific filenames to complex text search-and-replace that
  465. * should be performed upon install. The format is:
  466. * <pre>
  467. * filename => array('type' => php-const|pear-config|package-info
  468. * 'from' => text in file
  469. * 'to' => name of variable)
  470. * </pre>
  471. * if type is php-const, then 'to' must be the name of a PHP Constant.
  472. * If type is pear-config, then 'to' must be the name of a PEAR config
  473. * variable accessible through a PEAR_Config class->get() method. If
  474. * type is package-info, then 'to' must be the name of a section from
  475. * the package.xml file used to install this file.
  476. * - globalreplacements: a list of replacements that should be performed on every single file.
  477. * The format is the same as replacements (since 1.4.0)
  478. * - configure_options: array specifies build options for PECL packages (you should probably
  479. * use PECL_Gen instead, but it's here for completeness)
  480. *
  481. * @param array $options (optional) list of generation options
  482. * @param boolean $internal (optional) private function call
  483. *
  484. * @see PEAR_PackageFileManager_File
  485. * @see PEAR_PackageFileManager_CVS
  486. * @return void|PEAR_Error
  487. * @throws PEAR_PACKAGEFILEMANAGER_NOSTATE
  488. * @throws PEAR_PACKAGEFILEMANAGER_NOVERSION
  489. * @throws PEAR_PACKAGEFILEMANAGER_NOPKGDIR
  490. * @throws PEAR_PACKAGEFILEMANAGER_NOBASEDIR
  491. * @throws PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND_ANYWHERE
  492. * @throws PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND
  493. * @access public
  494. * @since 0.1
  495. */
  496. function setOptions($options = array(), $internal = false)
  497. {
  498. if (!$internal) {
  499. if (!isset($options['state']) || empty($options['state'])) {
  500. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOSTATE);
  501. }
  502. if (!isset($options['version']) || empty($options['version'])) {
  503. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOVERSION);
  504. }
  505. }
  506. if (!isset($options['packagedirectory']) && !$internal) {
  507. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOPKGDIR);
  508. } elseif (isset($options['packagedirectory'])) {
  509. $options['packagedirectory'] = str_replace(DIRECTORY_SEPARATOR,
  510. '/',
  511. realpath($options['packagedirectory']));
  512. if ($options['packagedirectory']{strlen($options['packagedirectory']) - 1} != '/') {
  513. $options['packagedirectory'] .= '/';
  514. }
  515. }
  516. if (isset($options['pathtopackagefile'])) {
  517. $options['pathtopackagefile'] = str_replace(DIRECTORY_SEPARATOR,
  518. '/',
  519. realpath($options['pathtopackagefile']));
  520. if ($options['pathtopackagefile']{strlen($options['pathtopackagefile']) - 1} != '/') {
  521. $options['pathtopackagefile'] .= '/';
  522. }
  523. }
  524. if (!isset($options['baseinstalldir']) && !$internal) {
  525. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOBASEDIR);
  526. }
  527. $this->_options = array_merge($this->_options, $options);
  528. if (!isset($this->_options['roles']['*'])) {
  529. $this->_options['roles']['*'] = 'data';
  530. }
  531. if (!class_exists($this->_options['pearcommonclass'])) {
  532. if ($this->_options['simpleoutput']) {
  533. if ($this->isIncludeable('PEAR/PackageFile/Generator/v1.php')) {
  534. include_once 'PEAR/PackageFileManager/SimpleGenerator.php';
  535. $this->_options['pearcommonclass'] = 'PEAR_PackageFileManager_SimpleGenerator';
  536. } else {
  537. include_once 'PEAR/PackageFileManager/XMLOutput.php';
  538. $this->_options['pearcommonclass'] = 'PEAR_PackageFileManager_XMLOutput';
  539. }
  540. } else {
  541. if ($this->isIncludeable('PEAR/PackageFile/Generator/v1.php')) {
  542. include_once 'PEAR/PackageFileManager/ComplexGenerator.php';
  543. $this->_options['pearcommonclass'] = 'PEAR_PackageFileManager_ComplexGenerator';
  544. } else {
  545. $this->_options['pearcommonclass'] = 'PEAR_Common';
  546. }
  547. }
  548. }
  549. $path = ($this->_options['pathtopackagefile'] ?
  550. $this->_options['pathtopackagefile'] : $this->_options['packagedirectory']);
  551. $this->_options['filelistgenerator'] =
  552. ucfirst(strtolower($this->_options['filelistgenerator']));
  553. if (!$internal) {
  554. if (PEAR::isError($res =
  555. $this->_getExistingPackageXML($path, $this->_options['packagefile']))) {
  556. return $res;
  557. }
  558. }
  559. // file generator resource to load
  560. $resource = 'PEAR/PackageFileManager/' . $this->_options['filelistgenerator'] . '.php';
  561. // file generator class name
  562. $className = substr($resource, 0, -4);
  563. $className = str_replace('/', '_', $className);
  564. if (!class_exists($className)) {
  565. // attempt to load the interface from the standard PEAR location
  566. if ($this->isIncludeable($resource)) {
  567. include_once $resource;
  568. } elseif (isset($this->_options['usergeneratordir'])) {
  569. // attempt to load from a user-specified directory
  570. if (is_dir(realpath($this->_options['usergeneratordir']))) {
  571. $this->_options['usergeneratordir'] =
  572. str_replace(DIRECTORY_SEPARATOR,
  573. '/',
  574. realpath($this->_options['usergeneratordir']));
  575. if ($this->_options['usergeneratordir']{strlen($this->_options['usergeneratordir'])
  576. - 1} != '/') {
  577. $this->_options['usergeneratordir'] .= '/';
  578. }
  579. } else {
  580. $this->_options['usergeneratordir'] = '////';
  581. }
  582. $usergenerator = $this->_options['usergeneratordir'] .
  583. $this->_options['filelistgenerator'] . '.php';
  584. if (file_exists($usergenerator) && is_readable($usergenerator)) {
  585. include_once $usergenerator;
  586. }
  587. if (!class_exists($className)) {
  588. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND_ANYWHERE,
  589. $className);
  590. }
  591. } else {
  592. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND,
  593. $className);
  594. }
  595. }
  596. }
  597. /**
  598. * Import options from an existing package.xml
  599. *
  600. * @param string $packagefile name of package file
  601. * @param array $options (optional) list of generation options
  602. *
  603. * @return true|PEAR_Error
  604. * @access public
  605. * @since 1.5.0
  606. */
  607. function importOptions($packagefile, $options = array())
  608. {
  609. $options['deps'] = $options['maintainers'] = false;
  610. $this->setOptions($options, true);
  611. if (PEAR::isError($res = $this->_getExistingPackageXML(dirname($packagefile) .
  612. DIRECTORY_SEPARATOR, basename($packagefile)))) {
  613. return $res;
  614. }
  615. $this->_options['package'] = $this->_oldPackageXml['package'];
  616. $this->_options['summary'] = $this->_oldPackageXml['summary'];
  617. $this->_options['description'] = $this->_oldPackageXml['description'];
  618. $this->_options['date'] = $this->_oldPackageXml['release_date'];
  619. $this->_options['version'] = $this->_oldPackageXml['version'];
  620. $this->_options['license'] = $this->_oldPackageXml['release_license'];
  621. $this->_options['state'] = $this->_oldPackageXml['release_state'];
  622. $this->_options['notes'] = $this->_oldPackageXml['release_notes'];
  623. $this->setOptions($options, true);
  624. if (isset($this->_packageXml['release_deps'])) {
  625. $this->_options['deps'] = $this->_packageXml['release_deps'];
  626. }
  627. $this->_options['maintainers'] = $this->_oldPackageXml['maintainers'];
  628. return true;
  629. }
  630. /**
  631. * Get the existing options
  632. *
  633. * @return array
  634. * @access public
  635. * @since 1.5.0
  636. */
  637. function getOptions()
  638. {
  639. return $this->_options;
  640. }
  641. /**
  642. * Add an extension/role mapping to the role mapping option
  643. *
  644. * Roles influence both where a file is installed and how it is installed.
  645. * Files with role="data" are in a completely different directory hierarchy
  646. * from the program files of role="php"
  647. *
  648. * In PEAR 1.3b2, these roles are
  649. * - php (most common)
  650. * - data
  651. * - doc
  652. * - test
  653. * - script (gives the file an executable attribute)
  654. * - src
  655. *
  656. * @param string $extension file extension
  657. * @param string $role role
  658. *
  659. * @return void|PEAR_Error
  660. * @throws PEAR_PACKAGEFILEMANAGER_INVALID_ROLE
  661. * @access public
  662. * @since 0.1
  663. */
  664. function addRole($extension, $role)
  665. {
  666. $roles = call_user_func(array($this->_options['pearcommonclass'], 'getfileroles'));
  667. if (!in_array($role, $roles)) {
  668. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_INVALID_ROLE, implode($roles, ', '), $role);
  669. }
  670. $this->_options['roles'][$extension] = $role;
  671. }
  672. /**
  673. * Add an install-time platform conditional install for a file
  674. *
  675. * The format of the platform string must be
  676. * OS-version-cpu-extra if any more specific information is needed,
  677. * and the OS must be in lower case as in "windows." The match is
  678. * performed using a regular expression, but uses * and ? wildcards
  679. * instead of .* and .?. Note that hpux/aix/irix/linux are all
  680. * exclusive. To select non-windows, use (*ix|*ux)
  681. *
  682. * This information is based on eyeing the source for OS/Guess.php, so
  683. * if you are unsure of what to do, read that file.
  684. *
  685. * @param string $path relative path of file (relative to packagedirectory option)
  686. * @param string $platform platform descriptor string
  687. *
  688. * @return void
  689. * @access public
  690. * @since 0.10
  691. */
  692. function addPlatformException($path, $platform)
  693. {
  694. if (!isset($this->_options['platformexceptions'])) {
  695. $this->_options['platformexceptions'] = array();
  696. }
  697. $this->_options['platformexceptions'][$path] = $platform;
  698. }
  699. /**
  700. * Add a replacement option for all files
  701. *
  702. * This sets an install-time complex search-and-replace function
  703. * allowing the setting of platform-specific variables in all
  704. * installed files.
  705. *
  706. * if $type is php-const, then $to must be the name of a PHP Constant.
  707. * If $type is pear-config, then $to must be the name of a PEAR config
  708. * variable accessible through a {@link PEAR_Config::get()} method. If
  709. * type is package-info, then $to must be the name of a section from
  710. * the package.xml file used to install this file.
  711. *
  712. * @param string $type variable type, either php-const, pear-config or package-info
  713. * @param string $from text to replace in the source file
  714. * @param string $to variable name to use for replacement
  715. *
  716. * @return void|PEAR_Error
  717. * @throws PEAR_PACKAGEFILEMANAGER_INVALID_REPLACETYPE
  718. * @access public
  719. * @since 1.4.0
  720. */
  721. function addGlobalReplacement($type, $from, $to)
  722. {
  723. if (!isset($this->_options['globalreplacements'])) {
  724. $this->_options['globalreplacements'] = array();
  725. }
  726. $types = call_user_func(array($this->_options['pearcommonclass'], 'getreplacementtypes'));
  727. if (!in_array($type, $types)) {
  728. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_INVALID_REPLACETYPE,
  729. implode($types, ', '), $type);
  730. }
  731. $this->_options['globalreplacements'][] =
  732. array('type' => $type, 'from' => $from, 'to' => $to);
  733. }
  734. /**
  735. * Add a replacement option for a file
  736. *
  737. * This sets an install-time complex search-and-replace function
  738. * allowing the setting of platform-specific variables in an
  739. * installed file.
  740. *
  741. * if $type is php-const, then $to must be the name of a PHP Constant.
  742. * If $type is pear-config, then $to must be the name of a PEAR config
  743. * variable accessible through a {@link PEAR_Config::get()} method. If
  744. * type is package-info, then $to must be the name of a section from
  745. * the package.xml file used to install this file.
  746. *
  747. * @param string $path relative path of file (relative to packagedirectory option)
  748. * @param string $type variable type, either php-const, pear-config or package-info
  749. * @param string $from text to replace in the source file
  750. * @param string $to variable name to use for replacement
  751. *
  752. * @return void|PEAR_Error
  753. * @throws PEAR_PACKAGEFILEMANAGER_INVALID_REPLACETYPE
  754. * @access public
  755. * @since 0.10
  756. */
  757. function addReplacement($path, $type, $from, $to)
  758. {
  759. if (!isset($this->_options['replacements'])) {
  760. $this->_options['replacements'] = array();
  761. }
  762. $types = call_user_func(array($this->_options['pearcommonclass'], 'getreplacementtypes'));
  763. if (!in_array($type, $types)) {
  764. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_INVALID_REPLACETYPE,
  765. implode($types, ', '), $type);
  766. }
  767. $this->_options['replacements'][$path][] = array('type' => $type, 'from' => $from, 'to' => $to);
  768. }
  769. /**
  770. * Add a maintainer to the list of maintainers.
  771. *
  772. * Every maintainer must have a valid account at pear.php.net. The
  773. * first parameter is the account name (for instance, cellog is the
  774. * handle for Greg Beaver at pear.php.net). Every maintainer has
  775. * one of four possible roles:
  776. * - lead: the primary maintainer
  777. * - developer: an important developer on the project
  778. * - contributor: self-explanatory
  779. * - helper: ditto
  780. *
  781. * Finally, specify the name and email of the maintainer
  782. *
  783. * @param string $handle username on pear.php.net of maintainer
  784. * @param string $role lead|developer|contributor|helper role of maintainer
  785. * @param string $name full name of maintainer
  786. * @param string $email email address of maintainer
  787. *
  788. * @return void|PEAR_Error
  789. * @access public
  790. * @since 0.9
  791. */
  792. function addMaintainer($handle, $role, $name, $email)
  793. {
  794. if (!$this->_packageXml) {
  795. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS);
  796. }
  797. if (!in_array($role, $GLOBALS['_PEAR_Common_maintainer_roles'])) {
  798. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_WRONG_MROLE,
  799. implode(', ', call_user_func(array($this->_options['pearcommonclass'],
  800. 'getUserRoles'))),
  801. $role);
  802. }
  803. if (!isset($this->_packageXml['maintainers'])) {
  804. $this->_packageXml['maintainers'] = array();
  805. }
  806. $found = false;
  807. foreach ($this->_packageXml['maintainers'] as $index => $maintainer) {
  808. if ($maintainer['handle'] == $handle) {
  809. $found = $index;
  810. break;
  811. }
  812. }
  813. $maintainer =
  814. array('handle' => $handle, 'role' => $role, 'name' => $name, 'email' => $email);
  815. if ($found !== false) {
  816. $this->_packageXml['maintainers'][$found] = $maintainer;
  817. } else {
  818. $this->_packageXml['maintainers'][] = $maintainer;
  819. }
  820. }
  821. /**
  822. * Add an install-time configuration option for building of source
  823. *
  824. * This option is only useful to PECL projects that are built upon
  825. * installation
  826. *
  827. * @param string $name name of the option
  828. * @param string $prompt prompt to display to the user
  829. * @param string $default (optional) default value
  830. *
  831. * @throws PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS
  832. * @return void|PEAR_Error
  833. * @access public
  834. * @since 0.9
  835. */
  836. function addConfigureOption($name, $prompt, $default = null)
  837. {
  838. if (!$this->_packageXml) {
  839. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS);
  840. }
  841. if (!isset($this->_packageXml['configure_options'])) {
  842. $this->_packageXml['configure_options'] = array();
  843. }
  844. $found = false;
  845. foreach ($this->_packageXml['configure_options'] as $index => $option) {
  846. if ($option['name'] == $name) {
  847. $found = $index;
  848. break;
  849. }
  850. }
  851. $option = array('name' => $name, 'prompt' => $prompt);
  852. if (isset($default)) {
  853. $option['default'] = $default;
  854. }
  855. if ($found !== false) {
  856. $this->_packageXml['configure_options'][$found] = $option;
  857. } else {
  858. $this->_packageXml['configure_options'][] = $option;
  859. }
  860. }
  861. /**
  862. * Uses PEAR::PHP_CompatInfo package to detect dependencies (extensions, php version)
  863. *
  864. * @return void|PEAR_Error
  865. * @throws PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS
  866. * @throws PEAR_PACKAGEFILEMANAGER_NO_PHPCOMPATINFO
  867. * @access public
  868. * @since 1.3.0
  869. */
  870. function detectDependencies()
  871. {
  872. if (!$this->_packageXml) {
  873. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS);
  874. }
  875. if (!$this->isIncludeable('PHP/CompatInfo.php')) {
  876. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NO_PHPCOMPATINFO);
  877. } else {
  878. include_once 'PHP/CompatInfo.php';
  879. $this->_detectDependencies = true;
  880. }
  881. }
  882. /**
  883. * Returns whether or not a file is in the include path.
  884. *
  885. * @param string $file path to filename
  886. *
  887. * @return boolean true if the file is in the include path, false otherwise
  888. * @access public
  889. * @since 1.3.0
  890. */
  891. function isIncludeable($file)
  892. {
  893. if (!defined('PATH_SEPARATOR')) {
  894. define('PATH_SEPARATOR', strtolower(substr(PHP_OS, 0, 3)) == 'win' ? ';' : ':');
  895. }
  896. foreach (explode(PATH_SEPARATOR, ini_get('include_path')) as $path) {
  897. if (file_exists($path . DIRECTORY_SEPARATOR . $file) &&
  898. is_readable($path . DIRECTORY_SEPARATOR . $file)) {
  899. return true;
  900. }
  901. }
  902. return false;
  903. }
  904. /**
  905. * Add a dependency on another package, or an extension/php
  906. *
  907. * This will overwrite an existing dependency if it is found. In
  908. * other words, if a dependency on PHP 4.1.0 exists, and
  909. * addDependency('php', '4.3.0', 'ge', 'php') is called, the existing
  910. * dependency on PHP 4.1.0 will be overwritten with the new one on PHP 4.3.0
  911. *
  912. * @param string $name Dependency element name
  913. * @param string $version (optional) Dependency version
  914. * @param string $operator A specific operator for the version, this can be one of:
  915. * 'has', 'not', 'lt', 'le', 'eq', 'ne', 'ge', or 'gt'
  916. * @param string $type (optional) Dependency type. This can be one of:
  917. * 'pkg', 'ext', 'php', 'prog', 'os', 'sapi', or 'zend'
  918. * @param boolean $optional (optional) true if dependency is optional
  919. *
  920. * @throws PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS
  921. * @throws PEAR_PACKAGEFILEMANAGER_PHP_NOT_PACKAGE
  922. * @return void|PEAR_Error
  923. * @access public
  924. * @since 0.1
  925. */
  926. function addDependency($name, $version = false, $operator = 'ge', $type = 'pkg', $optional = false)
  927. {
  928. if (!$this->_packageXml) {
  929. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS);
  930. }
  931. if ((strtolower($name) == 'php') && (strtolower($type) == 'pkg')) {
  932. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_PHP_NOT_PACKAGE);
  933. }
  934. if (!isset($this->_packageXml['release_deps']) || !is_array($this->_packageXml['release_deps'])) {
  935. $this->_packageXml['release_deps'] = array();
  936. }
  937. $found = false;
  938. foreach ($this->_packageXml['release_deps'] as $index => $dep) {
  939. if ($type == 'php') {
  940. if ($dep['type'] == 'php') {
  941. $found = $index;
  942. break;
  943. }
  944. } else {
  945. if (isset($dep['name']) && $dep['name'] == $name && $dep['type'] == $type) {
  946. $found = $index;
  947. break;
  948. }
  949. }
  950. }
  951. $dep =
  952. array(
  953. 'name' => $name,
  954. 'type' => $type);
  955. if ($type == 'php') {
  956. unset($dep['name']);
  957. }
  958. if ($operator) {
  959. $dep['rel'] = $operator;
  960. if ($dep['rel'] != 'has' && $version) {
  961. $dep['version'] = $version;
  962. }
  963. }
  964. if ($optional) {
  965. $dep['optional'] = 'yes';
  966. } else {
  967. $dep['optional'] = 'no';
  968. }
  969. if ($found !== false) {
  970. $this->_packageXml['release_deps'][$found] = $dep; // overwrite existing dependency
  971. } else {
  972. $this->_packageXml['release_deps'][] = $dep; // add new dependency
  973. }
  974. }
  975. /**
  976. * Writes the package.xml file out with the newly created <release></release> tag
  977. *
  978. * ALWAYS use {@link debugPackageFile} to verify that output is correct before
  979. * overwriting your package.xml
  980. *
  981. * @param boolean $debuginterface (optional) null if no debugging, true if web interface, false if command-line
  982. *
  983. * @throws PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS
  984. * @throws PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS
  985. * @throws PEAR_PACKAGEFILEMANAGER_NONOTES
  986. * @throws PEAR_PACKAGEFILEMANAGER_NOLICENSE
  987. * @throws PEAR_PACKAGEFILEMANAGER_INVALID_PACKAGE
  988. * @throws PEAR_PACKAGEFILEMANAGER_CANTWRITE_PKGFILE
  989. * @throws PEAR_PACKAGEFILEMANAGER_CANTCOPY_PKGFILE
  990. * @throws PEAR_PACKAGEFILEMANAGER_CANTOPEN_TMPPKGFILE
  991. * @throws PEAR_PACKAGEFILEMANAGER_DEST_UNWRITABLE
  992. * @return true|PEAR_Error
  993. * @access public
  994. * @since 0.1
  995. */
  996. function writePackageFile($debuginterface = null)
  997. {
  998. if (!$this->_packageXml) {
  999. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS);
  1000. }
  1001. if (!isset($this->_packageXml['maintainers']) || empty($this->_packageXml['maintainers'])) {
  1002. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS);
  1003. }
  1004. if (!isset($this->_options['notes']) || empty($this->_options['notes'])) {
  1005. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NONOTES);
  1006. }
  1007. if (!isset($this->_options['license']) || empty($this->_options['license'])) {
  1008. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOLICENSE);
  1009. }
  1010. extract($this->_options);
  1011. $date = date('Y-m-d');
  1012. if (isset($package)) {
  1013. $this->_packageXml['package'] = $package;
  1014. }
  1015. if (isset($summary)) {
  1016. $this->_packageXml['summary'] = $summary;
  1017. }
  1018. if (isset($description)) {
  1019. $this->_packageXml['description'] = $description;
  1020. }
  1021. $this->_packageXml['release_date'] = $date;
  1022. $this->_packageXml['version'] = $version;
  1023. $this->_packageXml['release_license'] = $license;
  1024. $this->_packageXml['release_state'] = $state;
  1025. $this->_packageXml['release_notes'] = $notes;
  1026. $PEAR_Common = $this->_options['pearcommonclass'];
  1027. $this->_pear = new $PEAR_Common;
  1028. if (method_exists($this->_pear, 'setPackageFileManager')) {
  1029. $this->_pear->setPackageFileManager($this);
  1030. }
  1031. $this->_packageXml['filelist'] = $this->_getFileList();
  1032. $warnings = $this->getWarnings();
  1033. if (count($warnings)) {
  1034. $nl = (isset($debuginterface) && $debuginterface ? '<br />' : "\n");
  1035. foreach ($warnings as $errmsg) {
  1036. echo 'WARNING: ' . $errmsg['message'] . $nl;
  1037. }
  1038. }
  1039. if (PEAR::isError($this->_packageXml['filelist'])) {
  1040. return $this->_packageXml['filelist'];
  1041. }
  1042. if (isset($this->_pear->pkginfo['provides'])) {
  1043. $this->_packageXml['provides'] = $this->_pear->pkginfo['provides'];
  1044. }
  1045. if ($this->_options['simpleoutput']) {
  1046. unset($this->_packageXml['provides']);
  1047. }
  1048. $this->_packageXml['release_deps'] = $this->_getDependencies();
  1049. $this->_updateChangeLog();
  1050. $common = &$this->_pear;
  1051. $warnings = $errors = array();
  1052. if (method_exists($common, 'setPackageFileManagerOptions')) {
  1053. $common->setPackageFileManagerOptions($this->_options);
  1054. }
  1055. $packagexml = $common->xmlFromInfo($this->_packageXml);
  1056. if (PEAR::isError($packagexml)) {
  1057. $errs = $packagexml->getUserinfo();
  1058. if (is_array($errs)) {
  1059. foreach ($errs as $error) {
  1060. if ($error['level'] == 'error') {
  1061. $errors[] = $error['message'];
  1062. } else {
  1063. $warnings[] = $error['message'];
  1064. }
  1065. }
  1066. }
  1067. } else {
  1068. $common->validatePackageInfo($packagexml, $warnings, $errors,
  1069. $this->_options['packagedirectory']);
  1070. }
  1071. if (count($errors)) {
  1072. $ret = '';
  1073. $nl = (isset($debuginterface) && $debuginterface ? '<br />' : "\n");
  1074. foreach ($errors as $errmsg) {
  1075. $ret .= $errmsg . $nl;
  1076. }
  1077. return $this->raiseError(PEAR_PACKAGEFILEMANAGER_INVALID_PACKAGE, $nl, $ret);
  1078. }
  1079. if (count($warnings)) {
  1080. $nl = (isset($debuginterface) && $debuginterface ? '<br />' : "\n");
  1081. foreach ($warnings as $errmsg) {
  1082. echo $errmsg . $nl;
  1083. }
  1084. }
  1085. if (!strpos($packagexml, '<!DOC…

Large files files are truncated, but you can click here to view the full file