cvs: pear /PEAR_PackageFileManager PackageFileManager2.php

From: Date: Fri, 06 Oct 2006 12:10:55 +0000
Subject: cvs: pear /PEAR_PackageFileManager PackageFileManager2.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42432@lists.php.net to get a copy of this message
farell Fri Oct 6 12:10:55 2006 UTC Modified files: /pear/PEAR_PackageFileManager PackageFileManager2.php Log: - exportCompatiblePackageFile1() method is maked as deprecated, because package xml 1.0 will not be supported with stable version 1.6.0 - method getTaskFiles() renamed to _importTasks() and declared as private allow now with a single option (clearcontents => false) to import all previous options of an existing package xml That means you get tasks files (postinstallscript, replace, eol) but also role file exceptions. http://cvs.php.net/viewvc.cgi/pear/PEAR_PackageFileManager/PackageFileManager2.php?r1=1.53&r2=1.54&diff_format=u Index: pear/PEAR_PackageFileManager/PackageFileManager2.php diff -u pear/PEAR_PackageFileManager/PackageFileManager2.php:1.53 pear/PEAR_PackageFileManager/PackageFileManager2.php:1.54 --- pear/PEAR_PackageFileManager/PackageFileManager2.php:1.53 Fri Oct 6 07:51:23 2006 +++ pear/PEAR_PackageFileManager/PackageFileManager2.php Fri Oct 6 12:10:55 2006 @@ -14,7 +14,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 2005-2006 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: PackageFileManager2.php,v 1.53 2006/10/06 07:51:23 farell Exp $ + * @version CVS: $Id: PackageFileManager2.php,v 1.54 2006/10/06 12:10:55 farell Exp $ * @link http://pear.php.net/package/PEAR_PackageFileManager * @since File available since Release 1.6.0 */ @@ -652,6 +652,7 @@ * @return PEAR_PackageFileManager * @access public * @since 1.6.0a1 + * @deprecated package xml 1.0 will not be supported with stable version 1.6.0 */ function &exportCompatiblePackageFile1($options = array()) { @@ -790,7 +791,7 @@ if (!isset($options['clearcontents']) || $options['clearcontents']) { $res->clearContents(); } else { - $res->getTaskFiles($options); + $res->_importTasks($options); } $packagefile = $packagefile->getPackageFile(); } @@ -1587,11 +1588,15 @@ } /** + * Import tasks options and files roles (if exceptions) + * from an existing package.xml + * * @param array list of generation options - * @return array PEAR_Task_* object + * @return void|PEAR_Error + * @access private * @since 1.6.0b5 */ - function getTaskFiles($options) + function _importTasks($options) { $filelist = $this->getFilelist(true); $vroles = array_values($this->_options['roles']); @@ -1618,6 +1623,35 @@ } elseif ($task == 'unixeol') { $this->addUnixEol($file); + + } elseif ($task == 'postinstallscript') { + $script = &$this->initPostinstallScript($file); + $raw = $this->_stripNamespace($raw); + + foreach ($raw['paramgroup'] as $paramgroup) { + if (isset($paramgroup['instructions'])) { + $instructions = $paramgroup['instructions']; + } else { + $instructions = false; + } + + if (isset($paramgroup['param'][0])) { + $params = $paramgroup['param']; + } else { + $params = array($paramgroup['param']); + } + $param = array(); + foreach ($params as $p) { + $default = isset($p['default']) ? $p['default'] : null; + $param[] = $script->getParam($p['name'], + $p['prompt'], $p['type'], $default); + } + $script->addParamGroup($paramgroup['id'], $param, $instructions); + } + $ret = $this->addPostinstallTask($script, $file); + if (PEAR::isError($ret)) { + return $ret; + } } } } @@ -1649,7 +1683,26 @@ $this->_options['installexceptions'][$file] = $atts['baseinstalldir']; } } - return $this->_options['replacements']; + } + + /** + * Strip namespace from postinstallscript task array + * + * @param array tasks options + * @return array + * @access private + * @since 1.6.0b5 + */ + function _stripNamespace($params) + { + $newparams = array(); + foreach ($params as $i => $param) { + if (is_array($param)) { + $param = $this->_stripNamespace($param); + } + $newparams[str_replace($this->getTasksNs() . ':', '', $i)] = $param; + } + return $newparams; } /** @@ -1705,7 +1758,11 @@ if (!isset($options['clearcontents']) || $options['clearcontents']) { $pf->clearContents(); } else { - $pf->getTaskFiles($options); + // merge options is required to use PEAR_PackageFileManager2::addPostinstallTask() + if (PEAR::isError($ret = $pf->_importOptions($packagefile, $options))) { + return $ret; + } + $pf->_importTasks($options); } } return $pf;

« previous php.pear.cvs (#42432) next »