Debian Codegraph @

debian/texlive-base.libpaper

raw
1 #!/bin/sh -e
2 # created 2010 by Frank Küster [email protected]
3 # The code may be freely copied, distributed and/or modified
4
5 # The plan:
6 # 1. Analyze the current situation and compare with the libpaper setting:
7 # a) Get the settings for dvips, xdvi, pdftex and dvipdfmx from
8 # their respective conffiles - use texconfig-sys for that
9 # b) Get the libpaper setting
10 # c) Check whether all 4 binaries have the same current setting.
11 # 2. Depending on the comparison, act differently
12 # a) if Yes, check whether current setting and libpaper setting are the same
13 # i. if Yes, we are done
14 # ii. if no, call "texconfig-sys paper $libpaper-default" and check the return value
15 # A. If the return value is 1, give a debconf warning that nothing has been changed
16 # In any case we are done
17 # b) if No,
18 # i. print a debconf multiselect window that lists the current settings and
19 # lets the admin select which binaries should get the new, changed configuration
20 # ii. next, call "texconfig-sys $binary paper $libpaper-default" for each selected binary,
21 # and check the return value
22 # A. If the return value is 1, give a debconf warning that nothing has been changed
23 # Done.
24
25 # If texlive-base is removed, just do nothing.
26 test -x /usr/bin/tl-paper || exit 0
27
28 . /usr/share/debconf/confmodule
29 db_version 2.0
30
31
32 #####################################
33 #
34 # code from tex-common postinst
35 #
36 ####################################
37 #
38 dhit_package_configured()
39 {
40 stat=$(dpkg-query -W -f='${Status}' $1 2>/dev/null || true)
41 case "$stat" in
42 "install ok installed")
43 return 0
44 ;;
45 *)
46 return 1
47 ;;
48 esac
49 }
50
51 dhit_base_bin_configured ()
52 {
53 we_are_ready=0
54 if ! dhit_package_configured texlive-binaries ; then
55 return 1
56 fi
57 dhit_package_configured texlive-base
58 }
59
60 dhit_update_lsr_files ()
61 {
62 tempfile=$(mktemp -p /tmp mktexlsr.XXXXXXXX)
63 printf "Running mktexlsr. This may take some time... "
64 if mktexlsr $* > $tempfile 2>&1 ; then
65 rm -f $tempfile
66 echo "done."
67 else
68 exec >&2
69 echo
70 echo "mktexlsr $* failed. Output has been stored in"
71 echo "$tempfile"
72 echo "Please include this file if you report a bug."
73 echo
74 exit 1
75 fi
76 }
77 dhit_build_format ()
78 {
79 tempfile=$(mktemp -p /tmp fmtutil.XXXXXXXX)
80 printf "Building format(s) $*.\n\tThis may take some time... "
81 if fmtutil-sys "$@" > $tempfile 2>&1 ; then
82 rm -f $tempfile
83 echo "done."
84 else
85 exec >&2
86 echo
87 echo "fmtutil-sys failed. Output has been stored in"
88 echo "$tempfile"
89 echo "Please include this file if you report a bug."
90 echo
91 exit 1
92 fi
93 }
94 #####################################
95 #
96 # end code from tex-common postinst
97 #
98 ####################################
99
100
101 dvips=$(tl-paper get dvips)
102 xdvi=$(tl-paper get xdvi)
103 pdftex=$(tl-paper get pdftex)
104 dvipdfmx=$(tl-paper get dvipdfmx)
105
106 LibpaperPaper=$(paperconf)
107
108 FourPapersAllSame=false
109
110 if [ "$dvips" = "$xdvi" ] && \
111 [ "$dvips" = "$pdftex" ] && \
112 [ "$dvips" = "$dvipdfmx" ]; then
113 FourPapersAllSame=true
114 fi
115
116 if [ $FourPapersAllSame = true ]; then
117 if [ "$dvips" = $LibpaperPaper ]; then
118 exit 0
119 else
120 if tl-paper set all $LibpaperPaper; then
121 if dhit_base_bin_configured ; then
122 dhit_update_lsr_files /var/lib/texmf
123 dhit_build_format --refresh
124 fi
125 # finished now
126 exit 0
127 else
128 # texconfig-sys didn't understand the paper name
129 db_subst texlive-base/texconfig_ignorant libpaperPaper $LibpaperPaper
130 db_subst texlive-base/texconfig_ignorant binary "all programs"
131 db_subst texlive-base/texconfig_ignorant binary_commandline ""
132 # the priority will be treated as critical anyway for all error templates.
133 db_input critical texlive-base/texconfig_ignorant || true
134 db_go || true
135 fi
136 fi
137 else
138 # b) if No,
139 # i. print a debconf multiselect window that lists the current settings and
140 # lets the admin select which binaries should get the new, changed configuration
141 # ii. next, call "texconfig-sys $binary paper $libpaper-default" for each selected binary,
142 # and check the return value
143 # A. If the return value is 1, give a debconf warning that nothing has been changed
144 # Done.
145 # the four Papers are not all the same. Ask the user.
146 db_subst texlive-base/binary_chooser libpaperPaper $LibpaperPaper
147 db_fset texlive-base/binary_chooser seen false
148 db_input high texlive-base/binary_chooser || true
149 db_go || true
150
151 db_get texlive-base/binary_chooser
152 ListOfBinariesToUseLibpaper="$RET"
153
154 # now get rid of the commas by assigning to the positional parameters
155 OLD_IFS="$IFS"
156 IFS=', '
157 set $ListOfBinariesToUseLibpaper
158 # IFS needs to be restored before talking to debconf
159 IFS=$OLD_IFS
160
161 for binary in "$@"; do
162 if tl-paper list $binary | grep "^$LibpaperPaper\$"; then
163 # use this instead once set has a proper return code
164 # if tl-paper set $binary $LibpaperPaper; then
165
166 # all is well
167 tl-paper set $binary $LibpaperPaper
168 if dhit_base_bin_configured; then
169 dhit_update_lsr_files /var/lib/texmf
170 # only rebuild when pdftex has changed, all others are
171 # run time files
172 if [ "$binary" = "pdftex" ] ; then
173 dhit_build_format --refresh
174 fi
175 fi
176 :
177 else
178 db_subst texlive-base/texconfig_ignorant binary "$binary"
179 db_subst texlive-base/texconfig_ignorant binary_commandline "$binary"
180 db_subst texlive-base/texconfig_ignorant libpaperPaper "$LibpaperPaper"
181 db_input high texlive-base/texconfig_ignorant || true
182
183 db_go || true
184 fi
185 done
186
187 fi
188
189
190 # Let vim know that we don't want tabs
191 # vim:set expandtab tabstop=2 autoindent: #