Source: libwibble
Version: 1.1-1
Severity: wishlist
Tags: patch
User: [email protected]
Usertags: toolchain timestamps
X-Debbugs-Cc: [email protected]

Hi,

Whilst working on the Reproducible Builds effort [0], we noticed
that libwibble generates non-reproducible manpages that use its
wibble/commandline/doc.h library.

For example, goplay:

  ├── ./usr/share/man/man1/goplay.1.gz
  ├── ./usr/share/man/man1/goplay.1.gz
  │ │ │ │ │ @@ -1,8 +1,8 @@
  │ │ │ │ │ -.TH GOPLAY 1 "May 29, 2018" "0.5"
  │ │ │ │ │ +.TH GOPLAY 1 "April 26, 2017" "0.5"


Patch attached that uses SOURCE_DATE_EPOCH if available.


 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/specs/source-date-epoch/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      [email protected] / chris-lamb.co.uk
       `-
diff --git a/wibble/commandline/doc.cpp b/wibble/commandline/doc.cpp
index 0b99206..7498605 100644
--- a/wibble/commandline/doc.cpp
+++ b/wibble/commandline/doc.cpp
@@ -230,6 +230,15 @@ static string toupper(const std::string& str)
 static string man_date()
 {
        time_t tnow = time(0);
+       char* source_date_epoch = std::getenv("SOURCE_DATE_EPOCH");
+       if (source_date_epoch) {
+               std::istringstream iss(source_date_epoch);
+               iss >> tnow;
+               if (iss.fail() || !iss.eof()) {
+                       std::cerr << "Error: Cannot parse SOURCE_DATE_EPOCH as 
integer\n";
+                       exit(27);
+               }
+       }
        struct tm* now = gmtime(&tnow);
        char buf[20];
        const char* oldlocale = setlocale(LC_TIME, "C");

Reply via email to