[pdftex] Please make the CreationDate, ModDate and ID field deterministic
Maria Valentina Marin
marivalenm at gmail.com
Wed Aug 12 13:08:35 CEST 2015
Hi,
On 07/14/2015 12:39 AM, Karl Berry wrote:
> Thanh is away for ~3 weeks. He will review both the SOURCE_DATE_EPOCH
> patch (which I suspect will be fine) and Nicolas's other comments when
> he's back.
In addition to my patch to honour $SOURCE_DATE_EPOCH please find
attached an additional patch which uses UTC in the printed timestamps to
also make the timezone reproducible.
I have patched the function makepdftime to use gmtime if
$SOURCE_DATE_EPOCH is set. Otherwise the old behaviour will be kept.
I have tested the patch in our autobuilders against 4 Debian packages
that use pdflatex and these become reproducible.
Cheers,
akira
-------------- next part --------------
Description: Use gmtime instead of localtime to produce timezone independent output if SOURCE_DATE_EPOCH is set
--- a/texk/web2c/lib/texmfmp.c
+++ b/texk/web2c/lib/texmfmp.c
@@ -2876,7 +2876,7 @@ char start_time_str[TIME_STR_SIZE];
static char time_str[TIME_STR_SIZE];
/* minimum size for time_str is 24: "D:YYYYmmddHHMMSS+HH'MM'" */
-static void makepdftime(time_t t, char *time_str)
+static void makepdftime(time_t t, char *time_str, int utc)
{
struct tm lt, gmt;
@@ -2884,7 +2884,12 @@ static void makepdftime(time_t t, char *
int i, off, off_hours, off_mins;
/* get the time */
- lt = *localtime(&t);
+ if (utc){
+ lt = *gmtime(&t);
+ }
+ else {
+ lt = *localtime(&t);
+ }
size = strftime(time_str, TIME_STR_SIZE, "D:%Y%m%d%H%M%S", <);
/* expected format: "YYYYmmddHHMMSS" */
if (size == 0) {
@@ -2958,11 +2963,12 @@ void initstarttime(void)
uexit(EXIT_FAILURE);
}
start_time = epoch;
+ makepdftime(start_time, start_time_str, 1);
}
else {
start_time = time((time_t *) NULL);
+ makepdftime(start_time, start_time_str, 0);
}
- makepdftime(start_time, start_time_str);
}
}
@@ -3049,7 +3055,7 @@ void getfilemoddate(integer s)
if (stat(file_name, &file_data) == 0) {
size_t len;
- makepdftime(file_data.st_mtime, time_str);
+ makepdftime(file_data.st_mtime, time_str, 0);
len = strlen(time_str);
if ((unsigned) (poolptr + len) >= (unsigned) (poolsize)) {
poolptr = poolsize;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://tug.org/pipermail/pdftex/attachments/20150812/2082a9e9/attachment.bin>
More information about the pdftex
mailing list