latex3 / pdfresources

LaTeX PDF resource management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XMP-Metadata does not honor `SOURCE_DATE_EPOCH`

wangweixuan opened this issue · comments

The metadata generated by l3meta module hinders reproducible builds.

The module does not honor SOURCE_DATE_EPOCH environment variable, which overrides the current date value. It uses file timestamp to determine current date:

\file_get_timestamp:nN{\jobname.log}\l_@@_xmp_currentdate_tl

I believe SOURCE_DATE_EPOCH should be supported. It was supported by LaTeX prior to pdfmanagement-testphase.

LaTeX never "supported" SOURCE_DATE_EPOCH, it doesn't read environment variables and only some (not all) of the engines honors it.

That said we could probably read the environment variable in the backend and then set the metadata to a fix value. But there aren't time functions to convert the unix-timestamp so you would get the fix date I use for regression data (2001-01-01T20:59:59-00:00 currently).

@josephwright @davidcarlisle what do you think?

\DocumentMetadata{uncompress}
\ExplSyntaxOn

\ior_shell_open:Nn \g_tmpa_ior 
 { kpsewhich~--expand-var=$SOURCE_DATE_EPOCH }
\ior_if_eof:NF\g_tmpa_ior
 { 
   \ior_get:NN \g_tmpa_ior \l_tmpa_tl 
   \str_if_eq:VnF\l_tmpa_tl {$SOURCE_DATE_EPOCH} 
   \pdfmeta_set_regression_data: 
 }   
\ExplSyntaxOff
\documentclass{article}
\begin{document}
blub
\end{document}

@u-fischer do you need to read the enviroment? the engine will already have read it and set clock the for \pdffilemoddate \year and friends probably needs FORCE_SOURCE_DATE as well

I have uploaded a new version to ctan that corrects this, the SOURCE_DATE_EPOCH setting is now honored. This requires a new l3backend/l3kernel which has been uploaded today too.

Thanks for the quick fix!