summaryrefslogtreecommitdiff
path: root/Master/bin/hppa-hpux/dvipdft
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-12-18 18:47:27 +0000
committerKarl Berry <karl@freefriends.org>2006-12-18 18:47:27 +0000
commite06209b676740916385f8b394d8330ddc0e41918 (patch)
tree91c699943424611275d7aac867f3f168af936c41 /Master/bin/hppa-hpux/dvipdft
parent28885f3399755436fff3ffc8ab90e11f31b5b968 (diff)
hpux binaries from tim arnold
git-svn-id: svn://tug.org/texlive/trunk@2792 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/bin/hppa-hpux/dvipdft')
-rwxr-xr-xMaster/bin/hppa-hpux/dvipdft130
1 files changed, 130 insertions, 0 deletions
diff --git a/Master/bin/hppa-hpux/dvipdft b/Master/bin/hppa-hpux/dvipdft
new file mode 100755
index 00000000000..db53bd2f5a0
--- /dev/null
+++ b/Master/bin/hppa-hpux/dvipdft
@@ -0,0 +1,130 @@
+#!/bin/sh
+
+#
+# dvipdft, completely rewtitten by Thomas Esser for teTeX after an
+# original script by Mark A. Wicks
+#
+# Thomas Esser. Public Domain.
+#
+
+# This script makes a first (fast) run with dvipdfm, then calls gs on
+# the resulting pdf file to get the thumbnails and finally calls dvipdfm.
+
+test -f /bin/sh5 && test -z "$RUNNING_SH5" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
+ && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; }
+unset RUNNING_SH5
+
+test -f /bin/bsh && test -z "$RUNNING_BSH" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \
+ && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; }
+unset RUNNING_BSH
+
+# hack around a bug in zsh:
+test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
+
+progname=dvipdft
+version=1111942378 # seconds since `00:00:00 1970-01-01 UTC'
+ # date '+%s' (with GNU date)
+
+help="Usage: $progname [options] dvifile
+ $progname --help
+ $progname --version"
+
+tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$
+
+quoteit()
+{
+ echo "x$1" | sed "s@.@@; s@'@'\\\\''@; s@^@'@; s@\$@'@"
+}
+
+# process args 1 to (n-1) and scan for a -o argument keep a properly
+# quoted backup of the options, so that they can be restored later
+unset s outfile
+while test $# -gt 1; do
+ case $1 in
+ -o) outfile=$2;;
+ esac
+ s="$s${s+ }"`quoteit "$1"`
+ shift
+done
+
+# check for last argument
+case $1 in
+ --help)
+ echo "$help"
+ exit 0
+ ;;
+ --version)
+ echo "$progname version $version by Thomas Esser"
+ exit 0
+ ;;
+ "")
+ echo "$help"
+ exit 1
+ ;;
+esac
+
+# args 1 to (n-1) are gone, last one must be the dvifile
+dvifile=$1
+
+# outfile comes from -o argument, else it is derived from the input file
+test -n "$outfile" \
+ || outfile=`echo "$dvifile" | sed 's@.*/@@; s@\.dvi$@@; s@$@.pdf@'`
+
+# outBase is part of the thumbname files just as dvipdfm expects them:
+outBase=`echo "$outfile" | sed 's@\.pdf$@@'`
+
+# restore args 1 to (n-1):
+eval set x "$s"; shift
+
+# Run dvipdfm with the fastest options for the first pass
+echo "$progname: running dvipdfm $@ -e -z0 $dvifile" >&2
+dvipdfm ${1+"$@"} -e -z0 "$dvifile" || {
+ echo "$progname: dvipdfm failed." >&2
+ exit 1
+}
+
+# before we create the tmpdir, set trap for cleanup
+trap '
+ rm -rf $tmpdir
+ exit 1
+' 1 2 3 7 13 15
+
+mkdir "$tmpdir" || {
+ echo "$progname: failed to create temp directory." >&2
+ exit 1
+}
+
+# if outBase contains a /, we might need to create a directory
+case $outBase in
+ */*)
+ fq=`echo "$tmpdir/$outBase" | sed 's@//@/@g; s@/[^/]*$@@'`
+ test -d "$fq" || mkdir -p "$fq" || {
+ echo "$progname: failed to create temp thumbnail directory." >&2
+ rm -rf $tmpdir
+ exit 1
+ }
+ ;;
+esac
+
+# run gs
+echo "$progname: running gs" >&2
+gs -r10 -dNOPAUSE -dBATCH -sDEVICE=png256 \
+ -sOutputFile="$tmpdir/$outBase.%d" "$outfile" || {
+ echo "$progname: gs failed." >&2
+ rm -rf $tmpdir
+ exit 1
+}
+
+# run dvipdfm with the users specified options for the last pass
+echo "$progname: running dvipdfm -dt $@ $dvifile" >&2
+TMP=$tmpdir dvipdfm -dt ${1+"$@"} "$dvifile" || {
+ echo "$progname: dvipdfm failed." >&2
+ rm -rf $tmpdir
+ exit 1
+}
+
+# nothing failed, so cleanup and report success to caller
+rm -rf $tmpdir
+exit 0