Gentoo Archives: gentoo-dev

From: Henrik Pihl <ahvenas@×××××.com>
To: gentoo-dev@l.g.o
Cc: Henrik Pihl <ahvenas@×××××.com>
Subject: [gentoo-dev] [PATCH] Update xorg-3.eclass to handle fonts (again).
Date: Sun, 02 Aug 2020 20:55:48
Message-Id: 20200802205522.1016745-1-ahvenas@gmail.com
1 Sorry about the last patch, ignore it, still managed to send with the wrong
2 commit sha.
3
4 Signed-off-by: Henrik Pihl <ahvenas@×××××.com>
5 ---
6 eclass/xorg-3.eclass | 181 ++++++++++++++++++++++++++++++++++++++++++-
7 1 file changed, 177 insertions(+), 4 deletions(-)
8
9 diff --git a/eclass/xorg-3.eclass b/eclass/xorg-3.eclass
10 index 168e58b42c8..a52c0146baa 100644
11 --- a/eclass/xorg-3.eclass
12 +++ b/eclass/xorg-3.eclass
13 @@ -27,6 +27,20 @@ if [[ ${PV} == *9999* ]]; then
14 XORG_EAUTORECONF="yes"
15 fi
16
17 +# If we're a font package, but not the font.alias one
18 +FONT_ECLASS=""
19 +if [[ ${CATEGORY} = media-fonts ]]; then
20 + case ${PN} in
21 + font-alias|font-util)
22 + ;;
23 + font*)
24 + # Activate font code in the rest of the eclass
25 + FONT="yes"
26 + FONT_ECLASS="font"
27 + ;;
28 + esac
29 +fi
30 +
31 # @ECLASS-VARIABLE: XORG_MULTILIB
32 # @DESCRIPTION:
33 # If set to 'yes', the multilib support for package will be enabled. Set
34 @@ -34,13 +48,14 @@ fi
35 : ${XORG_MULTILIB:="no"}
36
37 # we need to inherit autotools first to get the deps
38 -inherit autotools libtool multilib toolchain-funcs flag-o-matic ${GIT_ECLASS}
39 +inherit autotools libtool multilib toolchain-funcs flag-o-matic ${GIT_ECLASS} \
40 + flag-o-matic ${FONT_ECLASS} ${GIT_ECLASS}
41
42 if [[ ${XORG_MULTILIB} == yes ]]; then
43 inherit multilib-minimal
44 fi
45
46 -EXPORTED_FUNCTIONS="src_prepare src_configure src_unpack src_compile src_install"
47 +EXPORTED_FUNCTIONS="src_prepare src_configure src_unpack src_compile src_install pkg_postinst pkg_postrm"
48 case "${EAPI:-0}" in
49 7) ;;
50 *) die "EAPI=${EAPI} is not supported" ;;
51 @@ -66,7 +81,7 @@ IUSE=""
52 # @ECLASS-VARIABLE: XORG_MODULE
53 # @DESCRIPTION:
54 # The subdirectory to download source from. Possible settings are app,
55 -# doc, data, util, driver, lib, proto, xserver. Set above the
56 +# doc, data, util, driver, font, lib, proto, xserver. Set above the
57 # inherit to override the default autoconfigured module.
58 : ${XORG_MODULE:="auto"}
59 if [[ ${XORG_MODULE} == auto ]]; then
60 @@ -116,7 +131,9 @@ EAUTORECONF_DEPEND+="
61 >=sys-devel/libtool-2.2.6a
62 sys-devel/m4"
63 if [[ ${PN} != util-macros ]] ; then
64 - EAUTORECONF_DEPEND+=" >=x11-misc/util-macros-1.18 >=media-fonts/font-util-1.2.0"
65 + EAUTORECONF_DEPEND+=" >=x11-misc/util-macros-1.18"
66 + # Required even by xorg-server
67 + [[ ${PN} == "font-util" ]] || EAUTORECONF_DEPEND+=" >=media-fonts/font-util-1.2.0"
68 fi
69 WANT_AUTOCONF="latest"
70 WANT_AUTOMAKE="latest"
71 @@ -129,6 +146,36 @@ BDEPEND+=" ${EAUTORECONF_DEPENDS}"
72 unset EAUTORECONF_DEPENDS
73 unset EAUTORECONF_DEPEND
74
75 +if [[ ${FONT} == yes ]]; then
76 + RDEPEND+=" media-fonts/encodings
77 + >=x11-apps/mkfontscale-1.2.0"
78 + PDEPEND+=" media-fonts/font-alias"
79 + DEPEND+=" >=media-fonts/font-util-1.2.0
80 + >=x11-apps/mkfontscale-1.2.0"
81 +
82 + # @ECLASS-VARIABLE: FONT_DIR
83 + # @DESCRIPTION:
84 + # If you're creating a font package and the suffix of PN is not equal to
85 + # the subdirectory of /usr/share/fonts/ it should install into, set
86 + # FONT_DIR to that directory or directories. Set before inheriting this
87 + # eclass.
88 + [[ -z ${FONT_DIR} ]] && FONT_DIR=${PN##*-}
89 +
90 + # Fix case of font directories
91 + FONT_DIR=${FONT_DIR/ttf/TTF}
92 + FONT_DIR=${FONT_DIR/otf/OTF}
93 + FONT_DIR=${FONT_DIR/type1/Type1}
94 + FONT_DIR=${FONT_DIR/speedo/Speedo}
95 +
96 + # Set up configure options, wrapped so ebuilds can override if need be
97 + [[ -z ${FONT_OPTIONS} ]] && FONT_OPTIONS="--with-fontdir=\"${EPREFIX}/usr/share/fonts/${FONT_DIR}\""
98 +
99 + [[ ${PN} = font-misc-misc || ${PN} = font-schumacher-misc || ${PN##*-} = 75dpi || ${PN##*-} = 100dpi || ${PN##*-} = cyrillic ]] && IUSE+=" nls"
100 +fi
101 +
102 +# If we're a driver package, then enable DRIVER case
103 +[[ ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] && DRIVER="yes"
104 +
105 # @ECLASS-VARIABLE: XORG_STATIC
106 # @DESCRIPTION:
107 # Enables static-libs useflag. Set to no, if your package gets:
108 @@ -138,6 +185,7 @@ unset EAUTORECONF_DEPEND
109
110 # Add static-libs useflag where useful.
111 if [[ ${XORG_STATIC} == yes \
112 + && ${FONT} != yes \
113 && ${CATEGORY} != app-doc \
114 && ${CATEGORY} != x11-apps \
115 && ${CATEGORY} != x11-drivers \
116 @@ -224,6 +272,15 @@ debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND=${RDEPEND}"
117 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: PDEPEND=${PDEPEND}"
118 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: BDEPEND=${BDEPEND}"
119
120 +# @FUNCTION: xorg-3_pkg_setup
121 +# @DESCRIPTION:
122 +# Setup prefix compat
123 +xorg-3_pkg_setup() {
124 + debug-print-function ${FUNCNAME} "$@"
125 +
126 + [[ ${FONT} == yes ]] && font_pkg_setup "$@"
127 +}
128 +
129 # @FUNCTION: xorg-3_src_unpack
130 # @DESCRIPTION:
131 # Simply unpack source code.
132 @@ -235,6 +292,8 @@ xorg-3_src_unpack() {
133 else
134 unpack ${A}
135 fi
136 +
137 + [[ -n ${FONT_OPTIONS} ]] && einfo "Detected font directory: ${FONT_DIR}"
138 }
139
140 # @FUNCTION: xorg-3_reconf_source
141 @@ -270,6 +329,40 @@ xorg-3_src_prepare() {
142 xorg-3_reconf_source
143 }
144
145 +# @FUNCTION: xorg-3_font_configure
146 +# @DESCRIPTION:
147 +# If a font package, perform any necessary configuration steps
148 +xorg-3_font_configure() {
149 + debug-print-function ${FUNCNAME} "$@"
150 +
151 + if has nls ${IUSE//+} && ! use nls; then
152 + if grep -q -s "disable-all-encodings" ${ECONF_SOURCE:-.}/configure; then
153 + FONT_OPTIONS+="
154 + --disable-all-encodings
155 + --enable-iso8859-1"
156 + else
157 + FONT_OPTIONS+="
158 + --disable-iso8859-2
159 + --disable-iso8859-3
160 + --disable-iso8859-4
161 + --disable-iso8859-5
162 + --disable-iso8859-6
163 + --disable-iso8859-7
164 + --disable-iso8859-8
165 + --disable-iso8859-9
166 + --disable-iso8859-10
167 + --disable-iso8859-11
168 + --disable-iso8859-12
169 + --disable-iso8859-13
170 + --disable-iso8859-14
171 + --disable-iso8859-15
172 + --disable-iso8859-16
173 + --disable-jisx0201
174 + --disable-koi8-r"
175 + fi
176 + fi
177 +}
178 +
179 # @FUNCTION: xorg-3_flags_setup
180 # @DESCRIPTION:
181 # Set up CFLAGS for a debug build
182 @@ -308,6 +401,8 @@ xorg-3_src_configure() {
183 # @DEFAULT_UNSET
184 local xorgconfadd=("${XORG_CONFIGURE_OPTIONS[@]}")
185
186 + [[ -n "${FONT}" ]] && xorg-3_font_configure
187 +
188 # Check if package supports disabling of dep tracking
189 # Fixes warnings like:
190 # WARNING: unrecognized options: --disable-dependency-tracking
191 @@ -323,6 +418,7 @@ xorg-3_src_configure() {
192 local econfargs=(
193 ${dep_track}
194 ${selective_werror}
195 + ${FONT_OPTIONS}
196 "${xorgconfadd[@]}"
197 )
198
199 @@ -388,4 +484,81 @@ xorg-3_src_install() {
200
201 # Don't install libtool archives (even for modules)
202 find "${D}" -type f -name '*.la' -delete || die
203 +
204 + [[ -n ${FONT} ]] && remove_font_metadata
205 +}
206 +
207 +# @FUNCTION: xorg-3_pkg_postinst
208 +# @DESCRIPTION:
209 +# Run X-specific post-installation tasks on the live filesystem. The
210 +# only task right now is some setup for font packages.
211 +xorg-3_pkg_postinst() {
212 + debug-print-function ${FUNCNAME} "$@"
213 +
214 + if [[ -n ${FONT} ]]; then
215 + create_fonts_scale
216 + create_fonts_dir
217 + font_pkg_postinst "$@"
218 +
219 + ewarn "Installed fonts changed. Run 'xset fp rehash' if you are using non-fontconfig applications."
220 + fi
221 +}
222 +
223 +# @FUNCTION: xorg-3_pkg_postrm
224 +# @DESCRIPTION:
225 +# Run X-specific post-removal tasks on the live filesystem. The only
226 +# task right now is some cleanup for font packages.
227 +xorg-3_pkg_postrm() {
228 + debug-print-function ${FUNCNAME} "$@"
229 +
230 + if [[ -n ${FONT} ]]; then
231 + # if we're doing an upgrade, postinst will do
232 + if [[ -z ${REPLACED_BY_VERSION} ]]; then
233 + create_fonts_scale
234 + create_fonts_dir
235 + font_pkg_postrm "$@"
236 + fi
237 + fi
238 +}
239 +
240 +# @FUNCTION: remove_font_metadata
241 +# @DESCRIPTION:
242 +# Don't let the package install generated font files that may overlap
243 +# with other packages. Instead, they're generated in pkg_postinst().
244 +remove_font_metadata() {
245 + debug-print-function ${FUNCNAME} "$@"
246 +
247 + if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
248 + einfo "Removing font metadata"
249 + rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1}
250 + fi
251 +}
252 +
253 +# @FUNCTION: create_fonts_scale
254 +# @DESCRIPTION:
255 +# Create fonts.scale file, used by the old server-side fonts subsystem.
256 +create_fonts_scale() {
257 + debug-print-function ${FUNCNAME} "$@"
258 +
259 + if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
260 + ebegin "Generating fonts.scale"
261 + mkfontscale \
262 + -a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \
263 + -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
264 + eend $?
265 + fi
266 +}
267 +
268 +# @FUNCTION: create_fonts_dir
269 +# @DESCRIPTION:
270 +# Create fonts.dir file, used by the old server-side fonts subsystem.
271 +create_fonts_dir() {
272 + debug-print-function ${FUNCNAME} "$@"
273 +
274 + ebegin "Generating fonts.dir"
275 + mkfontdir \
276 + -e "${EROOT}"/usr/share/fonts/encodings \
277 + -e "${EROOT}"/usr/share/fonts/encodings/large \
278 + -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
279 + eend $?
280 }
281 --
282 2.28.0