/usr/bin/debiandoc2latexps is in debiandoc-sgml 1.2.28-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | #!/bin/bash
## ----------------------------------------------------------------------
## ----------------------------------------------------------------------
## exit on erroneous subcommand
set -e
## ----------------------------------------------------------------------
## get script name
script=$(basename ${0})
## ----------------------------------------------------------------------
## print version and usage message
function usage_message
{
cat >&2 <<'END'
debiandoc2latexps version 1.1
Copyright (C) 2005-2008 Osamu Aoki
Copyright (C) 1998-2004 Ardo van Rangelrooij
Copyright (C) 1996 Ian Jackson
This is free software; see the GNU General Public Licence
version 2 or later for copying conditions. There is NO warranty.
usage: debiandoc2latexps [options] <filename>.sgml
options: -h print this help message
-O send output to stdout instead of <filename>.ps
-b <basename> basename to be used
-c use content-negotiation (w/ encoding suffix)
-C use content-negotiation (w/o encoding suffix)
-d <declaration> SGML declaration to be used
-e <extension> extension to be used
-k keep intermediate files
-l <locale> locale to be used
-s <script> apply script on intermediate latex source
-n <options> nsgmls options to be passed on
-1 1 page per page (deprecated, default)
-p <papersize> paper size to be used
-v be verbose
-X <custom_dir> switch locale dependent format data tree
END
exit 0;
}
## ----------------------------------------------------------------------
## print error message
function usage_error
{
echo >&2 "${script}: ${@}";
exit 2;
}
## ----------------------------------------------------------------------
## check for presence of latex
if ! which latex >/dev/null 2>&1
then
echo >&2 "${script}: LaTeX typesetting system not found"
echo >&2 "${script}: please install the package 'texlive-latex-base'"
exit 2
fi
## ----------------------------------------------------------------------
## check for presence of used latex styles
if ! kpsewhich \
fancyhdr.sty \
helvet.sty \
hyperref.sty \
palatino.sty \
pifont.sty \
times.sty \
url.sty \
>/dev/null 2>&1
then
echo >&2 "${script}: one or more used LaTeX typesetting styles not found"
echo >&2 "${script}: please install the package 'texlive-latex-base'"
exit 2
fi
## ----------------------------------------------------------------------
## check for presence of used latex styles
if ! kpsewhich \
footmisc.sty \
paralist.sty \
vmargin.sty \
>/dev/null 2>&1
then
echo >&2 "${script}: one or more used LaTeX typesetting styles not found"
echo >&2 "${script}: please install the package 'texlive-latex-extra'"
exit 2
fi
## ----------------------------------------------------------------------
## check for presence of used latex styles
if ! kpsewhich \
wasysym.sty \
>/dev/null 2>&1
then
echo >&2 "${script}: one or more used LaTeX typesetting styles not found"
echo >&2 "${script}: please install the package 'texlive-fonts-recommended'"
exit 2
fi
## ----------------------------------------------------------------------
## set default values
basename=''
content=''
contentx=''
postprocessing='/usr/share/debiandoc-sgml/fixlatex'
declaration='-d /usr/share/sgml/debiandoc/dtd/sgml/1.0/debiandoc.dcl'
extension=''
keep=false
keepopt=''
locale=''
nsgmls=''
paperopt=''
stdout=false
verbose=false
custom_dir=''
## ----------------------------------------------------------------------
## get command line options
options=':'
options="${options}h"
options="${options}O"
options="${options}b:"
options="${options}c"
options="${options}C"
options="${options}s:"
options="${options}d:"
options="${options}e:"
options="${options}k"
options="${options}l:"
options="${options}n:"
options="${options}1"
options="${options}p:"
options="${options}v"
options="${options}X:"
while getopts ${options} opt
do
case ${opt}
in
h ) usage_message
;;
O ) stdout=true
;;
b ) basename="-${opt} ${OPTARG}"
;;
c ) content="-${opt}"
;;
C ) contentx="-${opt}"
;;
s ) postprocessing="${OPTARG}"
;;
d ) declaration="-${opt} ${OPTARG}"
;;
e ) extension="-${opt} ${OPTARG}"
;;
k ) keep=true
keepopt="-${opt}"
;;
l ) locale="-${opt} ${OPTARG}"
;;
n ) nsgmls="-${opt} ${OPTARG} ${nsgmls}"
;;
p ) PAPERSIZE=${OPTARG}
export PAPERSIZE
paperopt="-t ${PAPERSIZE}"
;;
1 ) echo >&2 "${script}: the -1 option is deprecated and may be removed in the future. It is activated by default now."
;;
v ) verbose=true
;;
X ) custom_dir="${OPTARG}"
;;
\? ) usage_error "unknown option \`${OPTARG}'"
;;
esac
done
shift $((${OPTIND} - 1))
## ----------------------------------------------------------------------
## check remaining command line options
if [ ${#} -ne 1 ]
then
usage_error "need exactly one input filename: $*"
fi
## ----------------------------------------------------------------------
## get basename
if [ -n "${basename}" ]
then
bsn="$(echo ${basename} | cut -d' ' -f2- | cut -d'/' -f-1)"
else
bsn="$(basename ${1} .sgml)"
fi
case "${bsn}"
in
-* ) bsn="./${bsn}"
;;
esac
## ----------------------------------------------------------------------
## get content-negotiation
cnt=''
if [ -n "${content}" ]
then
if [ -n "${locale}" ]
then
cnt="$(echo ${locale} | cut -d' ' -f2-)"
else
cnt='en'
fi
cnt=".${cnt}"
fi
if [ -n "${contentx}" ]
then
if [ -n "${locale}" ]
then
cnt="$(echo ${locale} | cut -d' ' -f2- | sed -e 's/[@\.].*$//')"
else
cnt='en'
fi
cnt=".${cnt}"
fi
## ----------------------------------------------------------------------
## get extension
if [ -n "${extension}" ]
then
ext="$(echo ${extension} | cut -d' ' -f2-)"
else
ext='ps'
fi
ext=".${ext}"
## ----------------------------------------------------------------------
## what needs to be passed on to the backend
passing_on=''
passing_on="${passing_on} ${basename}"
passing_on="${passing_on} ${declaration}"
passing_on="${passing_on} ${keepopt}"
passing_on="${passing_on} ${locale}"
passing_on="${passing_on} ${nsgmls}"
if [ -n "${postprocessing}" ]; then
passing_on="${passing_on} -s ${postprocessing}"
fi
if [ -n "${custom_dir}" ]; then
passing_on="${passing_on} -X ${custom_dir}"
fi
if [ -n "${cnt}" ]; then
# Remove Largest Suffix Pattern if -C or -c is used.
bsn="${bsn%%.*}"
fi
## ----------------------------------------------------------------------
## do the actual work
if [ -e ${bsn}.tex ]
then
echo >&2 "${script}: WARNING: overwriting ${bsn}.tex"
fi
if ! debiandoc2latex ${passing_on} ${1}
then
echo >&2 "${script}: ERROR: ${bsn}.tex could not be generated properly"
exit 1
fi
if [ -e ${bsn}.dvi ] && ( [ -n "${content}" ] || [ -n "${contentx}" ] || [ -n "${extension}" ] )
then
echo >&2 "${script}: WARNING: overwriting ${bsn}.dvi"
fi
touch prior.aux pprior.aux
MAX_LEVEL=9
LEVEL=1
while [ ${LEVEL} -lt ${MAX_LEVEL} ]
do
if ! ( ${verbose} || exec >/dev/null;
latex -interaction=nonstopmode ${bsn}.tex )
then
echo >&2 "${script}: ERROR: ${bsn}.dvi could not be generated properly"
if ! ${verbose}
then
echo >&2 "${script}: rerun with the -v option to find out why"
echo >&2 "${script}: or check the log file ${bsn}.log"
fi
rm -f prior.aux pprior.aux
exit 1
fi
if ( ! cmp ${bsn}.aux prior.aux >/dev/null 2>&1 ) \
&& ( ! cmp ${bsn}.aux pprior.aux >/dev/null 2>&1 )
then
cp -pf prior.aux pprior.aux
cp -pf ${bsn}.aux prior.aux
let LEVEL=LEVEL+1
else
let LEVEL=MAX_LEVEL+1
fi
done
rm -f prior.aux pprior.aux
if [ ${LEVEL} -eq ${MAX_LEVEL} ]
then
echo >&2 "${script}: ERROR: reached maximum rebuilding level (= ${MAX_LEVEL})"
if ! ${verbose}
then
echo >&2 "${script}: rerun with the -v option to find out why"
echo >&2 "${script}: or check the log file ${bsn}.log"
fi
exit 1
fi
if ! ( ${verbose} || exec >/dev/null 2>&1;
dvips -z ${paperopt} -o ${bsn}.ps ${bsn} || dvips ${paperopt} -o ${bsn}.ps ${bsn} )
then
echo -n >&2 "${script}: ERROR: "
if ${stdout}
then
echo -n >&2 "output"
else
echo -n >&2 "${bsn}${cnt}${ext}"
fi
echo >&2 " could not be generated properly"
if ! ${verbose}
then
echo >&2 "${script}: rerun with the -v option to find out why"
fi
exit 1
fi
if ${stdout}
then
cat ${bsn}.ps
if ! ${keep}
then
rm -f ${bsn}.ps
fi
else
if [ -n "${content}" ] || [ -n "${contentx}" ] || [ -n "${extension}" ]
then
mv -f ${bsn}.ps ${bsn}${cnt}${ext}
fi
fi
## ----------------------------------------------------------------------
## remove temporary files
if ! ${keep}
then
rm -f ${bsn}.dvi ${bsn}.tex ${bsn}.aux ${bsn}.log ${bsn}.toc ${bsn}.tex-in
fi
## ----------------------------------------------------------------------
exit 0
## ----------------------------------------------------------------------
|