Source: php-apigen
Version: 2.8.0+dfsg-3
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: toolchain timestamps
X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org

Hi,

While working on the "reproducible builds" effort [1], we have noticed
that php-apigen is generating non-reproducible output.

The attached patch adds a --reproducible option that removes timestamps
and so forth. Once applied, packages that use php-apigen can be built
reproducibly in our reproducible toolchain.

 [1]: https://wiki.debian.org/ReproducibleBuilds


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
diff --git a/ApiGen-2.8.0/ApiGen/Config.php b/ApiGen-2.8.0/ApiGen/Config.php
index ea35741..7a9e925 100644
--- a/ApiGen-2.8.0/ApiGen/Config.php
+++ b/ApiGen-2.8.0/ApiGen/Config.php
@@ -73,6 +73,7 @@ class Config
                'progressbar' => true,
                'colors' => true,
                'updateCheck' => true,
+               'reproducible' => true,
                'debug' => false
        );
 
@@ -565,6 +566,7 @@ Options:
        @option@--progressbar@c      <@value@yes@c|@value@no@c>    Display 
progressbars, default "@value@yes@c"
        @option@--colors@c           <@value@yes@c|@value@no@c>    Use colors, 
default "@value@no@c" on Windows, "@value@yes@c" on other systems
        @option@--update-check@c     <@value@yes@c|@value@no@c>    Check for 
update, default "@value@yes@c"
+       @option@--reproducible@c     <@value@yes@c|@value@no@c>    Try and make 
output reproducible, default "@value@yes@c"
        @option@--debug@c            <@value@yes@c|@value@no@c>    Display 
additional information in case of an error, default "@value@no@c"
        @option@--help@c|@option@-h@c                      Display this help
 
diff --git a/ApiGen-2.8.0/ApiGen/Generator.php 
b/ApiGen-2.8.0/ApiGen/Generator.php
index 56e8418..e87f8f8 100644
--- a/ApiGen-2.8.0/ApiGen/Generator.php
+++ b/ApiGen-2.8.0/ApiGen/Generator.php
@@ -1393,12 +1393,19 @@ class Generator extends Nette\Object
                        throw new RuntimeException('Could not open ZIP 
archive');
                }
 
-               $archive->setArchiveComment(trim(sprintf('%s API documentation 
generated by %s %s on %s', $this->config->title, self::NAME, self::VERSION, 
date('Y-m-d H:i:s'))));
+               $comment = sprintf('%s API documentation generated by %s %s', 
$this->config->title, self::NAME, self::VERSION);
+               if (!$this->config->reproducible) {
+                       $comment .= sprintf(' on %s', date('Y-m-d H:i:s'));
+               }
+               $archive->setArchiveComment(trim($comment));
 
                $directory = Nette\Utils\Strings::webalize(trim(sprintf('%s API 
documentation', $this->config->title)), null, false);
                $destinationLength = strlen($this->config->destination);
                foreach ($this->getGeneratedFiles() as $file) {
                        if (is_file($file)) {
+                               if ($this->config->reproducible) {
+                                       touch($file, 0);
+                               }
                                $archive->addFile($file, $directory . 
DIRECTORY_SEPARATOR . substr($file, $destinationLength + 1));
                        }
                }

Reply via email to