cvs: pear /PEAR_PackageFileManager PackageFileManager2.php
| From: | Laurent Laville | Date: | Sat, 30 Sep 2006 15:37:21 +0000 |
| Subject: | cvs: pear /PEAR_PackageFileManager PackageFileManager2.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-42320@lists.php.net to get a copy of this message | ||
farell Sat Sep 30 15:37:21 2006 UTC
Modified files:
/pear/PEAR_PackageFileManager PackageFileManager2.php
Log:
allow now to retrieve previous tasks : replacement, eol, and even baseinstalldir condition
when importOptions() of an existing package (1.0 or 2.0)
It will simplfy package generator script as it most simple expression !
http://cvs.php.net/viewvc.cgi/pear/PEAR_PackageFileManager/PackageFileManager2.php?r1=1.48&r2=1.49&diff_format=u
Index: pear/PEAR_PackageFileManager/PackageFileManager2.php
diff -u pear/PEAR_PackageFileManager/PackageFileManager2.php:1.48
pear/PEAR_PackageFileManager/PackageFileManager2.php:1.49
--- pear/PEAR_PackageFileManager/PackageFileManager2.php:1.48 Sat Sep 30 12:57:15 2006
+++ pear/PEAR_PackageFileManager/PackageFileManager2.php Sat Sep 30 15:37:21 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.48 2006/09/30 12:57:15 farell Exp $
+ * @version CVS: $Id: PackageFileManager2.php,v 1.49 2006/09/30 15:37:21 farell Exp $
* @link http://pear.php.net/package/PEAR_PackageFileManager
* @since File available since Release 1.6.0
*/
@@ -789,6 +789,8 @@
}
if (!isset($options['clearcontents']) || $options['clearcontents'])
{
$res->clearContents();
+ } else {
+ $res->getTaskFiles($options);
}
$packagefile = $packagefile->getPackageFile();
}
@@ -1584,6 +1586,63 @@
}
/**
+ * @param array list of generation options
+ * @return array PEAR_Task_* object
+ * @since 1.6.0b5
+ */
+ function getTaskFiles($options)
+ {
+ $filelist = $this->getFilelist(true);
+ $kroles = array_keys($this->_options['roles']);
+ $vroles = array_values($this->_options['roles']);
+
+ foreach ($filelist as $file => $contents) {
+ $atts = $contents['attribs'];
+ unset($contents['attribs']);
+ // check for tasks replacement, eol
+ if (count($contents)) {
+ foreach ($contents as $tag => $raw) {
+ $taskNs = $this->getTasksNs();
+ $task = str_replace("$taskNs:", '', $tag);
+ if ($task == 'replace') {
+ if (!isset($raw[0])) {
+ $raw = array($raw);
+ }
+ foreach ($raw as $attrs) {
+ $a = $attrs['attribs'];
+ $this->addReplacement($file, $a['type'],
$a['from'], $a['to']);
+ }
+
+ } elseif ($task == 'windowseol') {
+ $this->addWindowsEol($file);
+
+ } elseif ($task == 'unixeol') {
+ $this->addUnixEol($file);
+ }
+ }
+ }
+ // check for role attribute
+ if (isset($atts['role'])) {
+ $myrole = $atts['role'];
+ if (!in_array($myrole, $vroles)) {
+ $this->_options['exceptions'][$file] = $myrole;
+ } else {
+ $inf = pathinfo($file);
+ if (isset($inf['extension']) &&
$kroles[$inf['extension']] != $myrole) {
+ $this->_options['exceptions'][$file] = $myrole;
+ }
+ }
+ }
+ // check for baseinstalldir attribute
+ if (isset($options['baseinstalldir'])
+ && $atts['baseinstalldir'] !=
$options['baseinstalldir']) {
+ $this->_options['installexceptions'][$file] =
$atts['baseinstalldir'];
+ }
+ }
+ return $this->_options['replacements'];
+ }
+
+ /**
* @return true|PEAR_Error
* @uses _generateNewPackageXML() if no package.xml is found, it
* calls this to create a new one
@@ -1635,6 +1694,8 @@
}
if (!isset($options['clearcontents']) ||
$options['clearcontents']) {
$pf->clearContents();
+ } else {
+ $pf->getTaskFiles($options);
}
}
return $pf;