/usr/bin/debiandoc2latex is in debiandoc-sgml 1.2.29-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 | #!/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'
debiandoc2latex 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: debiandoc2latex [options] <filename>.sgml
options: -h print this help message
-O send output to stdout instead of <filename>.tex
-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 generated file
-n <options> nsgmls options to be passed on
-X <custom_dir> switch locale dependent format data tree
END
exit 0;
}
## ----------------------------------------------------------------------
## print error message
function usage_error
{
echo >&2 "${script}: ${@}";
exit 2;
}
## ----------------------------------------------------------------------
## 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
locale=''
nsgmls=''
stdout=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}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
;;
l ) locale="-${opt} ${OPTARG}"
;;
n ) nsgmls="${nsgmls} ${OPTARG}"
;;
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 input file name
case "${1}"
in
- ) nsgmlsi="-"
if ${keep}
then
usage_error "-k not possible with input from stdin"
fi
stdout=true
;;
-?* ) nsgmlsi="./${1}"
;;
* ) nsgmlsi="${1}"
;;
esac
## ----------------------------------------------------------------------
## get basename
if [ -n "${basename}" ]
then
bsn="$(echo ${basename} | cut -d' ' -f2- | cut -d'/' -f-1)"
else
if [ "${nsgmlsi}" != "-" ]
then
bsn="$(basename ${1} .sgml)"
basename="-b ${bsn}"
fi
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='tex'
extension="-e ${ext}"
fi
ext=".${ext}"
## ----------------------------------------------------------------------
## get declaration
if [ -n "${declaration}" ]
then
declaration="$(echo ${declaration} | cut -d' ' -f2-)"
if [ "$(basename ${declaration})" = "${declaration}" ]
then
declaration="declaration/${declaration}"
fi
fi
## ----------------------------------------------------------------------
## construct temporary file names
tf1="${bsn}.sasp"
tf2="${bsn}.sasp-latex"
## ----------------------------------------------------------------------
## what needs to be passed on to the backend
passing_on=''
passing_on="${passing_on} ${basename}"
passing_on="${passing_on} ${content}"
passing_on="${passing_on} ${contentx}"
passing_on="${passing_on} ${extension}"
passing_on="${passing_on} ${locale}"
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
nsgmls -oline ${nsgmls} ${declaration} ${nsgmlsi} >${tf1}
/usr/share/debiandoc-sgml/saspconvert <${tf1} >${tf2}
if ! ${stdout}
then
exec >${bsn}${cnt}${ext}
fi
sgmlspl /usr/share/perl5/DebianDoc_SGML/Format/Driver.pm -f latex ${passing_on} <${tf2}
if [ -n "${postprocessing}" ]
then
mv ${bsn}${cnt}${ext} ${bsn}${cnt}${ext}-in
"${postprocessing}" ${locale} ${bsn}${cnt}${ext}-in ${bsn}${cnt}${ext}
fi
## ----------------------------------------------------------------------
## remove temporary files
if ! ${keep}
then
rm -f ${tf1} ${tf2} ${bsn}${cnt}${ext}-in
fi
## ----------------------------------------------------------------------
exit 0
## ----------------------------------------------------------------------
|