Bug #77229 [Com]: Phar::buildFromDirectory() generates tar archives in 'PAX' format
| From: | hanskrentel at yahoo dot de | Date: | Tue, 04 Dec 2018 06:03:55 +0000 |
| Subject: | Bug #77229 [Com]: Phar::buildFromDirectory() generates tar archives in 'PAX' format | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218259@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77229&edit=1
ID: 77229
Comment by: hanskrentel at yahoo dot de
Reported by: michae dot lee at zerustech dot com
Summary: Phar::buildFromDirectory() generates tar archives in
'PAX' format
Status: Open
Type: Bug
Package: PHAR related
Operating System: macOS High Sierra 10.13.6
PHP Version: 7.2.4
Block user comment: N
Private report: N
New Comment:
It can also be - I think like w/ from iterator - that temporary files are in use behind the secenes
with new timestamps in each operation and therefore changing the checksum.
To create phar file in a reproducible manner it normally needs to store the phar file and then to
modify the binary records resetting the timestamps in there, e.g. to the latest timestamp of the
revision in CVS or in your example you perhaps want to keep track of file-system timestamps and
binary edit the phar file to sync those w/ the file-system.
See the phar build script in the composer project for some reference on how to do that.
Previous Comments:
------------------------------------------------------------------------
[2018-12-03 03:46:38] michae dot lee at zerustech dot com
PHP version is 7.2.4
------------------------------------------------------------------------
[2018-12-03 02:54:23] michae dot lee at zerustech dot com
Description:
------------
The
Phar::buildFromDirectory() method generates tar archives in PAX
format, so different tar archives that contain the same files may have different sha1
checksums.
Test script:
---------------
<?php
// mkdir test && echo 'hello' > test/test.txt
$phar = new \PharData('a.tar');
$phar->buildFromDirectory('test');
// sleep for 1 second to produce different atime.
sleep(1);
$phar = new \PharData('b.tar');
$phar->buildFromDirectory('test');
echo sha1_file('a.tar') . "\n";
echo sha1_file('b.tar') . "\n";
// a.tar and b.tar contain the same files, but have different checksums
// Looks like the buildFromDirectory() method generates tar archives
// with PAX headers. Calling "tar --format=ustar -cf ..." from command line
// resolves this issue.
Expected result:
----------------
The sha1 checksums for a.tar and b.tar should be the same.
Actual result:
--------------
The sha1 checksums for a.tar and b.tar are different.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77229&edit=1