Re: Issue with PEAR_PackageFileManage2 1.0.2 and package.xml validation
| From: | Helgi Þormar Þorbjörnsson | Date: | Thu, 31 Mar 2011 15:37:05 +0000 |
| Subject: | Re: Issue with PEAR_PackageFileManage2 1.0.2 and package.xml validation | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-54201@lists.php.net to get a copy of this message | ||
That is very strange indeed, I don't have a working PHP 5.2 around but I will try to get one
going to test this.
My tests were PHP 5.3.2 on OS X and Windows 7, everything passed on those.
- Helgi
On 31 Mar 2011, at 16:32, Laurent Laville wrote:
>
>
> I was on my way to propose a patch when I found a surprise.
>
> I've reinstalled plugins and PFM on version 1.0.2 to be sure to have a clean version, and
> I run tests on PHP5.2.17 and PHP5.3.5 both on Windows XP and PEAR 1.9.2
>
> Here are the strange results, I got :
>
> PHP 5.2.17
>
> TOTAL TIME: 01:01
> 31 PASSED TESTS
> 0 SKIPPED TESTS
> 11 FAILED TESTS:
>
> TESTS FAILED are 3,4,19,20,21,22,23,28,29,39,40
>
>
> PHP 5.3.5
>
> TOTAL TIME: 00:50
> 35 PASSED TESTS
> 0 SKIPPED TESTS
> 7 FAILED TESTS:
>
> TESTS FAILED are 19,20,21,22,23,28,29
>
> Strange situation !
>
> Are you aware of a such issue ?
>
> Le 31/03/2011 15:40, Helgi Þormar Þorbjörnsson a écrit :
>> Yeah, that mess is all over the import/setup - I only fiddled with it a bit, I did run all
>> the tests on Windows 7 without problem but it didn't seem to catch that bit.
>>
>> If you feel like cooking up a patch, that'd be good - otherwise I'll try to clean
>> this all up. This whole stripping of / or \ is kinda silly anyway because all the OS out there can
>> handle a double // or \\ just fine when you request files and do various matching, even a realpath
>> would solve most of those issues.
>>
>> - Helgi
>>
>> On 31 Mar 2011, at 14:35, Laurent Laville wrote:
>>
>>> 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
>>>>
>>
>>
>