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

Re: tex-common: Please provide dh_installtex functions for packages that need only mktexlsr



Hi all!

I have implemented this behaviour, wasn't too hard. But before
submitting I want to show you the patch and ask you for comments.

> The current list of RC bugs includes two "postrm fails: mktexlsr is not
> available at purge time" bugs.  It would be nice if we could recommend
> maintainers to just use dh_installtex even if all they need to do is
> call mktexlsr.  
> 
> The script would then detect in which TEXMF trees files are installed in
> the temporary directory and call mktexlsr only for these.  It should
> also accept an argument specifying  additional TEXMF trees, for example
> if files in TEXMFSYSVAR are generated manually.  And of course, it
> wouldn't need to include the complete post{rm,inst}-tex, only
> dhit_libkpathsea_configured and dhit_update_lsr_files.

First a commented diff, and the whole diff is also in the attachment.

Basic idea: Add another debhelper autoscript 
	post{inst,rm}-texlsr
which takes over the functions for mktexlsr calls from
post{inst,rm}-tex. In the dh_installtex we check whether we have any
map/language/fmt to be installed ($dothefullstuff). If not, ONLY include
the post{inst,rm}-texlsr, otherwise include post{inst,rm}-texlsr and
post{inst,rm}-tex.

Furthermore, dh_installtex checks for a list of texmf trees (/u/s/texmf,
/u/s/texmf-texlive, /u/s/texmf-tetex, /v/l/texmf) whether they are
present and IF yes, mktexlsr is called only for these trees. If none of
it is present, NOTHING is added to the post{inst,rm} scripts.


Ok, here the diff:

Index: debian/rules
===================================================================
--- debian/rules	(revision 1874)
+++ debian/rules	(working copy)

Install the new autoscript snippets.

@@ -89,6 +89,8 @@
         # dh_installtex(.1) is already installed via the bin_scripts
 	grep -v '^[ \t]*#' scripts/postrm-tex > $(INSTDIR)/usr/share/debhelper/autoscripts/postrm-tex
 	grep -v '^[ \t]*#' scripts/postinst-tex > $(INSTDIR)/usr/share/debhelper/autoscripts/postinst-tex
+	grep -v '^[ \t]*#' scripts/postrm-texlsr > $(INSTDIR)/usr/share/debhelper/autoscripts/postrm-texlsr
+	grep -v '^[ \t]*#' scripts/postinst-texlsr > $(INSTDIR)/usr/share/debhelper/autoscripts/postinst-texlsr
 
         # fontcache stuff with proper permissions
 	install -d $(INSTDIR)/etc/texmf/web2c/


Remove the autoscripts parts which are moved to postinst-texlsr
Not that we ALSO move (!!!) the dhit_libkpathsea_configured which is
used in the same postinst-tex snippet, but we are sure that IF the
postinst-tex is included, also the postinst-texlsr is included, so the
function will be defined. 
But we could also leave it in both, don't mind.

Index: scripts/postinst-tex
===================================================================
--- scripts/postinst-tex	(revision 1874)
+++ scripts/postinst-tex	(working copy)
@@ -14,34 +14,6 @@
 # Let vim know that we don't want tabs
 # vim:set expandtab: #
 
-
-# Tell if kpsewhich works. If this is the case:
-#
-#   1. kpsewhich is installed and;
-#
-#   2. libkpathsea is configured.
-dhit_libkpathsea_configured ()
-{
-    kpsewhich --version >/dev/null 2>&1
-}
-
-dhit_update_lsr_files ()
-{
-    tempfile=$(mktemp -p /tmp mktexlsr.XXXXXXXX)
-    printf "Running mktexlsr. This may take some time... "
-    if mktexlsr > $tempfile 2>&1 ; then
-        rm -f $tempfile
-        echo "done."
-    else
-        echo
-        echo "mktexlsr failed. Output has been stored in"
-        echo "$tempfile"
-        echo "Please include this file if you report a bug."
-        echo
-        exit 1
-    fi
-}
-
 dhit_create_fontmaps ()
 {
     tempfile=$(mktemp -p /tmp updmap.XXXXXXXX)
@@ -99,18 +71,9 @@
 
 case "$1" in
     configure|abort-upgrade|abort-remove|abort-deconfigure)
-        # It doesn't hurt to call all of them.
-        # These programs are all in tex-common and can be run immediately.
-        update-updmap --quiet
-        update-language
-        update-fmtutil
         # All of the following needs an installed and configured
         # basic TeX system, so check this.
         if dhit_libkpathsea_configured; then
-            # mktexlsr may not be present
-            if which mktexlsr >/dev/null; then
-                dhit_update_lsr_files
-            fi
             for i in #WHATTODO# ; do
                 if [ "$i" = map ] ; then
                     if which updmap-sys >/dev/null; then



Same for postrm-tex

Index: scripts/postrm-tex
===================================================================
--- scripts/postrm-tex	(revision 1874)
+++ scripts/postrm-tex	(working copy)
@@ -14,17 +14,6 @@
 # Let vim know that we don't want tabs
 # vim:set expandtab: #
 
-
-# Tell if kpsewhich works. If this is the case:
-#
-#   1. kpsewhich is installed and;
-#
-#   2. libkpathsea is configured.
-dhit_libkpathsea_configured ()
-{
-    kpsewhich --version >/dev/null 2>&1
-}
-
 dhit_check_run_without_errors ()
 {
     silent=0
@@ -91,15 +80,6 @@
 
 case "$1" in
     remove|disappear)
-        # It doesn't hurt to call all of them.
-        dhit_check_run_without_errors -silent update-updmap --quiet
-        dhit_check_run_without_errors -silent update-language
-        dhit_check_run_without_errors -silent update-fmtutil
-        # The mktexlsr call needs an installed and configured basic TeX
-        # system, so check this.
-        if dhit_libkpathsea_configured; then
-            dhit_check_run_without_errors mktexlsr
-        fi
         for i in #WHATTODO# ; do
             if [ "$i" = map ] ; then
                 dhit_libkpathsea_configured && \


Now for the new postinst-texlsr snippet. It contains as in the other
autoscripts a magic strings
	#TEXMFTREES#
which is replaced by those we want to rebuild.

Index: scripts/postinst-texlsr
===================================================================
--- scripts/postinst-texlsr	(revision 0)
+++ scripts/postinst-texlsr	(revision 0)
@@ -0,0 +1,66 @@
+#
+# postinst-texlsr
+#
+# postinst snippets for calling maketexlsr
+#
+# Authors:
+#       Florent Rougon <f.rougon@free.fr>
+#       Norbert Preining <preining@logic.at>
+#
+# Please note that comments in this file are stripped before installation
+# by calling a grep -v '^[ \t]*#'
+# So please be careful if you add stuff here!
+#
+# Let vim know that we don't want tabs
+# vim:set expandtab: #
+
+
+# Tell if kpsewhich works. If this is the case:
+#
+#   1. kpsewhich is installed and;
+#
+#   2. libkpathsea is configured.
+dhit_libkpathsea_configured ()
+{
+    kpsewhich --version >/dev/null 2>&1
+}
+
+dhit_update_lsr_files ()
+{
+    tempfile=$(mktemp -p /tmp mktexlsr.XXXXXXXX)
+    printf "Running mktexlsr. This may take some time... "
+    if mktexlsr #TEXMFTREES# > $tempfile 2>&1 ; then
+        rm -f $tempfile
+        echo "done."
+    else
+        echo
+        echo "mktexlsr failed. Output has been stored in"
+        echo "$tempfile"
+        echo "Please include this file if you report a bug."
+        echo
+        exit 1
+    fi
+}
+
+case "$1" in
+    configure|abort-upgrade|abort-remove|abort-deconfigure)
+        # It doesn't hurt to call all of them.
+        # These programs are all in tex-common and can be run immediately.
+        update-updmap --quiet
+        update-language
+        update-fmtutil
+        # All of the following needs an installed and configured
+        # basic TeX system, so check this.
+        if dhit_libkpathsea_configured; then
+            # mktexlsr may not be present
+            if which mktexlsr >/dev/null; then
+                dhit_update_lsr_files
+            fi
+        fi
+    ;;
+
+    *)
+        echo "postinst called with unknown argument '$1'" >&2
+        exit 1
+    ;;
+esac


Same with postrm-texlsr....

Index: scripts/postrm-texlsr
===================================================================
--- scripts/postrm-texlsr	(revision 0)
+++ scripts/postrm-texlsr	(revision 0)
@@ -0,0 +1,79 @@
+#
+# postrm-texlsr
+#
+# postinst snippets for calling mktexlsr
+#
+# Authors:
+#       Florent Rougon <f.rougon@free.fr>
+#       Norbert Preining <preining@logic.at>
+#
+# Please note that comments in this file are stripped before installation
+# by calling a grep -v '^[ \t]*#'
+# So please be careful if you add stuff here!
+#
+# Let vim know that we don't want tabs
+# vim:set expandtab: #
+
+
+# Tell if kpsewhich works. If this is the case:
+#
+#   1. kpsewhich is installed and;
+#
+#   2. libkpathsea is configured.
+dhit_libkpathsea_configured ()
+{
+    kpsewhich --version >/dev/null 2>&1
+}
+
+dhit_check_run_without_errors ()
+{
+    silent=0
+    if [ "$1" = "-silent" ] ; then
+        silent=1
+	shift
+    fi
+    if which "$1" >/dev/null; then
+        tempfile=$(mktemp -p /tmp checkrun.XXXXXXXX)
+        if [ $silent = 0 ] ; then
+	    printf "Running $*. This may take some time..."
+	fi
+        set +e
+        if "$@" > $tempfile 2>&1 ; then
+            rm -f $tempfile
+            [ $silent = 0 ] && echo " done."
+        else
+            echo
+            echo "$* failed. Output has been stored in"
+            echo "$tempfile"
+            echo "If tex-common is not configured you can ignore this error" \
+                 "message!"
+            echo "Otherwise, please include this file if you report a bug."
+            echo
+        fi
+        set -e
+    fi
+
+    return 0
+}
+
+case "$1" in
+    remove|disappear)
+        # It doesn't hurt to call all of them.
+        dhit_check_run_without_errors -silent update-updmap --quiet
+        dhit_check_run_without_errors -silent update-language
+        dhit_check_run_without_errors -silent update-fmtutil
+        # The mktexlsr call needs an installed and configured basic TeX
+        # system, so check this.
+        if dhit_libkpathsea_configured; then
+            dhit_check_run_without_errors mktexlsr #TEXMFTREES#
+        fi
+    ;;
+
+    purge|upgrade|failed-upgrade|abort-upgrade|abort-install)
+    ;;
+
+    *)
+        echo "postrm called with unknown argument '$1'" >&2
+        exit 1
+    ;;
+esac


Now for the changes to dh_installtex:


Index: scripts/dh_installtex
===================================================================
--- scripts/dh_installtex	(revision 1874)
+++ scripts/dh_installtex	(working copy)

New cmd line option, and some documentation. ...

@@ -22,18 +22,39 @@
 [B<language=>I<lang>,I<pattern>[,I<alternate>,...]]
 [B<languagefile=>I<file.cnf>[=I<n>]]
 [B<format=>I<format>,I<engine>,I<hyphenfile>,I<rest args>]
-[B<formatfile=>I<file.cnf>[=I<n>]
+[B<formatfile=>I<file.cnf>[=I<n>]]
+[B<texmftrees=>I<tree>[,I<tree>]]
 
 =head1 DESCRIPTION
 
 dh_installtex is a debhelper program that is responsible for
-registering map files, new formats, and new languages with TeX.
+updating the ls-R databases, registering map files, new formats, 
+and new languages with TeX.
 
 Your package should depend on tex-common so that the
 update-* commands are available. (This program adds that dependency to
 ${misc:Depends}.)
 
-In each of the three cases you can use three different methods to
+If you only install file into /usr/share/texmf or some other TEXMF tree
+and want to be sure that mktexlsr is called in a correct way (ie also
+in the postrm script if there is no functional mktexlsr), simply call
+
+	dh_installtex
+
+without specifying anything else. In this case (and in all the others)
+dh_installtex will search for used TEXMF trees and update all those trees
+were files were installed. 
+
+If you install files after the call to dh_installtex or you want to add
+a different TEXMF tree, just add the option
+
+	dh_installtex texmftrees=tree1,tree2,...
+
+Currently dh_installtex checks for /usr/share/texmf, /usr/share/texmf-texlive,
+/usr/share/texmf-tetex, and /var/lib/texmf.
+
+If in addition you have to install map files, language definitions, or 
+format definitions you can use three different methods to
 specify what should be installed:
 
 1) B<Pre made config files:> These files can be specified with the



We use $dothefullstuff to track whether we have to include everything or
only the lsr magic.


@@ -161,10 +182,18 @@
 my $flavor;		
 my $mapdoconfig =  0;	# doconfig depending map/subflavor
 my $priority=10;	# priority with which files are installed
+my $dothefullstuff = 0;
 my %cmdlineargs;
 my %cmdlinefiles;
 my %cmdlinefilespriority;
+my @cmdlinetexmftrees;
 

The trees we are checking. ARE THESE ALL WE SHOULD CHECK????

+my @texmftrees = qw, 	/usr/share/texmf 
+			/usr/share/texmf-texlive
+			/usr/share/texmf-tetex
+			/var/lib/texmf
+		,;
+	
 #
 # definitions for the different flavors
 #


The fucntion checking for the existence of the tree. We do NOT search
for files in the trees, we ONLY check whether the actual texmf tree
is present in the tmp dir:

@@ -283,9 +312,22 @@
 	return 0;
 }
 
+#
+# find_used_texmf_trees($basedir)
+# returns a list of trees under $basedir where files are installed
+sub find_used_texmf_trees {
+	my ($basedir) = @_;
+	my @ret = ();
+	foreach my $tmt (@texmftrees) {
+		if (-d "$basedir$tmt") { push @ret, $tmt; }
+	}
+	return @ret;
+}
 

Additional cmdline option, and immediately splitting of the argument
into the array holding the cmdlinetexmftrees

@@ -306,6 +348,8 @@
 		$cmdlinefilespriority{$type}{$fn}=$pr;
 	} elsif (m/^(map|language|format)=(.*)$/) {
 		push @{$cmdlineargs{$1}}, $2;
+	} elsif (m/^texmftrees=(.*)$/) {
+		@cmdlinetexmftrees = split /,/, $1;
 	} else {
 		error("Unrecognized argument: $_\n");
 	}

The new comments says everything...

@@ -375,6 +419,10 @@
 			# we have nothing to do here, skip to the next one!
 			next;
 		}
+		# we got something, either a cmd line are for one of the
+		# config files, or a package file, or whatever, so 
+		# do the full maintainer stuff!
+		$dothefullstuff = 1;
 		push @whattodo, $type;
 		if ($pkgfileoncmdline && ($pkgprovidedfile || ($#cmdlinearguments >= 0))) {
 			error("This call would create multiple copies of $priority$package.$configfileext{$_}.\nPlease read the man page on how this should be fixed!\n");



Now the final magic: 
First we collect the cmdline texmftrees and those automatically found
into one list of all texmftrees (MISSING MISSING: make the list uniq!,
or do we ignore this? If maintainers are so stupid and add the same tree
...). 

Now IF we have some tree present, we include the post{inst,rm}-texlsr
snippet and replace #TEXMFTREES# with the trees. 

Then, if we have to $dothefullstuff, we also include the other snippets.


@@ -478,8 +526,16 @@
 		@fmtdata = @{$data{"format"}};
 	}
 	if (! $dh{NOSCRIPTS}) {
-		autoscript($package, "postinst", "postinst-tex", "s/#FORMATS#/@fmtdata/; s/#WHATTODO#/@whattodo/");
-		autoscript($package, "postrm",   "postrm-tex", "s/#FORMATS#/@fmtdata/; s/#WHATTODO#/@whattodo/");
+		my @alltexmftrees = @cmdlinetexmftrees;
+		push @alltexmftrees, find_used_texmf_trees($tmp);
+		if ($#alltexmftrees >= 0) {
+			autoscript($package, "postinst", "postinst-texlsr", "s|#TEXMFTREES#|@alltexmftrees|");
+			autoscript($package, "postrm",   "postrm-texlsr", "s|#TEXMFTREES#|@alltexmftrees|");
+		}
+		if ($dothefullstuff) {
+			autoscript($package, "postinst", "postinst-tex", "s/#FORMATS#/@fmtdata/; s/#WHATTODO#/@whattodo/");
+			autoscript($package, "postrm",   "postrm-tex", "s/#FORMATS#/@fmtdata/; s/#WHATTODO#/@whattodo/");
+		}
 	}
 
 	addsubstvar($package, "misc:Depends", "tex-common", ">= 0.7");


I have tested it with prosper and some dummy packages, and it worked.


PLEASE COMMENT!!

Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <preining@logic.at>                    Università di Siena
Debian Developer <preining@debian.org>                         Debian TeX Group
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
SITTINGBOURNE (n.)
One of those conversions where both people are waiting for the other
one to shut up so they can get on with their bit.
			--- Douglas Adams, The Meaning of Liff
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 1874)
+++ debian/changelog	(working copy)
@@ -1,8 +1,13 @@
-tex-common (0.36) UNRELEASED; urgency=low
+tex-common (0.35.1) UNRELEASED; urgency=low
 
   * fix format extraction regexp in dh_installtex [preining]
+  * dh_installtex: include only the minimal mktexlsr code in case no other
+    installation is done (ie no maps, formats, languages) [preining]
+  * dh_installtex: add ability to specify texmf trees on cmdline, and
+    find those trees where files are actually installed [preining]
+    (Closes: 392359)
 
- -- Norbert Preining <preining@debian.org>  Sun, 22 Oct 2006 17:37:24 +0200
+ -- Norbert Preining <preining@debian.org>  Mon, 23 Oct 2006 20:08:13 +0200
 
 tex-common (0.35) unstable; urgency=low
 
Index: debian/rules
===================================================================
--- debian/rules	(revision 1874)
+++ debian/rules	(working copy)
@@ -89,6 +89,8 @@
         # dh_installtex(.1) is already installed via the bin_scripts
 	grep -v '^[ \t]*#' scripts/postrm-tex > $(INSTDIR)/usr/share/debhelper/autoscripts/postrm-tex
 	grep -v '^[ \t]*#' scripts/postinst-tex > $(INSTDIR)/usr/share/debhelper/autoscripts/postinst-tex
+	grep -v '^[ \t]*#' scripts/postrm-texlsr > $(INSTDIR)/usr/share/debhelper/autoscripts/postrm-texlsr
+	grep -v '^[ \t]*#' scripts/postinst-texlsr > $(INSTDIR)/usr/share/debhelper/autoscripts/postinst-texlsr
 
         # fontcache stuff with proper permissions
 	install -d $(INSTDIR)/etc/texmf/web2c/
Index: scripts/postinst-tex
===================================================================
--- scripts/postinst-tex	(revision 1874)
+++ scripts/postinst-tex	(working copy)
@@ -14,34 +14,6 @@
 # Let vim know that we don't want tabs
 # vim:set expandtab: #
 
-
-# Tell if kpsewhich works. If this is the case:
-#
-#   1. kpsewhich is installed and;
-#
-#   2. libkpathsea is configured.
-dhit_libkpathsea_configured ()
-{
-    kpsewhich --version >/dev/null 2>&1
-}
-
-dhit_update_lsr_files ()
-{
-    tempfile=$(mktemp -p /tmp mktexlsr.XXXXXXXX)
-    printf "Running mktexlsr. This may take some time... "
-    if mktexlsr > $tempfile 2>&1 ; then
-        rm -f $tempfile
-        echo "done."
-    else
-        echo
-        echo "mktexlsr failed. Output has been stored in"
-        echo "$tempfile"
-        echo "Please include this file if you report a bug."
-        echo
-        exit 1
-    fi
-}
-
 dhit_create_fontmaps ()
 {
     tempfile=$(mktemp -p /tmp updmap.XXXXXXXX)
@@ -99,18 +71,9 @@
 
 case "$1" in
     configure|abort-upgrade|abort-remove|abort-deconfigure)
-        # It doesn't hurt to call all of them.
-        # These programs are all in tex-common and can be run immediately.
-        update-updmap --quiet
-        update-language
-        update-fmtutil
         # All of the following needs an installed and configured
         # basic TeX system, so check this.
         if dhit_libkpathsea_configured; then
-            # mktexlsr may not be present
-            if which mktexlsr >/dev/null; then
-                dhit_update_lsr_files
-            fi
             for i in #WHATTODO# ; do
                 if [ "$i" = map ] ; then
                     if which updmap-sys >/dev/null; then
Index: scripts/postrm-tex
===================================================================
--- scripts/postrm-tex	(revision 1874)
+++ scripts/postrm-tex	(working copy)
@@ -14,17 +14,6 @@
 # Let vim know that we don't want tabs
 # vim:set expandtab: #
 
-
-# Tell if kpsewhich works. If this is the case:
-#
-#   1. kpsewhich is installed and;
-#
-#   2. libkpathsea is configured.
-dhit_libkpathsea_configured ()
-{
-    kpsewhich --version >/dev/null 2>&1
-}
-
 dhit_check_run_without_errors ()
 {
     silent=0
@@ -91,15 +80,6 @@
 
 case "$1" in
     remove|disappear)
-        # It doesn't hurt to call all of them.
-        dhit_check_run_without_errors -silent update-updmap --quiet
-        dhit_check_run_without_errors -silent update-language
-        dhit_check_run_without_errors -silent update-fmtutil
-        # The mktexlsr call needs an installed and configured basic TeX
-        # system, so check this.
-        if dhit_libkpathsea_configured; then
-            dhit_check_run_without_errors mktexlsr
-        fi
         for i in #WHATTODO# ; do
             if [ "$i" = map ] ; then
                 dhit_libkpathsea_configured && \
Index: scripts/dh_installtex
===================================================================
--- scripts/dh_installtex	(revision 1874)
+++ scripts/dh_installtex	(working copy)
@@ -22,18 +22,39 @@
 [B<language=>I<lang>,I<pattern>[,I<alternate>,...]]
 [B<languagefile=>I<file.cnf>[=I<n>]]
 [B<format=>I<format>,I<engine>,I<hyphenfile>,I<rest args>]
-[B<formatfile=>I<file.cnf>[=I<n>]
+[B<formatfile=>I<file.cnf>[=I<n>]]
+[B<texmftrees=>I<tree>[,I<tree>]]
 
 =head1 DESCRIPTION
 
 dh_installtex is a debhelper program that is responsible for
-registering map files, new formats, and new languages with TeX.
+updating the ls-R databases, registering map files, new formats, 
+and new languages with TeX.
 
 Your package should depend on tex-common so that the
 update-* commands are available. (This program adds that dependency to
 ${misc:Depends}.)
 
-In each of the three cases you can use three different methods to
+If you only install file into /usr/share/texmf or some other TEXMF tree
+and want to be sure that mktexlsr is called in a correct way (ie also
+in the postrm script if there is no functional mktexlsr), simply call
+
+	dh_installtex
+
+without specifying anything else. In this case (and in all the others)
+dh_installtex will search for used TEXMF trees and update all those trees
+were files were installed. 
+
+If you install files after the call to dh_installtex or you want to add
+a different TEXMF tree, just add the option
+
+	dh_installtex texmftrees=tree1,tree2,...
+
+Currently dh_installtex checks for /usr/share/texmf, /usr/share/texmf-texlive,
+/usr/share/texmf-tetex, and /var/lib/texmf.
+
+If in addition you have to install map files, language definitions, or 
+format definitions you can use three different methods to
 specify what should be installed:
 
 1) B<Pre made config files:> These files can be specified with the
@@ -161,10 +182,18 @@
 my $flavor;		
 my $mapdoconfig =  0;	# doconfig depending map/subflavor
 my $priority=10;	# priority with which files are installed
+my $dothefullstuff = 0;
 my %cmdlineargs;
 my %cmdlinefiles;
 my %cmdlinefilespriority;
+my @cmdlinetexmftrees;
 
+my @texmftrees = qw, 	/usr/share/texmf 
+			/usr/share/texmf-texlive
+			/usr/share/texmf-tetex
+			/var/lib/texmf
+		,;
+	
 #
 # definitions for the different flavors
 #
@@ -283,9 +312,22 @@
 	return 0;
 }
 
+#
+# find_used_texmf_trees($basedir)
+# returns a list of trees under $basedir where files are installed
+sub find_used_texmf_trees {
+	my ($basedir) = @_;
+	my @ret = ();
+	foreach my $tmt (@texmftrees) {
+		if (-d "$basedir$tmt") { push @ret, $tmt; }
+	}
+	return @ret;
+}
 
 #
 #
+#
+#
 # START OF THE MAIN PROGRAM
 #
 #
@@ -306,6 +348,8 @@
 		$cmdlinefilespriority{$type}{$fn}=$pr;
 	} elsif (m/^(map|language|format)=(.*)$/) {
 		push @{$cmdlineargs{$1}}, $2;
+	} elsif (m/^texmftrees=(.*)$/) {
+		@cmdlinetexmftrees = split /,/, $1;
 	} else {
 		error("Unrecognized argument: $_\n");
 	}
@@ -375,6 +419,10 @@
 			# we have nothing to do here, skip to the next one!
 			next;
 		}
+		# we got something, either a cmd line are for one of the
+		# config files, or a package file, or whatever, so 
+		# do the full maintainer stuff!
+		$dothefullstuff = 1;
 		push @whattodo, $type;
 		if ($pkgfileoncmdline && ($pkgprovidedfile || ($#cmdlinearguments >= 0))) {
 			error("This call would create multiple copies of $priority$package.$configfileext{$_}.\nPlease read the man page on how this should be fixed!\n");
@@ -440,9 +488,9 @@
 			close(CFGFILE);
 			push @listlines, "$priority$package";
 		}
-	
+		
         	if ( ! -d "$tmp/var/lib/tex-common/$managedir{$type}/") {
-        	    doit("install","-d","$tmp/var/lib/tex-common/$managedir{$type}/");
+            		doit("install","-d","$tmp/var/lib/tex-common/$managedir{$type}/");
         	}
 		$dofilen = "$tmp/var/lib/tex-common/$managedir{$type}/$package.list";
 		open(LISTFILE, ">>$dofilen")||
@@ -478,8 +526,16 @@
 		@fmtdata = @{$data{"format"}};
 	}
 	if (! $dh{NOSCRIPTS}) {
-		autoscript($package, "postinst", "postinst-tex", "s/#FORMATS#/@fmtdata/; s/#WHATTODO#/@whattodo/");
-		autoscript($package, "postrm",   "postrm-tex", "s/#FORMATS#/@fmtdata/; s/#WHATTODO#/@whattodo/");
+		my @alltexmftrees = @cmdlinetexmftrees;
+		push @alltexmftrees, find_used_texmf_trees($tmp);
+		if ($#alltexmftrees >= 0) {
+			autoscript($package, "postinst", "postinst-texlsr", "s|#TEXMFTREES#|@alltexmftrees|");
+			autoscript($package, "postrm",   "postrm-texlsr", "s|#TEXMFTREES#|@alltexmftrees|");
+		}
+		if ($dothefullstuff) {
+			autoscript($package, "postinst", "postinst-tex", "s/#FORMATS#/@fmtdata/; s/#WHATTODO#/@whattodo/");
+			autoscript($package, "postrm",   "postrm-tex", "s/#FORMATS#/@fmtdata/; s/#WHATTODO#/@whattodo/");
+		}
 	}
 
 	addsubstvar($package, "misc:Depends", "tex-common", ">= 0.7");
Index: scripts/postinst-texlsr
===================================================================
--- scripts/postinst-texlsr	(revision 0)
+++ scripts/postinst-texlsr	(revision 0)
@@ -0,0 +1,66 @@
+#
+# postinst-texlsr
+#
+# postinst snippets for calling maketexlsr
+#
+# Authors:
+#       Florent Rougon <f.rougon@free.fr>
+#       Norbert Preining <preining@logic.at>
+#
+# Please note that comments in this file are stripped before installation
+# by calling a grep -v '^[ \t]*#'
+# So please be careful if you add stuff here!
+#
+# Let vim know that we don't want tabs
+# vim:set expandtab: #
+
+
+# Tell if kpsewhich works. If this is the case:
+#
+#   1. kpsewhich is installed and;
+#
+#   2. libkpathsea is configured.
+dhit_libkpathsea_configured ()
+{
+    kpsewhich --version >/dev/null 2>&1
+}
+
+dhit_update_lsr_files ()
+{
+    tempfile=$(mktemp -p /tmp mktexlsr.XXXXXXXX)
+    printf "Running mktexlsr. This may take some time... "
+    if mktexlsr #TEXMFTREES# > $tempfile 2>&1 ; then
+        rm -f $tempfile
+        echo "done."
+    else
+        echo
+        echo "mktexlsr failed. Output has been stored in"
+        echo "$tempfile"
+        echo "Please include this file if you report a bug."
+        echo
+        exit 1
+    fi
+}
+
+case "$1" in
+    configure|abort-upgrade|abort-remove|abort-deconfigure)
+        # It doesn't hurt to call all of them.
+        # These programs are all in tex-common and can be run immediately.
+        update-updmap --quiet
+        update-language
+        update-fmtutil
+        # All of the following needs an installed and configured
+        # basic TeX system, so check this.
+        if dhit_libkpathsea_configured; then
+            # mktexlsr may not be present
+            if which mktexlsr >/dev/null; then
+                dhit_update_lsr_files
+            fi
+        fi
+    ;;
+
+    *)
+        echo "postinst called with unknown argument '$1'" >&2
+        exit 1
+    ;;
+esac
Index: scripts/postrm-texlsr
===================================================================
--- scripts/postrm-texlsr	(revision 0)
+++ scripts/postrm-texlsr	(revision 0)
@@ -0,0 +1,79 @@
+#
+# postrm-texlsr
+#
+# postinst snippets for calling mktexlsr
+#
+# Authors:
+#       Florent Rougon <f.rougon@free.fr>
+#       Norbert Preining <preining@logic.at>
+#
+# Please note that comments in this file are stripped before installation
+# by calling a grep -v '^[ \t]*#'
+# So please be careful if you add stuff here!
+#
+# Let vim know that we don't want tabs
+# vim:set expandtab: #
+
+
+# Tell if kpsewhich works. If this is the case:
+#
+#   1. kpsewhich is installed and;
+#
+#   2. libkpathsea is configured.
+dhit_libkpathsea_configured ()
+{
+    kpsewhich --version >/dev/null 2>&1
+}
+
+dhit_check_run_without_errors ()
+{
+    silent=0
+    if [ "$1" = "-silent" ] ; then
+        silent=1
+	shift
+    fi
+    if which "$1" >/dev/null; then
+        tempfile=$(mktemp -p /tmp checkrun.XXXXXXXX)
+        if [ $silent = 0 ] ; then
+	    printf "Running $*. This may take some time..."
+	fi
+        set +e
+        if "$@" > $tempfile 2>&1 ; then
+            rm -f $tempfile
+            [ $silent = 0 ] && echo " done."
+        else
+            echo
+            echo "$* failed. Output has been stored in"
+            echo "$tempfile"
+            echo "If tex-common is not configured you can ignore this error" \
+                 "message!"
+            echo "Otherwise, please include this file if you report a bug."
+            echo
+        fi
+        set -e
+    fi
+
+    return 0
+}
+
+case "$1" in
+    remove|disappear)
+        # It doesn't hurt to call all of them.
+        dhit_check_run_without_errors -silent update-updmap --quiet
+        dhit_check_run_without_errors -silent update-language
+        dhit_check_run_without_errors -silent update-fmtutil
+        # The mktexlsr call needs an installed and configured basic TeX
+        # system, so check this.
+        if dhit_libkpathsea_configured; then
+            dhit_check_run_without_errors mktexlsr #TEXMFTREES#
+        fi
+    ;;
+
+    purge|upgrade|failed-upgrade|abort-upgrade|abort-install)
+    ;;
+
+    *)
+        echo "postrm called with unknown argument '$1'" >&2
+        exit 1
+    ;;
+esac

Reply to: