From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 83438138334 for ; Thu, 21 Feb 2019 06:10:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ED73FE0822; Thu, 21 Feb 2019 06:10:09 +0000 (UTC) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6A0B1E07D0 for ; Thu, 21 Feb 2019 06:10:09 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id o6so13607853pls.13 for ; Wed, 20 Feb 2019 22:10:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=of953UhvPeaH2ynIdtbTgY0EWtKVXUR3GZiQzQDjzo4=; b=koerapBGJE3++lM4N8TGEA96XrINHui1Byh+bmVc9awGXJugOH3lQTHgF+GJnvf0dN L4cqqVz9CAoUxlyucVJIq8ZgI3bd/Z6qszPkrJ+GdtwIPwfcsGRWxrwIyk8wPU1XPE33 w2s5NnVCQM72bHyRb02yUZxBYsxnu0C57QtrpKj9c0vXrsfUoH1hDEoHMLrSKKCqbR6D wpOURjczPu5GwLQXdtgKrRw6JSwGzbN/TVNtCHn0ARQjtiABAtqMV7ZlVRaOAllo5ThR CPr3W2ngAPU4zlS77Zk6pukoDLntfCvlfYD22z5+8fLW6xNMSRUBZN/goPCyXAYeD8TF 4A/A== X-Gm-Message-State: AHQUAuaWDOXTYd8Qo5Z7qLstNkj2JTMt/A5OzsW7KaXGyPcEE9wJC5p6 Kxl9rJr5twh43cMDn7Vg4BShSf/c X-Google-Smtp-Source: AHgI3IbTFHtAFFj5Th9aWYGNVfrQ/AOjYRuOgKKMbEJDsu6eg7Th7A9ZwtDxAcYhvzh75mDnBQbcSw== X-Received: by 2002:a17:902:584:: with SMTP id f4mr41894145plf.28.1550729407851; Wed, 20 Feb 2019 22:10:07 -0800 (PST) Received: from localhost ([108.161.26.224]) by smtp.gmail.com with ESMTPSA id g71sm7971719pfg.157.2019.02.20.22.10.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 22:10:06 -0800 (PST) From: Matt Turner To: gentoo-dev@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-dev] [PATCH] xorg-3.eclass: Copy from xorg-2.eclass and add EAPI 7 support Date: Wed, 20 Feb 2019 22:09:57 -0800 Message-Id: <20190221060957.775-1-mattst88@gentoo.org> X-Mailer: git-send-email 2.19.2 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 3ca0b569-b92f-49a8-a456-962713169f1a X-Archives-Hash: 8f4efd166041987a354f207eee2f3089 Nearly all the work is just removing uses of autotools-multilib and autotools-utils. Bug: https://bugs.gentoo.org/619832 Signed-off-by: Matt Turner --- Let's just make an xorg-3 eclass to avoid any possibility of breaking stable things. Points of concern: 1) The fonts code is dead code as a result of fonts.eclass only supporting EAPI=6. None of the fonts ebuilds have changed since the transition to git, so we might just drop that code from xorg-3 and perhaps ultimately rename xorg-2 to xorg-fonts or something when all other ebuilds have transitioned? 2) Suggestions welcome for solving https://bugs.gentoo.org/637898 I have no ideas... 3) Meson support? This eclass is pretty autotools focused. Can we somehow allow Meson support without too much hassle? Maybe it's not worth it, since I'm not aware of any X11 projects other than the Xserver to have Meson build systems. I'm happy to punt. eclass/xorg-3.eclass | 583 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 583 insertions(+) create mode 100644 eclass/xorg-3.eclass diff --git a/eclass/xorg-3.eclass b/eclass/xorg-3.eclass new file mode 100644 index 00000000000..fd045122013 --- /dev/null +++ b/eclass/xorg-3.eclass @@ -0,0 +1,583 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: xorg-3.eclass +# @MAINTAINER: +# x11@gentoo.org +# @AUTHOR: +# Author: Tomáš Chvátal +# Author: Donnie Berkholz +# Author: Matt Turner +# @SUPPORTED_EAPIS: 7 +# @BLURB: Reduces code duplication in the modularized X11 ebuilds. +# @DESCRIPTION: +# This eclass makes trivial X ebuilds possible for apps, fonts, drivers, +# and more. Many things that would normally be done in various functions +# can be accessed by setting variables instead, such as patching, +# running eautoreconf, passing options to configure and installing docs. +# +# All you need to do in a basic ebuild is inherit this eclass and set +# DESCRIPTION, KEYWORDS and RDEPEND/DEPEND. If your package is hosted +# with the other X packages, you don't need to set SRC_URI. Pretty much +# everything else should be automatic. + +GIT_ECLASS="" +if [[ ${PV} == *9999* ]]; then + GIT_ECLASS="git-r3" + XORG_EAUTORECONF="yes" +fi + +# If we're a font package, but not the font.alias one +FONT_ECLASS="" +if [[ ${PN} == font* \ + && ${CATEGORY} = media-fonts \ + && ${PN} != font-alias \ + && ${PN} != font-util ]]; then + # Activate font code in the rest of the eclass + FONT="yes" + FONT_ECLASS="font" +fi + +# @ECLASS-VARIABLE: XORG_MULTILIB +# @DESCRIPTION: +# If set to 'yes', the multilib support for package will be enabled. Set +# before inheriting this eclass. +: ${XORG_MULTILIB:="no"} + +# we need to inherit autotools first to get the deps +inherit autotools eutils libtool multilib toolchain-funcs \ + flag-o-matic ${FONT_ECLASS} ${GIT_ECLASS} + +if [[ ${XORG_MULTILIB} == yes ]]; then + inherit multilib-minimal +fi + +EXPORTED_FUNCTIONS="src_prepare src_configure src_unpack src_compile src_install pkg_postinst pkg_postrm" +case "${EAPI:-0}" in + 7) ;; + *) die "EAPI=${EAPI} is not supported" ;; +esac + +# exports must be ALWAYS after inherit +EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS} + +IUSE="" +HOMEPAGE="https://www.x.org/wiki/ https://cgit.freedesktop.org/" + +# @ECLASS-VARIABLE: XORG_EAUTORECONF +# @DESCRIPTION: +# If set to 'yes' and configure.ac exists, eautoreconf will run. Set +# before inheriting this eclass. +: ${XORG_EAUTORECONF:="no"} + +# @ECLASS-VARIABLE: XORG_BASE_INDIVIDUAL_URI +# @DESCRIPTION: +# Set up SRC_URI for individual modular releases. If set to an empty +# string, no SRC_URI will be provided by the eclass. +: ${XORG_BASE_INDIVIDUAL_URI="https://www.x.org/releases/individual"} + +# @ECLASS-VARIABLE: XORG_MODULE +# @DESCRIPTION: +# The subdirectory to download source from. Possible settings are app, +# doc, data, util, driver, font, lib, proto, xserver. Set above the +# inherit to override the default autoconfigured module. +if [[ -z ${XORG_MODULE} ]]; then + case ${CATEGORY} in + app-doc) XORG_MODULE=doc/ ;; + media-fonts) XORG_MODULE=font/ ;; + x11-apps|x11-wm) XORG_MODULE=app/ ;; + x11-misc|x11-themes) XORG_MODULE=util/ ;; + x11-base) XORG_MODULE=xserver/ ;; + x11-drivers) XORG_MODULE=driver/ ;; + x11-libs) XORG_MODULE=lib/ ;; + *) XORG_MODULE= ;; + esac +fi + +# @ECLASS-VARIABLE: XORG_PACKAGE_NAME +# @DESCRIPTION: +# For git checkout the git repository might differ from package name. +# This variable can be used for proper directory specification +: ${XORG_PACKAGE_NAME:=${PN}} + +if [[ -n ${GIT_ECLASS} ]]; then + : ${EGIT_REPO_URI:="https://anongit.freedesktop.org/git/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME}.git"} +elif [[ -n ${XORG_BASE_INDIVIDUAL_URI} ]]; then + SRC_URI="${XORG_BASE_INDIVIDUAL_URI}/${XORG_MODULE}${P}.tar.bz2" +fi + +: ${SLOT:=0} + +# Set the license for the package. This can be overridden by setting +# LICENSE after the inherit. Nearly all FreeDesktop-hosted X packages +# are under the MIT license. (This is what Red Hat does in their rpms) +: ${LICENSE:=MIT} + +# Set up autotools shared dependencies +# Remember that all versions here MUST be stable +XORG_EAUTORECONF_ARCHES="ppc-aix x86-winnt" +EAUTORECONF_DEPEND+=" + >=sys-devel/libtool-2.2.6a + sys-devel/m4" +if [[ ${PN} != util-macros ]] ; then + EAUTORECONF_DEPEND+=" >=x11-misc/util-macros-1.18" + # Required even by xorg-server + [[ ${PN} == "font-util" ]] || EAUTORECONF_DEPEND+=" >=media-fonts/font-util-1.2.0" +fi +WANT_AUTOCONF="latest" +WANT_AUTOMAKE="latest" +for arch in ${XORG_EAUTORECONF_ARCHES}; do + EAUTORECONF_DEPENDS+=" ${arch}? ( ${EAUTORECONF_DEPEND} )" +done +DEPEND+=" ${EAUTORECONF_DEPENDS}" +[[ ${XORG_EAUTORECONF} != no ]] && BDEPEND+=" ${EAUTORECONF_DEPEND}" +unset EAUTORECONF_DEPENDS +unset EAUTORECONF_DEPEND + +if [[ ${FONT} == yes ]]; then + RDEPEND+=" media-fonts/encodings + x11-apps/mkfontscale + x11-apps/mkfontdir" + PDEPEND+=" media-fonts/font-alias" + DEPEND+=" >=media-fonts/font-util-1.2.0" + + # @ECLASS-VARIABLE: FONT_DIR + # @DESCRIPTION: + # If you're creating a font package and the suffix of PN is not equal to + # the subdirectory of /usr/share/fonts/ it should install into, set + # FONT_DIR to that directory or directories. Set before inheriting this + # eclass. + [[ -z ${FONT_DIR} ]] && FONT_DIR=${PN##*-} + + # Fix case of font directories + FONT_DIR=${FONT_DIR/ttf/TTF} + FONT_DIR=${FONT_DIR/otf/OTF} + FONT_DIR=${FONT_DIR/type1/Type1} + FONT_DIR=${FONT_DIR/speedo/Speedo} + + # Set up configure options, wrapped so ebuilds can override if need be + [[ -z ${FONT_OPTIONS} ]] && FONT_OPTIONS="--with-fontdir=\"${EPREFIX}/usr/share/fonts/${FONT_DIR}\"" + + [[ ${PN} = font-misc-misc || ${PN} = font-schumacher-misc || ${PN##*-} = 75dpi || ${PN##*-} = 100dpi || ${PN##*-} = cyrillic ]] && IUSE+=" nls" +fi + +# If we're a driver package, then enable DRIVER case +[[ ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] && DRIVER="yes" + +# @ECLASS-VARIABLE: XORG_STATIC +# @DESCRIPTION: +# Enables static-libs useflag. Set to no, if your package gets: +# +# QA: configure: WARNING: unrecognized options: --disable-static +: ${XORG_STATIC:="yes"} + +# Add static-libs useflag where usefull. +if [[ ${XORG_STATIC} == yes \ + && ${FONT} != yes \ + && ${CATEGORY} != app-doc \ + && ${CATEGORY} != x11-apps \ + && ${CATEGORY} != x11-drivers \ + && ${CATEGORY} != media-fonts \ + && ${PN} != util-macros \ + && ${PN} != xbitmaps \ + && ${PN} != xorg-cf-files \ + && ${PN/xcursor} = ${PN} ]]; then + IUSE+=" static-libs" +fi + +DEPEND+=" virtual/pkgconfig" + +# @ECLASS-VARIABLE: XORG_DRI +# @DESCRIPTION: +# Possible values are "always" or the value of the useflag DRI capabilities +# are required for. Default value is "no" +# +# Eg. XORG_DRI="opengl" will pull all dri dependant deps for opengl useflag +: ${XORG_DRI:="no"} + +DRI_COMMON_DEPEND=" + x11-base/xorg-server[-minimal] + x11-libs/libdrm +" +case ${XORG_DRI} in + no) + ;; + always) + COMMON_DEPEND+=" ${DRI_COMMON_DEPEND}" + ;; + *) + COMMON_DEPEND+=" ${XORG_DRI}? ( ${DRI_COMMON_DEPEND} )" + IUSE+=" ${XORG_DRI}" + ;; +esac +unset DRI_COMMON_DEPEND + +if [[ -n "${DRIVER}" ]]; then + COMMON_DEPEND+=" + x11-base/xorg-server[xorg] + " +fi +if [[ -n "${DRIVER}" && ${PN} == xf86-input-* ]]; then + DEPEND+=" x11-base/xorg-proto" +fi +if [[ -n "${DRIVER}" && ${PN} == xf86-video-* ]]; then + COMMON_DEPEND+=" + x11-libs/libpciaccess + " + DEPEND+=" x11-base/xorg-proto" +fi + +# @ECLASS-VARIABLE: XORG_DOC +# @DESCRIPTION: +# Possible values are "always" or the value of the useflag doc packages +# are required for. Default value is "no" +# +# Eg. XORG_DOC="manual" will pull all doc dependant deps for manual useflag +: ${XORG_DOC:="no"} + +DOC_DEPEND=" + doc? ( + app-text/asciidoc + app-text/xmlto + app-doc/doxygen + app-text/docbook-xml-dtd:4.1.2 + app-text/docbook-xml-dtd:4.2 + app-text/docbook-xml-dtd:4.3 + ) +" +case ${XORG_DOC} in + no) + ;; + always) + DEPEND+=" ${DOC_DEPEND}" + ;; + *) + DEPEND+=" ${XORG_DOC}? ( ${DOC_DEPEND} )" + IUSE+=" ${XORG_DOC}" + ;; +esac +unset DOC_DEPEND + +# @ECLASS-VARIABLE: XORG_MODULE_REBUILD +# @DESCRIPTION: +# Describes whether a package contains modules that need to be rebuilt on +# xorg-server upgrade. +# Possible values are "yes" or "no". Default value is "yes" for packages which +# are recognized as DRIVER by this eclass and "no" for all other packages. +if [[ "${DRIVER}" == yes ]]; then + : ${XORG_MODULE_REBUILD:="yes"} +else + : ${XORG_MODULE_REBUILD:="no"} +fi +[[ ${XORG_MODULE_REBUILD} == yes ]] && RDEPEND+=" x11-base/xorg-server:=" + +DEPEND+=" ${COMMON_DEPEND}" +RDEPEND+=" ${COMMON_DEPEND}" +unset COMMON_DEPEND + +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND=${DEPEND}" +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND=${RDEPEND}" +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: PDEPEND=${PDEPEND}" + +# @FUNCTION: xorg-3_pkg_setup +# @DESCRIPTION: +# Setup prefix compat +xorg-3_pkg_setup() { + debug-print-function ${FUNCNAME} "$@" + + [[ ${FONT} == yes ]] && font_pkg_setup "$@" +} + +# @FUNCTION: xorg-3_src_unpack +# @DESCRIPTION: +# Simply unpack source code. +xorg-3_src_unpack() { + debug-print-function ${FUNCNAME} "$@" + + if [[ -n ${GIT_ECLASS} ]]; then + git-r3_src_unpack + else + unpack ${A} + fi + + [[ -n ${FONT_OPTIONS} ]] && einfo "Detected font directory: ${FONT_DIR}" +} + +# @FUNCTION: xorg-3_reconf_source +# @DESCRIPTION: +# Run eautoreconf if necessary, and run elibtoolize. +xorg-3_reconf_source() { + debug-print-function ${FUNCNAME} "$@" + + case ${CHOST} in + *-aix* | *-winnt*) + # some hosts need full eautoreconf + [[ -e "./configure.ac" || -e "./configure.in" ]] \ + && XORG_EAUTORECONF=yes + ;; + *) + # elibtoolize required for BSD + [[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] \ + && XORG_EAUTORECONF=yes + ;; + esac + + [[ ${XORG_EAUTORECONF} != no ]] && eautoreconf + elibtoolize --patch-only +} + +# @FUNCTION: xorg-3_src_prepare +# @DESCRIPTION: +# Prepare a package after unpacking, performing all X-related tasks. +xorg-3_src_prepare() { + debug-print-function ${FUNCNAME} "$@" + + default + xorg-3_reconf_source + + [[ ${PATCHES} ]] && epatch "${PATCHES[@]}" +} + +# @FUNCTION: xorg-3_font_configure +# @DESCRIPTION: +# If a font package, perform any necessary configuration steps +xorg-3_font_configure() { + debug-print-function ${FUNCNAME} "$@" + + if has nls ${IUSE//+} && ! use nls; then + if grep -q -s "disable-all-encodings" ${ECONF_SOURCE:-.}/configure; then + FONT_OPTIONS+=" + --disable-all-encodings + --enable-iso8859-1" + else + FONT_OPTIONS+=" + --disable-iso8859-2 + --disable-iso8859-3 + --disable-iso8859-4 + --disable-iso8859-5 + --disable-iso8859-6 + --disable-iso8859-7 + --disable-iso8859-8 + --disable-iso8859-9 + --disable-iso8859-10 + --disable-iso8859-11 + --disable-iso8859-12 + --disable-iso8859-13 + --disable-iso8859-14 + --disable-iso8859-15 + --disable-iso8859-16 + --disable-jisx0201 + --disable-koi8-r" + fi + fi +} + +# @FUNCTION: xorg-3_flags_setup +# @DESCRIPTION: +# Set up CFLAGS for a debug build +xorg-3_flags_setup() { + debug-print-function ${FUNCNAME} "$@" + + # Win32 require special define + [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__ + # hardened ldflags + [[ ${PN} = xorg-server || -n ${DRIVER} ]] && append-ldflags -Wl,-z,lazy + + # Quite few libraries fail on runtime without these: + if has static-libs ${IUSE//+}; then + filter-flags -Wl,-Bdirect + filter-ldflags -Bdirect + filter-ldflags -Wl,-Bdirect + fi +} + +multilib_src_configure() { + ECONF_SOURCE="${S}" econf "${econfargs[@]}" +} + +# @FUNCTION: xorg-3_src_configure +# @DESCRIPTION: +# Perform any necessary pre-configuration steps, then run configure +xorg-3_src_configure() { + debug-print-function ${FUNCNAME} "$@" + + xorg-3_flags_setup + + # @VARIABLE: XORG_CONFIGURE_OPTIONS + # @DESCRIPTION: + # Array of an additional options to pass to configure. + # @DEFAULT_UNSET + if [[ $(declare -p XORG_CONFIGURE_OPTIONS 2>&-) != "declare -a"* ]]; then + # fallback to CONFIGURE_OPTIONS, deprecated. + if [[ -n "${CONFIGURE_OPTIONS}" ]]; then + eqawarn "CONFIGURE_OPTIONS are deprecated. Please migrate to XORG_CONFIGURE_OPTIONS" + eqawarn "to preserve namespace." + fi + + local xorgconfadd=(${CONFIGURE_OPTIONS} ${XORG_CONFIGURE_OPTIONS}) + else + local xorgconfadd=("${XORG_CONFIGURE_OPTIONS[@]}") + fi + + [[ -n "${FONT}" ]] && xorg-3_font_configure + + # Check if package supports disabling of dep tracking + # Fixes warnings like: + # WARNING: unrecognized options: --disable-dependency-tracking + if grep -q -s "disable-depencency-tracking" ${ECONF_SOURCE:-.}/configure; then + local dep_track="--disable-dependency-tracking" + fi + + # Check if package supports disabling of selective -Werror=... + if grep -q -s "disable-selective-werror" ${ECONF_SOURCE:-.}/configure; then + local selective_werror="--disable-selective-werror" + fi + + local econfargs=( + ${dep_track} + ${selective_werror} + ${FONT_OPTIONS} + "${xorgconfadd[@]}" + ) + + # Handle static-libs found in IUSE, disable them by default + if in_iuse static-libs; then + econfargs+=( + --enable-shared + $(use_enable static-libs static) + ) + fi + + if [[ ${XORG_MULTILIB} == yes ]]; then + multilib-minimal_src_configure "$@" + else + econf "${econfargs[@]}" "$@" + fi +} + +multilib_src_compile() { + emake "$@" || die 'emake failed' +} + +# @FUNCTION: xorg-3_src_compile +# @DESCRIPTION: +# Compile a package, performing all X-related tasks. +xorg-3_src_compile() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${XORG_MULTILIB} == yes ]]; then + multilib-minimal_src_compile "$@" + else + emake "$@" || die 'emake failed' + fi +} + +multilib_src_install() { + emake DESTDIR="${D}" "${install_args[@]}" "$@" install || die "emake install failed" +} + +# @FUNCTION: xorg-3_src_install +# @DESCRIPTION: +# Install a built package to ${D}, performing any necessary steps. +# Creates a ChangeLog from git if using live ebuilds. +xorg-3_src_install() { + debug-print-function ${FUNCNAME} "$@" + + local install_args=( docdir="${EPREFIX}/usr/share/doc/${PF}" ) + + if [[ ${XORG_MULTILIB} == yes ]]; then + multilib-minimal_src_install "$@" + else + emake DESTDIR="${D}" "${install_args[@]}" "$@" install || die "emake install failed" + fi + + if [[ -n ${GIT_ECLASS} ]]; then + pushd "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" > /dev/null || die + git log ${EGIT_COMMIT} > "${S}"/ChangeLog + popd > /dev/null || die + fi + + if [[ -e "${S}"/ChangeLog ]]; then + dodoc "${S}"/ChangeLog || die "dodoc failed" + fi + + # Don't install libtool archives (even for modules) + find "${D}" -type f -name '*.la' -delete || die + + [[ -n ${FONT} ]] && remove_font_metadata +} + +# @FUNCTION: xorg-3_pkg_postinst +# @DESCRIPTION: +# Run X-specific post-installation tasks on the live filesystem. The +# only task right now is some setup for font packages. +xorg-3_pkg_postinst() { + debug-print-function ${FUNCNAME} "$@" + + if [[ -n ${FONT} ]]; then + create_fonts_scale + create_fonts_dir + font_pkg_postinst "$@" + + ewarn "Installed fonts changed. Run 'xset fp rehash' if you are using non-fontconfig applications." + fi +} + +# @FUNCTION: xorg-3_pkg_postrm +# @DESCRIPTION: +# Run X-specific post-removal tasks on the live filesystem. The only +# task right now is some cleanup for font packages. +xorg-3_pkg_postrm() { + debug-print-function ${FUNCNAME} "$@" + + if [[ -n ${FONT} ]]; then + # if we're doing an upgrade, postinst will do + if [[ -z ${REPLACED_BY_VERSION} ]]; then + create_fonts_scale + create_fonts_dir + font_pkg_postrm "$@" + fi + fi +} + +# @FUNCTION: remove_font_metadata +# @DESCRIPTION: +# Don't let the package install generated font files that may overlap +# with other packages. Instead, they're generated in pkg_postinst(). +remove_font_metadata() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then + einfo "Removing font metadata" + rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1} + fi +} + +# @FUNCTION: create_fonts_scale +# @DESCRIPTION: +# Create fonts.scale file, used by the old server-side fonts subsystem. +create_fonts_scale() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then + ebegin "Generating fonts.scale" + mkfontscale \ + -a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \ + -- "${EROOT}/usr/share/fonts/${FONT_DIR}" + eend $? + fi +} + +# @FUNCTION: create_fonts_dir +# @DESCRIPTION: +# Create fonts.dir file, used by the old server-side fonts subsystem. +create_fonts_dir() { + debug-print-function ${FUNCNAME} "$@" + + ebegin "Generating fonts.dir" + mkfontdir \ + -e "${EROOT}"/usr/share/fonts/encodings \ + -e "${EROOT}"/usr/share/fonts/encodings/large \ + -- "${EROOT}/usr/share/fonts/${FONT_DIR}" + eend $? +} -- 2.19.2