latex3 / pdfresources

LaTeX PDF resource management
LaTeX Project Public License v1.3c
22 stars 5 forks source link

XMP-Metadata does not honor `SOURCE_DATE_EPOCH` #53

Closed wangweixuan closed 10 months ago

wangweixuan commented 10 months ago

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: https://github.com/latex3/pdfresources/blob/f8b0b6d3dd157bec33dfbba0a365ef34275e2bb0/l3pdfmeta.dtx#L2588

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

u-fischer commented 10 months ago

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}
davidcarlisle commented 10 months ago

@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

u-fischer commented 10 months ago

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.

wangweixuan commented 10 months ago

Thanks for the quick fix!