/usr/bin/debiandoc2info is in debiandoc-sgml 1.2.32-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 | #!/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'
debiandoc2info 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: debiandoc2info [options] <filename>.sgml
options: -h print this help message
-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 texinfo source
-n <options> onsgmls options to be passed on
-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 makeinfo
if ! which makeinfo >/dev/null 2>&1
then
echo >&2 "${script}: Texinfo documentation system not found"
echo >&2 "${script}: please install the package 'texinfo'"
exit 2
fi
## ----------------------------------------------------------------------
## set default values
basename=''
content=''
contentx=''
postprocessing=''
declaration='-d /usr/share/sgml/debiandoc/dtd/sgml/1.0/debiandoc.dcl'
extension=''
keep=false
keepopt=''
locale=''
onsgmls=''
stdout=false
verbose=false
custom_dir=''
## ----------------------------------------------------------------------
## get command line options
options=':'
options="${options}h"
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}v"
options="${options}X:"
while getopts ${options} opt
do
case ${opt}
in
h ) usage_message
;;
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 ) onsgmls="${onsgmls} -${opt} ${OPTARG}"
;;
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='info'
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} ${onsgmls}"
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}.texinfo ]
then
echo >&2 "${script}: WARNING: overwriting ${bsn}.texinfo"
fi
if ! debiandoc2texinfo ${passing_on} ${1}
then
echo >&2 "${script}: ERROR: ${bsn}.texinfo could not be generated properly"
exit 1
fi
if ! ( ${verbose} || exec >/dev/null 2>&1;
makeinfo --no-validate -v -o ${bsn}${cnt}${ext} ${bsn}.texinfo )
then
echo >&2 "${script}: ERROR: ${bsn}${cnt}${ext} could not be generated properly"
if ! ${verbose}
then
echo >&2 "${script}: rerun with the -v option to find out why"
fi
exit 1
fi
## ----------------------------------------------------------------------
## remove temporary files
if ! ${keep}
then
rm -f ${bsn}.texinfo-in ${bsn}.texinfo
fi
## ----------------------------------------------------------------------
exit 0
## ----------------------------------------------------------------------
|