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

Re: triggers support in tex-common



Hi Frank, hi all,

On Fr, 16 Mai 2008, Frank Küster wrote:
> I would prefer to do it the other way round, namely add an option in our
> maintainer scripts when we want it to call dpkg-trigger. The reason is
> that the update-foo scripts are also intended for local admins, and even
> for local users in case of updmap and fmtutil. It seems odd to require
> them to add a "--real" option when they want to the script to do what it
> is intended for...

Ok, that is implemented. But now I ask myself ... do we need to change
dh_installtex *at*all*??


Ok, we have to change it that making a package with dh_installtex
guarantees the it depends on tex-common >= 1.12 (with triggers) and dpkg
>= with.trigger.version. With that we don't need the update-* calls at
all in the maintainer scripts, and no --trigger or --real arguments.

If an old package still calls the update-texmf stuff fine with me, not
all will be converted immediately, but over the time. And in the mean
time we will have TWO invocation of updmap-sys when installing an old
font pack.

But that will happen anyway, since the *really* long lasting task is not
the update-* call, but the updmap-sys call, and we don't want to hack
into this one. Right?!

So I propose the attached patch, please review.

Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <preining@logic.at>        Vienna University of Technology
Debian Developer <preining@debian.org>                         Debian TeX Group
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
DEAL (n.)
The gummy substance found between damp toes.
			--- Douglas Adams, The Meaning of Liff
Index: debian/control
===================================================================
--- debian/control	(revision 3358)
+++ debian/control	(revision 3379)
@@ -11,7 +11,7 @@
 
 Package: tex-common
 Architecture: all
-Depends: ucf, debconf (>= 1.4.69) | cdebconf (>= 0.39)
+Depends: ucf, debconf (>= 1.4.69) | cdebconf (>= 0.39), dpkg (>= 1.14.18)
 Suggests: debhelper (>= 4.0)
 Replaces: tetex-base (<= 3.0-10)
 Conflicts: tetex-base (<< 2007)
Index: debian/triggers
===================================================================
--- debian/triggers	(revision 0)
+++ debian/triggers	(revision 3379)
@@ -0,0 +1,2 @@
+interest /etc/texmf/updmap.d
+interest /etc/texmf/language.d
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 3358)
+++ debian/changelog	(revision 3379)
@@ -1,4 +1,4 @@
-tex-common (1.12~1) unstable; urgency=normal
+tex-common (1.12~triggers.1) unstable; urgency=normal
 
   * bump version of tex-common packages built with dh_installtex to 1.11
     otherwise the conflict with tetex-base is not included properly. This really
@@ -13,8 +13,10 @@
     nor installed, anyway [fk]
   * register TeX on Debian and the Policy in section Debian [hp, np]
   * remove double definition of OPENTYPEFONTS in texmf.d [np]
+  * implement support for triggers for /etc/texmf/updmap.d and
+    /etc/texmf/language.d [np]
 
- -- Norbert Preining <preining@debian.org>  Fri, 09 May 2008 17:44:57 +0200
+ -- Norbert Preining <preining@debian.org>  Mon, 19 May 2008 12:58:12 +0200
 
 tex-common (1.11) unstable; urgency=medium
 
Index: debian/postinst.in
===================================================================
--- debian/postinst.in	(revision 3358)
+++ debian/postinst.in	(revision 3379)
@@ -21,6 +21,7 @@
 
 # Give a name to the first commandline argument
 action=$1
+trigger=$2
 
 . <:=${CONFMODULE}:>
 db_version 2.0
@@ -36,8 +37,81 @@
 #################################################################
 
 case $action in
-  configure|reconfigure)
+    triggered)
+        # currently we only support only triggers for updmap.d and
+        # language.d changes
+        # because all the other calls are quite fast 
+        # - call all the update-* scripts (it doesn't hurt)
+        # - go through all the triggers and call the respective fmtutil/updmap
+        #   calls.
 
+        # in any case call the update-* calls
+        update-updmap --quiet
+        update-language
+        update-fmtutil
+        case " $trigger " in
+            *" /etc/texmf/updmap.d "*) 
+                # do the processing
+	            # code from postinst.tex
+	            if dhit_libkpathsea_configured; then
+	                if which updmap-sys >/dev/null; then
+                        tempfile=$(mktemp -p /tmp updmap.XXXXXXXX)
+                        printf "Running updmap-sys. This may take some time... "
+                        if updmap-sys > $tempfile 2>&1 ; then
+                            rm -f $tempfile
+                            echo "done."
+                        else
+                            exec >&2
+                            echo
+                            echo "updmap-sys failed. Output has been stored in"
+                            echo "$tempfile"
+                            echo "Please include this file if you report a bug."
+                            echo
+                            echo "Sometimes, not accepting conffile updates in /etc/texmf/updmap.d"
+                            echo "causes updmap-sys to fail.  Please check for files with extension"
+                            echo ".dpkg-dist or .ucf-dist in this directory" 
+                            echo
+                            exit 1
+        	            fi
+                    fi
+                fi
+            ;;
+        esac
+        case " $trigger " in
+            *" /etc/texmf/language.d "*) 
+                # do the processing
+	            # code from postinst.tex
+                v=$(kpsewhich -var-value TEXMFSYSVAR)
+                c=$(kpsewhich -var-value TEXMFSYSCONFIG)
+                TEXMFVAR="$v"
+                TEXMFCONFIG="$c"
+                export TEXMFVAR TEXMFCONFIG
+                fmtcnffile=$(kpsewhich --format='web2c files' fmtutil.cnf)
+                X=$(grep "^[[:space:]]*latex[[:space:]]" $fmtcnffile || true)
+                if [ -n "$X" ] ; then
+                    # latex is installed so we can actually try to recreate
+                    # formats based on language.dat
+                    tempfile=$(mktemp -p /tmp fmtutil.XXXXXXXX)
+                    printf "Building formats --byhyphen $(kpsewhich language.dat).\n\tThis may take some time... "
+                    if fmtutil-sys --byhyphen "$(kpsewhich language.dat)" > $tempfile 2>&1 ; then
+                        rm -f $tempfile
+                        echo "done."
+                    else
+                        exec >&2
+                        echo
+                        echo "fmtutil-sys failed. Output has been stored in"
+                        echo "$tempfile"
+                        echo "Please include this file if you report a bug."
+                        echo
+                        exit 1
+                    fi
+                fi
+            ;;
+        esac
+    ;;
+      
+    configure|reconfigure)
+
 # is there a file /etc/texmf/language.dat already? Move it out of the way
     if [ -f $OLD_LDAT ]; then
       old_ldat_md5sum=`md5sum $OLD_LDAT`
@@ -220,6 +294,9 @@
 
 #DEBHELPER#
 
-# Local Variables:
-# mode: shell-script
-# End:
+### Local Variables:
+### perl-indent-level: 4
+### tab-width: 4
+### indent-tabs-mode: nil
+### End:
+# vim:set tabstop=4 expandtab: #
Index: scripts/postinst-texlsr
===================================================================
--- scripts/postinst-texlsr	(revision 3358)
+++ scripts/postinst-texlsr	(revision 3379)
@@ -46,11 +46,6 @@
 
 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
Index: scripts/dh_installtex
===================================================================
--- scripts/dh_installtex	(revision 3358)
+++ scripts/dh_installtex	(revision 3379)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 # dh_installtex --- register Type 1 fonts, languages, or formats with TeX
 # Copyright (C) 2006, 2007 Florent Rougon
-# Copyright (C) 2006, 2007 Norbert Preining
+# Copyright (C) 2006, 2007, 2008 Norbert Preining
 # Copyright (C) 2006, 2007 Frank KÃŒster
 #
 # This program is free software; you can redistribute it and/or modify
@@ -176,8 +176,9 @@
 This option will be used to switch additional options on. The argument
 specify a list from flavors to be selected.
 At the moment you can select from the following list of flavors:
-B<map:config_for_active_maps>, B<map:config_for_all_maps>,
-B<format:build_all>, and B<format:add_one:I<formatname>>.
+B<map:config_for_active_maps>, B<map:config_for_all_maps>, B<map:notriggers>,
+B<format:build_all>, B<format:add_one:I<formatname>>, and 
+B<language:notriggers>.
 
 B<map:config_for_active_maps> will create a file I<config.bar> for each active
 (i.e. uncommented) map in each of the cfg file generated by one of the
@@ -193,6 +194,10 @@
 
 Default is I<not> to generate any config files.
 
+B<map:notriggers> allows to circumvent the delayed calls to updmap-sys
+using triggers. Use this only if other postinst code requires that the
+fonts are properly installed.
+
 B<format:build_all> will add code to the postinst script to create all
 defined formats, and to the postrm script to clean and recreate? FIXME?
 the generated formats.
@@ -211,6 +216,10 @@
 exists, dh_installtex will skip this format with an informational
 message, even if this option is not given.
 
+<language:notriggers> allows to circumvent the delayed calls to fmtutil-sys
+using triggers. Use this only if other postinst code requires that the
+hyphenation patterns are properly installed.
+
 =head1 NOTES
 
 Note that this command is not idempotent. "dh_clean -k" should be called
@@ -237,6 +246,8 @@
 my @addbuildformats = (); # additional formats to be build
 my $priority=20;	# priority with which files are installed
 my $doformatlinks = 1;
+my $no_updmap_triggers = 0;
+my $no_language_triggers = 0;
 my %cmdlineargs;
 my %cmdlinefiles;
 my %cmdlinefilespriority;
@@ -410,6 +421,10 @@
 			push @addbuildformats , $1;
 		} elsif ($fl eq "format:no_links") {
 			$doformatlinks = 0;
+		} elsif ($fl eq "map:notriggers") {
+			$no_updmap_triggers = 1;
+		} elsif ($fl eq "language:notriggers") {
+			$no_language_triggers = 1;
 		} else {
 			error("Specified flavor $fl not supported.\nPlease see man page for supported flavors!\n");
 		}
@@ -637,12 +652,28 @@
 		autoscript($package, "postinst", "postinst-texlsr", "s|#TEXMFTREES#|@foo|");
 		autoscript($package, "postrm",   "postrm-texlsr", "s|#TEXMFTREES#|@foo|");
 		if ($dothefullstuff) {
+			# updmap-sys is now done with triggers, so we should 
+			# filter out the "map" from the @whattodo list
+			# but only if we are not running with flavor notriggers
+			my @newwhat = ();
+			foreach my $t (@whattodo) {
+				if ($t eq "map") {
+					push @newwhat, $t if $no_updmap_triggers;
+				} elsif ($t eq "language") {
+					push @newwhat, $t if $no_language_triggers;
+				} else {
+					push @newwhat, $t;
+				}
+			}
+			@whattodo = @newwhat;
 			autoscript($package, "postinst", "postinst-tex", "s|#FORMATSFILES#|@fmtconffiles|; s|#WHATTODO#|@whattodo|");
 			autoscript($package, "postrm",   "postrm-tex", "s|#FORMATS#|@postrmfmtdata|; s|#WHATTODO#|@whattodo|");
 		}
 	}
 
-	addsubstvar($package, "misc:Depends", "tex-common", ">= 1.11");
+	# for trigger support
+	addsubstvar($package, "misc:Depends", "dpkg", ">= 1.14.18");
+	addsubstvar($package, "misc:Depends", "tex-common", ">= 1.12");
 }
 
 =head1 SEE ALSO

Reply to: