Debian Codegraph @

texk/texlive/linked_scripts/pst-pdf/ps4pdf

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # Copyright (C) 2004, Thomas Esser. Public domain.
4 # 2005-03-08: New option "--crop", Rolf Niepraschk.
5 # dvips call only if the dvi file exist (RN).
6 # 2005-06-27: ps2pdf call only if the ps file exist (RN).
7 # 2006-04-05: "\RequirePackage{pst-pdf}" added to the (pdf)LaTeX calls
8 # as suggested by Niall Murphy.
9 # 2006-07-14: Better temp dir handling (suggested by Karl Berry) (RN).
10 # 2006-07-23: New option --Xps2pdf and code cleanup (thanks to Karl Berry) (RN).
11 # 2008-08-04: Remove the parameter "-Ppdf" from the dvips call (RN).
12 # 2016-07-02: New option "--xelatex", (hv)
13 # "--lualatex" , (hv)
14 # 2016-07-11: Better tests if xelatex or lualatex (RN)
15
16 # First, work around bugs/limitations in some shells on some systems:
17 testscip-shell system . . test. -f /bin/sh5scip-shell filesystem . . `/bin/sh5`. && testscip-shell system . . test. -z "$RUNNING_SH5" \
18 && { UNAMES=`unamescip-shell system . . uname. -s`; testscip-shell system . . test. "x$UNAMES" = xULTRIX; } 2>/dev/nullscip-shell filesystem . . `/dev/null`. \
19 && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5scip-shell filesystem . . `/bin/sh5`. $0 ${1+"$@"}; }
20 unset RUNNING_SH5
21
22 testscip-shell system . . test. -f /bin/bshscip-shell filesystem . . `/bin/bsh`. && testscip-shell system . . test. -z "$RUNNING_BSH" \
23 && { UNAMES=`unamescip-shell system . . uname. -s`; testscip-shell system . . test. "x$UNAMES" = xAIX; } 2>/dev/nullscip-shell filesystem . . `/dev/null`. \
24 && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bshscip-shell filesystem . . `/bin/bsh`. $0 ${1+"$@"}; }
25 unset RUNNING_BSH
26
27 # hack around a bug in zsh:
28 testscip-shell system . . test. -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
29
30 ###############################################################################
31 # cleanup()
32 # clean up the temp area and exit with proper exit status
33 ###############################################################################
34 cleanupscip-shell shell texlive-bin 2026.20260303.78225+ds-4 cleanup().()
35 {
36 rc=$?
37 $needsCleanup && testscip-shell system . . test. -n "$tmpdir" && testscip-shell system . . test. -d "$tmpdir" \
38 && { rmscip-shell system . . rm. -f "$tmpdir"/*; cd /scip-shell filesystem . . `/`.; rmdirscip-shell system . . rmdir. "$tmpdir"; }
39
40 # set exit code in a portable way; see the autoconf manual for details:
41 (exit $rc); exit $rc
42 }
43
44 ###############################################################################
45 # setupTmpDir()
46 # set up a temp directory and a trap to remove it
47 ###############################################################################
48 setupTmpDirscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupTmpDir().()
49 {
50 $needsCleanup && return
51
52 trap 'cleanup' 1 2 3 7 13 15
53 needsCleanup=true
54 (umask 077; mkdirscip-shell system . . mkdir. "$tmpdir") \
55 || abort "could not create directory \`$tmpdir'"
56 }
57 ###############################################################################
58 # myexec(args)
59 # execute the command given as "args"; abort on error; redirect messages to
60 # log in "silent" mode; redirect stdin (</dev/null) in silent mode
61 ###############################################################################
62 myexecscip-shell shell texlive-bin 2026.20260303.78225+ds-4 myexec().()
63 {
64 if $silent; then
65 echoscip-shell system . . echo. "$0: running $@"
66 "$@" >$log 2>&1 </dev/nullscip-shell filesystem . . `/dev/null`.
67 rc=$?
68 else
69 "$@"
70 rc=$?
71 fi
72 if testscip-shell system . . test. $rc != 0; then
73 echoscip-shell system . . echo. "$0: command $@ returned with code $rc"
74 catscip-shell system . . cat. <$log
75 (exit $rc) # set return value
76 cleanupscip-shell shell texlive-bin 2026.20260303.78225+ds-4 cleanup().
77 fi
78 }
79
80 # some initializations
81 progname=pdflatexps
82 silent=true # default setting; change if you like
83 crop=false
84 needsCleanup=false
85 ps2pdf_opts="-dAutoRotatePages=/None"
86 tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/.$progname$$
87 log=$tmpdir/log
88 version="1.0"
89
90 ## the defaults
91 ENGINE1=latex
92 OPTIONS=
93 ENGINE2=pdflatex
94 DVIPS=dvips
95 PS2PDF=ps2pdf
96 FILE=$1
97
98 # look for optional things first
99 while
100 case $1 in
101 --help|-h) echoscip-shell system . . echo. "$0 [-v|-q|--crop|--version|--Xps2pdf OPT] FILE"
102 echoscip-shell system . . echo. "Process LaTeX document FILE using the pst-pdf package,"
103 echoscip-shell system . . echo. "including running latex, dvips, and ps2pdf as necessary."
104 echoscip-shell system . . echo. "--Xps2pdf OPT passes OPT to ps2pdf."
105 echoscip-shell system . . echo. " (-dAutoRotatePages=/None is always passed.)"
106 echoscip-shell system . . echo. "--crop runs pdfcrop on ps2pdf output."
107 echoscip-shell system . . echo. "--lualatex using the luatex engine for .dvi and .pdf"
108 echoscip-shell system . . echo. "--xelatex using the xetex engine for .xdv and .pdf"
109 exit 0;;
110 --version) echoscip-shell system . . echo. "$progname version $version"; exit 0;;
111 --lualatex) ENGINE1=lualatex;
112 OPTIONS="--output-format=dvi";
113 ENGINE2=lualatex; FILE=$2;;
114 --xelatex) ENGINE1=xelatex;
115 OPTIONS="-no-pdf";
116 ENGINE2=xelatex;
117 DVIPS=xdvipdfmx; FILE=$2;;
118 --crop|-c) crop=true;;
119 --Xps2pdf|-Xps2pdf) shift; ps2pdf_opts="$ps2pdf_opts $1";;
120 -q) silent=true;;
121 -v) silent=false;;
122 -*) echoscip-shell system . . echo. "$progname: unknown option $1 ignored";;
123 *) break;;
124 esac
125 do
126 shift
127 done
128
129 # remaining option: filename
130 if testscip-shell system . . test. -z "$FILE"; then
131 echoscip-shell system . . echo. "$0: no file to process, try --help for more information." >&2
132 exit 1
133 fi
134
135 # jobname von TeX: Verzeichnisse entfernen, evtl. vorhandene Extension
136 # entfernen.
137 job=`echoscip-shell system . . echo. "x$1" | sedscip-shell system . . sed. 's@x@@; s@.*/@@; s@\.[^.]*$@@'`
138
139 setupTmpDirscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupTmpDir().
140 myexecscip-shell shell texlive-bin 2026.20260303.78225+ds-4 myexec(). ${ENGINE1} ${OPTIONS} "\AtBeginDocument{\RequirePackage{pst-pdf}} \input{$FILE}"
141
142 if testscip-shell system . . test. "$ENGINE1" = "latex" || testscip-shell system . . test. "$ENGINE1" = "lualatex"; then
143 myexecscip-shell shell texlive-bin 2026.20260303.78225+ds-4 myexec(). ${DVIPS} -o "$job-pics.ps" "$job.dvi"
144 else
145 myexecscip-shell shell texlive-bin 2026.20260303.78225+ds-4 myexec(). ${DVIPS} -o "$job-pics.pdf" "$job.xdv"
146 fi
147
148 testscip-shell system . . test. -f "$job-pics.ps" && myexecscip-shell shell texlive-bin 2026.20260303.78225+ds-4 myexec(). ${PS2PDF} "$ps2pdf_opts" "$job-pics.ps" "$job-pics.pdf"
149
150 if $crop; then
151 myexecscip-shell shell texlive-bin 2026.20260303.78225+ds-4 myexec(). pdfcrop "$job-pics.pdf" "$job-pics-crop.pdf"
152 mvscip-shell system . . mv. "$job-pics-crop.pdf" "$job-pics.pdf"
153 fi
154 myexecscip-shell shell texlive-bin 2026.20260303.78225+ds-4 myexec(). ${ENGINE2} "\AtBeginDocument{\RequirePackage{pst-pdf}} \input{$FILE}"
155 truescip-shell system . . true.
156 cleanupscip-shell shell texlive-bin 2026.20260303.78225+ds-4 cleanup().
157