Re: language.dat handling in Debian
Hi Frank!
On Mon, 18 Jul 2005, Frank Küster wrote:
> > Attached is a draft. What I don't know is what to do with remove without
> > purge stuff?! Do you have an idea?
>
> Oh, shi^W It's getting complicated again. Well, but no too hard, since
Grin.
> - change /var/lib/tetex/fontmap-cfg to /var/lib/tex-common/fontmap-cfg
Done, in fact
from /var/lib/tetex/debian/fontmap-cfg
to /var/lib/tex-common/fontmap-cfg
> - externalize the code by writing a function that can handle both types
> of files, and either put it in a file in /usr/share/tex-common and
> source it by both scripts, or make both scripts generated files using
> the eperl mechanism
I have done something similar. I have generalized update-updmap to
update-fontlang and depending on the calling name the settings are
diffenrent. I attach the update-fontlang file. update-language and
update-updmap should only be links to this file.
And I have also included the change to the above location.
I have (up to now) not included:
- fixes to the man pages
- fixes to the policy
Please incorporate this stuff in the way it should be, if it is ok for
you.
I have adjusted the debian-texlive making script to take care of this,
but I now need a new tex-common again ;-)
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <preining AT logic DOT at> Università di Siena
sip:preining@at43.tuwien.ac.at +43 (0) 59966-690018
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
COTTERSTOCK (n.)
A piece of wood used to stir paint and thereafter stored uselessly in
a shed in perpetuity.
--- Douglas Adams, The Meaning of Liff
#!/bin/sh
#
# update-fontlang --- Generate updmap.cfg and language.dat from a set of files
# Copyright (C) 2002 Atsuhito Kohda
# Copyright (C) 2004 Florent Rougon
# Copyright (C) 2005 Norbert Preining
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.
version="0.5"
progname=$(basename "$0")
if [ "$progname" = "update-language" ] ; then
CNFDIR=/etc/texmf/language.d
CHECKFILE="$CNFDIR/00tex.cnf"
EXT="cnf"
MEMORY_DIR=/var/lib/tex-common/language-cnf
VARD=/var/lib/texmf/tex/generic/config
CFGFILE_BASENAME=language.dat
CFGFILE="$VARD/$CFGFILE_BASENAME"
CC="%" # for COMMENTCHAR
elif [ "$progname" = "update-updmap" ] ; then
CNFDIR=/etc/texmf/updmap.d
CHECKFILE="$CNFDIR/00updmap.cfg"
EXT="cfg"
MEMORY_DIR=/var/lib/tex-common/fontmap-cfg
VARD=/var/lib/texmf/web2c
CFGFILE_BASENAME=updmap.cfg
CFGFILE="$VARD/$CFGFILE_BASENAME"
CC="#"
else
echo "Please call me either as update-updmap or update-language!"
exit 1
fi
usage="Usage: $progname [OPTION...]
Generate $CFGFILE from the files in $CNFDIR.
Options:
--quiet don't write anything to the standard output during
normal operation
--help display this help message and exit
--version output version information and exit"
DebPkgProvidedMaps_magic_comment="^# -_- DebPkgProvidedMaps -_-"
include_file()
{
echo "${CC}${CC}${CC} From file: $file" >>"$tempfile"
cat "$file" >>"$tempfile"
echo "${CC}${CC}${CC} End of file: $file" >>"$tempfile"
}
do_not_include_file()
{
cat >>"$tempfile" <<EOF
${CC}${CC}
${CC}${CC}${CC} $file not included because the
${CC}${CC}${CC} corresponding package seems to be removed.
${CC}${CC}
EOF
}
# -v (verbose) is here for backward compatibility only.
TEMP=$(getopt -o +v --longoptions quiet,help,version -n "$progname" -- "$@")
case $? in
0) : ;;
1) echo "$usage" >&2; exit 1 ;;
*) exit 1 ;;
esac
# Don't remove the quotes around $TEMP!
eval set -- "$TEMP"
# Defaults
quiet=1
while true; do
case "$1" in
--quiet) quiet=1; shift ;;
-v) printf "\
${progname}'s -v option is deprecated. The default mode of operation will
be verbose as soon as enough packages use the --quiet option. Please update
your scripts accordingly.\n\n" >&2; quiet=0; shift ;;
--help) echo "$usage"; exit 0 ;;
--version) echo "$progname $version"; exit 0 ;;
--) shift; break ;;
*) echo "$progname: unexpected option '$1'; please report a bug." >&2
exit 1 ;;
esac
done
# Non-option arguments are not allowed.
if [ $# -ne 0 ]; then
echo "$usage" >&2
exit 1
fi
if [ -L "$CFGFILE" ]; then
if [ $quiet = 0 ]; then
echo "$CFGFILE is a symbolic link; $progname won't do anything."
fi
exit 0
fi
if ! [ -r "$CHECKFILE" ] ; then
echo "$progname: cannot read $CHECKFILE" >&2
exit 1
fi
if [ $quiet = 0 ]; then
if [ -f "${CFGFILE}" ]; then
echo -n "Regenerating ${CFGFILE}... "
else
echo -n "Generating ${CFGFILE}... "
fi
fi
tempfile=$(mktemp -t "${progname}.XXXXXX") || exit 1
# This should not be racy, because the file should be created by mktemp with
# root as the owner (if we are running as root) and 600 as the mode. Depending
# on local configuration, the owner group might be something else than root,
# so we call chown to be sure, and then set the appropriate mode, i.e. 644.
chown root:root "$tempfile"
chmod 644 "$tempfile"
cat > "$tempfile" <<EOF
${CC}${CC}${CC} This file is automatically generated by $progname
${CC}
${CC} PLEASE DO NOT EDIT THIS FILE DIRECTLY. It is meant to be generated from
${CC} files in $CNFDIR
${CC}
${CC} If you want a smooth upgrade, please edit the files in ${CNFDIR},
${CC} or create an additional one (with the extension .$EXT),
${CC} and invoke $progname.
${CC}${CC}
EOF
find "$CNFDIR" -type f -name '*.'${EXT} | LC_COLLATE=C sort | while read file; do
# Does "$file" have the magic comment?
if grep -E "$DebPkgProvidedMaps_magic_comment" "$file" >/dev/null; then
# Is the package "$file" comes from still installed?
if [ -d "$MEMORY_DIR" ] \
&& find "$MEMORY_DIR" -name '*.list' -print0 \
| xargs -0r cat \
| grep -E "^$(basename "$file" .$ext)\$" >/dev/null; then
include_file "$file"
else
do_not_include_file "$file"
fi
else
include_file "$file"
fi
done
mv "$tempfile" "$CFGFILE"
if [ $quiet = 0 ]; then
printf "done.\n\n"
echo "$progname has updated ${CFGFILE_BASENAME}."
fi
Reply to: