Contents of /mage/branches/alx07x-unstable/include/xorg.minc
Parent Directory | Revision Log
Revision 7861 -
(show annotations)
(download)
Wed Nov 18 09:35:23 2015 UTC (8 years, 10 months ago) by niro
File size: 5522 byte(s)
Wed Nov 18 09:35:23 2015 UTC (8 years, 10 months ago) by niro
File size: 5522 byte(s)
-release alx070x-unstable
1 | # $Header: /magellan-cvs/mage/include/xorg.minc,v 1.10 2008/01/29 10:22:08 niro Exp $ |
2 | # xorg global smage2 functions |
3 | |
4 | # check if old <=Xorg-6.9 is installed; aborts installation |
5 | is_old_xorg_installed() |
6 | { |
7 | local RED="\033[1;6m\033[31m" |
8 | local DEF="\033[0m" |
9 | |
10 | if [ -e ${MROOT}/usr/X11R6 ] && [[ $(readlink ${MROOT}/usr/X11R6) != ../usr ]] |
11 | then |
12 | echo |
13 | echo -e ${RED}" !!! Remove all old <=xorg-6.9 installations first."${DEF} |
14 | echo -e ${RED}" !!! You also need to check all packages which are installed to /usr/X11R6"${DEF} |
15 | echo |
16 | |
17 | # print a pkg list if magequery supports this |
18 | if [[ -n $(${MROOT}/sbin/magequery -h | grep -- -f) ]] |
19 | then |
20 | echo "Please check following packages:" |
21 | ${MROOT}/sbin/magequery -f /usr/X11R6 | while read pkg |
22 | do |
23 | echo -e " ${RED}*${DEF} ${pkg}" |
24 | done |
25 | echo |
26 | fi |
27 | |
28 | die "${MROOT}/usr/X11R6 directory exists ..." |
29 | fi |
30 | } |
31 | |
32 | xorg_cleanup_fonts() |
33 | { |
34 | local ALLOWED_FILES="encodings.dir fonts.cache-1 fonts.dir fonts.scale" |
35 | |
36 | for DIR in ${FONT_DIR} |
37 | do |
38 | unset KEEP_FONTDIR |
39 | REAL_DIR=${MROOT}/usr/share/fonts/${DIR} |
40 | |
41 | echo "Checking ${REAL_DIR} for useless files" |
42 | pushd ${REAL_DIR} &> /dev/null |
43 | for FILE in * |
44 | do |
45 | unset MATCH |
46 | for ALLOWED_FILE in ${ALLOWED_FILES} |
47 | do |
48 | if [[ ${FILE} = ${ALLOWED_FILE} ]] |
49 | then |
50 | # If it's allowed, then move on to the next file |
51 | MATCH="yes" |
52 | break |
53 | fi |
54 | done |
55 | # If we found a match in allowed files, move on to the next file |
56 | if [[ -n ${MATCH} ]] |
57 | then |
58 | continue |
59 | fi |
60 | # If we get this far, there wasn't a match in the allowed files |
61 | KEEP_FONTDIR="yes" |
62 | # We don't need to check more files if we're already keeping it |
63 | break |
64 | done |
65 | popd &> /dev/null |
66 | # If there are no files worth keeping, then get rid of the dir |
67 | if [[ -z "${KEEP_FONTDIR}" ]] |
68 | then |
69 | rm -rf ${REAL_DIR} |
70 | fi |
71 | done |
72 | } |
73 | |
74 | xorg_setup_fonts() |
75 | { |
76 | if [[ ! -n "${FONT_DIRS}" ]] |
77 | then |
78 | msg="FONT_DIRS is empty. The ebuild should set it to at least one subdir of /usr/share/fonts." |
79 | echo "${msg}" |
80 | die "${msg}" |
81 | fi |
82 | |
83 | xorg_create_fonts_scale |
84 | xorg_create_fonts_dir |
85 | xorg_fix_font_permissions |
86 | xorg_create_font_cache |
87 | } |
88 | |
89 | xorg_discover_font_dirs() |
90 | { |
91 | local DB_ENTRY="${BUILDDIR}/${PKGNAME}/binfiles" |
92 | |
93 | pushd ${DB_ENTRY}/usr/share/fonts &> /dev/null |
94 | FONT_DIRS="$(find . -maxdepth 1 -mindepth 1 -type d)" |
95 | FONT_DIRS="$(echo ${FONT_DIRS} | sed -e 's:./::g')" |
96 | popd &> /dev/null |
97 | } |
98 | |
99 | xorg_create_fonts_scale() |
100 | { |
101 | echo "Creating fonts.scale files" |
102 | |
103 | local x |
104 | for FONT_DIR in ${FONT_DIRS} |
105 | do |
106 | x=${MROOT}/usr/share/fonts/${FONT_DIR} |
107 | [[ -z "$(ls ${x}/)" ]] && continue |
108 | [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue |
109 | |
110 | # Only generate .scale files if truetype, opentype or type1 |
111 | # fonts are present ... |
112 | |
113 | # First truetype (ttf,ttc) |
114 | # NOTE: ttmkfdir does NOT work on type1 fonts (#53753) |
115 | # Also, there is no way to regenerate Speedo/CID fonts.scale |
116 | # <spyderous@gentoo.org> 2 August 2004 |
117 | if [[ "${x/encodings}" = "${x}" ]] \ |
118 | && [[ -n "$(find ${x} -iname '*.tt[cf]' -print)" ]] |
119 | then |
120 | if [[ -x ${MROOT}/usr/bin/ttmkfdir ]] |
121 | then |
122 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${MROOT}/usr/$(mlibdir)" \ |
123 | ${MROOT}/usr/bin/ttmkfdir -x 2 \ |
124 | -e ${MROOT}/usr/share/fonts/encodings/encodings.dir \ |
125 | -o ${x}/fonts.scale -d ${x} |
126 | # ttmkfdir fails on some stuff, so try mkfontscale if it does |
127 | local ttmkfdir_return=$? |
128 | else |
129 | # We didn't use ttmkfdir at all |
130 | local ttmkfdir_return=2 |
131 | fi |
132 | if [[ ${ttmkfdir_return} -ne 0 ]] |
133 | then |
134 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${MROOT}/usr/$(mlibdir)" \ |
135 | ${MROOT}/usr/bin/mkfontscale \ |
136 | -a /usr/share/fonts/encodings/encodings.dir \ |
137 | -- ${x} |
138 | fi |
139 | # Next type1 and opentype (pfa,pfb,otf,otc) |
140 | elif [[ "${x/encodings}" = "${x}" ]] \ |
141 | && [[ -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]] |
142 | then |
143 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${MROOT}/usr/$(mlibdir)" \ |
144 | ${MROOT}/usr/bin/mkfontscale \ |
145 | -a ${MROOT}/usr/share/fonts/encodings/encodings.dir \ |
146 | -- ${x} |
147 | fi |
148 | done |
149 | } |
150 | |
151 | xorg_create_fonts_dir() |
152 | { |
153 | echo "Generating fonts.dir files" |
154 | for FONT_DIR in ${FONT_DIRS} |
155 | do |
156 | x=${MROOT}/usr/share/fonts/${FONT_DIR} |
157 | [[ -z "$(ls ${x}/)" ]] && continue |
158 | [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue |
159 | |
160 | if [[ "${x/encodings}" = "${x}" ]]; then |
161 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${MROOT}/usr/$(mlibdir)" \ |
162 | ${MROOT}/usr/bin/mkfontdir \ |
163 | -e ${MROOT}/usr/share/fonts/encodings \ |
164 | -e ${MROOT}/usr/share/fonts/encodings/large \ |
165 | -- ${x} |
166 | fi |
167 | done |
168 | } |
169 | |
170 | xorg_fix_font_permissions() |
171 | { |
172 | echo "Fixing permissions" |
173 | for FONT_DIR in ${FONT_DIRS} |
174 | do |
175 | find ${MROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \ |
176 | -exec chmod 0644 {} \; |
177 | done |
178 | } |
179 | |
180 | xorg_create_font_cache() |
181 | { |
182 | # danarmak found out that fc-cache should be run AFTER all the above |
183 | # stuff, as otherwise the cache is invalid, and has to be run again |
184 | # as root anyway |
185 | if [[ -x ${MROOT}/usr/bin/fc-cache ]] |
186 | then |
187 | echo "Creating font cache" |
188 | HOME="/root" ${MROOT}/usr/bin/fc-cache |
189 | fi |
190 | } |
191 | |
192 | xorg_preinstall() |
193 | { |
194 | # check for old xorg installations |
195 | is_old_xorg_installed |
196 | |
197 | # run this in postinstall to cover --src-install builds |
198 | # ( the is now package-dir at this moment, cause its not already builded :) |
199 | # if [[ -n ${XORG_FONT_PKG} ]] |
200 | # then |
201 | # xorg_discover_font_dirs |
202 | # fi |
203 | } |
204 | |
205 | xorg_postinstall() |
206 | { |
207 | if [[ -n ${XORG_FONT_PKG} ]] |
208 | then |
209 | xorg_discover_font_dirs |
210 | xorg_setup_fonts |
211 | unset XORG_FONT_PKG |
212 | fi |
213 | } |
214 | |
215 | xorg_postremove() |
216 | { |
217 | if [[ -n ${XORG_FONT_PKG} ]] |
218 | then |
219 | xorg_cleanup_fonts |
220 | unset XORG_FONT_PKG |
221 | fi |
222 | } |
223 | |
224 | export_inherits xorg preinstall postinstall postremove |