This file is indexed.

postinst is in tex-common 6.09.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
#!/bin/sh -e
# 
# postinst maintainer script for the Debian tex-common package.
#
# Copyright (C) 2004 by Frank Küster <frank@kuesterei.ch>. 
# Copyright (C) 2012-2016 by Norbert Preining <preining@debian.org>
#
# This file 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; either version 2 of the License, or (at your
# option) any later version.
#
# This file 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; if not, write to: The Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# On Debian GNU/Linux System you can find a copy of the GNU General Public
# License in "/usr/share/common-licenses/GPL".

umask 022

#
# definitions of necessary trees
TEXMFSYSVARDIR=/var/lib/texmf

# fmtutil program and common arguments
# --sys     we are running in fmtutil-sys mode
# --strict  error out if a format is not build
# --no-error-...    luajittex is not available on all archs
FMTUTIL="fmtutil --sys --strict --no-error-if-no-engine=luajittex,mfluajit"

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>


# Give a name to the first commandline argument
action=$1
trigger=$2

. /usr/share/debconf/confmodule
db_version 2.0

dhit_texlive_binaries_configured ()
{
    # unfortunately this seems not to work anymore, we have to make
    # sure that texlive-binaries is properly configured, otherwise
    # a squeeze in libkpathsea and engines might occur
    # kpsewhich --version >/dev/null 2>&1
    stat=$(dpkg-query -W -f='${Status}' texlive-binaries 2>/dev/null || true)
    case "$stat" in
        "install ok installed")
            return 0
            ;;
        *)
            return 1
            ;;
    esac
}

dhit_build_format ()
{

    tempfile=$(mktemp -p /tmp fmtutil.XXXXXXXX)
    # save LANG
    LANGSAVE=$LANG
    LANG=C
    printf "Building format(s) $*.\n\tThis may take some time... "
    if $FMTUTIL "$@" > $tempfile 2>&1 ; then
        rm -f $tempfile
        LANG=$LANGSAVE
        echo "done."
    else
        exec >&2
        echo
        echo "fmtutil failed. Output has been stored in"
        echo "$tempfile"
        echo "Please include this file if you report a bug."
        echo
        exit 1
    fi
}

run_mtxrun_if_possible()
{
    # code from postinst-tex
    if dhit_texlive_binaries_configured; then
        if which mtxrun >/dev/null; then
            # we also have to check that texlive-base is installed
            # and configured, otherwise we cannot be sure that
            # all necessary basic files are present
            #
            # dpkg-query has two defects wrt not existing packages
            # - it is noisy to stderr
            # - it returns 1
            # so shut both errors up
            stat=$(dpkg-query -W -f='${Status}' context 2>/dev/null || true)
            case "$stat" in
                "install ok installed")
                    do_it=1
                    ;;
                *)
                    do_it=0
                    ;;
            esac
            if [ "$do_it" = 1 ] ; then
                tempfile=$(mktemp -p /tmp mtxrun.XXXXXXXX)
                printf "Running mtxrun --generate. This may take some time... "
                if mtxrun --generate > $tempfile 2>&1 ; then
                    rm -f $tempfile
                    echo "done."
                else
                    exec >&2
                    echo
                    echo "mtxrun --generate failed. Output has been stored in"
                    echo "$tempfile"
                    echo "Please include this file if you report a bug."
                    echo
                    exit 1
    	        fi
            fi
        fi
    fi
}

run_updmap()
{
    if dhit_texlive_binaries_configured; then
        if which updmap-sys >/dev/null; then
            # we also have to check that texlive-base is installed
            # and configured, otherwise we cannot be sure that
            # all necessary basic files are present
            #
            # dpkg-query has two defects wrt not existing packages
            # - it is noisy to stderr
            # - it returns 1
            # so shut both errors up
            stat=$(dpkg-query -W -f='${Status}' texlive-base 2>/dev/null || true)
            case "$stat" in
                "install ok installed")
                    do_it=1
                    ;;
                *)
                    do_it=0
                    ;;
            esac
            if [ "$do_it" = 0 ] ; then
                echo "texlive-base is not ready, delaying updmap-sys call" >&2
            else
                tempfile=$(mktemp -p /tmp updmap.XXXXXXXX)
                printf "Running updmap-sys. This may take some time... "
                # call updmap with --nohash so that no ls-R files
                # are created in /usr/local/share/texmf/
                # see bug report #607857
                # instead of that we call mktexlsr $TEXMFSYSVARDIR 
                # afterwards. This can be done without checks as
                # we know that dhit_texlive_binaries_configured and
                # since mktexlsr and updmap are in the same package
                # and we checked for updmap already
                if updmap-sys --nohash > $tempfile 2>&1 ; then
                    rm -f $tempfile
                    echo "done."
                    tempfile=$(mktemp -p /tmp mktexlsr.XXXXXXXX)
                    printf "Running mktexlsr $TEXMFSYSVARDIR ... "
                    if mktexlsr $TEXMFSYSVARDIR > $tempfile 2>&1 ; then
                        rm -f $tempfile
                        echo "done."
                    else
                        exec >&2
                        echo
                        echo "mktexlsr $TEXMFSYSVARDIR failed. Output has been stored in"
                        echo "$tempfile"
                        echo "Please include this file if you report a bug."
                        echo
                        exit 1
                    fi
                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
    fi
}

run_fmtutil()
{
    # now call the equivalent of fmtutil-sys --all explicitely
    # we also have to check that texlive-base is installed
    # and configured, otherwise we cannot be sure that
    # all necessary basic files are present
    if dhit_texlive_binaries_configured; then
        # see above for information on dpkg-query usage
        stat=$(dpkg-query -W -f='${Status}' texlive-base  2>/dev/null || true)
        case "$stat" in
            "install ok installed")
                do_it=1
                ;;
            *)
                do_it=0
                ;;
        esac
        if [ "$do_it" = 0 ] ; then
            echo "texlive-base is not ready, skipping fmtutil --all call" >&2
        else
            dhit_build_format --all
        fi
    fi
}

run_mktexlsr()
{
    trees=$*
    if dhit_texlive_binaries_configured; then
        # mktexlsr may not be present
        if which mktexlsr >/dev/null; then
            tempfile=$(mktemp -p /tmp mktexlsr.XXXXXXXX)
            printf "Running mktexlsr. This may take some time... "
            if mktexlsr $trees > $tempfile 2>&1 ; then
                rm -f $tempfile
                echo "done."
            else
                exec >&2
                echo
                echo "mktexlsr $trees failed. Output has been stored in"
                echo "$tempfile"
                echo "Please include this file if you report a bug."
                echo
                exit 1
            fi
        fi
    fi
}

run_hyphen()
{
    if dhit_texlive_binaries_configured; then
        if which kpsewhich >/dev/null; then
            if which fmtutil >/dev/null; then
                # code from postinst.tex
                v=$(kpsewhich -var-value TEXMFSYSVAR)
                c=$(kpsewhich -var-value TEXMFSYSCONFIG)
                TEXMFVAR="$v"
                TEXMFCONFIG="$c"
                export TEXMFVAR TEXMFCONFIG
                tempfile=$(mktemp -p /tmp fmtutil.XXXXXXXX)
                printf "Building latex-based formats --byhyphen language.dat.\n\tThis may take some time... "
                LANGSAVE=$LANG
                LANG=C
                if $FMTUTIL --byhyphen language.dat > $tempfile 2>&1 ; then
                    rm -f $tempfile
                    LANG=$LANGSAVE
                    echo "done."
                else
                    exec >&2
                    echo
                    echo "fmtutil failed. Output has been stored in"
                    echo "$tempfile"
                    echo "Please include this file if you report a bug."
                    echo
                    exit 1
                fi
                tempfile=$(mktemp -p /tmp fmtutil.XXXXXXXX)
                printf "Building e-tex based formats --byhyphen language.def.\n\tThis may take some time... "
                if $FMTUTIL --byhyphen language.def > $tempfile 2>&1 ; then
                    rm -f $tempfile
                    echo "done."
                else
                    exec >&2
                    echo
                    echo "fmtutil failed. Output has been stored in"
                    echo "$tempfile"
                    echo "Please include this file if you report a bug."
                    echo
                    exit 1
                fi
            fi
        fi
    fi
}

do_triggers() 
{
    DO_TEXMF=0
    DO_TEXMFDIST=0
    DO_UPDMAP=0
    DO_FMTUTIL=0
    DO_HYPHEN=0
    case " $trigger " in 
        *" /usr/share/texmf "*)                DO_TEXMF=1 ;; esac
    case " $trigger " in
        *" /usr/share/texlive/texmf-dist "*)   DO_TEXMFDIST=1 ;; esac
    case " $trigger " in
        *" texmf-map "*)                       DO_UPDMAP=1 ;; esac
    case " $trigger " in
        *" texmf-format "*)                    DO_FMTUTIL=1 ;; esac
    case " $trigger " in
        *" texmf-hyphen "*)                    DO_HYPHEN=1 ;; esac

    DO_MKTEXLSR=0
    #
    # ls-R updates
    trees="$TEXMFSYSVARDIR"
    if [ $DO_TEXMF = 1 ] ; then
        DO_MKTEXLSR=1
        trees="$trees /usr/share/texmf"
    fi
    if [ $DO_TEXMFDIST = 1 ] ; then
        DO_MKTEXLSR=1
        trees="$trees /usr/share/texlive/texmf-dist"
    fi
    if [ $DO_MKTEXLSR = 1 ] ; then
        run_mktexlsr $trees
        run_mtxrun_if_possible
    fi
    if [ $DO_UPDMAP = 1 ] ; then
        update-updmap --quiet
        run_updmap
    fi
    if [ $DO_FMTUTIL = 1 ] ; then
        update-language --quiet
        update-fmtutil --quiet
        run_fmtutil
        # reset hyphen, we already rebuilt all formats
        DO_HYPHEN=0
    fi
    if [ $DO_HYPHEN = 1 ] ; then
        update-language --quiet
        update-fmtutil --quiet
        run_hyphen
    fi
}


#################################################################
# Here starts the real action
#################################################################


case $action in
    triggered)
        do_triggers
        ;;

    configure|reconfigure)

    # if we are upgrading from before 4, remove the preinst created
    # backup of the symlink
    if dpkg --compare-versions "$trigger" lt "4" ; then
      if [ -L /usr/share/texmf/doc.dpkg-remove ] ; then
        rm -f /usr/share/texmf/doc.dpkg-remove
      fi
    fi


    # remove outdated thailatex babel.sty
    if [ -f $TEXMFSYSVARDIR/tex/generic/babel/babel.sty ] ; then
        echo "Removing outdated babel.sty from thailatex."
        rm $TEXMFSYSVARDIR/tex/generic/babel/babel.sty
        rmdir --ignore-fail-on-non-empty $TEXMFSYSVARDIR/tex/generic/babel
        rmdir --ignore-fail-on-non-empty $TEXMFSYSVARDIR/tex/generic
        rmdir --ignore-fail-on-non-empty $TEXMFSYSVARDIR/tex
    fi

    update-texmf
    update-updmap --quiet
    update-fmtutil --quiet
    update-language --quiet
    trees="$TEXMFSYSVARDIR /usr/share/texmf"
    if [ -d /usr/share/texlive/texmf-dist ] ; then
        trees="$trees /usr/share/texlive/texmf-dist"
    fi
    run_mktexlsr $trees
    run_mtxrun_if_possible
    run_updmap
    run_fmtutil

    # create empty dirs in /usr/local/share/
    if [ ! -e /usr/local/share/texmf ]
    then
      if mkdir -p /usr/local/share/texmf 2>/dev/null
      then
        chown root:staff /usr/local/share/texmf
        chmod 2775 /usr/local/share/texmf
      fi
    fi

    # remove out dated dir /etc/texmf/language.d
    if [ -d /etc/texmf/language.d ] ; then 
        rmdir --ignore-fail-on-non-empty /etc/texmf/language.d/
    fi


    ;;
  *)
    ;;
esac


# Automatically added by dh_installdeb/10.7.2ubuntu2
dpkg-maintscript-helper rm_conffile /etc/texmf/language.d/00tex.cnf 2.11 -- "$@"
# End automatically added section
# Automatically added by dh_installdeb/10.7.2ubuntu2
dpkg-maintscript-helper rm_conffile /etc/texmf/fmt.d/00tex.cnf 6.00~ -- "$@"
# End automatically added section
# Automatically added by dh_installdeb/10.7.2ubuntu2
dpkg-maintscript-helper rm_conffile /etc/texmf/hyphen.d/00tex.cnf 6.00~ -- "$@"
# End automatically added section


### Local Variables:
### perl-indent-level: 4
### tab-width: 4
### indent-tabs-mode: nil
### End:
# vim:set tabstop=4 expandtab: #