Re: Issue with PEAR_PackageFileManage2 1.0.2 and package.xml validation
| From: | Laurent Laville | Date: | Thu, 31 Mar 2011 13:39:51 +0000 |
| Subject: | Re: Issue with PEAR_PackageFileManage2 1.0.2 and package.xml validation | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-54198@lists.php.net to get a copy of this message | ||
Last to finish the report, forget to tell it in previous.
Package directory options is set on PEAR_PackageFileManager2::setOptions()
$options['packagedirectory'] = str_replace(DIRECTORY_SEPARATOR,
'/', realpath($options['packagedirectory']));Le 31/03/2011 15:35, Laurent Laville a écrit :
This time I found it (ouf) Look inside "PackageFileManager\File.php" getFileList() $dir = $package_directory; if ($dir{strlen($dir) - 1} === DIRECTORY_SEPARATOR) { $dir = substr($package_directory, 0, strlen($package_directory) - 1); } With $package_directory = $this->_options['packagedirectory']; And its contents $package_directory = 'C:/www/github/php-compat-info/' We cannot remove the trailing / (on windows DIRECTORY_SEPARATOR is \) That is why we still have a / in front of each file and what I've already said its true , cannot match file Laurent Le 31/03/2011 14:19, Helgi Þormar Þorbjörnsson a écrit :I may have a solution for the issue, need to do a bit of work before I can investigate it further. It is possible that the packagedirectory and related options are not keeping / at the end anymore, hence it kinda working for you to add / but it looks like it is only related to the install-as - Helgi On 31 Mar 2011, at 13:16, Laurent Laville wrote:TAKE CARE: it's not a FIX . I've found horrible side effects. I'll keep continue to investigate. Sorry Le 31/03/2011 13:52, Laurent Laville a écrit :As there is already a bug report related to this subject ( http://pear.php.net/bugs/bug.php?id=15534 ) I don't see any reason to open a new one . Have found a temporary solution to bypass the error validation. There is also a description of issue, and probably a way to fix it. In my package script generator, I have with previous version code below $p2->generateContents(); $p2->addRelease(); $p2->setOSInstallCondition('windows'); $p2->addInstallAs('scripts/phpci.bat', 'phpci.bat'); $p2->addInstallAs('scripts/phpci', 'phpci'); $p2->addRelease(); $p2->addIgnoreToRelease('scripts/phpci.bat'); $p2->addInstallAs('scripts/phpci', 'phpci'); I've changed it to $p2->generateContents(); $p2->addRelease(); $p2->setOSInstallCondition('windows'); $p2->addInstallAs('/scripts/phpci.bat', 'phpci.bat'); $p2->addInstallAs('/scripts/phpci', 'phpci'); $p2->addRelease(); $p2->addIgnoreToRelease('/scripts/phpci.bat'); $p2->addInstallAs('/scripts/phpci', 'phpci'); NOTICE the slash in front of each script files While searching where the validation come from, I've seen that in PEAR\PackageFile\v2\Validator.php (rev 308729) lines 1029 to 1031 we check and tag if file exist in contents foreach ($fcontents['dir']['file'] as $file) { $filelist[$file['attribs']['name']] = true; } But this array have as key - file name that all start with / slash .... more ... [/PHP/CompatInfo/Token/String.php] => 1 [/scripts/phpci] => 1 [/scripts/phpci.bat] => 1 [/tests/ClassTest.php] => 1 .... more .... But not in the array $list['install'] [0] => Array ( [attribs] => Array ( [as] => phpci.bat [name] => scripts/phpci.bat ) ) [1] => Array ( [attribs] => Array ( [as] => phpci [name] => scripts/phpci ) ) ) That is why it tagged it as _notInContents Hope it will help. Laurent Le 31/03/2011 12:36, Helgi Þormar Þorbjörnsson a écrit :Much appreciated. This may be related to http://pear.php.net/bugs/bug.php?id=13310 and http://pear.php.net/bugs/bug.php?id=15534 but they are more likely than not a bug in the CLI code, the part that manipulates scripts and install-as tags. One thing that comes to mind is that I added 'scripts' => 'script', dir->role mapping at the top; It may be having a bigger knock on effect than I anticipated. - Helgi On 31 Mar 2011, at 11:29, Laurent Laville wrote:Ok, no problem. I'll open a bug report, and try to see if I can find something. I've some free time this afternoon. Later Laurent Le 31/03/2011 12:22, Helgi Þormar Þorbjörnsson a écrit :Hi, Thanks for taking the time writing this up. Could you please file a bug report as that is easier to track. Off the top of my head, I don't know what it is but I am still at work and don't have time to look at it yet. - Helgi On 31 Mar 2011, at 11:17, Laurent Laville wrote:Hello Helgi, I've just installed the new version 1.0.2 (with its plugins package) of PEAR_PackageFileManager2 on my local windows platform. PEAR 1.9.2, PHP 5.2.17, Windows XP And I got a Package Validation error, while it was not the cas in previous version 1.0.1 PEAR_PackageFileManager2 Error: Package validation failed: Error:<ignore name="scripts/phpci.bat"> is invalid, file is not in<contents> Error:<install name="scripts/phpci"> is invalid, file is not in<contents> Error:<install name="scripts/phpci"> is invalid, file is not in<contents> Error:<install name="scripts/phpci.bat"> is invalid, file is not in<contents> See my package.xml online at [1] I used a PHP script that generate the package.xml. Something standard. Here is a chunk of code ... <code> require_once 'PEAR/PackageFileManager2.php'; PEAR::setErrorHandling(PEAR_ERROR_DIE); $p2 = new PEAR_PackageFileManager2(); $p2->setOptions( array( 'packagedirectory' => dirname(__FILE__), 'baseinstalldir' => 'Bartlett', 'filelistgenerator' => 'file', 'simpleoutput' => true, 'clearcontents' => false, 'changelogoldtonew' => false, 'ignore' => array( basename(__FILE__), '*.tgz', '*.log', 'Thumbs.db', 'packageRC*.xml', 'makephpci.php', '_extension.php', 'phpcompatinfo.xml', ), 'exceptions' => array( 'phpcompatinfo.xml.dist' => 'cfg', 'scripts/phpci' => 'script', 'scripts/phpci.bat' => 'script', 'README.markdown' => 'doc', 'LICENSE' => 'doc', 'HOWTO.txt' => 'doc', ), 'installexceptions' => array( 'phpcompatinfo.xml.dist' => '', 'scripts/phpci' => '', 'scripts/phpci.bat' => '', ), ) ); // ... more $p2->generateContents(); $p2->addRelease(); $p2->setOSInstallCondition('windows'); $p2->addInstallAs('scripts/phpci.bat', 'phpci.bat'); $p2->addInstallAs('scripts/phpci', 'phpci'); $p2->addRelease(); $p2->addIgnoreToRelease('scripts/phpci.bat'); $p2->addInstallAs('scripts/phpci', 'phpci'); $p2->writePackageFile(); </code> If you don't know what it could be, I'll try to investigate later. Laurent [1] https://github.com/llaville/php-compat-info/blob/master/package.xml