[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#209395: teTeX: language.dat mislinked



frank@kuesterei.ch (Frank Küster) wrote:

> So here comes my stuff. The patch I propose is not very complicated, I
> hope, but still rather long. 

I have integrated the two improvements that I discussed with Florent: 

- the aliases ("=austrian", "=patois") are now correctly handled

- to check whether the defaults french and ngerman need to be added, I
  now use the mechanism we built in exactly for that, i.e. the
  shown_again flag of tetex-bin/hyphen.

This is the updated patch, it's against tetex-bin_2.0.2-6.

Regards, Frank

--- tetex-bin-2.0.2/debian/config.orig	Sat Feb  7 15:42:49 2004
+++ tetex-bin-2.0.2/debian/config	Fri Feb  6 22:38:43 2004
@@ -1,6 +1,13 @@
 #!/bin/sh -e
 
-DEFAULTS="french[=patois], ngerman[=naustrian-neue_Rechtschreibung]"
+DEFAULTS_ADD="french[=patois], ngerman[=naustrian-neue_Rechtschreibung]"
+DFLT=/usr/share/tetex-base/language.dflt
+TEXMF_LDAT=/usr/share/texmf/tex/generic/config/language.dat
+LDAT_PATTERNS="inhyph bahyph hrhyph czhyph dehypht dehyphn dkhyphen nehyph \
+    fi8hyph frhyph grhyph ithyph lahyph huhyph nohyph nohyphb nohyphbc \
+    plhyph pt8hyph rohyphen ruhyphen skhyph sihyph23 sphyph trhyph \
+    ukhyphen ukrhyph ukrhyph.t2a ukrhyph.lcy ukrhyph.ot2"
+
 
 # Use debconf.
 . /usr/share/debconf/confmodule || exit
@@ -49,49 +56,184 @@
     fi
 fi
 
-# suggest a user to select extra hyphen patterns to load
+# handling of language.dat (hyphenation). We first define some functions, 
+# the actual work begins at "user interaction"
+parse_ldat (){
+  file=$1
+  tempfile=`mktemp`
+  # get non-comment, non-blank, non-alias lines, then filter out 
+  # american and nohyphenation
+  egrep -v '^[[:blank:]]*%|^[[:blank:]]*$|^[[:blank:]]*=' $file | \
+    egrep -v 'american|nohyphenation'  > $tempfile
+
+  for language in $LDAT_PATTERNS; do
+    if grep  $language $tempfile >/dev/null 2>&1; then
+      # we found the pattern in current language.dat, use it also
+      # as debconf default:
+      assign_default $language
+    fi
+  done
+  # now remove the ", " from the beginning of the variable, it is there because
+  # when assign_default was called for the first time, default was empty.
+  default=${default#, }
+  # assign the external variable
+  DEFAULTS=$default
+  rm $tempfile
+}
+
+assign_default () {
+  case $1 in
+    ukhyphen)
+      default="$default, british" ;;
+    frhyph) 
+      default="$default, french[=patois]" ;;
+    dehypht)
+      default="$default, german[=austrian-alte_Rechtschreibung]" ;;
+    dehyphn)
+      default="$default, ngerman[=naustrian-neue_Rechtschreibung]" ;;
+    inhyph)
+      default="$default, bahasa" ;;
+    bahyph)
+      default="$default, basque" ;;
+    hrhyph)
+      default="$default, croatian" ;;
+    czhyph)
+      default="$default, czech" ;;
+    dkhyphen)
+      default="$default, danish" ;;
+    nehyph)
+      default="$default, dutch" ;;
+    fi8hyph)
+      default="$default, finnish" ;;
+    grhyph)
+      default="$default, greek" ;;
+    ithyph)
+      default="$default, italian" ;;
+    lahyph)
+      default="$default, latin" ;;
+    huhyph)
+      default="$default, magyar" ;;
+    nohyph)
+      default="$default, norsk[old]" ;;
+    nohyphb)
+      default="$default, norsk[nohyphb.tex]" ;;
+    nohyphbc)
+      default="$default, norsk[nohyphbc.tex]" ;;
+    plhyph)
+      default="$default, polish" ;;
+    pt8hyph)    
+      default="$default, portuges" ;;
+    rohyphen)
+      default="$default, romanian" ;;
+    ruhyphen)
+      default="$default, russian" ;;
+    skhyph)
+      default="$default, slovak" ;;
+    sihyph23)
+      default="$default, slovene" ;;
+    sphyph)
+      default="$default, spanish" ;;
+    trhyph)
+      default="$default, turkish" ;;
+    ukrhyph)
+      default="$default, ukrainian[ukrhyph.tex]" ;;
+    ukrhyph.t2a)    
+      default="$default, ukranian[ukrhyph.t2a]" ;;
+    ukrhyph.lcy)
+      default="$default, ukranian[ukrhyph.lcy]" ;;
+    ukrhyph.ot2)
+      default="$default, ukranian[ukrhyph.ot2]" ;;
+  esac
+}
+
+# user interaction:
+#
+# First, ask the user whether to handle language.dat with debconf at all.
 db_input medium tetex-bin/use_debconf || true
 db_go
 db_get tetex-bin/use_debconf || true
 if [ "$RET" = "true" ]; then
-    db_fget tetex-bin/hyphen seen
-    # has this question been seen? If yes, we want to make the 
-    # values chosen part of the default
-    if [ "$RET" = "true" ]; then
-	db_get tetex-bin/hyphen
-    # there might still have been no extra pattern selected
-	if [ -z "$RET" ]; then
-	    DEFAULT_ANS="$DEFAULTS"				
-	else
-    # If we add a default in the future, or somebody has added
-    # patterns in the buggy versions, there might be double
-    # occurences. we have to fish them out.
-	    DEFAULTS_MERGED="$DEFAULTS, $RET"
-	    DEFAULT_ANS=`echo -n "$DEFAULTS_MERGED" | tr -d ',' | tr ' ' '\n' | sort -u | tr '\n' ',' | sed 's/,$//' | sed 's/,/, /g'`
-	fi
+  # O.K., we are using debconf for hyphenation.
+  #
+  # is there a language.dat yet? It may be at different places.
+  if [ -f  $TEXMF_LDAT ]; then 
+    # -f is also true if it is a symlink to a regular file, so we have to
+    # check this separately
+    if [ ! -L $TEXMF_LDAT ]; then
+      CUR_LDAT=$TEXMF_LDAT;
     else
-    # the question has never been seen (either fresh install 
-    # or upgrading directly from woody), so there's nothing to keep:
-	DEFAULT_ANS="$DEFAULTS"				
-    fi
-    db_set tetex-bin/hyphen "$DEFAULT_ANS"
-    # Every user has to see this question once again, even if he/she has
-    # yet answered the question in a previous upgrade. But this script 
-    # is run again on every subsequent upgrade, and by postinst, we have
-    # to check for that.
-    db_fget tetex-bin/hyphen shown_again
-    if [ "$RET" = "false" ]; then
-	db_fset tetex-bin/hyphen seen false
-	db_fset tetex-bin/hyphen shown_again true
+      CUR_LDAT=`readlink -f /usr/share/texmf/tex/generic/config/language.dat` || true;
     fi
-    db_input medium tetex-bin/hyphen || true
-    db_go
-    # after fiddling with the seen flag, it has to be set to true manually. 
-    # We do this only if the debconf command succeeded.
-    RETVAL=$?
-    if [  "$RETVAL" -eq 0 ]; then
-	if [ "$RET" = "true" ]; then
-	    db_fset tetex-bin/hyphen seen true
+  fi
+  if [ -n "$CUR_LDAT" ]; then
+    # we have to respect what is in there. Therefore we parse the
+    # current language.dat to see which of the hyphenation patterns we
+    # ship are enabled, and set our debconf defaults accordingly. To
+    # do this, we use the functions defined above.
+    #
+    # This sets the variable DEFAULTS
+    parse_ldat $CUR_LDAT
+    # it might be that the user's setup really used
+    # /etc/texmf/language.dat, but he still tried to enable patterns
+    # using debconf. Or the other way round: it might be that the link
+    # really pointed to /var/lib/texmf/language.dat, but the user has 
+    # edited /etc/texmf/language.dat We look also for these. 
+    for other_ldat in /etc/texmf/language.dat /var/lib/texmf/language.dat; do
+      if [ $CUR_LDAT != $other_ldat -a -f $other_ldat ]; then
+	DEFAULTS_BAK="$DEFAULTS"
+	parse_ldat $other_ldat
+        # and add them. The if-statement is the easy way to get the comma in; 
+        # IFS=', ' could also work?
+	if [ -n "$DEFAULTS" ]; then
+	  DEFAULTS="$DEFAULTS, $DEFAULTS_BAK"
+	else
+	  DEFAULTS="$DEFAULTS_BAK"
 	fi
+      fi
+    done
+  else
+    # no language.dat yet. We will copy the default file in postinst, and
+    # now set DEFAULTS to nothing. 
+    DEFAULTS=""
+  fi
+  # 
+  # In version 2.0.2-4.3 we introduced a change that resulted in bug
+  # #208408.  The problem was that french, german and ngerman, which
+  # were (implicitly) in the defaults before 4.3, were quietly dropped.
+  # To enable the user to get them again, everyone has to see this
+  # question once again, even if he/she has yet answered the question
+  # in a previous upgrade. But this script is run again on every
+  # subsequent upgrade, and by postinst, we have to check for that, 
+  # using the additional flag shown_again.
+  # 
+  # Furthermore, if we have to show again, we also need to add french
+  # and ngerman to the defaults
+  db_fget tetex-bin/hyphen shown_again
+  if [ "$RET" = "false" ]; then
+    db_fset tetex-bin/hyphen seen false
+    db_fset tetex-bin/hyphen shown_again true
+    # now add the additional defaults
+    DEFAULTS_MERGED="$DEFAULTS, $DEFAULTS_ADD"
+    # pick out double occurences
+    DEFAULT_ANS=`echo -n "$DEFAULTS_MERGED" | \
+    tr -d ',' | tr ' ' '\n' | sort -u | tr '\n' ',' | \
+    sed 's/,$//' | sed 's/,/, /g'`
+  else
+    DEFAULT_ANS="$DEFAULTS"
+  fi
+  # now set the debconf default to the list we got. It doesn't matter if
+  # we set a question that will not be shown (again), because it will be 
+  # set to what has been answered before (plus the manual changes).
+  db_set tetex-bin/hyphen "$DEFAULT_ANS"
+  #
+  db_input medium tetex-bin/hyphen || true
+  db_go
+  # after fiddling with the seen flag, it has to be set to true manually. 
+  # We do this only if the debconf command succeeded.
+  RETVAL=$?
+  if [  "$RETVAL" -eq 0 ]; then
+    if [ "$RET" = "true" ]; then
+      db_fset tetex-bin/hyphen seen true
     fi
+  fi
 fi
--- tetex-bin-2.0.2/debian/postinst.orig	Sat Feb  7 15:42:37 2004
+++ tetex-bin-2.0.2/debian/postinst	Sat Feb  7 15:16:58 2004
@@ -16,6 +16,7 @@
 install-info --quiet --section teTeX teTeX --menuentry="LaTeX2e" --description="LaTeX2e help 1.6." /usr/share/info/latex.info
 
 PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
+TMPDIR=/tmp # mktemp will create its files there
 envvars="
 AFMFONTS BIBINPUTS BSTINPUTS DVILJFONTS DVIPSFONTS DVIPSHEADERS GFFONTS
 GLYPHFONTS INDEXSTYLE MFBASES MFINPUTS MFPOOL MFTINPUTS MPINPUTS MPMEMS
@@ -46,10 +47,19 @@
 VUMAPC=${VDIR}/updmap.cfg
 UMAPCTPL=/usr/share/tetex-base/updmap.cfg
 UPDMAP=/usr/sbin/update-updmap
-LDAT=/var/lib/texmf/language.dat
+LDAT=/etc/texmf/language.dat
 LDATD=/usr/share/texmf/tex/generic/config
-ELDAT=/etc/texmf/language.dat
+#ELDAT=/etc/texmf/language.dat
 DFLT=/usr/share/tetex-base/language.dflt
+MOVE_EXT=dpkg-old
+LDAT_VERSION=2.0.2-6 # this should be the version of tetex-base
+                     # that ships the correct language.dflt    
+LDAT_PATTERNS="inhyph.tex bahyph.tex hrhyph.tex czhyph.tex dehypht.tex dehyphn.tex \
+    dkhyphen.tex nehyph.tex fi8hyph.tex frhyph.tex grhyph.tex ithyph.tex lahyph.tex huhyph.tex nohyph.tex nohyphb.tex nohyphbc.tex \
+    plhyph.tex pt8hyph.tex rohyphen.tex ruhyphen.tex skhyph.tex sihyph23.tex sphyph.tex trhyph.tex \
+    ukhyphen.tex ukrhyph.tex ukrhyph.t2a ukrhyph.lcy ukrhyph.ot2"
+
+
 umask 022
 
 if [ ! -L /usr/lib/texmf/web2c ]
@@ -189,47 +199,315 @@
     { mkdir "$vardir/source" && chmod 1777 "$vardir/source"; }
 fi
 
-# language.dat handling
+###########################################
+#      handling of language.dat
+###########################################
+
+# first some helper function. The real action begins at the next db_get.
+uncomment_ldat(){
+  pattern="$1"
+  TMP_LDAT=`mktemp`
+  
+  newpattern=${pattern#%! }
+  # we do the replacement globally, in case there are two lines for that pattern. 
+  sed -e "s/$pattern/$newpattern/g" $LDAT > $TMP_LDAT
+  chown --reference=$LDAT $TMP_LDAT
+  chmod --reference=$LDAT $TMP_LDAT
+  mv $TMP_LDAT $LDAT
+}
+
+add_pattern(){
+  pattern=$1
+  tofile=$2
+  sourcefile=$3
+  if [ $debconf_added = 0 ]; then
+    debconf_added=1
+    cat >> $tofile <<EOF
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%                        patterns added by debconf                      %%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% the following patterns have been added by debconf, and can be managed 
+%% by it, but it will notice if you change them manually. 
+%% As always, use "%! " as comment sign!
+
+EOF
+  fi
+  line=`grep $pattern $sourcefile`
+  echo $line >> $tofile
+}
+
+sanitize_ldat(){
+  debconf_added=0 # see add_pattern()
+  file=$1
+  tempfile=`mktemp`
+  source=`mktemp`
+  # have we checked this file before? If yes, we don't do anything.
+  grep "checked by postinst $LDAT_VERSION" $file >/dev/null && return 0
+  # Still there? So there is work to be done.
+  #
+  # first make a backup copy
+  cat >/etc/texmf/language.dat.postinst-bak <<EOF
+%% ********************************************************************
+%%  this is a backup copy of your old language.dat, which was modified
+%%  by the postinst script of the tetex-bin package. You can savely 
+%%  delete it once you're sure the new setup works.
+%%
+%% ********************************************************************
+
+EOF
+  cat $file >>/etc/texmf/language.dat.postinst-bak
+  # put in comment remark 
+  # this should be in $DFLT in the future, just check for it then.
+  if ! grep "To make it possible for package scripts to parse this file" $file >/dev/null 2>&1; then
+    cat > $tempfile <<EOF 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%  To make it possible for package scripts to parse this file, 
+%%  please use only "%! " to comment out hyphenation patterns!
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+EOF
+    cat $file >> $tempfile
+    chmod --reference=$file $tempfile
+    chown --reference=$file $tempfile
+    mv -f $tempfile $file
+  fi
+  # unfortunately, norsk (nohyph) is matched by "nohyphenation". We take that out.
+  grep -v nohyphenation $DFLT > $source
+  grep -v nohyphenation $file > $tempfile
+  # add missing patterns
+  for language in $LDAT_PATTERNS; do
+    if ! grep $language $tempfile >/dev/null 2>&1; then
+      # this pattern is not yet in the file
+      add_pattern $language $file $source # yes, add them to file, not tempfile!
+    fi
+  done
+  if [ $debconf_added = 1 ]; then
+    cat >> $file <<EOF
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%                      end of debconf added patterns                    %%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+EOF
+  fi
+  # 
+  # now make sure we don't repeat this without need.
+  echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" >> $file 
+  echo "%%                 checked by postinst $LDAT_VERSION                           %%" >> $file 
+  echo "%%                    do not remove this comment!                        %%" >> $file 
+  echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" >> $file 
+  # now remove temporary files
+  rm $tempfile $source
+}
+
+uncomment_alias(){
+  parent_pattern=$1
+  file=$2
+  aliastmp=`mktemp`
+  case $parent_pattern in
+    frhyph.tex)
+      alias=patois ;;
+    dehypht.tex)
+      alias=austrian ;;
+    dehyphn.tex)
+      alias=naustrian ;;
+    british)
+      alias=UKenglish ;;
+    *)
+      alias="" ;;
+    # we don't handle english, this can be an alias for both british and american
+  esac
+  if [ -n "$alias" ]; then
+    sed -s "s/^[[:blank:]]*\(=$alias\)/%! \1/g" $file > $aliastmp
+    chmod --reference=$file $aliastmp
+    chown --reference=$file $aliastmp
+    mv -f $aliastmp $file
+  fi
+}
+
+
+allcomment_ldat(){
+  file=$1
+  # comment out all debconf managed patterns, and make sure "%! "
+  # is used. This the easiest way to enable the user to deactivate
+  # patterns in debconf. The patterns used before and/or chosen in debconf
+  # will be enabled later.
+  for language in $LDAT_PATTERNS; do
+    tempfile1=`mktemp`
+    tempfile2=`mktemp`
+    # replace other comment signs. We don't replace them if they contain
+    # alphanumeric characters, because we cannot discriminate between
+    # %a lang langhyph.tex
+    # and
+    # % langb langbhyph.tex % better than: lang langhyph.tex
+    # and would blow away most of the line. Well, anybody using
+    # the first variant has been warned.
+    sed -s "s/^%[[:punct:][:blank:]]*\([[:alnum:]][[:alnum:]]*[[:blank:]][[:blank:]]*$language\)/%! \1/g" $file > $tempfile1
+    # comment out active patterns, we do the replacement
+    # globally. This means: If such a line occurs multiple times, both
+    # are commented out, and later uncommented if specified. Would be
+    # nice if we could take out one of them - but which?
+    sed -s "s/^\([[:blank:]]*[[:alnum:]]*[[:blank:]][[:blank:]]*$language\)/%! \1/g" $tempfile1 > $tempfile2
+    # the above expression will _not_ match nohyphenation, because it is the 
+    # first word on the line, unlike nohyph.tex.
+    #
+    # now replace the file
+    chmod --reference=$file $tempfile2
+    chown --reference=$file $tempfile2
+    mv -f $tempfile2 $file
+    rm $tempfile1
+    #
+    # now check whether there's an alias for that pattern, if yes comment it out, too.
+    uncomment_alias $language $file
+  done
+}
+
+move_ldat(){
+  oldplace=$1
+  newplace=$2
+  if [ -e $newplace ]; then
+    # there is a file yet, but since it is not the same as $CUR_LDAT, 
+    # it was not used.
+    mv $newplace $newplace.$MOVE_EXT
+  fi
+  mv $oldplace $newplace
+  cat >$oldplace.$MOVE_EXT <<EOF
+The configuration file language.dat has been moved to /etc/texmf/language.dat.
+
+Your settings have been preserved. Please make any changes there.
+EOF
+}
+
+# here begins the real language.dat action
 db_get tetex-bin/use_debconf || true
 if [ "$RET" = "true" ]; then
-# rename unused language.dat
-    if [ -f ${ELDAT} ]; then mv -f ${ELDAT} ${ELDAT}.dpkg-old; fi
-    if [ -f ${DFLT} ]; then
-      cp -f ${DFLT} ${LDAT}
-      rm -f ${LDATD}/language.dat
-      (cd ${LDATD} ; ln -s ${LDAT} .)
-    fi
-      db_get tetex-bin/hyphen || true
-      IFS=' ,'
-      lang="$RET"
-      for l in $lang; do
-	case $l in
-	none) cp -f $DFLT $LDAT ;;
-	british) sed -e "s/%! british  ukhyphen.tex/british  ukhyphen.tex/" $LDAT | sed -e "s/%! =UKenglish/=UKenglish/" > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	french\[=patois\]) sed -e "s/%! french/french/" $LDAT | sed -e "s/%! =patois/=patois/" > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	german\[=austrian-alte_Rechtschreibung\]) sed -e "s/%! german/german/" $LDAT | sed -e "s/%! =austrian/=austrian/" > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	ngerman\[=naustrian-neue_Rechtschreibung\]) sed -e "s/%! ngerman/ngerman/" $LDAT | sed -e "s/%! =naustrian/=naustrian/" > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	norsk\[old\]) sed -e "s/%! norsk	nohyph.tex/norsk	nohyph.tex/" $LDAT > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	norsk\[nohyphb\.tex\]) sed -e "s/%! norsk	nohyphb.tex/norsk	nohyphb.tex/" $LDAT > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	norsk\[nohyphbc\.tex\]) sed -e "s/%! norsk	nohyphbc.tex/norsk	nohyphbc.tex/" $LDAT > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	ukrainian\[ukrhyph\.tex\]) sed -e "s/%! ukrainian	ukrhyph.tex/ukrainian	ukrhyph.tex/" $LDAT > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	ukrainian\[ukrhyph\.t2a\]) sed -e "s/%! ukrainian	ukrhyph.t2a/ukrainian	ukrhyph.t2a/" $LDAT > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	ukrainian\[ukrhyph\.lcy\]) sed -e "s/%! ukrainian	ukrhyph.lcy/ukrainian	ukrhyph.lcy/" $LDAT > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	ukrainian\[ukrhyph\.ot2\]) sed -e "s/%! ukrainian	ukrhyph.ot2/ukrainian	ukrhyph.ot2/" $LDAT > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-	*) sed -e "s/%! $l/$l/" $LDAT > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
-        esac
-      done
+  # This means the user chose to manage language.dat with debconf.
+  #
+  # Where is language.dat (or is it not yet anywhere)?
+  if [ -f  $LDATD/language.dat ]; then 
+    # this is true if it is a regular file, or a link to a regular file
+    if [ ! -L $LDATD/language.dat ]; then
+      CUR_LDAT=$LDATD/language.dat; 
+    else
+      CUR_LDAT=`readlink -f $LDATD/language.dat` || true
+    fi
+  fi
+  if [ -n "$CUR_LDAT" ]; then
+    # There is a language.dat yet, now we have to make sure that it contains
+    # the debconf-managed patterns, and that they are all _commented_ (if not,
+    # we will never be able to remove any pattern via debconf). We do yet
+    # know which were active, from config via tetex-bin/hyphen
+    # 
+    # There are a functions to do that...
+    sanitize_ldat $CUR_LDAT
+    allcomment_ldat $CUR_LDAT
+    # if language.dat currently is in /etc/texmf, we are fine. Else we have to
+    # move it:
+    case $CUR_LDAT in
+      $LDAT)
+	;;
+      *)
+	# make sure that there's nothing in the way
+	move_ldat $CUR_LDAT $LDAT
+	;;
+    esac
+  else
+    # no language.dat so far, anywhere, so copy the default file. 
+    # No need to comment out anything
+    cp -f ${DFLT} ${LDAT}
+  fi
+  # now activate the correct patterns in LDAT
+  db_get tetex-bin/hyphen || true
+  IFS=' ,'
+  lang="$RET"
+  for l in $lang; do
+    case $l in
+      none) ;; # If the user wants to shoot himself in the foot and has 
+               # commented out any english, we let him do that.
+      british)
+	uncomment_ldat "%! british  ukhyphen.tex" 
+	uncomment_ldat "%! =UKenglish"
+	;;
+      french\[=patois\])
+      uncomment_ldat "%! french		frhyph.tex"
+      uncomment_ldat "%! =patois"
+      ;;
+      german\[=austrian-alte_Rechtschreibung\])
+      uncomment_ldat "%! german		dehypht.tex"
+      uncomment_ldat "%! =austrian"
+      ;;
+      ngerman\[=naustrian-neue_Rechtschreibung\])
+      uncomment_ldat "%! ngerman		dehyphn.tex"
+      uncomment_ldat "%! =naustrian"
+      ;;
+      norsk\[old\])
+      uncomment_ldat "%! norsk	nohyph.tex"
+      ;;
+      norsk\[nohyphb\.tex\])
+      uncomment_ldat "%! norsk	nohyphb.tex"
+      ;;
+      norsk\[nohyphbc\.tex\])
+      uncomment_ldat "%! norsk	nohyphbc.tex"
+      ;;
+      ukrainian\[ukrhyph\.tex\])
+      uncomment_ldat "%! ukrainian	ukrhyph.tex"
+      ;;
+      ukrainian\[ukrhyph\.t2a\])
+      uncomment_ldat "%! ukrainian	ukrhyph.t2a"
+      ;;
+      ukrainian\[ukrhyph\.lcy\])
+      uncomment_ldat "%! ukrainian	ukrhyph.lcy"
+      ;;
+      ukrainian\[ukrhyph\.ot2\])
+      uncomment_ldat "%! ukrainian	ukrhyph.ot2"
+      ;;
+      *) 
+	uncomment_ldat "%! $l"
+	;;
+    esac
+  done
 else
-    if [ ! -f ${ELDAT} ]; then
-	if [ -f ${ELDAT}.dpkg-old ]; then
-	    mv ${ELDAT}.dpkg-old ${ELDAT}
-	else
-	    cp ${DFLT} ${ELDAT}
-	fi
+  # else means that language.dat should not be managed by debconf. Still
+  # we have to make sure that one is there. Or it might be at some other place... 
+  if [ -f  $LDATD/language.dat ]; then 
+    if [ ! -L $LDATD/language.dat ]; then
+      CUR_LDAT=$LDATD/language.dat; 
+    else
+      CUR_LDAT=`readlink -f $LDATD/language.dat` || true
     fi
-    rm -f ${LDATD}/language.dat
-    (cd ${LDATD} ; ln -s ${ELDAT} .)
+  fi
+  if [ -n "$CUR_LDAT" ]; then
+    # this means there is some existing language.dat
+    case $CUR_LDAT in
+      $LDAT)
+	;; # nothing to do
+      *)
+	# make sure that there's nothing in the way
+	move_ldat $CUR_LDAT $LDAT
+	;;
+    esac
+  fi
 fi
+# with or without debconf managment of language.dat, we have to make the link
+#
+# Check whether it is yet there
+if [ -L ${LDATD}/language.dat ]; then
+  # remove it (no need to check whether it is yet correct, it's
+  # simpler this way)
+  rm ${LDATD}/language.dat
+else
+  # is there a file language.dat where we want the link to be?
+  if [ -f ${LDATD}/language.dat ]; then
+    mv -f ${LDATD}/language.dat ${LDATD}/language.dat.$MOVE_EXT
+  fi
+fi
+# now make the link. We do this without a further check, if it was 
+(cd ${LDATD} ; ln -s ${LDAT} .)
+
+###########################################
+# end of handling of language.dat
+###########################################
 
 if [ -e $TEXCONFIG_P -a -e /usr/share/texmf/dvips/config ]
 then
--- tetex-bin-2.0.2/debian/templates.orig	Sat Feb  7 15:42:59 2004
+++ tetex-bin-2.0.2/debian/templates	Tue Feb  3 12:43:01 2004
@@ -108,11 +108,10 @@
 Default: true
 _Description: Manage language.dat with debconf?
  The language.dat file, which contains the information for hyphenation
- patterns to load, can be handled automatically by debconf, or manually
- by you.
+ patterns to load, can be handled automatically by debconf.
  .
- Note that the configuration file will be handled by debconf if you select
- this option but if not you will have to modify the file manually.
+ We will preserve any manual changes you have made or will make, but if
+ you do not select this option, you will have to do everything manually.
 
 Template: tetex-bin/hyphen
 Type: multiselect
--- tetex-base-2.0.2/debian/prerm.orig	Wed Feb  4 11:19:03 2004
+++ tetex-base-2.0.2/debian/prerm	Wed Feb  4 11:07:25 2004
@@ -5,4 +5,8 @@
 	rm -f /usr/doc/texmf
 fi
 
+if [ $1 = purge ]; then
+  rm -f /usr/share/texmf/tex/generic/config/language.dat
+fi
+
 #DEBHELPER#



-- 
Frank Küster, Biozentrum der Univ. Basel
Abt. Biophysikalische Chemie




Reply to: