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

Bug#328291: debconf, tex-common and the management of ls-R and .cnf files



Hi Frank!

On Die, 27 Sep 2005, Frank Küster wrote:
> > one question with multiselect which replaces the "DO you want to manage
> > with debconf" question, and the others about perm/group.
> >
> > Would this be more useful? Do you prefer this?
> 
> Yes, that sounds best to me.

I have tried to implement it. Please see attached svn diff output of my
tex-common directory.

What it does: It sets the permissions correct.

What it *NOT* does: Ask me for the multiselect, not even if I call
	dpkg-reconfigure -plow tex-common

Do you see why? Did I miss something: The log with 
export DEBCONF_DEBUG=developer gives:
# dpkg-reconfigure -plow tex-common
debconf (developer): starting /var/lib/dpkg/info/tex-common.postinst configure 0.7.1
debconf (developer): <-- VERSION 2.0
debconf (developer): --> 0 2.0
debconf (developer): <-- GET tex-common/managedlsr
debconf (developer): --> 0 cache, local
Fixing permissions and group of (cache, local) ls-R as specified by debconf ...
debconf (developer): <-- GET tex-common/groupperm
debconf (developer): --> 0 true
debconf (developer): <-- GET tex-common/userperm
debconf (developer): --> 0 false
debconf (developer): <-- GET tex-common/groupname
debconf (developer): --> 0 users
mode of `/var/cache/fonts/ls-R' changed to 0664 (rw-rw-r--)
mode of `/var/lib/texmf/ls-R-LOCAL' changed to 0664 (rw-rw-r--)

> question is registered at all, this means that tetex-bin was installed,
> and consequently that its config script was run.  In this case either
> the question was shown (so we have an answer) or it wasn't shown due to

Ok, accepted.

> - either disregard tetex-bin's answer to the "manage with debconf"
>   question completely, and only look at the values for
>   groupname/userperm/groupperm when the answer to the new question is
>   yes 

This I have tried to implement. Please comment

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
-------------------------------------------------------------------------------
KELLING (participial vb.)
A person searching for something, who has reached the futile stage of
re-looking in all the places they have looked once already, is said to
be kelling.
			--- Douglas Adams, The Meaning of Liff
Index: debian/changelog
===================================================================
--- debian/changelog	(Revision 185)
+++ debian/changelog	(Arbeitskopie)
@@ -4,7 +4,8 @@
     number.  [frank]
   * Modify postrm.in script to remove TEXMFSYSVAR and /var/cache/fonts
     (thus also removing left over files at purge time) [preining]
-  * Add dependency alternative on debconf-2.0
+  * Add dependency alternative on debconf-2.0 [preining]
+  * revamped debconf questions [preining]
 
  -- Frank Küster <frank@debian.org>  Wed, 24 Aug 2005 20:40:48 +0200
 
Index: debian/postinst.in
===================================================================
--- debian/postinst.in	(Revision 185)
+++ debian/postinst.in	(Arbeitskopie)
@@ -8,6 +8,7 @@
 ## Define static variables we need
 MKTMPDIR=<:=$MKTMPDIR:> # mktemp will create its files there
 UCF_FILES="<:=$TEX_COMMON_UCF_FILES:>"
+TEXMFSYSVAR="<:=$TEXMFSYSVAR:>"
 UCF="ucf --debconf-ok"
 #UCF="ucf -d --debconf-ok --verbose"
 FIRST_VERSION_WITH_UPGRADE_PATH=0.3
@@ -106,6 +107,47 @@
     update-updmap
     update-language
 
+#
+# set permission of ls-R files
+    db_get tex-common/managedlsr || true
+    if [ -n "$RET" ] ; then
+      MANAGEDLSR="$RET"
+      echo "Fixing permissions and group of ($MANAGEDLSR) ls-R as specified by debconf ..."
+
+      db_get tex-common/groupperm || true
+      if [ x"$RET" = x"true" ]; then
+        LSRPERMS=66
+      else
+        LSRPERMS=64
+      fi
+      db_get tex-common/userperm || true
+      if [ x"$RET" = x"true" ]; then
+        LSRPERMS="$LSRPERMS"6
+      else
+        LSRPERMS="$LSRPERMS"4
+      fi
+      db_get tex-common/groupname || true
+      LSRGROUP="$RET"
+      # work through the list, stolen from locales.postinst
+      list=`echo $MANAGEDLSR | sed -e 's/, /,/g'`
+      save_IFS=$IFS
+      IFS=,
+      for lsr in $list; do
+        case $lsr in 
+	  main) LSR=$TEXMFSYSVAR/ls-R-TEXMFMAIN ;;
+	  var)  LSR=$TEXMFSYSVAR/ls-R ;;
+	  local) LSR=$TEXMFSYSVAR/ls-R-LOCAL ;;
+	  cache) LSR=/var/cache/fonts/ls-R ;;
+	  *) echo "This should not happen: Don't know how to set this! $lsr" ;;
+	esac
+        chmod -v $LSRPERMS $LSR 2>/dev/null | fgrep changed || true
+	chgrp -v $LSRGROUP $LSR 2>/dev/null | fgrep changed || true
+      done
+      IFS=$save_IFS
+    else
+      echo "Fixing permissions of ls-R files ..."
+      chmod -v 644 $LSRS 2>/dev/null | fgrep changed || true
+    fi
     ;;
   *)
     ;;
Index: debian/rules
===================================================================
--- debian/rules	(Revision 185)
+++ debian/rules	(Arbeitskopie)
@@ -95,6 +95,7 @@
 binary-arch: build install
 	dh_testdir
 	dh_testroot
+	dh_installdebconf 
 	dh_installchangelogs 
 	dh_installdocs
 	dh_installexamples
Index: debian/templates
===================================================================
--- debian/templates	(Revision 0)
+++ debian/templates	(Revision 0)
@@ -0,0 +1,67 @@
+Template: tex-common/managedlsr
+Type: multiselect
+Choices: main, cache, local, var
+Default: cache, local
+Description: Select the ls-R file which should be managed by debconf
+ There are many files installed in a typical TeX system. To speed up
+ the search of these files a list of available files is stored in a
+ file called ls-R. There are four different locations for TeX files
+ on a Debian system:
+  - main: usually /usr/share/texmf, contains only files installed
+    by debian packages.
+  - local: usually /usr/local/share/texmf, contains local additions
+  - var: usually /var/lib/texmf, contains generated files from the
+    TeX system like format files.
+  - cache: usually /var/cache/fonts, contains generated fonts.
+ You can select from these four locations those whose ls-R file should
+ be managed by debconf.
+ .
+ We suggest selecting cache and local (these are the defaults)
+ and allowing a selected user group to modify these ls-R files
+ out of the following reasons:
+ .
+ A lot of font files have to be generated before they can be used by
+ xdvi, dvips etc. These files are stored in /var/cache/fonts, so that
+ they do not need to be regenerated every time.
+ .
+ Some users may have the right to add files to the local texmf tree, so
+ they should also be allowed to change the ls-R file.
+ .
+ Accepting this option will allow you to easily manage the permissions of
+ those ls-R files using debconf. Otherwise you will have to manually
+ ensure that they get useful but safe permissions.
+
+Template: tex-common/groupname
+Type: string
+Default: users
+Description: Which group should own the ls-R files?
+ Modification of ls-R files can be restricted to the members of one group
+ which owns them.  To take advantage of this, add the users to the group of
+ your choice, and enter that group name here.  The default group, 'users', is
+ appropriate for most systems.
+
+Template: tex-common/groupperm
+Type: boolean
+Default: true
+Description: Allow group members to modify ls-R files?
+ Accepting this option will allow members of the owning group to modify the
+ ls-R files.
+
+Template: tex-common/userperm
+Type: boolean
+Default: false
+Description: Allow all users to modify ls-R files?
+ Accepting this option will allow all users to modify ls-R files.  This is
+ generally not a good idea for security reasons; you should instead
+ restrict such access to members of one group.
+
+Template: tex-common/cnf_name
+Type: note
+Description: Change of name of files in /etc/texmf/texmf.d/
+ texmf.cnf has previously been generated by update-texmf from all files
+ in /etc/texmf/texmf.d/. Now update-texmf is changed and only reads
+ files with extension '.cnf'
+ .
+ So if you had any private file in /etc/texmf/texmf.d/, then you should add
+ '.cnf' to its name; for example, 22mymacro => 22mymacro.cnf
+
Index: debian/config.in
===================================================================
--- debian/config.in	(Revision 0)
+++ debian/config.in	(Revision 0)
@@ -0,0 +1,76 @@
+#include variables
+#!/bin/sh -e
+# 
+# config maintainer script for the Debian <:=${PACKAGE}:> package.
+# $Id: config.in 114 2005-08-04 15:04:01Z frn $
+<:=@COPYRIGHT:>//
+
+# Give names to the commandline arguments
+action=$1
+installed_version=$2
+
+
+. <:=${CONFMODULE}:>
+db_version 2.0
+
+#
+# move the answers from tetex-bin to tex-common, if there are no answers
+# in the tex-common db
+maybe_move_answer_and_delete() {
+    $ans = $1
+    # did the user already see this question?
+    db_fget tex-common/$ans seen || true
+    if [ "$RET" = false ] ; then
+        # no, so if the user saw the tetex question, move the answer
+	# to the tex-common question and set the seen flag.
+	db_fget tetex-bin/$ans seen || true
+	if [ "$RET" = true ] ; then
+	    db_get tetex-bin/$ans || true
+	    db_set tex-common/$ans "$RET"
+	    db_fset tex-common/$ans seen true
+	    # now unregister the tetex question
+	    db_unregister tetex-bin/$ans
+	fi
+    fi
+}
+
+	
+## do the things we have to do for upgraders from old versions
+# it does not harm to do the checks also when $action is reconfigure.
+
+# suggest a user to rename old cnf files (copyright Atsuhito?)
+# (upgrade from woody, keep for etch?)
+if [ -d /etc/texmf/texmf.d ]; then
+    if ls /etc/texmf/texmf.d 2> /dev/null | egrep -vq '(\.cnf|\.dpkg-.*|~)$'; then
+	db_input medium tex-common/cnf_name || true
+	db_go || true
+    fi
+fi
+
+
+## do the things we have to do always
+db_input low tex-common/managedlsr || true
+db_go
+# we also unregister the tetex-bin/lsr-perms
+db_unregister tetex-bin/lsr-perms
+
+db_get tex-common/managedlsr && SELECTED_LSR="$RET"
+if [ ! -n "$SELECTED_LSR" ]; then
+    maybe_move_answer_and_delete groupname   
+    maybe_move_answer_and_delete groupperm
+    maybe_move_answer_and_delete userperm
+    db_beginblock
+    db_input low tex-common/groupname || true
+    db_input low tex-common/groupperm || true
+    db_input low tex-common/userperm || true
+    db_endblock
+fi
+
+db_go
+
+
+# Local Variables:
+# mode: shell-script
+# skeleton-pair: t
+# End:
+

Reply to: