I still have a few packages where the included pdf has a creation/mod time
stamp that differs.  I am __almost__ at the point where I can override the
created pdf file:

 - it works in a normal shell, ie the sequence

       pdfinfo somefile.pdf somefile.pdf 'timestamp_from_debian/changelog'
       pdfinfo somefile.pdf

   works:  the file remains valid, and pdfinfo shows the before/after
   timestamps as desired

 - it does NOT work in pbuilder and I cannot narrow down why -- the second
   pdfinfo call (added for debugging) reports a corrupted pdf file.

To be clear, I use the same exact helper script: it works 'on the shell' but
not in pbuilder.  What am I missing?

The script-let (in its current form) is below.


##  Override CreationDate and ModDate timestamps in pdf files
##  Based in part on 
##  as well as a fair amount of trial and error
##  Dirk Eddelbuettel, September 2015
##  Released under GPL-2 or later

set -u 
set -e

if [ $# -lt 2 ]; then
    echo "Usage: $0 file datestr"
    exit 1
#echo "Using arguments '${FILE}' and '${DEB_DATE}'"

##  Meant for debian/ subdirectories containing file debian/changelog
#DEB_DATE=$(dpkg-parsechangelog -S date)
PDF_DATE=$(date -ud "${DEB_DATE}" +D:%Y%m%d%H%M%S-00\'00\')
#echo "Using PDF_DATE ${PDF_DATE}"

sed -i -e "s|^/CreationDate (.*)$|/CreationDate (${PDF_DATE})|" \
       -e "s|^/ModDate (.*)$|/ModDate (${PDF_DATE})|" ${FILE}

MD5=$((echo "${DEB_DATE}" && du -b ${FILE}) | md5sum | cut -c -32)
sed -i "s|^/ID \\[\\(<[0-9A-F]\\{32\\}>\\) \\1]$|/ID [<${MD5}> <${MD5}>]|" 

-- | @eddelbuettel |

Reproducible-builds mailing list

Reply via email to