krb5/krb5-tex-pdf.sh
Nalin Dahyabhai f3820b972d - preserve timestamps on profile.d shell scriptlets
- first cut at making RPM scriptlets failproof for install-info
- pull up pre-generated PDF docs so that we don't have multiarch
    differences due to document IDs, timestamps, and compressed data,
- pull up the script to make sure that the PDF matches its source to guard
    against the package maintainer forgetting to update when we move to a
    new release
2007-01-22 21:23:54 +00:00

56 lines
1.4 KiB
Bash

#!/bin/sh
# Based on Enrico's snippet for using pdflatex for building PDFs, except we're
# switching to pregenerating the docs for the SRPM so that we don't get
# different contents when we build on multiple build machines and architectures
# (timestamps and IDs change, and even some of the compressed content looks
# different). The filename and checksum are used to verify that the PDF always
# matches the doc which was used to generate it, and we flag an error if that
# isn't the case.
create() {
pushd "$1" > /dev/null
touch "$2".ind
pdflatex "$2"
test ! -e "$2".idx || makeindex ${3:+-s "$3".ist} "$2".idx
pdflatex "$2"
pdflatex "$2"
sum=`sha1sum "$2".tex | sed 's,[[:blank:]].*,,g'`
sed -ri \
-e 's|^/ID \[<.{32}> <.{32}>\]|/ID [<'"$1/$2"'> <'"$sum"'>]|g' \
"$2".pdf
popd > /dev/null
}
check() {
pushd "$1" > /dev/null
sum=`sha1sum "$2".tex | sed 's, .*,,g'`
id=`sed -rn -e '/^\/ID \[<[^>]*> <[^>]*>\]/p' "$2".pdf`
filename=`echo "$id" | sed -r 's|^.*\[<([^>]*)> <([^>]*)>\].*|\1|g'`
checksum=`echo "$id" | sed -r 's|^.*\[<([^>]*)> <([^>]*)>\].*|\2|g'`
echo $filename
echo $checksum $sum
popd > /dev/null
test "$filename" = "$1/$2" && test "$checksum" = "$sum"
}
mode=$1
case $mode in
create)
while read subdir doc style ; do
if ! create $subdir $doc $style ; then
exit 1
fi
done
;;
check)
while read subdir doc style ; do
if ! check $subdir $doc $style ; then
exit 1
fi
done
;;
esac
exit 0