Debian Codegraph @

debian/fontconfig-config.postinst

raw
1 #!/bin/sh
2
3 set -e
4
5 . /usr/share/debconf/confmodule
6
7 CONFAVAIL=/usr/share/fontconfig/conf.avail
8 CONFDIR=/etc/fonts/conf.d
9
10 # Check if this is the initial configuration and not an upgrade of an
11 # existing configuration
12 # Usage: if is_initial_configuration "$@"; then ... fi from top level
13 is_initial_configuration() {
14 # Plain installation
15 if [ "$1" = configure ] && [ -z "$2" ]; then
16 return 0
17 fi
18 # Configuration via dpkg-reconfigure
19 if [ "$1" = reconfigure ] || [ "$DEBCONF_RECONFIGURE" ]; then
20 return 0
21 fi
22 return 1
23 }
24
25 # Create /etc/fonts/conf.d/10-hinting-slight.conf symlink on upgrade, this is
26 # upstream default
27 if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le-nl "2.12.3-0.2~"; then
28 test -e $CONFDIR/10-hinting-slight.conf || \
29 ln -s $CONFAVAIL/10-hinting-slight.conf $CONFDIR/10-hinting-slight.conf
30 fi
31
32 # Replace symlinks obsoleted by upstream with their equivalent new ones
33 if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le-nl "2.14.2-5~"; then
34 if [ -h $CONFDIR/10-no-sub-pixel.conf ] && ! readlink -e $CONFDIR/10-no-sub-pixel.conf >/dev/null; then
35 rm $CONFDIR/10-no-sub-pixel.conf
36 test -e $CONFDIR/10-sub-pixel-none.conf || \
37 ln -s $CONFAVAIL/10-sub-pixel-none.conf $CONFDIR/10-sub-pixel-none.conf
38 fi
39 fi
40
41 if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le-nl "2.15.0-1.1~"; then
42 if [ -h $CONFDIR/70-no-bitmaps.conf ]; then
43 rm $CONFDIR/70-no-bitmaps.conf
44 test -e $CONFDIR/70-no-bitmaps-except-emoji.conf || \
45 ln -s $CONFAVAIL/70-no-bitmaps-except-emoji.conf $CONFDIR/70-no-bitmaps-except-emoji.conf
46 fi
47 fi
48
49 if is_initial_configuration "$@"; then
50 db_get fontconfig/hinting_type
51 hinting_type="$RET"
52
53 unhinted="10-unhinted.conf"
54 autohint="10-autohint.conf"
55
56 if [ -h $CONFDIR/$unhinted ]; then
57 rm $CONFDIR/$unhinted
58 fi
59 if [ -h $CONFDIR/$autohint ]; then
60 rm $CONFDIR/$autohint
61 fi
62
63 case "$hinting_type" in
64 "Native")
65 ;;
66 "Autohinter")
67 ln -s $CONFAVAIL/$autohint $CONFDIR/$autohint
68 ;;
69 "None")
70 ln -s $CONFAVAIL/$unhinted $CONFDIR/$unhinted
71 ;;
72 esac
73
74 db_get fontconfig/hinting_style
75 hinting_style="$RET"
76
77 hintnone="10-hinting-none.conf"
78 hintslight="10-hinting-slight.conf"
79 hintmedium="10-hinting-medium.conf"
80 hintfull="10-hinting-full.conf"
81
82 if [ -h $CONFDIR/$hintnone ]; then
83 rm $CONFDIR/$hintnone
84 fi
85 if [ -h $CONFDIR/$hintslight ]; then
86 rm $CONFDIR/$hintslight
87 fi
88 if [ -h $CONFDIR/$hintmedium ]; then
89 rm $CONFDIR/$hintmedium
90 fi
91 if [ -h $CONFDIR/$hintfull ]; then
92 rm $CONFDIR/$hintfull
93 fi
94
95 case "$hinting_style" in
96 "hintnone")
97 ln -s $CONFAVAIL/$hintnone $CONFDIR/$hintnone
98 ;;
99 "hintslight")
100 ln -s $CONFAVAIL/$hintslight $CONFDIR/$hintslight
101 ;;
102 "hintmedium")
103 ln -s $CONFAVAIL/$hintmedium $CONFDIR/$hintmedium
104 ;;
105 "hintfull")
106 ln -s $CONFAVAIL/$hintfull $CONFDIR/$hintfull
107 ;;
108 esac
109
110 db_get fontconfig/subpixel_rendering
111 subpixel_rendering="$RET"
112
113 subpixel="10-sub-pixel-rgb.conf"
114 no_subpixel="10-sub-pixel-none.conf"
115
116 if [ -h $CONFDIR/$subpixel ]; then
117 rm $CONFDIR/$subpixel
118 fi
119
120 if [ -h $CONFDIR/$no_subpixel ]; then
121 rm $CONFDIR/$no_subpixel
122 fi
123
124 case "$subpixel_rendering" in
125 "Automatic")
126 ;;
127 "Always")
128 ln -s $CONFAVAIL/$subpixel $CONFDIR/$subpixel
129 ;;
130 "Never")
131 ln -s $CONFAVAIL/$no_subpixel $CONFDIR/$no_subpixel
132 ;;
133 esac
134
135
136 db_get fontconfig/enable_bitmaps
137 enable_bitmaps="$RET"
138
139 yes_bitmaps="70-yes-bitmaps.conf"
140 no_bitmaps="70-no-bitmaps-except-emoji.conf"
141
142 if [ -h $CONFDIR/$yes_bitmaps ]; then
143 rm $CONFDIR/$yes_bitmaps
144 fi
145
146 if [ -h $CONFDIR/$no_bitmaps ]; then
147 rm $CONFDIR/$no_bitmaps
148 fi
149
150 case "$enable_bitmaps" in
151 "true")
152 ln -s $CONFAVAIL/$yes_bitmaps $CONFDIR/$yes_bitmaps
153 ;;
154 *)
155 ln -s $CONFAVAIL/$no_bitmaps $CONFDIR/$no_bitmaps
156 ;;
157 esac
158 fi # end changes applied only for initial config / reconfiguration
159
160 # fontconfig-config 2.11.0-5 (and earlier) created /etc/fonts.conf.d by mistake
161 # remove it
162
163 if [ -d /etc/fonts.conf.d ]; then
164 rmdir --ignore-fail-on-non-empty /etc/fonts.conf.d
165 fi
166
167 #DEBHELPER#